java.lang.Object
org.jhotdraw8.geom.AbstractShape
org.jhotdraw8.geom.shape.SimplePathMetrics
- All Implemented Interfaces:
Shape,PathMetrics
The
PathMetrics class allows access to the
metrics needed to compute points along a path and to
create sub-paths of a path.
Requirements for the path:
- The path must start with a
PathIterator.SEG_MOVETO - A
PathIterator.SEG_MOVETOmust be followed by aPathIterator.SEG_LINETO,PathIterator.SEG_QUADTO,PathIterator.SEG_CUBICTO. - A
PathIterator.SEG_CLOSEmust be the last element, or it must be followed by aPathIterator.SEG_MOVETO. - The length of a
PathIterator.SEG_LINETO,PathIterator.SEG_QUADTO,PathIterator.SEG_CUBICTOmust be greater than 0. - The
x, ycoordinates of thePathIterator.SEG_MOVETOat the beginning of a closed path must equal to thex, ycoordinates of the last segment of the closed path.
-
Constructor Summary
ConstructorsConstructorDescriptionSimplePathMetrics(@NonNull Shape shape) SimplePathMetrics(@NonNull PathIterator pathIterator) SimplePathMetrics(@NonNull PathIterator pathIterator, double epsilon) -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the length of the path.booleancontains(double x, double y) booleancontains(double x, double y, double w, double h) This implementation checks if the bounding box of this shape contains the specified rectangle.booleanevalAtArcLength(double s) Evaluates the path at the specified arc lengthReturns a path iterator of the entire path.getSubPathIteratorAtArcLength(double s0, double s1, @Nullable AffineTransform tx) Gets an iterator over a segment of the path from arc length s0 to arc length s1.booleanisEmpty()Returns true if this path metrics is empty.reverse()Gets path metrics for the reversed path.toString()Methods inherited from class org.jhotdraw8.geom.AbstractShape
contains, getBounds, getPathIterator, intersects, intersectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jhotdraw8.geom.shape.PathMetrics
eval, getSubPathIteratorMethods inherited from interface java.awt.Shape
contains, getBounds, getPathIterator, intersects, intersects
-
Constructor Details
-
SimplePathMetrics
-
SimplePathMetrics
-
SimplePathMetrics
-
-
Method Details
-
evalAtArcLength
Evaluates the path at the specified arc length- Specified by:
evalAtArcLengthin interfacePathMetrics- Parameters:
s- the arc length, the value will be clamped to [0,arcLength()]- Returns:
- point and tangent at s
-
arcLength
public double arcLength()Gets the length of the path.- Specified by:
arcLengthin interfacePathMetrics- Returns:
- the length of the path in [0,Double.MAX_VALUE].
-
reverse
Description copied from interface:PathMetricsGets path metrics for the reversed path.- Specified by:
reversein interfacePathMetrics- Returns:
- reverse path metrics
-
isEmpty
public boolean isEmpty()Description copied from interface:PathMetricsReturns true if this path metrics is empty.- Specified by:
isEmptyin interfacePathMetrics- Returns:
- true if empty
-
getBounds2D
- Specified by:
getBounds2Din interfaceShape- Overrides:
getBounds2Din classAbstractShape
-
contains
public boolean contains(double x, double y) - Specified by:
containsin interfaceShape- Overrides:
containsin classAbstractShape
-
contains
public boolean contains(double x, double y, double w, double h) This implementation checks if the bounding box of this shape contains the specified rectangle.- Specified by:
containsin interfaceShape- Overrides:
containsin classAbstractShape- Parameters:
x- the X coordinate of the upper-left corner of the specified rectangular areay- the Y coordinate of the upper-left corner of the specified rectangular areaw- the width of the specified rectangular areah- the height of the specified rectangular area- Returns:
- true if the interior of the bounding box of this shape contains the interior of the specified rectangle.
-
contains
- Specified by:
containsin interfaceShape- Overrides:
containsin classAbstractShape- Parameters:
r- the specifiedRectangle2D- Returns:
- true if this shape contains r
-
getSubPathIteratorAtArcLength
public @NonNull PathIterator getSubPathIteratorAtArcLength(double s0, double s1, @Nullable AffineTransform tx) Gets an iterator over a segment of the path from arc length s0 to arc length s1.- Specified by:
getSubPathIteratorAtArcLengthin interfacePathMetrics- Parameters:
s0- the arc length at which the sub-path starts, the value will be clamped to [0,arcLength()].s1- the arc length at which the sub-path ends, the value will be clamped to [s0,arcLength()].tx- an optional transformation for the path iterator- Returns:
- the path iterator
-
getPathIterator
Returns a path iterator of the entire path.- Specified by:
getPathIteratorin interfacePathMetrics- Specified by:
getPathIteratorin interfaceShape- Parameters:
tx- an optional transformation for the path iterator- Returns:
- the path iterator
-
toString
-