java.awt.geom
public class Area extends Object implements Shape, Cloneable
The contains and intersects() methods are also more accurate than the specification of #Shape requires.
Please note that constructing an Area can be slow (Self-intersection resolving is proportional to the square of the number of segments).
add(Area)
,
subtract(Area)
,
intersect(Area)
,
exclusiveOr(Area)
Constructor and Description |
---|
Area()
Constructs an empty Area
|
Area(Shape s)
Constructs an Area from any given Shape.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Area area)
Performs an add (union) operation on this area with another Area.
|
Object |
clone()
Create a new area of the same run-time type with the same contents as
this one.
|
boolean |
contains(double x,
double y)
Determines if the point (x,y) is contained within this Area.
|
boolean |
contains(double x,
double y,
double w,
double h)
Determines if the rectangle specified by (x,y) as the upper-left
and with width w and height h is completely contained within this Area,
returns false otherwise.
|
boolean |
contains(Point2D p)
Determines if the Point2D p is contained within this Area.
|
boolean |
contains(Rectangle2D r)
Determines if the Rectangle2D specified by r is completely contained
within this Area, returns false otherwise.
|
Area |
createTransformedArea(AffineTransform at)
Returns a new Area equal to this one, transformed
by the AffineTransform at.
|
boolean |
equals(Area area)
Compares two Areas.
|
void |
exclusiveOr(Area area)
Performs an exclusive-or operation on this Area.
|
Rectangle |
getBounds()
Returns the bounds of this object in Rectangle format.
|
Rectangle2D |
getBounds2D()
Returns the bounding box of the Area.
|
PathIterator |
getPathIterator(AffineTransform at)
Returns a PathIterator object defining the contour of this Area,
transformed by at.
|
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Returns a flattened PathIterator object defining the contour of this
Area, transformed by at and with a defined flatness.
|
void |
intersect(Area area)
Performs an intersection operation on this Area.
|
boolean |
intersects(double x,
double y,
double w,
double h)
Determines if the rectangle specified by (x,y) as the upper-left
and with width w and height h intersects any part of this Area.
|
boolean |
intersects(Rectangle2D r)
Determines if the Rectangle2D specified by r intersects any
part of this Area.
|
boolean |
isEmpty()
Returns whether this area encloses any area.
|
boolean |
isPolygonal()
Determines whether the Area consists entirely of line segments
|
boolean |
isRectangular()
Determines if the Area is rectangular.
|
boolean |
isSingular()
Returns whether the Area consists of more than one simple
(non self-intersecting) subpath.
|
void |
reset()
Clears the Area object, creating an empty area.
|
void |
subtract(Area area)
Performs a subtraction operation on this Area.
|
void |
transform(AffineTransform at)
Transforms this area by the AffineTransform at.
|
public Area()
public Area(Shape s)
If the Shape is self-intersecting, the created Area will consist of non-self-intersecting subpaths, and any inner paths which are found redundant in accordance with the Shape's winding rule will not be included.
s
- the shape (null
not permitted).NullPointerException
- if s
is null
.public void add(Area area)
area
- - the area to be unioned with this onepublic void subtract(Area area)
area
- the area to be subtracted from this area.NullPointerException
- if area
is null
.public void intersect(Area area)
area
- - the area to be intersected with this area.NullPointerException
- if area
is null
.public void exclusiveOr(Area area)
area
- - the area to be XORed with this area.NullPointerException
- if area
is null
.public void reset()
public boolean isEmpty()
public boolean isPolygonal()
public boolean isRectangular()
This is strictly qualified. An area is considered rectangular if:
public boolean isSingular()
public Rectangle2D getBounds2D()
Unlike the CubicCurve2D and QuadraticCurve2D classes, this method will return the tightest possible bounding box, evaluating the extreme points of each curved segment.
getBounds2D
in interface Shape
Shape.getBounds()
public Rectangle getBounds()
getBounds
in interface Shape
getBounds2D()
public Object clone()
public boolean equals(Area area)
area
- the area to compare against this area (null
permitted).true
if the areas are equal, and false
otherwise.public void transform(AffineTransform at)
at
- the transform.public Area createTransformedArea(AffineTransform at)
at
- the transform.NullPointerException
- if at
is null
.public boolean contains(double x, double y)
public boolean contains(Point2D p)
contains
in interface Shape
p
- the point.true
if the point is contained, false
otherwise.NullPointerException
- if p
is null
.public boolean contains(double x, double y, double w, double h)
This method should always produce the correct results, unlike for other classes in geom.
public boolean contains(Rectangle2D r)
This method should always produce the correct results, unlike for other classes in geom.
contains
in interface Shape
r
- the rectangle.true
if the rectangle is considered containedNullPointerException
- if r
is null
.Shape.contains(double, double, double, double)
public boolean intersects(double x, double y, double w, double h)
intersects
in interface Shape
x
- the x-coordinate for the rectangle.y
- the y-coordinate for the rectangle.w
- the width of the rectangle.h
- the height of the rectangle.true
if the rectangle intersects the area,
false
otherwise.Area
public boolean intersects(Rectangle2D r)
intersects
in interface Shape
r
- the rectangle to test intersection with (null
not permitted).true
if the rectangle intersects the area,
false
otherwise.NullPointerException
- if r
is null
.Shape.intersects(double, double, double, double)
public PathIterator getPathIterator(AffineTransform at)
getPathIterator
in interface Shape
at
- the transform.public PathIterator getPathIterator(AffineTransform at, double flatness)
getPathIterator
in interface Shape
at
- the transform.flatness
- the flatness.