public class LineShape extends Object implements Shape, MutablePoints
| Constructor and Description |
|---|
LineShape(MutablePoints points)
Constructs a LineShape from a list of mutable points.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPoint(int pointIndex,
double x,
double y)
Adds a point with the given coordinates at the desired index.
|
boolean |
contains(double x,
double y)
Returns true if point is within 2 pixels of any line segment of this
LineShape.
|
boolean |
contains(double x,
double y,
double d)
Returns true if the given coordinates are within d units from any segment
of the LineShape.
|
boolean |
contains(double x,
double y,
double width,
double height)
Whether the LineShape contains the rectangle defined.
|
static boolean |
contains(double x,
double y,
double x1,
double y1,
double x2,
double y2,
boolean min,
boolean max,
double distance)
Returns whether the given coordinates are on the line defined by (x1,y1)
and (x2,y2) within the given distance.
|
boolean |
contains(Point2D p)
Returns true if point is within 2 pixels of any line segment of this
LineShape.
|
boolean |
contains(Rectangle2D r)
Whether the LineShape contains the rectangle.
|
Rectangle |
getBounds()
Returns the current points of this LineShape as a simple Rectangle.
|
Rectangle2D |
getBounds(Rectangle2D dst)
Computes the bounds of this LineShape and stores them in the provided
rectangle.
|
Rectangle2D |
getBounds2D()
Returns the current bounds in Rectangle2D format.
|
PathIterator |
getPathIterator(AffineTransform at)
Returns an iterator that can be used to iterate of the segments of this
LineShape.
|
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Returns an iterator that can be used to iterate of the segments of this
LineShape.
|
Point2D |
getPoint(int pointIndex,
Point2D destinationPoint)
Copies the point at the given index into the destination point.
|
int |
getPointCount()
Returns the number points in this LineShape.
|
double |
getX(int pointIndex)
Returns the x component of the point at the given index.
|
double |
getY(int pointIndex)
Returns the y component of the point at the given index.
|
boolean |
intersects(double x,
double y,
double w,
double h)
Returns true if any segment crosses an edge of the rectangle.
|
static boolean |
intersects(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4,
boolean min1,
boolean max1,
boolean min2,
boolean max2)
Returns true if the two segments defined by (x1,y1)->(x2,y2) and
(x3,y3)->(x4,y4) intersect.
|
boolean |
intersects(Rectangle2D r)
Returns true if any segment crosses an edge of the rectangle.
|
void |
removePoints(int pointIndex,
int num)
Removes n points from the LineShape starting at the provided index.
|
void |
setPoint(int pointIndex,
double x,
double y)
Sets the coordinate of the point at the given index.
|
void |
setPoints(MutablePoints points)
Changes the LineShape so that it's composed of the given points.
|
void |
transformPoints(AffineTransform transform)
Applies the given transform to all points in this LineShape.
|
void |
updateBounds()
Recalculates the bounds of this LineShape.
|
public LineShape(MutablePoints points)
points - points to use when constructing LineShapepublic void setPoints(MutablePoints points)
points - new Points to use as this shape's pathpublic int getPointCount()
getPointCount in interface Pointspublic double getX(int pointIndex)
public double getY(int pointIndex)
public Point2D getPoint(int pointIndex, Point2D destinationPoint)
public Rectangle2D getBounds(Rectangle2D dst)
public void updateBounds()
public void setPoint(int pointIndex,
double x,
double y)
setPoint in interface MutablePointspointIndex - index of the point to changex - x component to assign to the pointy - y component to assign to the pointpublic void addPoint(int pointIndex,
double x,
double y)
addPoint in interface MutablePointspointIndex - Index at which to add the pointx - x component of the new pointy - y component of the new pointpublic void removePoints(int pointIndex,
int num)
removePoints in interface MutablePointspointIndex - Starting index from which points are being removednum - The number of sequential points to removepublic void transformPoints(AffineTransform transform)
transformPoints in interface MutablePointstransform - Transform to applypublic Rectangle getBounds()
public Rectangle2D getBounds2D()
getBounds2D in interface Shapepublic static boolean contains(double x,
double y,
double x1,
double y1,
double x2,
double y2,
boolean min,
boolean max,
double distance)
x - x component of point being testedy - y component of point being testedx1 - x component of start point of line segmenty1 - y component of start point of line segmentx2 - x component of end point of line segmenty2 - y component of end point of line segmentmin - whether the point should be constrained to "after" the start
of the segmentmax - whether the point should be constrained to "before" the end of
the segmentdistance - distance from line acceptable as "touching"public boolean contains(double x,
double y,
double d)
x - x component of point being testedy - y component of point being testedd - acceptable distancepublic boolean contains(double x,
double y)
public boolean contains(Point2D p)
public static boolean intersects(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4,
boolean min1,
boolean max1,
boolean min2,
boolean max2)
x1 - segment 1's start x componenty1 - segment 1's start y componentx2 - segment 1's end x componenty2 - segment 1's end y componentx3 - segment 2's start x componenty3 - segment 2's start y componentx4 - segment 2's end x componenty4 - segment 2's end y componentmin1 - whether the second segment is acceptable if it passes
"before the start of the first segment"max1 - whether the second segment is acceptable if it passes
"after the end of the first segment"min2 - whether the first segment is acceptable if it passes
"before the start of the second segment"max2 - whether the first segment is acceptable if it passes
"after the start of the second segment"public boolean intersects(double x,
double y,
double w,
double h)
intersects in interface Shapex - left of rectangle to be testedy - top of rectangle to be testedw - width of rectangle to be testedh - height of rectangle to be testedpublic boolean intersects(Rectangle2D r)
intersects in interface Shaper - rectangle to be testedpublic boolean contains(double x,
double y,
double width,
double height)
public boolean contains(Rectangle2D r)
public PathIterator getPathIterator(AffineTransform at)
getPathIterator in interface Shapeat - optional transform to apply to segment before returning it. May
be nullpublic PathIterator getPathIterator(AffineTransform at, double flatness)
getPathIterator in interface Shapeat - optional transform to apply to segment before returning it. May
be nullflatness - ignored completelyCopyright © 1995-2012 Piccolo2D. All Rights Reserved.