|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.geom.Dimension2D
java.awt.Dimension
public class Dimension
This class holds a width and height value pair. This is used in plenty of windowing classes, but also has geometric meaning.
It is valid for a dimension to have negative width or height; but it is considered to have no area. Therefore, the behavior in various methods is undefined in such a case.
There are some public fields; if you mess with them in an inconsistent manner, it is your own fault when you get invalid results. Also, this class is not threadsafe.
Component,
LayoutManager,
Serialized Form| Field Summary | |
|---|---|
int |
height
The height of this object. |
int |
width
The width of this object. |
| Constructor Summary | |
|---|---|
Dimension()
Create a new Dimension with a width and height of zero. |
|
Dimension(Dimension d)
Create a new Dimension with width and height identical to that of the specified dimension. |
|
Dimension(int w,
int h)
Create a new Dimension with the specified width and height. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object obj)
Tests this object for equality against the specified object. |
double |
getHeight()
Gets the height of this dimension. |
Dimension |
getSize()
Returns the size of this dimension. |
double |
getWidth()
Gets the width of this dimension. |
int |
hashCode()
Return the hashcode for this object. |
void |
setSize(Dimension d)
Sets the width and height of this object to match that of the specified object. |
void |
setSize(double w,
double h)
Sets the size of this dimension. |
void |
setSize(int w,
int h)
Sets the width and height of this object to the specified values. |
String |
toString()
Returns a string representation of this object. |
| Methods inherited from class java.awt.geom.Dimension2D |
|---|
clone, setSize |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int width
getSize(),
setSize(double, double)public int height
getSize(),
setSize(double, double)| Constructor Detail |
|---|
public Dimension()
public Dimension(Dimension d)
d - the Dimension to copy
NullPointerException - if d is null
public Dimension(int w,
int h)
w - the width of this objecth - the height of this object| Method Detail |
|---|
public double getWidth()
getWidth in class Dimension2Dpublic double getHeight()
getHeight in class Dimension2D
public void setSize(double w,
double h)
setSize in class Dimension2Dw - the new widthh - the new heightpublic Dimension getSize()
setSize(Dimension)public void setSize(Dimension d)
d - the Dimension to get the new width and height from
NullPointerException - if d is nullgetSize()
public void setSize(int w,
int h)
w - the new width valueh - the new height valuepublic boolean equals(Object obj)
equals in class Objectobj - the object to test against
Object.hashCode()public int hashCode()
((width + height) * (width + height + 1) / 2) + width.
hashCode in class ObjectObject.equals(Object),
System.identityHashCode(Object)public String toString()
getClass().getName() + "[width=" + width + ",height=" + height
+ ']'.
toString in class ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||