public class Dimension extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
int |
height
The height dimension; negative values can be used.
|
int |
width
The width dimension; negative values can be used.
|
| Constructor and Description |
|---|
Dimension()
Creates an instance of
Dimension with a width
of zero and a height of zero. |
Dimension(Dimension d)
Creates an instance of
Dimension whose width
and height are the same as for the specified dimension. |
Dimension(double width,
double height)
Constructs a
Dimension and initializes
it to the specified width and specified height. |
Dimension(int width,
int height)
Constructs a
Dimension and initializes
it to the specified width and specified height. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
double |
getHeight() |
Dimension |
getSize()
Gets the size of this
Dimension object. |
double |
getWidth() |
int |
hashCode()
Returns the hash code for this
Dimension. |
void |
setSize(Dimension d)
Sets the size of this
Dimension object to the specified size. |
void |
setSize(double width,
double height)
Sets the size of this
Dimension object to
the specified width and height in double precision. |
void |
setSize(int width,
int height)
Sets the size of this
Dimension object
to the specified width and height. |
String |
toString()
Returns a string representation of the values of this
Dimension object's height and
width fields. |
public int width
getSize(),
setSize(double, double)public int height
getSize(),
setSize(double, double)public Dimension()
Dimension with a width
of zero and a height of zero.public Dimension(Dimension d)
Dimension whose width
and height are the same as for the specified dimension.d - the specified dimension for the
width and
height valuespublic Dimension(int width,
int height)
Dimension and initializes
it to the specified width and specified height.width - the specified widthheight - the specified heightpublic Dimension(double width,
double height)
Dimension and initializes
it to the specified width and specified height. All double
values are rounded and stored as int values.width - the specified widthheight - the specified heightpublic double getWidth()
public double getHeight()
public void setSize(double width,
double height)
Dimension object to
the specified width and height in double precision.
Note that if width or height
are larger than Integer.MAX_VALUE, they will
be reset to Integer.MAX_VALUE.width - the new width for the Dimension objectheight - the new height for the Dimension objectpublic Dimension getSize()
Dimension object.Dimension with the same width and heightsetSize(double, double)public void setSize(Dimension d)
Dimension object to the specified size.d - the new size for this Dimension objectgetSize()public void setSize(int width,
int height)
Dimension object
to the specified width and height.width - the new width for this Dimension objectheight - the new height for this Dimension objectgetSize()public int hashCode()
Dimension.public String toString()
Dimension object's height and
width fields. This method is intended to be used only
for debugging purposes, and the content and format of the returned
string may vary between implementations. The returned string may be
empty but may not be null.Copyright © 2019. All rights reserved.