Additional top-level class in compilation unit: AreaIterator.
Area object stores and manipulates a
resolution-independent description of an enclosed area of
2-dimensional space.
Area objects can be transformed and can perform
various Constructive Area Geometry (CAG) operations when combined
with other Area objects.
The CAG operations include area
addition, subtraction,
intersection, and exclusive or.
See the linked method documentation for examples of the various
operations.
The Area class implements the Shape
interface and provides full support for all of its hit-testing
and path iteration facilities, but an Area is more
specific than a generalized path in a number of ways:
Area objects constructed from unclosed paths
are implicitly closed during construction as if those paths
had been filled by the Graphics2D.fill method.
Area resembles the path from which it was
constructed only in that it describes the same enclosed
2-dimensional area, but may use entirely different types
and ordering of the path segments to do so.
Area include:
Area from an unclosed (open)
Shape results in a closed outline in the
Area object.
Area from a Shape
which encloses no area (even when "closed") produces an
empty Area. A common example of this issue
is that producing an Area from a line will
be empty since the line encloses no area. An empty
Area will iterate no geometry in its
PathIterator objects.
Shape may be split into
two (or more) sub-paths each enclosing one of the
non-intersecting portions of the original path.
Area may take more path segments to
describe the same geometry even when the original
outline is simple and obvious. The analysis that the
Area class must perform on the path may
not reflect the same concepts of "simple and obvious"
as a human being perceives.
| Modifier and Type | Field and Description |
|---|---|
| private RectBounds | |
| private Vector | |
| private static final Vector |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | contains(float
the specified X coordinate to be tested x, float the specified Y coordinate to be tested y)Implements abstract com. Tests if the specified coordinates are inside the boundary of the
|
| public boolean | contains(Point2D
the specified p)Point2D to be testedOverrides com. Tests if a specified |
| public boolean | contains(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Implements abstract com. Tests if the interior of the |
| public Area | copy()
Implements abstract com. Returns a new copy of this |
| public Area | Returns: a newArea object representing the transformed
geometry.the specified tx)BaseTransform used to transform
the new AreaCreates a new |
| public void | exclusiveOr(Area
the rhs)Area to be exclusive ORed with this
Area.Sets the shape of this |
| public RectBounds | Returns: the boundingRectBounds for the
Area.Implements abstract com. Returns a high precision bounding |
| private RectBounds | |
| public PathIterator | Returns: thePathIterator object that returns the
geometry of the outline of this Area, one
segment at a time.an optional tx)BaseTransform to be applied to
the coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredImplements abstract com. Creates a |
| public PathIterator | Returns: thePathIterator object that returns the
geometry of the outline of this Area, one segment
at a time.an optional tx, float BaseTransform to be
applied to the coordinates as they are returned in the
iteration, or null if untransformed coordinates
are desiredthe maximum amount that the control points
for a given curve can vary from colinear before a subdivided
curve is replaced by a straight line connecting the end points flatness)Implements abstract com. Creates a |
| public void | |
| public boolean | intersects(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Implements abstract com. Tests if the interior of the |
| private void | |
| public boolean | Returns: true if this Area object
represents an empty area; false otherwise.Tests whether this |
| public boolean | Returns: true if the two geometries are equivalent;
false otherwise.the other)Area to be compared to this
AreaTests whether the geometries of the two |
| public boolean | Returns: true if the geometry of this
Area consists entirely of line segments;
false otherwise.Tests whether this |
| public boolean | Returns: true if the geometry of this
Area is rectangular in shape; false
otherwise.Tests whether this |
| public boolean | Returns: true if the Area is comprised
of a single basic geometry; false otherwise.Tests whether this |
| private static Vector | |
| public void | |
| public void | |
| public void | transform(BaseTransform
the transformation used to transform the area tx)Transforms the geometry of this |
| cachedBounds | back to summary |
|---|---|
| private RectBounds cachedBounds | |
| curves | back to summary |
|---|---|
| private Vector<E> curves | |
| EmptyCurves | back to summary |
|---|---|
| private static final Vector<E> EmptyCurves | |
| Area | back to summary |
|---|---|
| public Area() Default constructor which creates an empty area. | |
| Area | back to summary |
|---|---|
| public Area(Shape s) The
| |
| Area | back to summary |
|---|---|
| public Area(PathIterator iter) | |
| add | back to summary |
|---|---|
| public void add(Area rhs) Adds the shape of the specified
// Example:
Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]);
Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]);
a1.add(a2);
a1(before) + a2 = a1(after)
################ ################ ################
############## ############## ################
############ ############ ################
########## ########## ################
######## ######## ################
###### ###### ###### ######
#### #### #### ####
## ## ## ##
| |
| contains | back to summary |
|---|---|
| public boolean contains(float x, float y) Implements abstract com. Doc from com. Tests if the specified coordinates are inside the boundary of the
| |
| contains | back to summary |
|---|---|
| public boolean contains(Point2D p) Overrides com. Doc from com. Tests if a specified | |
| contains | back to summary |
|---|---|
| public boolean contains(float x, float y, float w, float h) Implements abstract com. Doc from com. 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.
| |
| copy | back to summary |
|---|---|
| public Area copy() Implements abstract com. Doc from com. Returns a new copy of this | |
| createTransformedArea | back to summary |
|---|---|
| public Area createTransformedArea(BaseTransform tx) Creates a new
| |
| exclusiveOr | back to summary |
|---|---|
| public void exclusiveOr(Area rhs) Sets the shape of this
// Example:
Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]);
Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]);
a1.exclusiveOr(a2);
a1(before) xor a2 = a1(after)
################ ################
############## ############## ## ##
############ ############ #### ####
########## ########## ###### ######
######## ######## ################
###### ###### ###### ######
#### #### #### ####
## ## ## ##
| |
| getBounds | back to summary |
|---|---|
| public RectBounds getBounds() Implements abstract com. Returns a high precision bounding The Area class will attempt to return the tightest bounding box possible for the Shape. The bounding box will not be padded to include the control points of curves in the outline of the Shape, but should tightly fit the actual geometry of the outline itself.
| |
| getCachedBounds | back to summary |
|---|---|
| private RectBounds getCachedBounds() | |
| getPathIterator | back to summary |
|---|---|
| public PathIterator getPathIterator(BaseTransform tx) Implements abstract com. Creates a
| |
| getPathIterator | back to summary |
|---|---|
| public PathIterator getPathIterator(BaseTransform tx, float flatness) Implements abstract com. Creates a
| |
| intersect | back to summary |
|---|---|
| public void intersect(Area rhs) Sets the shape of this
// Example:
Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]);
Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]);
a1.intersect(a2);
a1(before) intersect a2 = a1(after)
################ ################ ################
############## ############## ############
############ ############ ########
########## ########## ####
######## ########
###### ######
#### ####
## ##
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(float x, float y, float w, float h) Implements abstract com. Doc from com. 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.
| |
| invalidateBounds | back to summary |
|---|---|
| private void invalidateBounds() | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Tests whether this
| |
| isEquivalent | back to summary |
|---|---|
| public boolean isEquivalent(Area other) Tests whether the geometries of the two
| |
| isPolygonal | back to summary |
|---|---|
| public boolean isPolygonal() Tests whether this
| |
| isRectangular | back to summary |
|---|---|
| public boolean isRectangular() Tests whether this
| |
| isSingular | back to summary |
|---|---|
| public boolean isSingular() Tests whether this
| |
| pathToCurves | back to summary |
|---|---|
| private static Vector | |
| reset | back to summary |
|---|---|
| public void reset() Removes all of the geometry from this | |
| subtract | back to summary |
|---|---|
| public void subtract(Area rhs) Subtracts the shape of the specified
// Example:
Area a1 = new Area([triangle 0,0 => 8,0 => 0,8]);
Area a2 = new Area([triangle 0,0 => 8,0 => 8,8]);
a1.subtract(a2);
a1(before) - a2 = a1(after)
################ ################
############## ############## ##
############ ############ ####
########## ########## ######
######## ######## ########
###### ###### ######
#### #### ####
## ## ##
| |
| transform | back to summary |
|---|---|
| public void transform(BaseTransform tx) Transforms the geometry of this
| |