|
Eclipse Draw2d 3.7 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.draw2d.geometry.Dimension
public class Dimension
Stores an integer width and height. This class provides various methods for manipulating this Dimension or creating new derived Objects.
| Field Summary | |
|---|---|
int |
height
The height. |
static Dimension |
SINGLETON
A singleton for use in short calculations. |
int |
width
The width. |
| Constructor Summary | |
|---|---|
Dimension()
Constructs a Dimension of zero width and height. |
|
Dimension(Dimension d)
Constructs a Dimension with the width and height of the passed Dimension. |
|
Dimension(int w,
int h)
Constructs a Dimension with the supplied width and height values. |
|
Dimension(org.eclipse.swt.graphics.Image image)
Constructs a Dimension with the width and height of the Image supplied as input. |
|
Dimension(org.eclipse.swt.graphics.Point p)
Constructs a Dimension where the width and height are the x and y distances of the input point from the origin. |
|
| Method Summary | |
|---|---|
boolean |
contains(Dimension d)
Returns true if the input Dimension fits into this
Dimension. |
boolean |
containsProper(Dimension d)
Returns true if this Dimension properly contains the one
specified. |
boolean |
equals(int w,
int h)
Returns true if this Dimension's width and height are equal
to the given width and height. |
boolean |
equals(Object o)
Returns whether the input Object is equivalent to this Dimension. |
Dimension |
expand(Dimension d)
Expands the size of this Dimension by the specified amount. |
Dimension |
expand(int w,
int h)
Expands the size of this Dimension by the specified width and height. |
Dimension |
expand(Point p)
Deprecated. Use expand(int, int) instead. |
int |
getArea()
Returns the area of this Dimension. |
Dimension |
getCopy()
Creates and returns a copy of this Dimension. |
Dimension |
getDifference(Dimension d)
Deprecated. Use getShrinked(Dimension) instead. |
Dimension |
getExpanded(Dimension d)
Creates and returns a Dimension representing the sum of this Dimension and the one specified. |
Dimension |
getExpanded(int w,
int h)
Creates and returns a new Dimension representing the sum of this Dimension and the one specified. |
Dimension |
getIntersected(Dimension d)
Creates and returns a new Dimension representing the intersection of this Dimension and the one specified. |
Dimension |
getNegated()
Creates and returns a new Dimension with negated values. |
Dimension |
getScaled(double amount)
Creates a new Dimension with its width and height scaled by the specified value. |
Dimension |
getShrinked(Dimension d)
Creates and returns a new Dimension whose size will be reduced by the width and height of the given Dimension. |
Dimension |
getShrinked(int w,
int h)
Creates and returns a new Dimension whose size will be reduced by the width and height of the given Dimension. |
Dimension |
getTransposed()
Creates a new Dimension with its height and width swapped. |
Dimension |
getUnioned(Dimension d)
Creates a new Dimension representing the union of this Dimension with the one specified. |
int |
hashCode()
|
int |
height()
Returns the height of this dimension. |
Dimension |
intersect(Dimension d)
This Dimension is intersected with the one specified. |
boolean |
isEmpty()
Returns true if either dimension is less than or equal to 0. |
static Dimension |
max(Dimension d1,
Dimension d2)
Creates a new Dimension representing the MAX of two provided Dimensions. |
static Dimension |
min(Dimension d1,
Dimension d2)
Creates a new Dimension representing the MIN of two provided Dimensions. |
Dimension |
negate()
Negates the width and height of this Dimension. |
void |
performScale(double factor)
Scales this object by the scale factor. |
void |
performTranslate(int dx,
int dy)
Translates this object horizontally by dx and vertically by
dy. |
double |
preciseHeight()
Returns double height |
double |
preciseWidth()
Returns double width |
Dimension |
scale(double factor)
Scales the width and height of this Dimension by the amount supplied, and returns this for convenience. |
Dimension |
scale(double widthFactor,
double heightFactor)
Scales the width of this Dimension by w and scales the height of this Dimension by h. |
Dimension |
setHeight(int height)
Sets the height of this Rectangle to the specified one. |
void |
setSize(Dimension d)
Copies the width and height values of the input Dimension to this Dimension. |
Dimension |
setSize(int w,
int h)
Sets the size of this dimension to the specified width and height. |
Dimension |
setWidth(int width)
Sets the width of this Rectangle to the specified one. |
Dimension |
shrink(Dimension d)
Shrinks the size of this Dimension by the width and height values of the given Dimension. |
Dimension |
shrink(int w,
int h)
Reduces the width of this Dimension by w, and reduces the height of this Dimension by h. |
String |
toString()
|
Dimension |
transpose()
Swaps the width and height of this Dimension, and returns this for convenience. |
Dimension |
union(Dimension d)
Sets the width of this Dimension to the greater of this Dimension's width and d.width. |
int |
width()
Returns the width of this dimension |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Dimension SINGLETON
public int width
public int height
| Constructor Detail |
|---|
public Dimension()
public Dimension(Dimension d)
d - the Dimension supplying the initial values
public Dimension(int w,
int h)
w - the widthh - the heightpublic Dimension(org.eclipse.swt.graphics.Image image)
image - the image supplying the dimensionspublic Dimension(org.eclipse.swt.graphics.Point p)
p - the Point supplying the initial values| Method Detail |
|---|
public static Dimension max(Dimension d1,
Dimension d2)
d1 - first dimensiond2 - second dimension
public static Dimension min(Dimension d1,
Dimension d2)
d1 - first dimensiond2 - second dimension
public boolean contains(Dimension d)
true if the input Dimension fits into this
Dimension. A Dimension of the same size is considered to "fit".
d - the dimension being tested
true if this Dimension contains dpublic boolean containsProper(Dimension d)
true if this Dimension properly contains the one
specified. Proper containment is defined as containment using \"<\",
instead of \"<=\".
d - the dimension being tested
true if this Dimension properly contains the one
specified
public boolean equals(int w,
int h)
true if this Dimension's width and height are equal
to the given width and height.
w - the widthh - the height
true if this dimension's width and height are equal
to those given.public boolean equals(Object o)
true if the Object is a Dimension and its width and height
are equal to this Dimension's width and height, false
otherwise.
equals in class Objecto - the Object being tested for equality
true if the given object is equal to this dimensionpublic Dimension expand(Dimension d)
d - the Dimension providing the expansion width and height
this for convenience
public Dimension expand(int w,
int h)
w - Value by which the width should be increasedh - Value by which the height should be increased
this for conveniencepublic Dimension expand(Point p)
expand(int, int) instead.
p - the Point supplying the dimensional values
this for conveniencepublic int getArea()
public Dimension getCopy()
public Dimension getDifference(Dimension d)
getShrinked(Dimension) instead.
d - the dimension being compared
public Dimension getExpanded(Dimension d)
d - the dimension providing the expansion width and height
public Dimension getExpanded(int w,
int h)
w - value by which the width of this is to be expandedh - value by which the height of this is to be expanded
public Dimension getIntersected(Dimension d)
d - the Dimension to intersect with
public Dimension getNegated()
public Dimension getScaled(double amount)
amount - Value by which the width and height are scaled
public Dimension getShrinked(Dimension d)
d - the dimension whose width and height values will be considered
public Dimension getShrinked(int w,
int h)
w - the value by which the width is to be reducedh - the value by which the height is to be reduced
public Dimension getTransposed()
public Dimension getUnioned(Dimension d)
d - the Dimension to be unioned
public int hashCode()
hashCode in class ObjectObject.hashCode()public int height()
public Dimension intersect(Dimension d)
d - the Dimension used to perform the min()
this for conveniencepublic boolean isEmpty()
true if either dimension is less than or equal to 0.
true if either dimension is less than or equal to 0.public Dimension negate()
this for conveniencepublic void performScale(double factor)
Translatable
performScale in interface Translatablefactor - The scale factorTranslatable.performScale(double)
public void performTranslate(int dx,
int dy)
Translatabledx and vertically by
dy.
performTranslate in interface Translatabledx - The amount to translate horizontallydy - The amount to translate verticallyTranslatable.performTranslate(int, int)public double preciseHeight()
double height
double heightpublic double preciseWidth()
double width
double widthpublic Dimension scale(double factor)
factor - value by which this Dimension's width and height are to be
scaled
this for convenience
public Dimension scale(double widthFactor,
double heightFactor)
widthFactor - the value by which the width is to be scaledheightFactor - the value by which the height is to be scaled
this for conveniencepublic Dimension setHeight(int height)
height - The new height
public void setSize(Dimension d)
d - the dimension supplying the values
public Dimension setSize(int w,
int h)
w - The new widthh - The new heightpublic Dimension setWidth(int width)
width - The new width
public Dimension shrink(Dimension d)
d - The dimension whose width and height values are to be used
this for convenience
public Dimension shrink(int w,
int h)
w - the value by which the width is to be reducedh - the value by which the height is to be reduced
this for conveniencepublic String toString()
toString in class ObjectObject.toString()public Dimension transpose()
this for conveniencepublic Dimension union(Dimension d)
d - the Dimension to union with this Dimension
this for conveniencepublic int width()
|
Eclipse Draw2d 3.7 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||