public class GDimension
extends java.lang.Object
Dimension
class
in java.awt
.Constructor and Description |
---|
GDimension()
Constructs a new dimension object with zero values for width and height.
|
GDimension(java.awt.Dimension size)
Constructs a new
GDimension object from an AWT Dimension . |
GDimension(double width,
double height)
Constructs a new dimension object with the specified components.
|
GDimension(GDimension size)
Constructs a new
GDimension object from an existing one. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Tests whether two
GDimension objects are equal. |
double |
getHeight()
Returns the height of this
GDimension . |
GDimension |
getSize()
Returns a new
GDimension object equal to this one. |
double |
getWidth()
Returns the width of this
GDimension . |
int |
hashCode()
Returns an integer hash code for the dimension object.
|
void |
setSize(double width,
double height)
Sets the components of the dimension object from the specified parameters.
|
void |
setSize(GDimension size)
Sets the width and height of one
GDimension object equal to that of another. |
java.awt.Dimension |
toDimension()
Converts this
GDimension to the nearest integer-based
Dimension . |
java.lang.String |
toString()
Converts this
GDimension to its string representation. |
public GDimension()
public GDimension(double width, double height)
width
- The width of the dimension objectheight
- The height of the dimension objectpublic GDimension(GDimension size)
GDimension
object from an existing one.size
- An existing GDimension
object specifying the sizepublic GDimension(java.awt.Dimension size)
GDimension
object from an AWT Dimension
.size
- An AWT Dimension
object specifying the sizepublic double getWidth()
GDimension
.GDimension
public double getHeight()
GDimension
.GDimension
public void setSize(double width, double height)
width
- The new width of the dimension objectheight
- The new height of the dimension objectpublic void setSize(GDimension size)
GDimension
object equal to that of another.size
- A GDimension
object specifying the new sizepublic GDimension getSize()
GDimension
object equal to this one.GDimension
object with the same sizepublic java.awt.Dimension toDimension()
GDimension
to the nearest integer-based
Dimension
.Dimension
objectpublic int hashCode()
GDimension
is constructed from the hash codes from the
float
values of the width and height, which are the ones used in the
equals
method.hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
GDimension
objects are equal.
Because floating-point values are inexact, this method checks for
equality by comparing the float
values (rather than the
double
values) of the coordinates.equals
in class java.lang.Object
obj
- Any objecttrue
if the obj
is a GDimension
equal to this one, and false
otherwisepublic java.lang.String toString()
GDimension
to its string representation.toString
in class java.lang.Object