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
Point s 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
Point s 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
BezierCurve s 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 Point
s 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
false
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean equals(Point... points)
public Polyline getCopy()
IGeometry
IGeometry
.public Line[] getCurves()
public Point[] getIntersections(ICurve c)
ICurve
getIntersections
in interface ICurve
c
- The ICurve
to compute intersection points with.public double getLength()
Polyline
.public ICurve[] getOverlaps(ICurve c)
ICurve
getOverlaps
in interface ICurve
c
- The curve to compute overlaps with.public Point getProjection(Point reference)
ICurve
Point
onto
this ICurve
, i.e. a Point
on this ICurve
that is
closest to the given reference Point
. Note, thatgetProjection
in interface ICurve
reference
- 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 IGeometry
t
- The AffineTransform
to be appliedPath
representation of this
IGeometry
public double getX1()
ICurve
Point
's x coordinate.public double getX2()
ICurve
Point
's x coordinate.public double getY1()
ICurve
Point
's y coordinate.public double getY2()
ICurve
Point
's y coordinate.public boolean intersects(ICurve c)
ICurve
ICurve
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 ICurve
c
- The ICurve
to test for intersections.true
if they intersect, false
otherwisepublic boolean overlaps(ICurve c)
ICurve
ICurve
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()
ICurve
BezierCurve
s 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
BezierCurve
s which approximate the ICurve
.toBezier
in interface ICurve
BezierCurve
s that approximate the
ICurve
public PolyBezier toPolyBezier()
Polyline
into a PolyBezier
.PolyBezier
representing this Polyline
public java.lang.String toString()
toString
in class java.lang.Object
public Point getCentroid()
AbstractPointListBasedGeometry
. The
centroid is the "center of gravity", i.e. assuming a Polygon
is
spanned by the Point
s 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
AbstractPointListBasedGeometry
public final double[] getCoordinates()
Point
s that make up this
AbstractPointListBasedGeometry
.AbstractPointListBasedGeometry
's pointspublic final Point[] getPoints()
Point
s that make up this
AbstractPointListBasedGeometry
.public T getRotatedCCW(Angle alpha)
IRotatable
Angle
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.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
alpha
- rotation Angle
IGeometry
representing the result of the rotationpublic T getRotatedCCW(Angle angle, double cx, double cy)
IRotatable
Angle
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.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
angle
- rotation Angle
cx
- 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)
IRotatable
Angle
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.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
alpha
- rotation Angle
center
- relative Point
for the rotationIGeometry
representing the result of the rotationpublic T getRotatedCW(Angle alpha)
IRotatable
Angle
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.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
alpha
- rotation Angle
IGeometry
representing the result of the rotationpublic T getRotatedCW(Angle angle, double cx, double cy)
IRotatable
Angle
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.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
angle
- rotation Angle
cx
- 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)
IRotatable
Angle
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.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
alpha
- rotation Angle
center
- relative Point
for the rotationIGeometry
representing the result of the rotationpublic T getScaled(double factor)
IScalable
Point
.public T getScaled(double factorX, double factorY)
IScalable
Point
.public T getScaled(double factor, double cx, double cy)
IScalable
Point
(cx, cy).getScaled
in interface IScalable<T extends org.eclipse.gef.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)
IScalable
Point
(cx, cy).getScaled
in interface IScalable<T extends org.eclipse.gef.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)
IScalable
Point
.public T getScaled(double factor, Point center)
IScalable
Point
.public T getTranslated(double dx, double dy)
ITranslatable
getTranslated
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
dx
- x-translationdy
- y-translationpublic T getTranslated(Point pt)
ITranslatable
Point
.getTranslated
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
pt
- translation Point
public T rotateCCW(Angle alpha)
AbstractPointListBasedGeometry
counter-clockwise
(CCW) by the given Angle
around its centroid (see
getCentroid()
).alpha
- the rotation Angle
this
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 Angle
cx
- 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 Angle
this
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 Angle
cx
- 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)
IScalable
Point
.public T scale(double fx, double fy)
IScalable
Point
.public T scale(double factor, double cx, double cy)
IScalable
Point
(cx, cy).public T scale(double fx, double fy, double cx, double cy)
IScalable
Point
(cx, cy).scale
in interface IScalable<T extends org.eclipse.gef.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)
IScalable
Point
.public T scale(double factor, Point center)
IScalable
Point
.public T translate(double dx, double dy)
ITranslatable
translate
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
dx
- x-translationdy
- y-translationthis
for conveniencepublic T translate(Point p)
ITranslatable
Point
.translate
in interface ITranslatable<T extends org.eclipse.gef.geometry.planar.AbstractPointListBasedGeometry<?>>
p
- translation Point
this
for conveniencepublic java.lang.Object clone()
Cloneable
.clone
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
Copyright (c) 2014 itemis AG, and others. All rights reserved.