Class Rectangle
- java.lang.Object
-
- org.eclipse.birt.chart.computation.Rectangle
-
public class Rectangle extends java.lang.Object
TheRectangle
class defines a rectangle specified in Rectangle coordinates.
-
-
Field Summary
Fields Modifier and Type Field Description double
height
The height of thisRectangle
.static int
OUT_BOTTOM
The bitmask that indicates that a point lies below thisRectangle2D
.static int
OUT_LEFT
The bitmask that indicates that a point lies to the left of thisRectangle2D
.static int
OUT_RIGHT
The bitmask that indicates that a point lies to the right of thisRectangle2D
.static int
OUT_TOP
The bitmask that indicates that a point lies above thisRectangle2D
.double
width
The width of thisRectangle
.double
x
The x coordinate of thisRectangle
.double
y
The 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 aRectangle
from the specified Rectangle coordinates.Rectangle(BoundingBox bb)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Point lo)
Rectangle
createIntersection(Rectangle r)
Returns a newRectangle
object representing the intersection of thisRectangle
with the specifiedRectangle
.Rectangle
createUnion(Rectangle r)
Returns a newRectangle
object representing the union of thisRectangle
with the specifiedRectangle
.Bounds
getBounds()
Rectangle
getBounds2D()
Returns the high precision bounding box of thisRectangle
.double
getHeight()
Returns the height of thisRectangle
in Rectangle precision.double
getMaxX()
Returns the largest X coordinate of the framing rectangle of theRectangle
indouble
precision.double
getMaxY()
Returns the largest Y coordinate of the framing rectangle of theRectangle
indouble
precision.double
getMinX()
Returns the smallest X coordinate of the framing rectangle of theRectangle
indouble
precision.double
getMinY()
Returns the smallest Y coordinate of the framing rectangle of theRectangle
indouble
precision.double
getWidth()
Returns the width of thisRectangle
in Rectangle precision.double
getX()
Returns the X coordinate of thisRectangle
in Rectangle precision.double
getY()
Returns the Y coordinate of thisRectangle
in Rectangle precision.boolean
isEmpty()
Determines whether or not thisRectangle
is empty.int
outcode(double x, double y)
Determines where the specified Rectangle coordinates lie with respect to thisRectangle
.void
setRect(double x, double y, double w, double h)
Sets the location and size of thisRectangle
to the specified Rectangle values.void
setRect(Rectangle r)
Sets thisRectangle
to be the same as the specifiedRectangle
.java.lang.String
toString()
Returns theString
representation of thisRectangle
.void
union(Rectangle rect)
static Rectangle
union(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 aRectangle
from the specified Rectangle coordinates.- Parameters:
x
- , y the coordinates of the upper left corner of the newly constructedRectangle
w
- the width of the newly constructedRectangle
h
- the height of the newly constructedRectangle
-
-
Method Detail
-
getBounds
public Bounds getBounds()
-
getX
public double getX()
Returns the X coordinate of thisRectangle
in Rectangle precision.- Returns:
- the X coordinate of this
Rectangle
.
-
getY
public double getY()
Returns the Y coordinate of thisRectangle
in Rectangle precision.- Returns:
- the Y coordinate of this
Rectangle
.
-
getWidth
public double getWidth()
Returns the width of thisRectangle
in Rectangle precision.- Returns:
- the width of this
Rectangle
.
-
getHeight
public double getHeight()
Returns the height of thisRectangle
in Rectangle precision.- Returns:
- the height of this
Rectangle
.
-
isEmpty
public boolean isEmpty()
Determines whether or not thisRectangle
is empty.- Returns:
true
if thisRectangle
is empty;false
otherwise.
-
setRect
public void setRect(double x, double y, double w, double h)
Sets the location and size of thisRectangle
to the specified Rectangle values.- Parameters:
x
- , y the coordinates to which to set the upper left corner of thisRectangle
w
- the value to use to set the width of thisdouble
h
- the value to use to set the height of thisdouble
-
setRect
public void setRect(Rectangle r)
Sets thisRectangle
to 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 newRectangle
object representing the intersection of thisRectangle
with the specifiedRectangle
.- Parameters:
r
- theRectangle
to be intersected with thisRectangle
- Returns:
- the largest
Rectangle
contained in both the specifiedRectangle
and in thisRectangle
.
-
createUnion
public Rectangle createUnion(Rectangle r)
Returns a newRectangle
object representing the union of thisRectangle
with the specifiedRectangle
.- Parameters:
r
- theRectangle
to be combined with thisRectangle
- Returns:
- the smallest
Rectangle
containing both the specifiedRectangle
and thisRectangle
.
-
union
public void union(Rectangle rect)
-
toString
public java.lang.String toString()
Returns theString
representation of thisRectangle
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a
String
representing thisRectangle
.
-
getMinX
public double getMinX()
Returns the smallest X coordinate of the framing rectangle of theRectangle
indouble
precision.- 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 theRectangle
indouble
precision.- 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 theRectangle
indouble
precision.- 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 theRectangle
indouble
precision.- Returns:
- the largest y coordinate of the framing rectangle of the
Rectangle
.
-
contains
public boolean contains(Point lo)
-
-