Class Rectangle
- java.lang.Object
-
- org.eclipse.birt.chart.computation.Rectangle
-
public class Rectangle extends java.lang.ObjectTheRectangleclass defines a rectangle specified in Rectangle coordinates.
-
-
Field Summary
Fields Modifier and Type Field Description doubleheightThe height of thisRectangle.static intOUT_BOTTOMThe bitmask that indicates that a point lies below thisRectangle2D.static intOUT_LEFTThe bitmask that indicates that a point lies to the left of thisRectangle2D.static intOUT_RIGHTThe bitmask that indicates that a point lies to the right of thisRectangle2D.static intOUT_TOPThe bitmask that indicates that a point lies above thisRectangle2D.doublewidthThe width of thisRectangle.doublexThe x coordinate of thisRectangle.doubleyThe y coordinate of thisRectangle.
-
Constructor Summary
Constructors Constructor Description Rectangle()Constructs a newRectangle, initialized to location (0, 0) and size (0, 0).Rectangle(double x, double y, double w, double h)Constructs and initializes aRectanglefrom the specified Rectangle coordinates.Rectangle(BoundingBox bb)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Point lo)RectanglecreateIntersection(Rectangle r)Returns a newRectangleobject representing the intersection of thisRectanglewith the specifiedRectangle.RectanglecreateUnion(Rectangle r)Returns a newRectangleobject representing the union of thisRectanglewith the specifiedRectangle.BoundsgetBounds()RectanglegetBounds2D()Returns the high precision bounding box of thisRectangle.doublegetHeight()Returns the height of thisRectanglein Rectangle precision.doublegetMaxX()Returns the largest X coordinate of the framing rectangle of theRectangleindoubleprecision.doublegetMaxY()Returns the largest Y coordinate of the framing rectangle of theRectangleindoubleprecision.doublegetMinX()Returns the smallest X coordinate of the framing rectangle of theRectangleindoubleprecision.doublegetMinY()Returns the smallest Y coordinate of the framing rectangle of theRectangleindoubleprecision.doublegetWidth()Returns the width of thisRectanglein Rectangle precision.doublegetX()Returns the X coordinate of thisRectanglein Rectangle precision.doublegetY()Returns the Y coordinate of thisRectanglein Rectangle precision.booleanisEmpty()Determines whether or not thisRectangleis empty.intoutcode(double x, double y)Determines where the specified Rectangle coordinates lie with respect to thisRectangle.voidsetRect(double x, double y, double w, double h)Sets the location and size of thisRectangleto the specified Rectangle values.voidsetRect(Rectangle r)Sets thisRectangleto be the same as the specifiedRectangle.java.lang.StringtoString()Returns theStringrepresentation of thisRectangle.voidunion(Rectangle rect)static Rectangleunion(Rectangle rect1, Rectangle rect2)
-
-
-
Field Detail
-
OUT_LEFT
public static final int OUT_LEFT
The bitmask that indicates that a point lies to the left of thisRectangle2D.- See Also:
- Constant Field Values
-
OUT_TOP
public static final int OUT_TOP
The bitmask that indicates that a point lies above thisRectangle2D.- See Also:
- Constant Field Values
-
OUT_RIGHT
public static final int OUT_RIGHT
The bitmask that indicates that a point lies to the right of thisRectangle2D.- See Also:
- Constant Field Values
-
OUT_BOTTOM
public static final int OUT_BOTTOM
The bitmask that indicates that a point lies below thisRectangle2D.- See Also:
- Constant Field Values
-
x
public double x
The x coordinate of thisRectangle.
-
y
public double y
The y coordinate of thisRectangle.
-
width
public double width
The width of thisRectangle.
-
height
public double height
The height of thisRectangle.
-
-
Constructor Detail
-
Rectangle
public Rectangle()
Constructs a newRectangle, initialized to location (0, 0) and size (0, 0).
-
Rectangle
public Rectangle(BoundingBox bb)
-
Rectangle
public Rectangle(double x, double y, double w, double h)Constructs and initializes aRectanglefrom the specified Rectangle coordinates.- Parameters:
x- , y the coordinates of the upper left corner of the newly constructedRectanglew- the width of the newly constructedRectangleh- the height of the newly constructedRectangle
-
-
Method Detail
-
getBounds
public Bounds getBounds()
-
getX
public double getX()
Returns the X coordinate of thisRectanglein Rectangle precision.- Returns:
- the X coordinate of this
Rectangle.
-
getY
public double getY()
Returns the Y coordinate of thisRectanglein Rectangle precision.- Returns:
- the Y coordinate of this
Rectangle.
-
getWidth
public double getWidth()
Returns the width of thisRectanglein Rectangle precision.- Returns:
- the width of this
Rectangle.
-
getHeight
public double getHeight()
Returns the height of thisRectanglein Rectangle precision.- Returns:
- the height of this
Rectangle.
-
isEmpty
public boolean isEmpty()
Determines whether or not thisRectangleis empty.- Returns:
trueif thisRectangleis empty;falseotherwise.
-
setRect
public void setRect(double x, double y, double w, double h)Sets the location and size of thisRectangleto the specified Rectangle values.- Parameters:
x- , y the coordinates to which to set the upper left corner of thisRectanglew- the value to use to set the width of thisdoubleh- the value to use to set the height of thisdouble
-
setRect
public void setRect(Rectangle r)
Sets thisRectangleto be the same as the specifiedRectangle.- Parameters:
r- the specifiedRectangle
-
outcode
public int outcode(double x, double y)Determines where the specified Rectangle coordinates lie with respect to thisRectangle. This method computes a binary OR of the appropriate mask values indicating, for each side of thisRectangle, whether or not the specified coordinates are on the same side of the edge as the rest of thisRectangle.- Parameters:
x- , y the specified coordinates- Returns:
- the logical OR of all appropriate out codes.
- See Also:
OUT_LEFT,OUT_TOP,OUT_RIGHT,OUT_BOTTOM
-
getBounds2D
public Rectangle getBounds2D()
Returns the high precision bounding box of thisRectangle.- Returns:
- the bounding box of this
Rectangle.
-
createIntersection
public Rectangle createIntersection(Rectangle r)
Returns a newRectangleobject representing the intersection of thisRectanglewith the specifiedRectangle.- Parameters:
r- theRectangleto be intersected with thisRectangle- Returns:
- the largest
Rectanglecontained in both the specifiedRectangleand in thisRectangle.
-
createUnion
public Rectangle createUnion(Rectangle r)
Returns a newRectangleobject representing the union of thisRectanglewith the specifiedRectangle.- Parameters:
r- theRectangleto be combined with thisRectangle- Returns:
- the smallest
Rectanglecontaining both the specifiedRectangleand thisRectangle.
-
union
public void union(Rectangle rect)
-
toString
public java.lang.String toString()
Returns theStringrepresentation of thisRectangle.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringrepresenting thisRectangle.
-
getMinX
public double getMinX()
Returns the smallest X coordinate of the framing rectangle of theRectangleindoubleprecision.- Returns:
- the smallest x coordinate of the framing rectangle of the
Rectangle.
-
getMinY
public double getMinY()
Returns the smallest Y coordinate of the framing rectangle of theRectangleindoubleprecision.- Returns:
- the smallest y coordinate of the framing rectangle of the
Rectangle.
-
getMaxX
public double getMaxX()
Returns the largest X coordinate of the framing rectangle of theRectangleindoubleprecision.- Returns:
- the largest x coordinate of the framing rectangle of the
Rectangle.
-
getMaxY
public double getMaxY()
Returns the largest Y coordinate of the framing rectangle of theRectangleindoubleprecision.- Returns:
- the largest y coordinate of the framing rectangle of the
Rectangle.
-
contains
public boolean contains(Point lo)
-
-