public abstract class TransformedShape extends Shape
TransformedShape objects are transformed "views" onto existing
Shape objects. These objects make no attempt to clone or protect
against access to the original Shape so any modifications to the
original Shape will be immediately reflected in the behaviors
and results of this object.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TransformedShape.General |
(package private) static class |
TransformedShape.Translate |
| Modifier and Type | Field and Description |
|---|---|
private Shape |
cachedTransformedShape |
protected Shape |
delegate |
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP, RECT_INTERSECTS| Modifier | Constructor and Description |
|---|---|
protected |
TransformedShape(Shape delegate) |
| Modifier and Type | Method and Description |
|---|---|
abstract BaseTransform |
adjust(BaseTransform tx)
Returns a new transform that represents the specified transform with
the transform of this
TransformedShape concatenated. |
boolean |
contains(float x,
float y)
Tests if the specified coordinates are inside the boundary of the
Shape. |
boolean |
contains(float x,
float y,
float w,
float h)
Tests if the interior of the
Shape entirely contains
the specified rectangular area. |
Shape |
copy()
Returns a new copy of this
Shape instance. |
RectBounds |
getBounds()
Note that there is no guarantee that the returned
RectBounds is the smallest bounding box that encloses
the Shape, only that the Shape lies
entirely within the indicated RectBounds. |
private Shape |
getCachedTransformedShape() |
Shape |
getDelegateNoClone() |
PathIterator |
getPathIterator(BaseTransform transform)
Returns an iterator object that iterates along the
Shape boundary and provides access to the geometry of the
Shape outline. |
PathIterator |
getPathIterator(BaseTransform transform,
float flatness)
Returns an iterator object that iterates along the
Shape
boundary and provides access to a flattened view of the
Shape outline geometry. |
abstract BaseTransform |
getTransformNoClone() |
boolean |
intersects(float x,
float y,
float w,
float h)
Tests if the interior of the
Shape intersects the
interior of a specified rectangular area. |
static TransformedShape |
transformedShape(Shape original,
BaseTransform tx)
Returns a
Shape object backed by the specified original
but with the indicated transform applied to all of its coordinates. |
static TransformedShape |
translatedShape(Shape original,
double tx,
double ty)
Returns a
Shape object backed by the specified original
but with the indicated translation applied to all of its coordinates. |
protected Point2D |
untransform(float x,
float y) |
protected BaseBounds |
untransformedBounds(float x,
float y,
float w,
float h) |
accumulate, accumulateCubic, accumulateCubic, accumulateQuad, contains, contains, intersects, intersectsLine, outcode, pointCrossingsForCubic, pointCrossingsForLine, pointCrossingsForPath, pointCrossingsForQuad, rectCrossingsForCubic, rectCrossingsForLine, rectCrossingsForPath, rectCrossingsForQuadprotected final Shape delegate
private Shape cachedTransformedShape
protected TransformedShape(Shape delegate)
public static TransformedShape transformedShape(Shape original, BaseTransform tx)
Shape object backed by the specified original
but with the indicated transform applied to all of its coordinates.
The original Shape is not cloned or copied by this factory
method so any changes to the original object will be immediately
reflected in the methods of the return value.
The original BaseTransform object is, however, copied since
transform objects are far more likely to be scratch objects and a
lot less costly to clone. In addition, the underlying implementation
may dig some values out of the transform and then discard the actual
object in some cases for optimization purposes. Since that would
make those cases independent of future changes to the transform, we
copy the transform so that all return values from this method are
independent of further mutations to the transform object.original - the backing Shapetx - the BaseTransform to apply to all of the
coordinates of the backing Shape on the flyShapepublic static TransformedShape translatedShape(Shape original, double tx, double ty)
Shape object backed by the specified original
but with the indicated translation applied to all of its coordinates.
The original Shape is not cloned or copied by this factory
method so any changes to the original object will be immediately
reflected in the methods of the return value.original - the backing Shapetx - the X coordinate translation to apply to all of the
coordinates of the backing Shape on the flyty - the Y coordinate translation to apply to all of the
coordinates of the backing Shape on the flyShapepublic Shape getDelegateNoClone()
public abstract BaseTransform getTransformNoClone()
public abstract BaseTransform adjust(BaseTransform tx)
TransformedShape concatenated.tx - the specified contextual transformprotected Point2D untransform(float x, float y)
protected BaseBounds untransformedBounds(float x, float y, float w, float h)
public RectBounds getBounds()
ShapeRectBounds is the smallest bounding box that encloses
the Shape, only that the Shape lies
entirely within the indicated RectBounds.public boolean contains(float x,
float y)
ShapeShape.private Shape getCachedTransformedShape()
public boolean intersects(float x,
float y,
float w,
float h)
ShapeShape intersects the
interior of a specified rectangular area.
The rectangular area is considered to intersect the Shape
if any point is contained in both the interior of the
Shape and the specified rectangular area.
The Shape.intersects() method allows a Shape
implementation to conservatively return true when:
Shape intersect, but
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 in class Shapex - the X coordinate of the upper-left corner
of the specified rectangular areay - the Y coordinate of the upper-left corner
of the specified rectangular areaw - the width of the specified rectangular areah - the height of the specified rectangular areatrue 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.public boolean contains(float x,
float y,
float w,
float h)
ShapeShape entirely contains
the specified rectangular area. All coordinates that lie inside
the rectangular area must lie within the Shape for the
entire rectanglar area to be considered contained within the
Shape.
The Shape.contains() method allows a Shape
implementation to conservatively return false when:
intersect method returns true and
Shape entirely contains the rectangular area are
prohibitively expensive.
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 in class Shapex - the X coordinate of the upper-left corner
of the specified rectangular areay - the Y coordinate of the upper-left corner
of the specified rectangular areaw - the width of the specified rectangular areah - the height of the specified rectangular areatrue 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.Shape.intersects(float, float, float, float)public PathIterator getPathIterator(BaseTransform transform)
ShapeShape boundary and provides access to the geometry of the
Shape outline. If an optional BaseTransform
is specified, the coordinates returned in the iteration are
transformed accordingly.
Each call to this method returns a fresh PathIterator
object that traverses the geometry of the Shape object
independently from any other PathIterator objects in use
at the same time.
It is recommended, but not guaranteed, that objects
implementing the Shape interface isolate iterations
that are in process from any changes that might occur to the original
object's geometry during such iterations.
getPathIterator in class Shapetransform - an optional BaseTransform to be applied to the
coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredPathIterator object, which independently
traverses the geometry of the Shape.public PathIterator getPathIterator(BaseTransform transform, float flatness)
ShapeShape
boundary and provides access to a flattened view of the
Shape outline geometry.
Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator.
If an optional BaseTransform is specified,
the coordinates returned in the iteration are transformed
accordingly.
The amount of subdivision of the curved segments is controlled
by the flatness parameter, which specifies the
maximum distance that any point on the unflattened transformed
curve can deviate from the returned flattened path segments.
Note that a limit on the accuracy of the flattened path might be
silently imposed, causing very small flattening parameters to be
treated as larger values. This limit, if there is one, is
defined by the particular implementation that is used.
Each call to this method returns a fresh PathIterator
object that traverses the Shape object geometry
independently from any other PathIterator objects in use at
the same time.
It is recommended, but not guaranteed, that objects
implementing the Shape interface isolate iterations
that are in process from any changes that might occur to the original
object's geometry during such iterations.
getPathIterator in class Shapetransform - an optional BaseTransform to be applied to the
coordinates as they are returned in the iteration, or
null if untransformed coordinates are desiredflatness - the maximum distance that the line segments used to
approximate the curved segments are allowed to deviate
from any point on the original curvePathIterator that independently traverses
a flattened view of the geometry of the Shape.