Shape interface provides definitions for objects
that represent some form of geometric shape. The Shape
is described by a PathIterator object, which can express the
outline of the Shape as well as a rule for determining
how the outline divides the 2D plane into interior and exterior
points. Each Shape object provides callbacks to get the
bounding box of the geometry, determine whether points or
rectangles lie partly or entirely within the interior
of the Shape, and retrieve a PathIterator
object that describes the trajectory path of the Shape
outline.
Definition of insideness:
A point is considered to lie inside a
Shape if and only if:
Shape boundary or
Shape boundary and the
space immediately adjacent to the
point in the increasing X direction is
entirely inside the boundary or
Y direction is inside the boundary.
The contains and intersects methods
consider the interior of a Shape to be the area it
encloses as if it were filled. This means that these methods
consider
unclosed shapes to be implicitly closed for the purpose of
determining if a shape contains or intersects a rectangle or if a
shape contains a point.
java.awt.geom.PathIterator , java.awt.geom.AffineTransform , java.awt.geom.FlatteningPathIterator , java.awt.geom.GeneralPath
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the specified coordinates are inside
the Shape boundary; false
otherwise.the specified X coordinate to be tested x, double the specified Y coordinate to be tested y)Tests if the specified coordinates are inside the boundary of the
|
| public boolean | Returns: true if the specified Point2D is
inside the boundary of the Shape;
false otherwise.the specified p)Point2D to be testedTests if a specified |
| public boolean | Returns: true if the interior of the Shape
entirely contains the specified rectangular area;
false otherwise or, if the Shape
contains the rectangular area and the
intersects method returns true
and the containment calculations would be too expensive to
perform.the X coordinate of the upper-left corner
of the specified rectangular area x, double the Y coordinate of the upper-left corner
of the specified rectangular area y, double the width of the specified rectangular area w, double the height of the specified rectangular area h)Tests if the interior of the |
| public boolean | Returns: true if the interior of the Shape
entirely contains the Rectangle2D;
false otherwise or, if the Shape
contains the Rectangle2D and the
intersects method returns true
and the containment calculations would be too expensive to
perform.The specified r)Rectangle2DTests if the interior of the |
| public Rectangle | |
| public Rectangle2D | Returns: an instance ofRectangle2D that is a
high-precision bounding box of the Shape.Returns a high precision and more accurate bounding box of
the |
| public PathIterator | Returns: a newPathIterator object, which independently
traverses the geometry of the Shape.an optional at)AffineTransform to be applied to the
coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredReturns an iterator object that iterates along the
|
| public PathIterator | Returns: a newPathIterator that independently traverses
a flattened view of the geometry of the Shape.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 flatness)Returns an iterator object that iterates along the |
| public boolean | Returns: true if the interior of the Shape and
the interior of the rectangular area intersect, or are
both highly likely to intersect and intersection calculations
would be too expensive to perform; false otherwise.the X coordinate of the upper-left corner
of the specified rectangular area x, double the Y coordinate of the upper-left corner
of the specified rectangular area y, double the width of the specified rectangular area w, double the height of the specified rectangular area h)Tests if the interior of the |
| public boolean | Returns: true if the interior of the Shape and
the interior of the specified Rectangle2D
intersect, or are both highly likely to intersect and intersection
calculations would be too expensive to perform; false
otherwise.the specified r)Rectangle2DTests if the interior of the |
| contains | back to summary |
|---|---|
| public boolean contains(double x, double y) Tests if the specified coordinates are inside the boundary of the
| |
| contains | back to summary |
|---|---|
| public boolean contains(Point2D p) Tests if a specified
| |
| contains | back to summary |
|---|---|
| public boolean contains(double x, double y, double w, double h) 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.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Rectangle2D r) Tests if the interior of the
Shapes this method might
return false even though the Shape contains
the Rectangle2D.
The Area class performs
more accurate geometric computations than most
Shape objects and therefore can be used if a more precise
answer is required.
| |
| getBounds | back to summary |
|---|---|
| public Rectangle getBounds() Returns an integer
Note that the
definition of insideness can lead to situations where points
on the defining outline of the
If a
If a
| |
| getBounds2D | back to summary |
|---|---|
| public Rectangle2D getBounds2D() 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) Returns an iterator object that iterates along the
Each call to this method returns a fresh
It is recommended, but not guaranteed, that objects
implementing the
| |
| getPathIterator | back to summary |
|---|---|
| public PathIterator getPathIterator(AffineTransform at, double flatness) Returns an iterator object that iterates along the Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator.
If an optional
The amount of subdivision of the curved segments is controlled
by the
Each call to this method returns a fresh
It is recommended, but not guaranteed, that objects
implementing the
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(double x, double y, double w, double h) 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.
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(Rectangle2D r) Tests if the interior of the
Shapes this method might
return true even though the Rectangle2D 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.
| |