|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.geometry.xy.XyPolyline
public class XyPolyline
A generalized polyline consisting of at least two vertices and one line segment.
Copyright 2007 Partner Software, Inc.
| Constructor Summary | |
|---|---|
XyPolyline(double... coords)
Defines a polygon via a varargs list of x,y coordinates. |
|
XyPolyline(double[] coordsX,
double[] coordsY)
Defines a polygon using a pair of coordinate arrays. |
|
XyPolyline(double[] coords,
int start,
int end)
Builds a polygon from an existing coordinate array, including start and ends. |
|
XyPolyline(DynamicXyPointArray points)
Creates a polygon from an ordered list of XyPoints. |
|
XyPolyline(java.util.List<XyPoint> points)
Private no-arg constructor, leaves properties unset. |
|
XyPolyline(XyPoint... points)
Creates a polygon using the varargs list of XyPoint vertices. |
|
| Method Summary | |
|---|---|
XyPolyline |
appendedWith(XyPolyline nother)
Appends the given polyline to the end of this one and returns the combined result. |
void |
appendPointsTo(DynamicXyPointArray array)
Appends the points of this polyline to the given DynamicXyPointArray. |
java.util.List<XyPolyline> |
clippedTo(XyBounds bounds)
Returns a list of polylines that result from clipping this polyline to the given bounds. |
XyPointOnPolyline |
closestPointOnPolylineTo(XyPoint nother)
Returns XyPointOnPolyline containing closest point, line segment, and segment's start point's vertex number as well as the original line. |
XyPoint |
closestPointTo(XyPoint test)
|
boolean |
contains(XyPoint point)
|
XyBounds |
getBounds()
Returns an XyBounds object representing the rectangular extents of this shape. |
XyPoint |
getCenterPoint()
Returns the center point of the polyline. |
XyPointOnPolyline |
getCenterPointOnPolyline()
Returns XyPointOnPolyline containing center point of the polyline. |
XyPoint |
getCentroid()
Returns Centroid of this Polyline. |
XyPoint |
getEndPoint()
Returns the last point in the shape. |
double |
getLength()
Returns the length of the path. |
int |
getLineSegmentCount()
|
int |
getPointCount()
|
XyPoint |
getStartPoint()
Returns the first point in the shape. |
java.util.Iterator<XyPoint> |
iterator()
|
XyLineSegment |
lineSegmentAt(int index)
Returns the index-th XyLineSegment for this XyPolyline. |
java.util.List<XyLineSegment> |
listLineSegments()
Returns a newly-allocated list of XyLineSegments for this polyline, in the same order as the XyPoints. |
XyPolyline |
parallelAt(XyPoint point)
Returns a polyline created by offsetting this polyline's shape to a parallel polyline running through the given point. |
XyPolyline |
parallelAt(XyRotation rotation,
double distance)
Returns a polyline created by offsetting this polyline's shape by the given distance in the given relative direction (indicated by a rotation angle). |
XyPoint |
pointAt(int index)
Returns the index-th XyPoint for this XyPolyline. |
XyPointOnPolyline |
pointOnPolylineForFraction(double fraction)
Returns XyPointOnPolyline located at the given fraction of the total length from the beginning of the XyPolyline. |
XyPointOnPolyline |
pointOnPolylineForLength(double length)
Returns XyPointOnPolyline located at the given length (following the polyline, not straight-line) from the beginning of the XyPolyline. |
XyPolyline |
reversed()
Reverses the order of points in this polyline from start to end. |
XyPolyline |
scaledBy(double factor)
Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions. |
XyPolyline |
scaledBy(double factorX,
double factorY)
|
XyPolyline |
simplifiedWithGrid(double granularity)
Simplify the polyline by eliminating points who share the same cell on a discreteness grid. |
XyPolyline |
simplifiedWithMinimumDistance(double granularity)
Simplify the polyline by eliminating segments shorter than a given length. |
java.util.List<XyPolyline> |
splitAtIntervals(double... intervals)
Returns a list of parts, determined by splitting this polyline up using the sequence of intervals given. |
java.util.List<XyPolyline> |
splitAtIntervalsOld(double... intervals)
Returns a list of parts, determined by splitting this polyline up using the sequence of intervals given. |
java.util.List<XyPolyline> |
splitInHalf()
|
double[] |
toDoubleArray()
Converts to an array of doubles [x0, y0, x1, y1...]. |
XyPoint[] |
toPointArray()
Converts this polyline to an array of XyPoints. |
XyPolyline |
toPolyline()
Same as XyPath.toPolyline(XyAngle) with a default angle granularity of
1/60 circle (6 degrees, pi/30 radians). |
XyPolyline |
toPolyline(XyAngle granularity)
Converts this area to a polyline which approximates it in some fashion. |
java.lang.String |
toString()
|
XyPolyline |
transformedBy(XyTransform transform)
Transform the shape using the given transform. |
XyPolyline |
translatedBy(double offsetX,
double offsetY)
Translate the shape by adding all coordinates to the given x and y offsets. |
XyPolyline |
withVertexChanged(int vertexIndex,
XyPoint newVertex)
Returns a new XyPolyline that is identical to this one except for the given vertex. |
XyPolyline |
withVertexInserted(int vertexIndex,
XyPoint vertex)
Returns a new XyPolyline that is identical to this one except for inserting the given vertex. |
XyPolyline |
withVertexRemoved(int vertexIndex)
Returns a new XyPolyline that is identical to this one except for removing the given vertex. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public XyPolyline(double[] coords,
int start,
int end)
public XyPolyline(double... coords)
public XyPolyline(double[] coordsX,
double[] coordsY)
coordsX - coordsY - public XyPolyline(XyPoint... points)
points - public XyPolyline(DynamicXyPointArray points)
points - public XyPolyline(java.util.List<XyPoint> points)
| Method Detail |
|---|
public XyPolyline withVertexChanged(int vertexIndex,
XyPoint newVertex)
public XyPolyline withVertexRemoved(int vertexIndex)
public XyPolyline withVertexInserted(int vertexIndex,
XyPoint vertex)
public XyPolyline simplifiedWithGrid(double granularity)
More accurately, what this method does is define a grid with square cells the size of the granularity. It then iterates through the polyline and eliminates points falling into the same cell as the previous point. This provides similar results to the elimination of short segments but much more efficiently. There will be edge effects, however (e.g. where point[i] is just barely to one side of a grid line and point[i + 1] is just barely to the other).
granularity - size of the discreteness grid applied to eliminate points that
are too closepublic XyPolyline simplifiedWithMinimumDistance(double granularity)
granularity - size of the discreteness grid applied to eliminate points that
are too closepublic XyPolyline reversed()
public XyPolyline appendedWith(XyPolyline nother)
public XyPoint[] toPointArray()
public void appendPointsTo(DynamicXyPointArray array)
public XyPointOnPolyline closestPointOnPolylineTo(XyPoint nother)
*
nother - -
XyPoint to find closest point to on this polyline.
public XyPointOnPolyline getCenterPointOnPolyline()
public XyPointOnPolyline pointOnPolylineForFraction(double fraction)
public XyPointOnPolyline pointOnPolylineForLength(double length)
public XyPoint getCenterPoint()
public XyPolyline parallelAt(XyPoint point)
public XyPolyline parallelAt(XyRotation rotation,
double distance)
public java.util.List<XyPolyline> splitAtIntervalsOld(double... intervals)
public java.util.List<XyPolyline> splitInHalf()
public java.util.List<XyPolyline> splitAtIntervals(double... intervals)
public java.util.List<XyLineSegment> listLineSegments()
public XyLineSegment lineSegmentAt(int index)
public XyPoint pointAt(int index)
public java.util.List<XyPolyline> clippedTo(XyBounds bounds)
public double getLength()
XyPath
getLength in interface XyPath<XyPolyline>public XyPolyline toPolyline()
XyPathXyPath.toPolyline(XyAngle) with a default angle granularity of
1/60 circle (6 degrees, pi/30 radians).
toPolyline in interface XyPath<XyPolyline>public XyPolyline toPolyline(XyAngle granularity)
XyPathThe angle parameter allows a certain level of control of the output. Essentially it dictates the minimum angular granularity used to approximate curved paths. For example, an arc would be turned into a polyline by placing points around the arc's slice of a circle, separated by the given angle.
toPolyline in interface XyPath<XyPolyline>public XyPoint getStartPoint()
XyPath
getStartPoint in interface XyPath<XyPolyline>public XyPoint getEndPoint()
XyPath
getEndPoint in interface XyPath<XyPolyline>public XyPoint getCentroid()
public double[] toDoubleArray()
public XyPoint closestPointTo(XyPoint test)
public XyPolyline scaledBy(double factor)
XyShape
scaledBy in interface XyShape<XyPolyline>factor - scaling factor
public XyPolyline scaledBy(double factorX,
double factorY)
public XyPolyline translatedBy(double offsetX,
double offsetY)
XyShape
translatedBy in interface XyShape<XyPolyline>offsetX - offset for the x dimensionoffsetY - offset for the y dimension
public XyPolyline transformedBy(XyTransform transform)
XyShape
transformedBy in interface XyShape<XyPolyline>transform - affine transform to apply.
public XyBounds getBounds()
XyShape
getBounds in interface XyShape<XyPolyline>public boolean contains(XyPoint point)
public java.util.Iterator<XyPoint> iterator()
iterator in interface java.lang.Iterable<XyPoint>public java.lang.String toString()
toString in class java.lang.Objectpublic int getPointCount()
public int getLineSegmentCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||