|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.draw2d.geometry.Rectangle
Represents a Rectangle(x, y, width, height). This class provides various methods for manipulating this Rectangle or creating new derived geometrical Objects.
Field Summary | |
int |
height
the height |
static Rectangle |
SINGLETON
A singleton for use in short calculations. |
int |
width
the width |
int |
x
the X value |
int |
y
the Y value |
Constructor Summary | |
Rectangle()
Constructs a Rectangle at the origin with zero width and height. |
|
Rectangle(int x,
int y,
int width,
int height)
Constructs a Rectangle with the provided values. |
|
Rectangle(Point p,
Dimension size)
Constructs a Rectangle given a location and size. |
|
Rectangle(Point p1,
Point p2)
Constructs the smallest Rectangle that contains the specified Points. |
|
Rectangle(Rectangle rect)
Constructs a copy of the provided Rectangle. |
|
Rectangle(Rectangle rect)
Constructs a copy of the provided SWT Rectangle . |
Method Summary | |
int |
bottom()
Returns the y-coordinate of the bottom of this Rectangle. |
boolean |
contains(int x,
int y)
Returns whether the given coordinates are within the boundaries of this Rectangle. |
boolean |
contains(Point pt)
Returns whether the given point is within the boundaries of this Rectangle. |
Rectangle |
crop(Insets insets)
Crops this rectangle by the amount specified in insets . |
boolean |
equals(Object o)
Returns whether the input object is equal to this Rectangle or not. |
Rectangle |
expand(Insets insets)
Expands the horizontal and vertical sides of this Rectangle by the width and height of the given Insets, and returns this for convenience. |
Rectangle |
expand(int h,
int v)
Expands the horizontal and vertical sides of this Rectangle with the values provided as input, and returns this for convenience. |
Point |
getBottom()
Returns a new Point representing the middle point of the bottom side of this Rectangle. |
Point |
getBottomLeft()
Returns a new Point representing the bottom left point of this Rectangle. |
Point |
getBottomRight()
Returns a new Point representing the bottom right point of this Rectangle. |
Point |
getCenter()
Returns a new point representing the center of this Rectangle. |
Rectangle |
getCopy()
Returns a new Rectangle which has the exact same parameters as this Rectangle. |
Rectangle |
getCropped(Insets insets)
Returns a new Rectangle with the specified insets cropped. |
Rectangle |
getExpanded(Insets insets)
Creates and returns a new Rectangle with the bounds of this
Rectangle, expanded by the given Insets. |
Rectangle |
getExpanded(int h,
int v)
Returns a new incremented Rectangle, where the sides are expanded by the horizonatal and vertical values provided. |
Rectangle |
getIntersection(Rectangle rect)
Returns a new Rectangle which has the intersection of this Rectangle and the rectangle provided as input. |
Point |
getLeft()
Returns a new Point representing the middle point of the left hand side of this Rectangle. |
Point |
getLocation()
Returns the upper left hand corner of the rectangle. |
int |
getPosition(Point pt)
Returns an integer which represents the position of the given point with respect to this rectangle. |
Rectangle |
getResized(Dimension d)
Returns a new Rectangle which is equivalent to this Rectangle with its dimensions modified by the passed Dimension d. |
Rectangle |
getResized(int w,
int h)
Returns a new Rectangle which is equivalent to this Rectangle with its dimensions modified by the passed width w and height h. |
Point |
getRight()
Returns a new Point which represents the middle point of the right hand side of this Rectangle. |
Dimension |
getSize()
Retuns the dimensions of this Rectangle. |
Point |
getTop()
Returns a new Point which represents the middle point of the top side of this Rectangle. |
Point |
getTopLeft()
Returns a new Point which represents the top left hand corner of this Rectangle. |
Point |
getTopRight()
Returns a new Point which represents the top right hand corner of this Rectangle. |
Rectangle |
getTranslated(int dx,
int dy)
Returns a new Rectangle which is shifted along each axis by the passed values. |
Rectangle |
getTranslated(Point pt)
Returns a new Rectangle which is shifted by the position of the given Point. |
Rectangle |
getTransposed()
Returns a new rectangle whose width and height have been interchanged, as well as its x and y values. |
Rectangle |
getUnion(Rectangle rect)
Returns a new Rectangle which contains both this Rectangle and the Rectangle supplied as input. |
Rectangle |
intersect(Rectangle rect)
Sets the size of this Rectangle to the intersection region with the Rectangle supplied as input, and returns this for convenience. |
boolean |
intersects(Rectangle rect)
Returns true if the input Rectangle intersects this Rectangle. |
boolean |
isEmpty()
Returns true if this Rectangle's width or height is less than or
equal to 0. |
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 . |
Rectangle |
resize(Dimension sizeDelta)
Resizes this Rectangle by the Dimension provided as input and returns this for convenience. |
Rectangle |
resize(int dw,
int dh)
Resizes this Rectangle by the values supplied as input and returns this for convenience. |
int |
right()
Returns the x-coordinate of the right side of this Rectangle. |
Rectangle |
scale(double scaleFactor)
Scales the location and size of this Rectangle by the given scale and returns this for convenience. |
Rectangle |
scale(double scaleX,
double scaleY)
Scales the location and size of this Rectangle by the given scales and returns this for convenience. |
Rectangle |
setBounds(Rectangle rect)
Sets the parameters of this Rectangle from the Rectangle passed in and returns this for convenience. |
Rectangle |
setLocation(int x1,
int y1)
Sets the location of this Rectangle to the coordinates given as input and returns this for convenience. |
Rectangle |
setLocation(Point p)
Sets the location of this Rectangle to the point given as input and returns this for convenience. |
Rectangle |
setSize(Dimension d)
Sets the width and height of this Rectangle to the width and height of the given Dimension and returns this for convenience. |
Rectangle |
setSize(int w,
int h)
Sets the width of this Rectangle to w and the height of this Rectangle to h and returns this for convenience. |
Rectangle |
shrink(int h,
int v)
Shrinks the sides of this Rectangle by the horizontal and vertical values provided as input, and returns this Rectangle for convenience. |
String |
toString()
Returns the description of this Rectangle. |
boolean |
touches(Rectangle rect)
Returns true if the input Rectangle touches this Rectangle. |
Rectangle |
translate(int dx,
int dy)
Moves this Rectangle horizontally by dx and vertically by dy, then returns this Rectangle for convenience. |
Rectangle |
translate(Point p)
Moves this Rectangle horizontally by the x value of the given Point and vertically by the y value of the given Point, then returns this Rectangle for convenience. |
Rectangle |
transpose()
Switches the x and y values, as well as the width and height of this Rectangle. |
Rectangle |
union(Dimension d)
Unions this Rectangle's width and height with the specified Dimension. |
Rectangle |
union(int x1,
int y1)
Updates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the coordinate (x,y). |
Rectangle |
union(int x,
int y,
int w,
int h)
Updates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the rectangle (x, y, w, h). |
void |
union(Point p)
Updates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the given Point. |
Rectangle |
union(Rectangle rect)
Updates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the given Rectangle. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int x
public int y
public int width
public int height
public static final Rectangle SINGLETON
Constructor Detail |
public Rectangle()
public Rectangle(Point p, Dimension size)
p
- the locationsize
- the sizepublic Rectangle(Rectangle rect)
rect
- Rectangle supplying the initial valuespublic Rectangle(Rectangle rect)
Rectangle
.
rect
- The SWT Rectangle being copiedpublic Rectangle(int x, int y, int width, int height)
x
- X locationy
- Y locationwidth
- Width of the rectangleheight
- Height of the rectanglepublic Rectangle(Point p1, Point p2)
p1
- Upper left hand cornerp2
- Lower right hand cornerMethod Detail |
public int bottom()
public boolean contains(Point pt)
pt
- Point being tested for containment
public boolean contains(int x, int y)
x
- X valuey
- Y value
public Rectangle crop(Insets insets)
insets
.
insets
- Insets to be removed from the Rectangle
this
for conveniencepublic boolean equals(Object o)
equals
in class Object
o
- Object being tested for equality
public Rectangle expand(int h, int v)
h
- Horizontal incrementv
- Vertical increment
this
for conveniencepublic Rectangle expand(Insets insets)
insets
- contains the amounts to expand on each side
this
for conveniencepublic Point getBottom()
public Point getBottomLeft()
public Point getBottomRight()
public Point getCenter()
public Rectangle getCopy()
public Rectangle getCropped(Insets insets)
insets
- Insets being cropped from the Rectangle
public Rectangle getExpanded(int h, int v)
h
- Horizontal incrementv
- Vertical inrement
public Rectangle getExpanded(Insets insets)
this
Rectangle, expanded by the given Insets.
insets
- The insets used to expand this rectangle
public Rectangle getIntersection(Rectangle rect)
rect
- Rectangle provided to test for intersection
public Point getLeft()
public Point getLocation()
setLocation(Point)
public int getPosition(Point pt)
Returns an integer which represents the position of the given point with respect to
this rectangle. Possible return values are bitwise ORs of the constants WEST, EAST,
NORTH, and SOUTH as found in PositionConstants
.
Returns PositionConstant.NONE if the given point is inside this Rectangle.
pt
- The Point whose position has to be determined
int
which is a PositionConstantPositionConstants
public Rectangle getResized(int w, int h)
w
- Amount by which width is to be resizedh
- Amount by which height is to be resized
public Rectangle getResized(Dimension d)
d
- Dimensions by which the rectangle's size should be modified
public Point getRight()
public Dimension getSize()
public Point getTop()
public Point getTopLeft()
public Point getTopRight()
public Rectangle getTranslated(int dx, int dy)
dx
- Displacement along X axisdy
- Displacement along Y axis
public Rectangle getTranslated(Point pt)
pt
- Point providing the amount of shift along each axis
public Rectangle getTransposed()
public Rectangle getUnion(Rectangle rect)
rect
- Rectangle for calculating union
public Rectangle intersect(Rectangle rect)
rect
- Rectangle for the calculating intersection.
this
for conveniencepublic boolean intersects(Rectangle rect)
true
if the input Rectangle intersects this Rectangle.
rect
- Rectangle for the intersetion test
true
if the input Rectangle intersects this Rectanglepublic boolean isEmpty()
true
if this Rectangle's width or height is less than or
equal to 0.
true
if this Rectangle is emptypublic void performScale(double factor)
Translatable
performScale
in interface Translatable
factor
- The scale factorTranslatable.performScale(double)
public void performTranslate(int dx, int dy)
Translatable
dx
and vertically by
dy
.
performTranslate
in interface Translatable
dx
- The amount to translate horizontallydy
- The amount to translate verticallyTranslatable.performTranslate(int, int)
public Rectangle resize(Dimension sizeDelta)
sizeDelta
- Resize data as a Dimension
this
for conveniencepublic Rectangle resize(int dw, int dh)
dw
- Amount by which width is to be resizeddh
- Amount by which height is to be resized
this
for conveniencepublic int right()
public final Rectangle scale(double scaleFactor)
scaleFactor
- The factor by which this rectangle will be scaled
this
for conveniencepublic Rectangle scale(double scaleX, double scaleY)
scaleX
- the factor by which the X dimension has to be scaledscaleY
- the factor by which the Y dimension has to be scaled
this
for conveniencepublic Rectangle setBounds(Rectangle rect)
rect
- Rectangle providing the bounding values
this
for conveniencepublic Rectangle setLocation(Point p)
p
- New position of this Rectangle
this
for conveniencepublic Rectangle setLocation(int x1, int y1)
x1
- The new X coordinatey1
- The new Y coordinate
this
for conveniencepublic Rectangle setSize(Dimension d)
d
- The new Dimension
this
for conveniencepublic Rectangle setSize(int w, int h)
w
- The new widthh
- The new height
this
for conveniencepublic Rectangle shrink(int h, int v)
h
- Horizontal reduction amountv
- Vertical reduction amount
this
for conveniencepublic String toString()
toString
in class Object
public boolean touches(Rectangle rect)
true
if the input Rectangle touches this Rectangle.
rect
- Rectangle being checked for contact
true
if rect touches this Rectanglepublic Rectangle translate(Point p)
p
- Point which provides translation information
this
for conveniencepublic Rectangle translate(int dx, int dy)
dx
- Shift along X axisdy
- Shift along Y axis
this
for conveniencepublic Rectangle transpose()
this
for conveniencepublic Rectangle union(Dimension d)
d
- Dimension being unioned
this
for conveniencepublic Rectangle union(int x1, int y1)
x1
- X coordinatey1
- Y coordinate
this
for conveniencepublic final void union(Point p)
p
- Point to be unioned with this Rectanglepublic final Rectangle union(Rectangle rect)
rect
- Rectangle to be unioned with this Rectangle
this
for conveniencepublic Rectangle union(int x, int y, int w, int h)
x
- X coordiante of desired union.y
- Y coordiante of desired union.w
- Width of desired union.h
- Height of desired union.
this
for convenience
|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |