Class RMPath
java.lang.Object
com.inductiveautomation.rm.graphics.RMPath
- All Implemented Interfaces:
Archivable
,Shape
,Cloneable
RMPath - A graphics path (moveTo, lineTo, etc.). It provides the following functionality:
- Allows for easy initialization with the path constructions methods (moveToPoint:, lineToPoint:, etc.).
- Provides simple methods for path operations (stroke, fill, clip, etc.).
Iterate over path like this:
RMPoint points[] = new RMPoint[3];
for(int i=0, iMax=path.getElementCount(); i<iMax; i++) { int element = path.getElement(i, points);
switch(element) {
case RMPath.MOVE_TO:
case RMPath.LINE_TO:
case RMPath.QUAD_TO:
case RMPath.CURVE_TO:
case RMPath.CLOSE:
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
static final byte
static final byte
static final byte
static final byte
static final RMPath
static final byte
static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSegment
(RMLine aSegment) Adds the list of segments to the path, starting with a moveto.void
addSegments
(List<? extends RMLine> theSegments) Adds the list of segments to the path, starting with a moveto.double
Returns the total arc length of path segments.clone()
Standard clone implementation.void
Adds a Close element to the given path.boolean
contains
(double x, double y) Returns whether the given xy coordinate is inside the path.boolean
contains
(double x, double y, double w, double h) Returns whether the interior of the shape entirely contains the specified rectangular area.boolean
Returns whether the given point is inside the path.boolean
contains
(Rectangle2D aRect) Returns whether the interior of the shape entirely contains the specified rectangular area.createTransformedPath
(AffineTransform aTransform) Returns a transformed version of this path.void
curveTo
(double cp1x, double cp1y, double cp2x, double cp2y, double px, double py) Adds a CurveTo element to the path for the given point and control points.void
Adds a CurveTo element to the path for the given point and control points.boolean
Standard equals implementation.fromXML
(RXArchiver anArchiver, RXElement anElement) XML unarchival.Returns the bounds for the path as an integer rect.Returns the bounds for the path.Returns the rectangle that encloses all the control points.byte
getElement
(int anIndex) Returns the element type at the given index.byte
getElement
(int anIndex, RMPoint[] points) Returns the element type at the given index and its associated points (returned in the given point array).int
Returns the number of elements in this path.int
getElementIndexForPointIndex
(int index) Returns the element index for the given point index.byte
Returns the last element.int
getElementPointIndex
(int anIndex) Returns the point index for a given element.double
Returns the height of the path.getHitInfo
(RMBezier aBezier, boolean findFirstHit) Returns the hit info for the given bezier curve against this path.getHitInfo
(RMLine aLine, boolean findFirstHit) Returns the hit info for the given line against this path.getPathInRect
(Rectangle2D aRect) Returns a copy of the path scaled to exactly fit in the given rect.getPathIterator
(AffineTransform aTransform) Returns a path iterator for this path and the given transform.getPathIterator
(AffineTransform aTransform, double flatness) Returns a path iterator for this path and the given transform and flatness.getPoint
(int anIndex) Returns the point at the given index.int
Returns the number of points in the path.Returns the last point in the path.Returns a new path with the same points as this path, but in reverse order.Converts a path into a list of RMLine/RMQuadratic/RMBezier.Converts a path into a list subpath lists of RMLine/RMQuadratic/RMBezier.double
getWidth()
Returns the width of the path.byte
Returns the winding rule which describes how inner path perimeters are filled and clipped.double
getX()
Returns the X of the path.double
getY()
Returns the Y of the path.int
handleAtPointForBounds
(RMPoint aPoint, RMRect aRect, int selectedPoint, RMSize handleSize) Returns the handle index for a given point against this path scaled to the given rect.boolean
Hit test the point (in path coords) against a given path point.boolean
intersects
(double x, double y, double w, double h) Returns whether the interior of the path intersects the interior of a specified rectangular area.boolean
intersects
(double x, double y, double w, double h, float lineWidth) Returns whether path drawn with given linewidth is hit by given rect.boolean
intersects
(RMPoint aPoint, float lineWidth) Returns whether path is hit by point for a path linewidth.boolean
intersects
(RMLine aLine) Returns whether path is hit by a line.boolean
intersects
(RMPath aPath, float lineWidth) Returns whether path drawn with given linewidth is hit by given path.boolean
intersects
(Rectangle2D aRect) Returns whether the interior of the path intersects the interior of a specified Rectangle2D.boolean
isClosed()
Returns whether path has any open subpaths.void
lineTo
(double px, double py) Adds a LineTo element to the path for the given point.void
Adds a LineTo element to the path for the given point.void
moveTo
(double px, double py) Adds a MoveTo element to the path for the given point.void
Adds a MoveTo element to the path for the given point.int
pointCountForElementType
(int element) Returns the total number of points associated with a given type of path element.pointInPathCoordsFromPoint
(RMPoint aPoint, RMRect aRect) Returns the given point converted to path coords for given path bounds.boolean
pointOnPath
(int pointIndex) Returns true of the point at pointIndex is on the path, and false if it is on the convex hull.void
quadTo
(double cpx, double cpy, double px, double py) Adds a QuadTo element to the path for the given point and control point.void
Adds a QuadTo element to the path for the given point and control point.void
relativeCurveTo
(RMPoint cp1, RMPoint cp2, RMPoint aPoint) Adds a CurveTo element to the path for the given point offset from the path's current point.void
relativeLineTo
(RMPoint aPoint) Adds a LineTo element to the path for the given point offset from the path's current point.void
relativeMoveTo
(RMPoint aPoint) Adds a MoveTo element to the path for the given point offset from the path's current point.void
removeElement
(int elementIndex) Removes an element, reconnecting the elements on either side of the deleted element.void
Removes the last element from the path.void
reset()
Resets the current path with no elements or points.void
Sets the bounds that the path is relative to.void
Sets the path point at the given index to the given point.void
setPointStructured
(int index, RMPoint point) Resets the point at the given index to the given point, while preserving something.void
setWindingRule
(byte windingRule) Sets the winding rule which describes how inner path perimeters are filled and clipped.toXML
(RXArchiver anArchiver) XML archival.void
transformBy
(RMTransform aTransform) Transforms the points in the path by the given transform.
-
Field Details
-
WIND_NON_ZERO
public static final byte WIND_NON_ZERO- See Also:
-
WIND_EVEN_ODD
public static final byte WIND_EVEN_ODD- See Also:
-
MOVE_TO
public static final byte MOVE_TO- See Also:
-
LINE_TO
public static final byte LINE_TO- See Also:
-
QUAD_TO
public static final byte QUAD_TO- See Also:
-
CURVE_TO
public static final byte CURVE_TO- See Also:
-
CLOSE
public static final byte CLOSE- See Also:
-
unitRectPath
-
-
Constructor Details
-
RMPath
public RMPath()Creates an empty path. -
RMPath
Creates a path for the given shape.
-
-
Method Details
-
moveTo
Adds a MoveTo element to the path for the given point. -
moveTo
public void moveTo(double px, double py) Adds a MoveTo element to the path for the given point. -
lineTo
Adds a LineTo element to the path for the given point. -
lineTo
public void lineTo(double px, double py) Adds a LineTo element to the path for the given point. -
quadTo
Adds a QuadTo element to the path for the given point and control point. -
quadTo
public void quadTo(double cpx, double cpy, double px, double py) Adds a QuadTo element to the path for the given point and control point. -
curveTo
Adds a CurveTo element to the path for the given point and control points. -
curveTo
public void curveTo(double cp1x, double cp1y, double cp2x, double cp2y, double px, double py) Adds a CurveTo element to the path for the given point and control points. -
closePath
public void closePath()Adds a Close element to the given path. -
reset
public void reset()Resets the current path with no elements or points. -
relativeMoveTo
Adds a MoveTo element to the path for the given point offset from the path's current point. -
relativeLineTo
Adds a LineTo element to the path for the given point offset from the path's current point. -
relativeCurveTo
Adds a CurveTo element to the path for the given point offset from the path's current point. -
getWindingRule
public byte getWindingRule()Returns the winding rule which describes how inner path perimeters are filled and clipped. -
setWindingRule
public void setWindingRule(byte windingRule) Sets the winding rule which describes how inner path perimeters are filled and clipped. -
getX
public double getX()Returns the X of the path. -
getY
public double getY()Returns the Y of the path. -
getWidth
public double getWidth()Returns the width of the path. -
getHeight
public double getHeight()Returns the height of the path. -
getBounds
Returns the bounds for the path as an integer rect. -
getBounds2D
Returns the bounds for the path.- Specified by:
getBounds2D
in interfaceShape
-
setBounds
Sets the bounds that the path is relative to. -
getControlPointBounds
Returns the rectangle that encloses all the control points. -
getElementCount
public int getElementCount()Returns the number of elements in this path. -
getElement
public byte getElement(int anIndex) Returns the element type at the given index. -
getElement
Returns the element type at the given index and its associated points (returned in the given point array). -
getElementLast
public byte getElementLast()Returns the last element. -
getPointCount
public int getPointCount()Returns the number of points in the path. -
getPoint
Returns the point at the given index. -
getPointLast
Returns the last point in the path. -
getElementPointIndex
public int getElementPointIndex(int anIndex) Returns the point index for a given element. -
getElementIndexForPointIndex
public int getElementIndexForPointIndex(int index) Returns the element index for the given point index. -
pointCountForElementType
public int pointCountForElementType(int element) Returns the total number of points associated with a given type of path element. -
pointOnPath
public boolean pointOnPath(int pointIndex) Returns true of the point at pointIndex is on the path, and false if it is on the convex hull. -
isClosed
public boolean isClosed()Returns whether path has any open subpaths. -
getPathInRect
Returns a copy of the path scaled to exactly fit in the given rect. -
contains
Returns whether the given point is inside the path. -
contains
public boolean contains(double x, double y) Returns whether the given xy coordinate is inside the path. -
contains
Returns whether the interior of the shape entirely contains the specified rectangular area. -
contains
public boolean contains(double x, double y, double w, double h) Returns whether the interior of the shape entirely contains the specified rectangular area. -
intersects
Returns whether the interior of the path intersects the interior of a specified Rectangle2D.- Specified by:
intersects
in interfaceShape
-
intersects
public boolean intersects(double x, double y, double w, double h) Returns whether the interior of the path intersects the interior of a specified rectangular area.- Specified by:
intersects
in interfaceShape
-
intersects
Returns whether path is hit by point for a path linewidth. -
intersects
Returns whether path is hit by a line. -
intersects
public boolean intersects(double x, double y, double w, double h, float lineWidth) Returns whether path drawn with given linewidth is hit by given rect. -
intersects
Returns whether path drawn with given linewidth is hit by given path. -
getHitInfo
Returns the hit info for the given line against this path. -
getSegments
Converts a path into a list of RMLine/RMQuadratic/RMBezier. -
getSubpathsSegments
Converts a path into a list subpath lists of RMLine/RMQuadratic/RMBezier. -
addSegments
Adds the list of segments to the path, starting with a moveto. -
addSegment
Adds the list of segments to the path, starting with a moveto. -
arcLength
public double arcLength()Returns the total arc length of path segments. -
getHitInfo
Returns the hit info for the given bezier curve against this path. -
handleAtPointForBounds
public int handleAtPointForBounds(RMPoint aPoint, RMRect aRect, int selectedPoint, RMSize handleSize) Returns the handle index for a given point against this path scaled to the given rect. Only returns points that are on the path, except for the control points of selectedPoint (if not -1) -
hitHandle
Hit test the point (in path coords) against a given path point. -
pointInPathCoordsFromPoint
Returns the given point converted to path coords for given path bounds. -
removeLastElement
public void removeLastElement()Removes the last element from the path. -
removeElement
public void removeElement(int elementIndex) Removes an element, reconnecting the elements on either side of the deleted element. -
setPoint
Sets the path point at the given index to the given point. -
setPointStructured
Resets the point at the given index to the given point, while preserving something. -
getPathIterator
Returns a path iterator for this path and the given transform.- Specified by:
getPathIterator
in interfaceShape
-
getPathIterator
Returns a path iterator for this path and the given transform and flatness.- Specified by:
getPathIterator
in interfaceShape
-
transformBy
Transforms the points in the path by the given transform. -
createTransformedPath
Returns a transformed version of this path. -
getReversedPath
Returns a new path with the same points as this path, but in reverse order. -
equals
Standard equals implementation. -
clone
Standard clone implementation. -
toXML
XML archival.- Specified by:
toXML
in interfaceArchivable
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceArchivable
-