math.geom2d.curve
Class PolyCurve2D<T extends ContinuousCurve2D>

Package class diagram package PolyCurve2D
java.lang.Object
  extended by math.geom2d.curve.CurveSet2D<T>
      extended by math.geom2d.curve.CurveArray2D<T>
          extended by math.geom2d.curve.PolyCurve2D<T>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, ContinuousCurve2D, Curve2D, Shape2D
Direct Known Subclasses:
PolyBezierCurve2D, PolyCubicBezierCurve2D, PolyOrientedCurve2D

public class PolyCurve2D<T extends ContinuousCurve2D>
extends CurveArray2D<T>
implements ContinuousCurve2D

A PolyCurve2D is a set of piecewise smooth curve arcs, such that the end of a curve is the beginning of the next curve, and such that they do not intersect nor self-intersect.

Author:
dlegland
See Also:
Serialized Form

Field Summary
protected  boolean closed
          flag for indicating if the curve is closed or not (default is open)
 
Fields inherited from class math.geom2d.curve.CurveSet2D
curves
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY
 
Constructor Summary
PolyCurve2D()
           
PolyCurve2D(Collection<? extends T> curves)
           
PolyCurve2D(Collection<? extends T> curves, boolean closed)
           
PolyCurve2D(int n)
           
PolyCurve2D(T[] curves)
           
PolyCurve2D(T[] curves, boolean closed)
           
 
Method Summary
 GeneralPath appendPath(GeneralPath path)
          Append the path of the curve to the given path.
 CurveSet2D<? extends ContinuousCurve2D> clip(Box2D box)
          Clip the PolyCurve2D by a box.
 void draw(Graphics2D g2)
          Draws the curve on the given Graphics2D object.
 boolean equals(Object obj)
          Returns true if obj is a CurveArray2D with the same number of curves, and such that each curve belongs to both objects.
 Polyline2D getAsPolyline(int n)
          Returns an approximation of the curve as a polyline with n line segments.
 Collection<? extends PolyCurve2D<?>> getContinuousCurves()
          Returns the collection of continuous curves which constitute this curve.
 GeneralPath getGeneralPath()
           
 Vector2D getLeftTangent(double t)
           
 PolyCurve2D<? extends ContinuousCurve2D> getReverseCurve()
          Returns the curve with same trace on the plane with parametrization in reverse order.
 Vector2D getRightTangent(double t)
           
 Collection<? extends SmoothCurve2D> getSmoothPieces()
          Returns a collection containing only instances of SmoothCurve2D.
 PolyCurve2D<? extends ContinuousCurve2D> getSubCurve(double t0, double t1)
          Returns an instance of PolyCurve2D.
 boolean isClosed()
          Returns true if the PolyCurve2D is closed.
 void setClosed(boolean b)
          Toggle the 'closed' flag of the polycurve.
 PolyCurve2D<? extends ContinuousCurve2D> transform(AffineTransform2D trans)
          Transforms each curve, and build a new CurveArray2D with the set of transformed curves.
protected static
<T extends ContinuousCurve2D>
Collection<T>
wrapCurve(T curve)
           
 
Methods inherited from class math.geom2d.curve.CurveArray2D
addCurve, clearCurves, clone, contains, contains, containsCurve, getAsAWTShape, getBoundingBox, getChildCurve, getCurve, getCurveIndex, getCurveNumber, getCurves, getDistance, getDistance, getFirstCurve, getFirstPoint, getGlobalPosition, getIntersections, getLastCurve, getLastPoint, getLocalPosition, getPoint, getPosition, getSingularPoints, getT0, getT1, isBounded, isEmpty, isSingular, iterator, project, removeCurve
 
Methods inherited from class math.geom2d.curve.CurveSet2D
fromUnitSegment, toUnitSegment
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface math.geom2d.curve.Curve2D
clone, getAsAWTShape, getFirstPoint, getIntersections, getLastPoint, getPoint, getPosition, getSingularPoints, getT0, getT1, isSingular, project
 
Methods inherited from interface math.geom2d.Shape2D
contains, contains, getBoundingBox, getDistance, getDistance, isBounded, isEmpty
 

Field Detail

closed

protected boolean closed
flag for indicating if the curve is closed or not (default is open)

Constructor Detail

PolyCurve2D

public PolyCurve2D()

PolyCurve2D

public PolyCurve2D(int n)

PolyCurve2D

public PolyCurve2D(T[] curves)

PolyCurve2D

public PolyCurve2D(T[] curves,
                   boolean closed)

PolyCurve2D

public PolyCurve2D(Collection<? extends T> curves)

PolyCurve2D

public PolyCurve2D(Collection<? extends T> curves,
                   boolean closed)
Method Detail

wrapCurve

protected static <T extends ContinuousCurve2D> Collection<T> wrapCurve(T curve)

setClosed

public void setClosed(boolean b)
Toggle the 'closed' flag of the polycurve.


getLeftTangent

public Vector2D getLeftTangent(double t)
Specified by:
getLeftTangent in interface ContinuousCurve2D

getRightTangent

public Vector2D getRightTangent(double t)
Specified by:
getRightTangent in interface ContinuousCurve2D

isClosed

public boolean isClosed()
Returns true if the PolyCurve2D is closed.

Specified by:
isClosed in interface ContinuousCurve2D

getAsPolyline

public Polyline2D getAsPolyline(int n)
Description copied from interface: ContinuousCurve2D
Returns an approximation of the curve as a polyline with n line segments. If the curve is closed, the method should return an instance of Ring2D.

Specified by:
getAsPolyline in interface ContinuousCurve2D
Parameters:
n - the number of line segments
Returns:
a polyline with n line segments.

getSmoothPieces

public Collection<? extends SmoothCurve2D> getSmoothPieces()
Returns a collection containing only instances of SmoothCurve2D.

Specified by:
getSmoothPieces in interface ContinuousCurve2D
Returns:
a collection of SmoothCurve2D

getContinuousCurves

public Collection<? extends PolyCurve2D<?>> getContinuousCurves()
Description copied from interface: Curve2D
Returns the collection of continuous curves which constitute this curve.

Specified by:
getContinuousCurves in interface Curve2D
Overrides:
getContinuousCurves in class CurveArray2D<T extends ContinuousCurve2D>
Returns:
a collection of continuous curves.

getReverseCurve

public PolyCurve2D<? extends ContinuousCurve2D> getReverseCurve()
Description copied from interface: Curve2D
Returns the curve with same trace on the plane with parametrization in reverse order.

Specified by:
getReverseCurve in interface ContinuousCurve2D
Specified by:
getReverseCurve in interface Curve2D
Overrides:
getReverseCurve in class CurveArray2D<T extends ContinuousCurve2D>

getSubCurve

public PolyCurve2D<? extends ContinuousCurve2D> getSubCurve(double t0,
                                                            double t1)
Returns an instance of PolyCurve2D. If t0>t1 and curve is not closed, return a PolyCurve2D without curves inside.

Specified by:
getSubCurve in interface ContinuousCurve2D
Specified by:
getSubCurve in interface Curve2D
Overrides:
getSubCurve in class CurveArray2D<T extends ContinuousCurve2D>
Parameters:
t0 - position of the start of the sub-curve
t1 - position of the end of the sub-curve
Returns:
the portion of original curve comprised between t0 and t1.

clip

public CurveSet2D<? extends ContinuousCurve2D> clip(Box2D box)
Clip the PolyCurve2D by a box. The result is an instance of CurveSet2D, which contains only instances of ContinuousCurve2D. If the PolyCurve2D is not clipped, the result is an instance of CurveSet2D which contains 0 curves.

Specified by:
clip in interface ContinuousCurve2D
Specified by:
clip in interface Curve2D
Specified by:
clip in interface Shape2D
Overrides:
clip in class CurveArray2D<T extends ContinuousCurve2D>
Parameters:
box - the clipping box
Returns:
the clipped shape

transform

public PolyCurve2D<? extends ContinuousCurve2D> transform(AffineTransform2D trans)
Description copied from class: CurveArray2D
Transforms each curve, and build a new CurveArray2D with the set of transformed curves.

Specified by:
transform in interface ContinuousCurve2D
Specified by:
transform in interface Curve2D
Specified by:
transform in interface Shape2D
Overrides:
transform in class CurveArray2D<T extends ContinuousCurve2D>
Parameters:
trans - an affine transform
Returns:
the transformed shape

appendPath

public GeneralPath appendPath(GeneralPath path)
Description copied from interface: ContinuousCurve2D
Append the path of the curve to the given path.

Specified by:
appendPath in interface ContinuousCurve2D
Parameters:
path - a path to modify
Returns:
the modified path

getGeneralPath

public GeneralPath getGeneralPath()
Overrides:
getGeneralPath in class CurveArray2D<T extends ContinuousCurve2D>

draw

public void draw(Graphics2D g2)
Description copied from interface: Curve2D
Draws the curve on the given Graphics2D object.

Specified by:
draw in interface Curve2D
Specified by:
draw in interface Shape2D
Overrides:
draw in class CurveArray2D<T extends ContinuousCurve2D>
Parameters:
g2 - the graphics to draw the curve

equals

public boolean equals(Object obj)
Description copied from class: CurveArray2D
Returns true if obj is a CurveArray2D with the same number of curves, and such that each curve belongs to both objects.

Overrides:
equals in class CurveArray2D<T extends ContinuousCurve2D>


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.