|
Eclipse Draw2d 3.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.draw2d.geometry.Rectangle
public class 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(org.eclipse.swt.graphics.Rectangle rect)
Constructs a copy of the provided SWT Rectangle . |
|
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. |
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 p)
Returns whether the given point is within the boundaries of this Rectangle. |
boolean |
contains(Rectangle rect)
Returns true if the given rectangle is contained within the
boundaries of this Rectangle. |
Rectangle |
crop(Insets insets)
Deprecated. Use shrink(Insets) instead. |
boolean |
equals(int x,
int y,
int width,
int height)
Returns true if this Rectangle's x, y, width, and height
values are identical to the provided ones. |
boolean |
equals(java.lang.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)
Deprecated. Use getShrinked(Insets) instead. |
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 horizontal 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 p)
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. |
Rectangle |
getShrinked(Insets insets)
Returns a new Rectangle shrinked by the specified insets. |
Rectangle |
getShrinked(int h,
int v)
Returns a new Rectangle, where the sides are shrinked by the horizontal and vertical values supplied. |
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(Point p)
Returns a new Rectangle which contains both this Rectangle and the Point supplied as input. |
Rectangle |
getUnion(Rectangle rect)
Returns a new Rectangle which contains both this Rectangle and the Rectangle supplied as input. |
int |
hashCode()
|
int |
height()
Returns the current height of this Rectangle |
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 . |
double |
preciseHeight()
Returns double height |
double |
preciseWidth()
Returns double width |
double |
preciseX()
Returns double x coordinate |
double |
preciseY()
Returns double y coordinate |
Rectangle |
resize(Dimension d)
Resizes this Rectangle by the Dimension provided as input and returns this for convenience. |
Rectangle |
resize(int w,
int h)
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(int x,
int y,
int width,
int height)
Sets the x, y, width, and height values of this Rectangle to the provided values. |
Rectangle |
setBounds(Point location,
Dimension size)
Sets the location and size of this rectangle to the provided ones. |
Rectangle |
setBounds(Rectangle rect)
Sets the parameters of this Rectangle from the Rectangle passed in and returns this for convenience. |
Rectangle |
setHeight(int height)
Sets the height of this Rectangle to the specified one. |
Rectangle |
setLocation(int x,
int y)
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 |
setWidth(int width)
Sets the width of this Rectangle to the specified one. |
Rectangle |
setX(int x)
Sets the x value of the Rectangle and returns this for convenience. |
Rectangle |
setY(int y)
Sets the y value of the Rectangle and returns this for convenience. |
Rectangle |
shrink(Insets insets)
Shrinks this rectangle by the amount specified in insets . |
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. |
java.lang.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)
Deprecated. Union with a dimension generally does not make much sense, thus deprecating this. Use Dimension.max(Dimension, Dimension) and
setSize(Dimension) to implement the desired behavior
instead. |
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. |
int |
width()
Returns the current width of this Rectangle |
int |
x()
Returns the x value of this Rectangle. |
int |
y()
Returns the y value of the Rectangle |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Rectangle SINGLETON
public int height
public int width
public int x
public int y
Constructor Detail |
---|
public Rectangle()
public Rectangle(int x, int y, int width, int height)
x
- X locationy
- Y locationwidth
- Width of the rectangleheight
- Height of the rectanglepublic Rectangle(org.eclipse.swt.graphics.Rectangle rect)
Rectangle
.
rect
- The SWT Rectangle being copiedpublic Rectangle(Point p, Dimension size)
p
- the locationsize
- the sizepublic Rectangle(Point p1, Point p2)
p1
- Upper left hand cornerp2
- Lower right hand cornerMethod Detail |
---|
public int bottom()
public boolean contains(int x, int y)
x
- X valuey
- Y value
public boolean contains(Point p)
p
- Point being tested for containment
public boolean contains(Rectangle rect)
true
if the given rectangle is contained within the
boundaries of this Rectangle.
rect
- the Rectangle to test
public Rectangle crop(Insets insets)
shrink(Insets)
instead.
insets
.
insets
- Insets to be removed from the Rectangle
this
for conveniencepublic boolean equals(int x, int y, int width, int height)
true
if this Rectangle's x, y, width, and height
values are identical to the provided ones.
x
- The x value to testy
- The y value to testwidth
- The width value to testheight
- The height value to test
true
if this Rectangle's x, y, width, and height
values are identical to the provided ones, false
otherwisepublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Object being tested for equality
public Rectangle expand(Insets insets)
insets
- contains the amounts to expand on each side
this
for conveniencepublic Rectangle expand(int h, int v)
h
- Horizontal incrementv
- Vertical increment
this
for conveniencepublic Point getBottom()
public Point getBottomLeft()
public Point getBottomRight()
public Point getCenter()
public Rectangle getCopy()
public Rectangle getCropped(Insets insets)
getShrinked(Insets)
instead.
insets
- Insets being cropped from the Rectangle
public Rectangle getExpanded(Insets insets)
this
Rectangle, expanded by the given Insets.
insets
- The insets used to expand this rectangle
public Rectangle getExpanded(int h, int v)
h
- Horizontal incrementv
- Vertical increment
public Rectangle getIntersection(Rectangle rect)
rect
- Rectangle provided to test for intersection
public Point getLeft()
public Point getLocation()
setLocation(Point)
public int getPosition(Point p)
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.
p
- The Point whose position has to be determined
int
which is a PositionConstantPositionConstants
public Rectangle getResized(Dimension d)
d
- Dimensions by which the rectangle's size should be modified
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 Point getRight()
public Rectangle getShrinked(Insets insets)
insets
- Insets being cropped from the Rectangle
public Rectangle getShrinked(int h, int v)
h
- Horizontal reduction amountv
- Vertical reduction amount
this
for conveniencepublic 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(Point p)
p
- Point for calculating union
public Rectangle getUnion(Rectangle rect)
rect
- Rectangle for calculating union
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public int height()
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 intersection 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 double preciseHeight()
double
height
double
heightpublic double preciseWidth()
double
width
double
widthpublic double preciseX()
double
x coordinate
double
x coordinatepublic double preciseY()
double
y coordinate
double
y coordinatepublic Rectangle resize(Dimension d)
d
- Resize data as a Dimension
this
for conveniencepublic Rectangle resize(int w, int h)
w
- Amount by which width is to be resizedh
- 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(int x, int y, int width, int height)
x
- The new xy
- The new ywidth
- The new widthheight
- The new height
public Rectangle setBounds(Point location, Dimension size)
location
- The new locationsize
- The new size
public Rectangle setBounds(Rectangle rect)
rect
- Rectangle providing the bounding values
this
for conveniencepublic Rectangle setHeight(int height)
height
- The new height
public Rectangle setLocation(int x, int y)
x
- The new X coordinatey
- The new Y coordinate
this
for conveniencepublic Rectangle setLocation(Point p)
p
- New position of this Rectangle
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 setWidth(int width)
width
- The new width
public Rectangle setX(int x)
x
- The new x value
this
for conveniencepublic Rectangle setY(int y)
y
- The new y value
this
for conveniencepublic Rectangle shrink(Insets insets)
insets
.
insets
- Insets to be removed from the Rectangle
this
for conveniencepublic Rectangle shrink(int h, int v)
h
- Horizontal reduction amountv
- Vertical reduction amount
this
for conveniencepublic java.lang.String toString()
toString
in class java.lang.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(int dx, int dy)
dx
- Shift along X axisdy
- Shift along Y axis
this
for conveniencepublic Rectangle translate(Point p)
p
- Point which provides translation information
this
for conveniencepublic Rectangle transpose()
this
for conveniencepublic Rectangle union(Dimension d)
Dimension.max(Dimension, Dimension)
and
setSize(Dimension)
to implement the desired behavior
instead.
d
- Dimension being unioned
this
for conveniencepublic Rectangle union(int x1, int y1)
x1
- X coordinatey1
- Y coordinate
this
for conveniencepublic Rectangle union(int x, int y, int w, int h)
x
- X coordinate of desired union.y
- Y coordinate of desired union.w
- Width of desired union.h
- Height of desired union.
this
for conveniencepublic void union(Point p)
p
- Point to be unioned with this Rectanglepublic Rectangle union(Rectangle rect)
rect
- Rectangle to be unioned with this Rectangle
this
for conveniencepublic int width()
public int x()
public int y()
|
Eclipse Draw2d 3.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |