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 Rectangle2D | |
private Vector | |
private static Vector |
Access | Constructor and Description |
---|---|
public | |
public |
Modifier and Type | Method and Description |
---|---|
public void | |
public Object | Returns: Created clone objectOverrides java. Area object.
|
public boolean | contains(double
the specified X coordinate to be tested x, double the specified Y coordinate to be tested y)Implements java. Shape , as described by the
definition of insideness.
|
public boolean | contains(Point2D
the specified p)Point2D to be testedImplements java. Point2D is inside the boundary
of the Shape , as described by the
definition of insideness.
|
public boolean | contains(double
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)Implements java. Shape entirely contains
the specified rectangular area.
|
public boolean | contains(Rectangle2D
The specified r)Rectangle2D Implements java. Shape entirely contains the
specified Rectangle2D .
|
public Area | Returns: a newArea object representing the transformed
geometry.the specified t)AffineTransform used to transform
the new Area Creates a new |
public boolean | |
public void | exclusiveOr(Area
the rhs)Area to be exclusive ORed with this
Area .Sets the shape of this |
public Rectangle | Returns: the boundingRectangle for the
Area .Implements java. Rectangle that completely encloses
this Area .
|
public Rectangle2D | Returns: the boundingRectangle2D for the
Area .Implements java. Rectangle2D that
completely encloses this Area .
|
private Rectangle2D | |
public PathIterator | Returns: thePathIterator object that returns the
geometry of the outline of this Area , 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. PathIterator for the outline of this
Area object.
|
public PathIterator | Returns: thePathIterator object that returns the
geometry of the outline of this Area , 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 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 java. PathIterator for the flattened outline of
this Area object.
|
public void | |
public boolean | intersects(double
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)Implements java. Shape intersects the
interior of a specified rectangular area.
|
public boolean | intersects(Rectangle2D
the specified r)Rectangle2D Implements java. Shape intersects the
interior of a specified Rectangle2D .
|
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 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(AffineTransform
the transformation used to transform the area t)Transforms the geometry of this |
cachedBounds | back to summary |
---|---|
private Rectangle2D cachedBounds |
curves | back to summary |
---|---|
private Vector<Curve> curves |
EmptyCurves | back to summary |
---|---|
private static Vector<Curve> EmptyCurves |
Area | back to summary |
---|---|
public Area() Default constructor which creates an empty area.
|
Area | back to summary |
---|---|
public Area(Shape s) The
|
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) ################ ################ ################ ############## ############## ################ ############ ############ ################ ########## ########## ################ ######## ######## ################ ###### ###### ###### ###### #### #### #### #### ## ## ## ##
|
clone | back to summary |
---|---|
public Object clone() Overrides java. Returns an exact copy of this
|
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(Point2D p) Implements java. Doc from java. Tests if a specified
|
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.
|
contains | back to summary |
---|---|
public boolean contains(Rectangle2D r) Implements java. Doc from java. 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.
|
createTransformedArea | back to summary |
---|---|
public Area createTransformedArea(AffineTransform t) Creates a new
|
equals | back to summary |
---|---|
public boolean equals(Area other) Tests whether the geometries of the two
|
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 Rectangle getBounds() Implements java. Returns a 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. Since the returned object represents the bounding box with integers, the bounding box can only be as tight as the nearest integer coordinates that encompass the geometry of the Shape.
|
getBounds2D | back to summary |
---|---|
public Rectangle2D getBounds2D() Implements java. 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 Rectangle2D getCachedBounds() |
getPathIterator | back to summary |
---|---|
public PathIterator getPathIterator(AffineTransform at) Implements java. Creates a
|
getPathIterator | back to summary |
---|---|
public PathIterator getPathIterator(AffineTransform at, double flatness) Implements java. 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(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.
|
intersects | back to summary |
---|---|
public boolean intersects(Rectangle2D r) Implements java. Doc from java. 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.
|
invalidateBounds | back to summary |
---|---|
private void invalidateBounds() |
isEmpty | back to summary |
---|---|
public boolean isEmpty() Tests whether this
|
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(AffineTransform t) Transforms the geometry of this
|