|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolox.util.LineShape
public class LineShape
A shape that can be used to represent hand drawn lines.
Constructor Summary | |
---|---|
LineShape(MutablePoints points)
Constructs a LineShape from a list of mutable points. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LineShape(MutablePoints points)
points
- points to use when constructing LineShapeMethod Detail |
---|
public void setPoints(MutablePoints points)
points
- new Points to use as this shape's pathpublic int getPointCount()
getPointCount
in interface Points
public double getX(int pointIndex)
getX
in interface Points
pointIndex
- index of desired point
public double getY(int pointIndex)
getY
in interface Points
pointIndex
- index of desired point
public Point2D getPoint(int pointIndex, Point2D destinationPoint)
getPoint
in interface Points
pointIndex
- the index of the desired pointdestinationPoint
- the point into which to load the values, or null
if a new point is desired
public Rectangle2D getBounds(Rectangle2D dst)
getBounds
in interface Points
dst
- rectangle to populate with this LineShape's bounds
public void updateBounds()
public void setPoint(int pointIndex, double x, double y)
setPoint
in interface MutablePoints
pointIndex
- 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 MutablePoints
pointIndex
- 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 MutablePoints
pointIndex
- Starting index from which points are being removednum
- The number of sequential points to removepublic void transformPoints(AffineTransform transform)
transformPoints
in interface MutablePoints
transform
- Transform to applypublic Rectangle getBounds()
getBounds
in interface Shape
public Rectangle2D getBounds2D()
getBounds2D
in interface Shape
public 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 distance
public boolean contains(double x, double y)
contains
in interface Shape
x
- x component of point being testedy
- y component of point being tested
public boolean contains(Point2D p)
contains
in interface Shape
p
- point being tested
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 Shape
x
- left of rectangle to be testedy
- top of rectangle to be testedw
- width of rectangle to be testedh
- height of rectangle to be tested
public boolean intersects(Rectangle2D r)
intersects
in interface Shape
r
- rectangle to be tested
public boolean contains(double x, double y, double width, double height)
contains
in interface Shape
x
- left of defined rectangley
- top of defined rectanglewidth
- width of defined rectangleheight
- height of defined rectangle
public boolean contains(Rectangle2D r)
contains
in interface Shape
r
- rectangle being tested
public PathIterator getPathIterator(AffineTransform at)
getPathIterator
in interface Shape
at
- optional transform to apply to segment before returning it. May
be null
public PathIterator getPathIterator(AffineTransform at, double flatness)
getPathIterator
in interface Shape
at
- optional transform to apply to segment before returning it. May
be nullflatness
- ignored completely
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |