|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fcmodeler.view.figures.LineShape
A Shape
implementation that contains methods appropriate for lines. LineShape
wraps another Shape
object, and provides contains
and
intersects
methods appropriate for arbitrary line shapes. These methods break up the
line into straight pieces before testing. This is in contrast to the approach most other
Shape
implementations take, which assume that the shape is an enclosed region.
The wrapped Shape
object provides the geometry of the line. LineShape
simply intercepts method calls to the wrapped Shape
. Clients will typically
setup the Shape
object, then provide it to LineShape
and use
the LineShape
instance in place of the original Shape
.
Constructor Summary | |
LineShape(java.awt.Shape shape)
Creates a new LineShape using the specified Shape . |
|
LineShape(java.awt.Shape shape,
float margin,
double flatness)
Creates a new LineShape using the specified Shape , margin, and
flatness. |
Method Summary | |
boolean |
contains(double x,
double y)
Tests if the specified point is within the margin of this line. |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if the specified rectangle intersects this LineShape . |
boolean |
contains(java.awt.geom.Point2D point)
Tests if the specified point is within the margin of this line. |
boolean |
contains(java.awt.geom.Rectangle2D rectangle)
Tests if the specified rectangle intersects this LineShape . |
java.awt.Rectangle |
getBounds()
Returns an integer Rectangle that completely encloses the Shape . |
java.awt.geom.Rectangle2D |
getBounds2D()
Returns a high precision and more accurate bounding box of the Shape
than the getBounds method. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform transform)
Returns an iterator object that iterates along the Shape boundary and
provides access to the geometry of the Shape outline. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform transform,
double flatness)
Returns an iterator object that iterates along the Shape boundary and
provides access to a flattened view of the Shape outline geometry. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if this LineShape intersects the specified rectangle. |
boolean |
intersects(java.awt.geom.Rectangle2D rectangle)
Tests if this LineShape intersects the specified rectangle. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LineShape(java.awt.Shape shape)
LineShape
using the specified Shape
. The margin is
set to 5.0f
and the flatness is set to 12.0d
.shape
- the Shape
providing the geomoetry for this LineShape
.public LineShape(java.awt.Shape shape, float margin, double flatness)
LineShape
using the specified Shape
, margin, and
flatness.shape
- the Shape
providing the geometry for this LineShape
.margin
- the maximum distance away from this LineShape
for point containment.flatness
- the flatness parameter provided to all getPathIterator(AffineTransform, double)
calls.Method Detail |
public boolean contains(double x, double y)
contains
in interface java.awt.Shape
x
- the x-coordinate of the point.y
- the y-coordinate of the point.true
if the specified point is within the margin of this line; false otherwise
.public boolean contains(double x, double y, double w, double h)
LineShape
. Calling this
method is equivalent to calling the intersects(double, double, double, double)
method.contains
in interface java.awt.Shape
x
- the x-coordinate of the rectangle.y
- the y-coordinate of the rectanglew
- the width of the rectangle.h
- the height of the rectangle.true
if the specified rectangle intersects this LineShape
; false
otherwise.public boolean contains(java.awt.geom.Point2D point)
contains
in interface java.awt.Shape
point
- the point to test.true
if the specified point is within the margin of this line; false otherwise
.public boolean contains(java.awt.geom.Rectangle2D rectangle)
LineShape
. Calling this
method is equivalent to calling the intersects(Rectangle2D)
method.contains
in interface java.awt.Shape
rectangle
- the rectangle to test for intersection.true
if the specified rectangle intersects this LineShape
; false
otherwise.public java.awt.Rectangle getBounds()
Rectangle
that completely encloses the Shape
.getBounds
in interface java.awt.Shape
Rectangle
that completely encloses the Shape
.public java.awt.geom.Rectangle2D getBounds2D()
Shape
than the getBounds
method.getBounds2D
in interface java.awt.Shape
Rectangle2D
that is a high-precision bounding box of the Shape
.public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform)
Shape
boundary and
provides access to the geometry of the Shape
outline.getPathIterator
in interface java.awt.Shape
transform
- an optional AffineTransform
to be applied to the coordinates as they
are returned in the iteration, or null
if untransformed coordinates
are desired.PathIterator
object, which independently traverses the
geometry of the Shape
.public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform, double flatness)
Shape
boundary and
provides access to a flattened view of the Shape
outline geometry.getPathIterator
in interface java.awt.Shape
transform
- an optional AffineTransform
to be applied to the coordinates as
they are returned in the iteration, or null
if untransformed
coordinates are desired.flatness
- the maximum distance that the line segments used to approximate the curved
segments are allowed to deviate from any point on the original curve.PathIterator
that independently traverses the Shape
geometry.public boolean intersects(double x, double y, double w, double h)
LineShape
intersects the specified rectangle. If the width
and height of the rectangle are both less than 2.0, the rectangle is assumed to represent
a single point, and the contains(double, double)
method is called with the
center point of the rectangle.intersects
in interface java.awt.Shape
x
- the x-coordinate of the rectangle.y
- the y-coordinate of the rectangle.w
- the width of the rectangle.h
- the height of the rectangle.true
if the specified rectangle intersects this LineShape
; false
otherwise.public boolean intersects(java.awt.geom.Rectangle2D rectangle)
LineShape
intersects the specified rectangle. If the width
and height of the rectangle are both less than 2.0, the rectangle is assumed to represent
a single point, and the contains(double, double)
method is called with the
center point of the rectangle.intersects
in interface java.awt.Shape
rectangle
- the rectangle to test for intersection.true
if the specified rectangle intersects this LineShape
; false
otherwise.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |