Rectangle2D class describes a rectangle
defined by a location (x,y) and dimension
(w x h).
This class is only the abstract superclass for all objects that store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass.
| Modifier and Type | Class and Description |
|---|---|
| public static class | Rectangle2D.
The |
| public static class | Rectangle2D.
The |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | OUT_BOTTOM
The bitmask that indicates that a point lies below
this |
| public static final int | OUT_LEFT
The bitmask that indicates that a point lies to the left of
this |
| public static final int | OUT_RIGHT
The bitmask that indicates that a point lies to the right of
this |
| public static final int | OUT_TOP
The bitmask that indicates that a point lies above
this |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(double
the X coordinate of the new point newx, double the Y coordinate of the new point newy)Adds a point, specified by the double precision arguments
|
| public void | |
| public void | add(Rectangle2D
the r)Rectangle2D to add to this
Rectangle2D.Adds a |
| public boolean | contains(double x, double y)
Implements java. Tests if the specified coordinates are inside the boundary of the
|
| public boolean | contains(double x, double y, double w, double h)
Implements java. Tests if the interior of the |
| public abstract Rectangle2D | Returns: the largestRectangle2D contained in both
the specified Rectangle2D and in this
Rectangle2D.the r)Rectangle2D to be intersected with
this Rectangle2DReturns a new |
| public abstract Rectangle2D | Returns: the smallestRectangle2D containing both
the specified Rectangle2D and this
Rectangle2D.the r)Rectangle2D to be combined with
this Rectangle2DReturns a new |
| public boolean | Returns: true if obj is an instance
of Rectangle2D and has
the same values; false otherwise.an obj)Object to be compared with this
Rectangle2D.Overrides java. Determines whether or not the specified |
| public Rectangle2D | getBounds2D()
Implements java. Returns a high precision and more accurate bounding box of
the |
| public PathIterator | Returns: thePathIterator object that returns the
geometry of the outline of this
Rectangle2D, one segment at a time.an optional at)AffineTransform to be applied to
the coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredImplements java. Returns an iteration object that defines the boundary of this
|
| public PathIterator | Returns: thePathIterator object that returns the
geometry of the outline of this
Rectangle2D, one segment at a time.an optional at, double AffineTransform to be applied to
the coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredthe maximum distance that the line segments used to
approximate the curved segments are allowed to deviate from any
point on the original curve. Since rectangles are already flat,
the flatness)flatness parameter is ignored.Overrides java. Implements java. Returns an iteration object that defines the boundary of the
flattened |
| public int | Returns: the hashcode for thisRectangle2D.Overrides java. Returns the hashcode for this |
| public static void | intersect(Rectangle2D
the first of a pair of src1, Rectangle2D Rectangle2D
objects to be intersected with each otherthe second of a pair of src2, Rectangle2D Rectangle2D
objects to be intersected with each otherthe dest)Rectangle2D that holds the
results of the intersection of src1 and
src2Intersects the pair of specified source |
| public boolean | intersects(double x, double y, double w, double h)
Implements java. Tests if the interior of the |
| public boolean | Returns: true if the specified line segment intersects
the interior of this Rectangle2D; false
otherwise.the X coordinate of the start point of the specified
line segment x1, double the Y coordinate of the start point of the specified
line segment y1, double the X coordinate of the end point of the specified
line segment x2, double the Y coordinate of the end point of the specified
line segment y2)Tests if the specified line segment intersects the interior of this
|
| public boolean | Returns: true if the specified Line2D
intersects the interior of this Rectangle2D;
false otherwise.the specified l)Line2D to test for intersection
with the interior of this Rectangle2DTests if the specified line segment intersects the interior of this
|
| public abstract int | Returns: the logical OR of all appropriate out codes.the specified X coordinate x, double the specified Y coordinate y)Determines where the specified coordinates lie with respect
to this |
| public int | |
| public void | setFrame(double
the X coordinate of the upper-left corner
of this x, double Rectangle2Dthe Y coordinate of the upper-left corner
of this y, double Rectangle2Dthe width of this w, double Rectangle2Dthe height of this h)Rectangle2DImplements abstract java. Sets the location and size of the outer bounds of this
|
| public abstract void | setRect(double
the X coordinate of the upper-left corner
of this x, double Rectangle2Dthe Y coordinate of the upper-left corner
of this y, double Rectangle2Dthe width of this w, double Rectangle2Dthe height of this h)Rectangle2DSets the location and size of this |
| public void | setRect(Rectangle2D
the specified r)Rectangle2DSets this |
| public static void | union(Rectangle2D
the first of a pair of src1, Rectangle2D Rectangle2D
objects to be combined with each otherthe second of a pair of src2, Rectangle2D Rectangle2D
objects to be combined with each otherthe dest)Rectangle2D that holds the
results of the union of src1 and
src2Unions the pair of source |
| OUT_BOTTOM | back to summary |
|---|---|
| public static final int OUT_BOTTOM The bitmask that indicates that a point lies below
this
| |
| OUT_LEFT | back to summary |
|---|---|
| public static final int OUT_LEFT The bitmask that indicates that a point lies to the left of
this
| |
| OUT_RIGHT | back to summary |
|---|---|
| public static final int OUT_RIGHT The bitmask that indicates that a point lies to the right of
this
| |
| OUT_TOP | back to summary |
|---|---|
| public static final int OUT_TOP The bitmask that indicates that a point lies above
this
| |
| Rectangle2D | back to summary |
|---|---|
| protected Rectangle2D() This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.
| |
| add | back to summary |
|---|---|
| public void add(double newx, double newy) Adds a point, specified by the double precision arguments
After adding a point, a call to
| |
| add | back to summary |
|---|---|
| public void add(Point2D pt) Adds the
After adding a point, a call to
| |
| add | back to summary |
|---|---|
| public void add(Rectangle2D r) Adds a
| |
| contains | back to summary |
|---|---|
| public boolean contains(double x, double y) Implements java. Doc from java. Tests if the specified coordinates are inside the boundary of the
| |
| contains | back to summary |
|---|---|
| public boolean contains(double x, double y, double w, double h) Implements java. Doc from java. Tests if the interior of the
The
Shapes this method might
return false even though the Shape contains
the rectangular area.
The Area class performs
more accurate geometric computations than most
Shape objects and therefore can be used if a more precise
answer is required.
| |
| createIntersection | back to summary |
|---|---|
| public abstract Rectangle2D createIntersection(Rectangle2D r) Returns a new
| |
| createUnion | back to summary |
|---|---|
| public abstract Rectangle2D createUnion(Rectangle2D r) Returns a new
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Determines whether or not the specified
| |
| getBounds2D | back to summary |
|---|---|
| public Rectangle2D getBounds2D() Implements java. Doc from java. Returns a high precision and more accurate bounding box of
the
Note that the
definition of insideness can lead to situations where points
on the defining outline of the
If a
If a
| |
| getPathIterator | back to summary |
|---|---|
| public PathIterator getPathIterator(AffineTransform at) Implements java. Returns an iteration object that defines the boundary of this
| |
| getPathIterator | back to summary |
|---|---|
| public PathIterator getPathIterator(AffineTransform at, double flatness) Overrides java. Implements java. Returns an iteration object that defines the boundary of the
flattened
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hashcode for this
| |
| intersect | back to summary |
|---|---|
| public static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) Intersects the pair of specified source
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(double x, double y, double w, double h) Implements java. Doc from java. Tests if the interior of the
The
Shapes this method might
return true even though the rectangular area does not
intersect the Shape.
The Area class performs
more accurate computations of geometric intersection than most
Shape objects and therefore can be used if a more precise
answer is required.
| |
| intersectsLine | back to summary |
|---|---|
| public boolean intersectsLine(double x1, double y1, double x2, double y2) Tests if the specified line segment intersects the interior of this
| |
| intersectsLine | back to summary |
|---|---|
| public boolean intersectsLine(Line2D l) Tests if the specified line segment intersects the interior of this
| |
| outcode | back to summary |
|---|---|
| public abstract int outcode(double x, double y) Determines where the specified coordinates lie with respect
to this
| |
| outcode | back to summary |
|---|---|
| public int outcode(Point2D p) Determines where the specified
| |
| setFrame | back to summary |
|---|---|
| public void setFrame(double x, double y, double w, double h) Implements abstract java. Sets the location and size of the outer bounds of this
| |
| setRect | back to summary |
|---|---|
| public abstract void setRect(double x, double y, double w, double h) Sets the location and size of this
| |
| setRect | back to summary |
|---|---|
| public void setRect(Rectangle2D r) Sets this
| |
| union | back to summary |
|---|---|
| public static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) Unions the pair of source
| |
Double class defines a rectangle specified in
double coordinates.
| Modifier and Type | Field and Description |
|---|---|
| public double | height
The height of this |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.6 for interoperability. |
| public double | width
The width of this |
| public double | x
The X coordinate of this |
| public double | y
The Y coordinate of this |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Double(double
the X coordinate of the upper-left corner
of the newly constructed x, double Rectangle2Dthe Y coordinate of the upper-left corner
of the newly constructed y, double Rectangle2Dthe width of the newly constructed
w, double Rectangle2Dthe height of the newly constructed
h)Rectangle2DConstructs and initializes a |
| Modifier and Type | Method and Description |
|---|---|
| public Rectangle2D | createIntersection(Rectangle2D r)
Implements abstract java. Returns a new |
| public Rectangle2D | createUnion(Rectangle2D r)
Implements abstract java. Returns a new |
| public Rectangle2D | getBounds2D()
Overrides java. Implements java. Returns a high precision and more accurate bounding box of
the |
| public double | getHeight()
Implements abstract java. Returns the height of the framing rectangle
in |
| public double | getWidth()
Implements abstract java. Returns the width of the framing rectangle in
|
| public double | getX()
Implements abstract java. Returns the X coordinate of the upper-left corner of
the framing rectangle in |
| public double | getY()
Implements abstract java. Returns the Y coordinate of the upper-left corner of
the framing rectangle in |
| public boolean | isEmpty()
Implements abstract java. Determines whether the |
| public int | outcode(double x, double y)
Implements abstract java. Determines where the specified coordinates lie with respect
to this |
| public void | setRect(double x, double y, double w, double h)
Implements abstract java. Sets the location and size of this |
| public void | setRect(Rectangle2D r)
Overrides java. Sets this |
| public String | Returns: aString representing this
Rectangle2D.Overrides java. Returns the |
| height | back to summary |
|---|---|
| public double height The height of this
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Use serialVersionUID from JDK 1.6 for interoperability. | |
| width | back to summary |
|---|---|
| public double width The width of this
| |
| x | back to summary |
|---|---|
| public double x The X coordinate of this
| |
| y | back to summary |
|---|---|
| public double y The Y coordinate of this
| |
| Double | back to summary |
|---|---|
| public Double() Constructs a new
| |
| Double | back to summary |
|---|---|
| public Double(double x, double y, double w, double h) Constructs and initializes a
| |
| createIntersection | back to summary |
|---|---|
| public Rectangle2D createIntersection(Rectangle2D r) Implements abstract java. Doc from java. Returns a new
| |
| createUnion | back to summary |
|---|---|
| public Rectangle2D createUnion(Rectangle2D r) Implements abstract java. Doc from java. Returns a new
| |
| getBounds2D | back to summary |
|---|---|
| public Rectangle2D getBounds2D() Overrides java. Implements java. Doc from java. Returns a high precision and more accurate bounding box of
the
Note that the
definition of insideness can lead to situations where points
on the defining outline of the
If a
If a
| |
| getHeight | back to summary |
|---|---|
| public double getHeight() Implements abstract java. Doc from java. Returns the height of the framing rectangle
in
| |
| getWidth | back to summary |
|---|---|
| public double getWidth() Implements abstract java. Doc from java. Returns the width of the framing rectangle in
| |
| getX | back to summary |
|---|---|
| public double getX() Implements abstract java. Doc from java. Returns the X coordinate of the upper-left corner of
the framing rectangle in
| |
| getY | back to summary |
|---|---|
| public double getY() Implements abstract java. Doc from java. Returns the Y coordinate of the upper-left corner of
the framing rectangle in
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements abstract java. Doc from java. Determines whether the
| |
| outcode | back to summary |
|---|---|
| public int outcode(double x, double y) Implements abstract java. Doc from java. Determines where the specified coordinates lie with respect
to this
| |
| setRect | back to summary |
|---|---|
| public void setRect(double x, double y, double w, double h) Implements abstract java. Doc from java. Sets the location and size of this
| |
| setRect | back to summary |
|---|---|
| public void setRect(Rectangle2D r) Overrides java. Doc from java. Sets this
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns the
| |
Float class defines a rectangle specified in float
coordinates.
| Modifier and Type | Field and Description |
|---|---|
| public float | height
The height of this |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.6 for interoperability. |
| public float | width
The width of this |
| public float | x
The X coordinate of this |
| public float | y
The Y coordinate of this |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Float(float
the X coordinate of the upper-left corner
of the newly constructed x, float Rectangle2Dthe Y coordinate of the upper-left corner
of the newly constructed y, float Rectangle2Dthe width of the newly constructed
w, float Rectangle2Dthe height of the newly constructed
h)Rectangle2DConstructs and initializes a |
| Modifier and Type | Method and Description |
|---|---|
| public Rectangle2D | createIntersection(Rectangle2D r)
Implements abstract java. Returns a new |
| public Rectangle2D | createUnion(Rectangle2D r)
Implements abstract java. Returns a new |
| public Rectangle2D | getBounds2D()
Overrides java. Implements java. Returns a high precision and more accurate bounding box of
the |
| public double | getHeight()
Implements abstract java. Returns the height of the framing rectangle
in |
| public double | getWidth()
Implements abstract java. Returns the width of the framing rectangle in
|
| public double | getX()
Implements abstract java. Returns the X coordinate of the upper-left corner of
the framing rectangle in |
| public double | getY()
Implements abstract java. Returns the Y coordinate of the upper-left corner of
the framing rectangle in |
| public boolean | isEmpty()
Implements abstract java. Determines whether the |
| public int | outcode(double x, double y)
Implements abstract java. Determines where the specified coordinates lie with respect
to this |
| public void | setRect(float
the X coordinate of the upper-left corner
of this x, float Rectangle2Dthe Y coordinate of the upper-left corner
of this y, float Rectangle2Dthe width of this w, float Rectangle2Dthe height of this h)Rectangle2DSets the location and size of this |
| public void | setRect(double x, double y, double w, double h)
Implements abstract java. Sets the location and size of this |
| public void | setRect(Rectangle2D r)
Overrides java. Sets this |
| public String | Returns: aString representing this
Rectangle2D.Overrides java. Returns the |
| height | back to summary |
|---|---|
| public float height The height of this
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Use serialVersionUID from JDK 1.6 for interoperability. | |
| width | back to summary |
|---|---|
| public float width The width of this
| |
| x | back to summary |
|---|---|
| public float x The X coordinate of this
| |
| y | back to summary |
|---|---|
| public float y The Y coordinate of this
| |
| Float | back to summary |
|---|---|
| public Float() Constructs a new
| |
| Float | back to summary |
|---|---|
| public Float(float x, float y, float w, float h) Constructs and initializes a
| |
| createIntersection | back to summary |
|---|---|
| public Rectangle2D createIntersection(Rectangle2D r) Implements abstract java. Doc from java. Returns a new
| |
| createUnion | back to summary |
|---|---|
| public Rectangle2D createUnion(Rectangle2D r) Implements abstract java. Doc from java. Returns a new
| |
| getBounds2D | back to summary |
|---|---|
| public Rectangle2D getBounds2D() Overrides java. Implements java. Doc from java. Returns a high precision and more accurate bounding box of
the
Note that the
definition of insideness can lead to situations where points
on the defining outline of the
If a
If a
| |
| getHeight | back to summary |
|---|---|
| public double getHeight() Implements abstract java. Doc from java. Returns the height of the framing rectangle
in
| |
| getWidth | back to summary |
|---|---|
| public double getWidth() Implements abstract java. Doc from java. Returns the width of the framing rectangle in
| |
| getX | back to summary |
|---|---|
| public double getX() Implements abstract java. Doc from java. Returns the X coordinate of the upper-left corner of
the framing rectangle in
| |
| getY | back to summary |
|---|---|
| public double getY() Implements abstract java. Doc from java. Returns the Y coordinate of the upper-left corner of
the framing rectangle in
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements abstract java. Doc from java. Determines whether the
| |
| outcode | back to summary |
|---|---|
| public int outcode(double x, double y) Implements abstract java. Doc from java. Determines where the specified coordinates lie with respect
to this
| |
| setRect | back to summary |
|---|---|
| public void setRect(float x, float y, float w, float h) Sets the location and size of this
| |
| setRect | back to summary |
|---|---|
| public void setRect(double x, double y, double w, double h) Implements abstract java. Doc from java. Sets the location and size of this
| |
| setRect | back to summary |
|---|---|
| public void setRect(Rectangle2D r) Overrides java. Doc from java. Sets this
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns the
| |