public class XyLineSegment extends java.lang.Object implements XyPath<XyLineSegment>
Copyright 2006-2007 Partner Software, Inc.
| Constructor and Description |
|---|
XyLineSegment(double startX,
double startY,
double endX,
double endY)
Create a new line segment with the given starting and ending coordinates.
|
XyLineSegment(XyPoint start,
XyPoint end)
Create a new line segment starting and ending at the given points.
|
| Modifier and Type | Method and Description |
|---|---|
XyLineSegment |
clippedTo(XyBounds bounds)
Clip this line to the given bounds.
|
XyPoint |
closestPointTo(XyPoint nother)
Solves for the closest point to the segment.
|
XyBounds |
getBounds()
Returns an XyBounds object representing the rectangular extents of this
shape.
|
XyPoint |
getCenterPoint()
Returns the midpoint, or center, of the segment.
|
XyDirection |
getDirection()
Returns the direction of the line segment, treating it as a vector from
start to end.
|
XyPoint |
getEndPoint()
Returns the last point in the shape.
|
double |
getLength()
Returns the length of the path.
|
XyLine |
getLine()
The line this is a segment of.
|
XyPoint |
getStartPoint()
Returns the first point in the shape.
|
java.util.Iterator<XyPoint> |
iterator() |
XyLineSegment |
scaledBy(double factor)
Return a scaled version of the shape by multiplying all coordinates by
the given factor in both dimensions.
|
java.util.List<XyPoint> |
splitAtIntervals(double... intervals)
Returns a list of points, determined by splitting this segment up using the sequence of intervals given.
|
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.
|
XyVector |
toVector()
Returns the vector equivalent for this line segment.
|
XyShape |
transformedBy(XyTransform transform)
Transform the shape using the given transform.
|
XyLineSegment |
translatedBy(double offsetX,
double offsetY)
Translate the shape by adding all coordinates to the given x and y
offsets.
|
XyLineSegment |
withEndPoint(XyPoint newEnd)
Returns a modified version of this line segment with the given end point.
|
XyLineSegment |
withStartPoint(XyPoint newStart)
Returns a modified version of this line segment with the given start
point.
|
public XyLineSegment(XyPoint start, XyPoint end)
public XyLineSegment(double startX,
double startY,
double endX,
double endY)
public XyLineSegment withStartPoint(XyPoint newStart)
public XyLineSegment withEndPoint(XyPoint newEnd)
public XyVector toVector()
public XyPoint closestPointTo(XyPoint nother)
public java.util.List<XyPoint> splitAtIntervals(double... intervals)
public XyLineSegment clippedTo(XyBounds bounds)
public double getLength()
XyPathgetLength in interface XyPath<XyLineSegment>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<XyLineSegment>public XyPolyline toPolyline()
XyPathXyPath.toPolyline(XyAngle) with a default angle granularity of
1/60 circle (6 degrees, pi/30 radians).toPolyline in interface XyPath<XyLineSegment>public XyPoint getStartPoint()
XyPathgetStartPoint in interface XyPath<XyLineSegment>public XyPoint getEndPoint()
XyPathgetEndPoint in interface XyPath<XyLineSegment>public java.util.Iterator<XyPoint> iterator()
iterator in interface java.lang.Iterable<XyPoint>public XyBounds getBounds()
XyShapegetBounds in interface XyShape<XyLineSegment>public XyLineSegment scaledBy(double factor)
XyShapescaledBy in interface XyShape<XyLineSegment>factor - scaling factorpublic XyShape transformedBy(XyTransform transform)
XyShapetransformedBy in interface XyShape<XyLineSegment>transform - affine transform to apply.public XyLineSegment translatedBy(double offsetX, double offsetY)
XyShapetranslatedBy in interface XyShape<XyLineSegment>offsetX - offset for the x dimensionoffsetY - offset for the y dimensionpublic XyLine getLine()
public XyPoint getCenterPoint()
public XyDirection getDirection()