public class Polyline extends java.lang.Object implements ICurve
PrecisionUtils) to compensate for rounding effects.| Constructor and Description |
|---|
Polyline(double... coordinates)
Constructs a new
Polyline from a even-numbered sequence of
coordinates. |
Polyline(Line[] segmentsArray)
|
Polyline(Point... points)
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Overridden with public visibility as recommended within
Cloneable
. |
boolean |
contains(double x,
double y)
Checks whether the point that is represented by its x- and y-coordinates
is contained within this
Polyline. |
boolean |
contains(Point p)
|
boolean |
equals(java.lang.Object o) |
boolean |
equals(Point... points)
Checks whether this
Polyline and the one that is indirectly given
via the sequence of points are regarded to be equal. |
Rectangle |
getBounds()
|
Point |
getCentroid()
Computes the centroid of this
AbstractPointListBasedGeometry. |
double[] |
getCoordinates()
Returns a double array which represents the sequence of coordinates of
the
Points that make up this
AbstractPointListBasedGeometry. |
Polyline |
getCopy()
Returns a new identical copy of this
IGeometry. |
Line[] |
getCurves()
|
Point[] |
getIntersections(ICurve c)
|
double |
getLength()
|
ICurve[] |
getOverlaps(ICurve c)
|
Point |
getP1()
|
Point |
getP2()
|
Point[] |
getPoints()
Returns a copy of the
Points that make up this
AbstractPointListBasedGeometry. |
Point |
getProjection(Point reference)
|
T |
getRotatedCCW(Angle alpha)
|
T |
getRotatedCCW(Angle angle,
double cx,
double cy)
|
T |
getRotatedCCW(Angle alpha,
Point center)
|
T |
getRotatedCW(Angle alpha)
|
T |
getRotatedCW(Angle angle,
double cx,
double cy)
|
T |
getRotatedCW(Angle alpha,
Point center)
|
T |
getScaled(double factor)
Scales a copy of the calling object by the given factor relative to its
center
Point. |
T |
getScaled(double factorX,
double factorY)
Scales a copy of the calling object by the given factors relative to its
center
Point. |
T |
getScaled(double factor,
double cx,
double cy)
Scales a copy of the calling object by the given factor relative to the
given center
Point (cx, cy). |
T |
getScaled(double fx,
double fy,
double cx,
double cy)
Scales a copy of the calling object by the given factors relative to the
given center
Point (cx, cy). |
T |
getScaled(double factorX,
double factorY,
Point center)
Scales a copy of the calling object by the given factors relative to the
given center
Point. |
T |
getScaled(double factor,
Point center)
Scales a copy of the calling object by the given factor relative to the
given center
Point. |
Polyline |
getTransformed(AffineTransform t)
|
T |
getTranslated(double dx,
double dy)
Translates a copy of this object by the given values in x and y
direction.
|
T |
getTranslated(Point pt)
Translates a copy of this object by the given
Point. |
double |
getX1()
Returns the start
Point's x coordinate. |
double |
getX2()
Returns the end
Point's x coordinate. |
double |
getY1()
Returns the start
Point's y coordinate. |
double |
getY2()
Returns the end
Point's y coordinate. |
int |
hashCode() |
boolean |
intersects(ICurve c)
|
boolean |
overlaps(ICurve c)
|
T |
rotateCCW(Angle alpha)
Rotates this
AbstractPointListBasedGeometry counter-clockwise
(CCW) by the given Angle around its centroid (see
getCentroid()). |
T |
rotateCCW(Angle alpha,
double cx,
double cy)
|
T |
rotateCCW(Angle alpha,
Point center)
|
T |
rotateCW(Angle alpha)
Rotates this
AbstractPointListBasedGeometry clockwise (CW) by the
given Angle around its centroid (see getCentroid()). |
T |
rotateCW(Angle alpha,
double cx,
double cy)
|
T |
rotateCW(Angle alpha,
Point center)
|
T |
scale(double factor)
Scales the calling object by the given factor relative to its center
Point. |
T |
scale(double fx,
double fy)
Scales the calling object by the given factors relative to the given
center
Point. |
T |
scale(double factor,
double cx,
double cy)
Scales the calling object by the given factor relative to the given
center
Point (cx, cy). |
T |
scale(double fx,
double fy,
double cx,
double cy)
Scales the calling object by the given factors relative to the given
center
Point (cx, cy). |
T |
scale(double fx,
double fy,
Point center)
Scales the calling object by the given factors relative to the given
center
Point. |
T |
scale(double factor,
Point center)
Scales the calling object by the given factor relative to the given
center
Point. |
Line[] |
toBezier()
Computes a list of
BezierCurves that approximate the
ICurve. |
Path |
toPath()
|
PolyBezier |
toPolyBezier()
Transforms this
Polyline into a PolyBezier. |
java.lang.String |
toString() |
boolean |
touches(IGeometry g)
|
T |
translate(double dx,
double dy)
Translates the object by the given values in x and y direction.
|
T |
translate(Point p)
Translates the object by the given
Point. |
public Polyline(double... coordinates)
Polyline from a even-numbered sequence of
coordinates. Similar to Polyline(Point...), only that
coordinates of points rather than Points are provided.coordinates - an alternating, even-numbered sequence of x- and
y-coordinates, representing the points from which the
Polyline is to be createdpublic Polyline(Line[] segmentsArray)
public Polyline(Point... points)
Polyline from the given sequence of
Point s. The Polyline that is created will be
automatically closed, i.e. it will not only contain a segment between
succeeding points of the sequence but as well back from the last to the
first point.points - a sequence of points, from which the Polyline is to be
createdpublic boolean contains(double x,
double y)
Polyline.x - the x coordinate of the point to testy - the y coordinate of the point to testtrue if the point represented by its coordinates if
contained within this Polyline, otherwise
falsepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic boolean equals(Point... points)
public Polyline getCopy()
IGeometryIGeometry.public Line[] getCurves()
public Point[] getIntersections(ICurve c)
ICurvegetIntersections in interface ICurvec - The ICurve to compute intersection points with.public double getLength()
Polyline.public ICurve[] getOverlaps(ICurve c)
ICurvegetOverlaps in interface ICurvec - The curve to compute overlaps with.public Point getProjection(Point reference)
ICurvePoint onto
this ICurve, i.e. a Point on this ICurve that is
closest to the given reference Point. Note, thatgetProjection in interface ICurvereference - The reference Point for which to return the
projection.Point onto
this ICurve.public Polyline getTransformed(AffineTransform t)
Path
representation of this IGeometry. Subclasses may override this
method to return a more specific representation.getTransformed in interface IGeometryt - The AffineTransform to be appliedPath representation of this
IGeometrypublic double getX1()
ICurvePoint's x coordinate.public double getX2()
ICurvePoint's x coordinate.public double getY1()
ICurvePoint's y coordinate.public double getY2()
ICurvePoint's y coordinate.public boolean intersects(ICurve c)
ICurveICurve and the given ICurve intersect, i.e.
whether a final set of intersection points exists. Two curves intersect
if they touch (see IGeometry.touches(IGeometry)) but do not
overlap (see ICurve.overlaps(ICurve)).intersects in interface ICurvec - The ICurve to test for intersections.true if they intersect, false otherwisepublic boolean overlaps(ICurve c)
ICurveICurve and the given ICurve overlap, i.e.
whether an infinite set of intersection points exists. Two curves overlap
if they touch (see IGeometry.touches(IGeometry)) but not
intersect (see ICurve.intersects(ICurve)).public Line[] toBezier()
ICurveBezierCurves that approximate the
ICurve. For example, a Line or a BezierCurve in
general could return a list with the curve itself as its only element.
But an Ellipse or an Arc may return a list of consecutive
BezierCurves which approximate the ICurve.toBezier in interface ICurveBezierCurves that approximate the
ICurvepublic PolyBezier toPolyBezier()
Polyline into a PolyBezier.PolyBezier representing this Polylinepublic java.lang.String toString()
toString in class java.lang.Objectpublic Point getCentroid()
AbstractPointListBasedGeometry. The
centroid is the "center of gravity", i.e. assuming a Polygon is
spanned by the Points of this
AbstractPointListBasedGeometry and it is made of a material of
constant density, then it is in a balanced state, if you put it on a pin
that is placed exactly on its centroid.Point (or centroid) of this
AbstractPointListBasedGeometrypublic final double[] getCoordinates()
Points that make up this
AbstractPointListBasedGeometry.AbstractPointListBasedGeometry's pointspublic final Point[] getPoints()
Points that make up this
AbstractPointListBasedGeometry.public T getRotatedCCW(Angle alpha)
IRotatableAngle counter-clock-wise
(CCW) around its center Point. Does not necessarily return an
object of the same type.getRotatedCCW in interface IRotatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>alpha - rotation AngleIGeometry representing the result of the rotationpublic T getRotatedCCW(Angle angle, double cx, double cy)
IRotatableAngle
counter-clock-wise (CCW) around the specified center Point (cx,
cy). Does not necessarily return an object of the same type.getRotatedCCW in interface IRotatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>angle - rotation Anglecx - x-coordinate of the relative Point for the rotationcy - y-coordinate of the relative Point for the rotationIGeometry representing the result of the rotationpublic T getRotatedCCW(Angle alpha, Point center)
IRotatableAngle
counter-clock-wise (CCW) around the specified center Point. Does
not necessarily return an object of the same type.getRotatedCCW in interface IRotatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>alpha - rotation Anglecenter - relative Point for the rotationIGeometry representing the result of the rotationpublic T getRotatedCW(Angle alpha)
IRotatableAngle clock-wise (CW)
around its center Point. Does not necessarily return an object of
the same type.getRotatedCW in interface IRotatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>alpha - rotation AngleIGeometry representing the result of the rotationpublic T getRotatedCW(Angle angle, double cx, double cy)
IRotatableAngle clock-wise (CW)
around the specified center Point (cx, cy). Does not necessarily
return an object of the same type.getRotatedCW in interface IRotatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>angle - rotation Anglecx - x-coordinate of the relative Point for the rotationcy - y-coordinate of the relative Point for the rotationIGeometry representing the result of the rotationpublic T getRotatedCW(Angle alpha, Point center)
IRotatableAngle clock-wise (CW)
around the specified center Point. Does not necessarily return an
object of the same type.getRotatedCW in interface IRotatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>alpha - rotation Anglecenter - relative Point for the rotationIGeometry representing the result of the rotationpublic T getScaled(double factor)
IScalablePoint.public T getScaled(double factorX,
double factorY)
IScalablePoint.public T getScaled(double factor,
double cx,
double cy)
IScalablePoint (cx, cy).getScaled in interface IScalable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>factor - scale-factorcx - x-coordinate of the relative Point for the scalingcy - y-coordinate of the relative Point for the scalingpublic T getScaled(double fx,
double fy,
double cx,
double cy)
IScalablePoint (cx, cy).getScaled in interface IScalable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>fx - x-scale-factorfy - y-scale-factorcx - x-coordinate of the relative Point for the scalingcy - y-coordinate of the relative Point for the scalingpublic T getScaled(double factorX,
double factorY,
Point center)
IScalablePoint.public T getScaled(double factor,
Point center)
IScalablePoint.public T getTranslated(double dx,
double dy)
ITranslatablegetTranslated in interface ITranslatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>dx - x-translationdy - y-translationpublic T getTranslated(Point pt)
ITranslatablePoint.getTranslated in interface ITranslatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>pt - translation Pointpublic T rotateCCW(Angle alpha)
AbstractPointListBasedGeometry counter-clockwise
(CCW) by the given Angle around its centroid (see
getCentroid()).alpha - the rotation Anglethis for conveniencerotateCCW(Angle, Point)public T rotateCCW(Angle alpha, double cx, double cy)
AbstractPointListBasedGeometry counter-clockwise
(CCW) by the given Angle around the Point specified by
the passed-in x and y coordinates.alpha - the rotation Anglecx - the x coordinate of the Point to rotate aroundcy - the y coordinate of the Point to rotate aroundthis for conveniencerotateCCW(Angle, Point)public T rotateCW(Angle alpha)
AbstractPointListBasedGeometry clockwise (CW) by the
given Angle around its centroid (see getCentroid()).alpha - the rotation Anglethis for conveniencerotateCW(Angle, Point)public T rotateCW(Angle alpha, double cx, double cy)
AbstractPointListBasedGeometry clockwise (CW) by the
given Angle around the Point specified by the passed-in x
and y coordinates.alpha - the rotation Anglecx - the x coordinate of the Point to rotate aroundcy - the y coordinate of the Point to rotate aroundthis for conveniencerotateCW(Angle, Point)public T scale(double factor)
IScalablePoint.public T scale(double fx,
double fy)
IScalablePoint.public T scale(double factor,
double cx,
double cy)
IScalablePoint (cx, cy).public T scale(double fx,
double fy,
double cx,
double cy)
IScalablePoint (cx, cy).scale in interface IScalable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>fx - x-scale-factorfy - y-scale-factorcx - x-coordinate of the relative Point for the scalingcy - y-coordinate of the relative Point for the scalingthis for conveniencepublic T scale(double fx,
double fy,
Point center)
IScalablePoint.public T scale(double factor,
Point center)
IScalablePoint.public T translate(double dx,
double dy)
ITranslatabletranslate in interface ITranslatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>dx - x-translationdy - y-translationthis for conveniencepublic T translate(Point p)
ITranslatablePoint.translate in interface ITranslatable<T extends org.eclipse.gef4.geometry.planar.AbstractPointListBasedGeometry<?>>p - translation Pointthis for conveniencepublic java.lang.Object clone()
Cloneable
.clone in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()Copyright (c) 2014 itemis AG, and others. All rights reserved.