Package com.reportmill.graphics
Class RMPath
- java.lang.Object
-
- com.reportmill.base.RMObject
-
- com.reportmill.graphics.RMPath
-
- All Implemented Interfaces:
RMArchiver.Archiving
,java.awt.Shape
,java.lang.Cloneable
public class RMPath extends RMObject implements java.awt.Shape
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-
-
Field Summary
Fields Modifier and Type Field Description static byte
CLOSE
static byte
CURVE_TO
static byte
LINE_TO
static byte
LineCapButt
static byte
LineCapProjectingSquare
static byte
LineCapRound
static byte
LineJoinBevel
static byte
LineJoinMiter
static byte
LineJoinRound
static byte
MOVE_TO
static byte
QUAD_TO
static RMPath
unitRectPath
static byte
WIND_EVEN_ODD
static byte
WIND_NON_ZERO
-
Constructor Summary
Constructors Constructor Description RMPath()
Creates an empty path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Standard clone implementation.void
closePath()
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
contains(java.awt.geom.Point2D aPoint)
Returns whether the given point is inside the path.boolean
contains(java.awt.geom.Rectangle2D aRect)
Returns whether the interior of the shape entirely contains the specified rectangular area.RMPath
createTransformedPath(java.awt.geom.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
curveTo(RMPoint cp1, RMPoint cp2, RMPoint p)
Adds a CurveTo element to the path for the given point and control points.boolean
equals(java.lang.Object anObj)
Standard equals implementation.java.lang.Object
fromXML(RXArchiver anArchiver, RXElement anElement)
XML unarchival.java.awt.Rectangle
getBounds()
Returns the bounds for the path as an integer rect.java.awt.geom.Rectangle2D
getBounds2D()
Returns the bounds for the path.RMRect
getBoundsRM()
Returns the bounds for the path.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
getElementCount()
Returns the number of elements in this path.int
getElementIndexForPointIndex(int index)
Returns the element index for the given point index.byte
getElementLast()
Returns the last element.int
getElementPointIndex(int anIndex)
Returns the point index for a given element.double
getHeight()
Returns the height of the path.RMHitInfo
getHitInfo(RMBezier aBezier, boolean findFirstHit)
Returns the hit info for the given bezier curve against this path.RMHitInfo
getHitInfo(RMLine aLine, boolean findFirstHit)
Returns the hit info for the given line against this path.RMPath
getPathInRect(java.awt.geom.Rectangle2D aRect)
Returns a copy of the path scaled to exactly fit in the given rect.java.awt.geom.PathIterator
getPathIterator(java.awt.geom.AffineTransform aTransform)
Returns a path iterator for this path and the given transform.java.awt.geom.PathIterator
getPathIterator(java.awt.geom.AffineTransform aTransform, double flatness)
Returns a path iterator for this path and the given transform and flatness.java.awt.geom.PathIterator
getPathIteratorInRect(java.awt.geom.Rectangle2D aRect)
Returns a path iterator for the path transformted to be in the given rect.RMPoint
getPoint(int anIndex)
Returns the point at the given index.int
getPointCount()
Returns the number of points in the path.RMPoint
getPointLast()
Returns the last point in the path.double
getWidth()
Returns the width of the path.byte
getWindingRule()
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)
Returns the handle index for a given point against this path scaled to the given rect.java.lang.Object
initWithArchiver(RMArchiver anArchiver)
Legacy archival.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(java.awt.geom.Rectangle2D aRect)
Returns whether the interior of the path intersects the interior of a specified Rectangle2D.void
lineTo(double px, double py)
Adds a LineTo element to the path for the given point.void
lineTo(RMPoint p)
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
moveTo(RMPoint p)
Adds a MoveTo element to the path for the given point.RMPoint
pointInPathCoordsFromPoint(RMPoint aPoint, RMRect aRect)
Returns the given point converted to path coords for given path bounds.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
quadTo(RMPoint cp, RMPoint p)
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
removeLastElement()
Removes the last element from the path.void
reset()
Resets the current path with no elements or points.void
setBounds(RMRect bounds)
Sets the bounds that the path is relative to.void
setPoint(int index, RMPoint point)
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.RXElement
toXML(RXArchiver anArchiver)
XML archival.void
transformBy(RMTransform aTransform)
Transforms the points in the path by the given transform.-
Methods inherited from class com.reportmill.base.RMObject
copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
-
-
-
-
Field Detail
-
LineCapButt
public static final byte LineCapButt
- See Also:
- Constant Field Values
-
LineCapRound
public static final byte LineCapRound
- See Also:
- Constant Field Values
-
LineCapProjectingSquare
public static final byte LineCapProjectingSquare
- See Also:
- Constant Field Values
-
LineJoinMiter
public static final byte LineJoinMiter
- See Also:
- Constant Field Values
-
LineJoinRound
public static final byte LineJoinRound
- See Also:
- Constant Field Values
-
LineJoinBevel
public static final byte LineJoinBevel
- See Also:
- Constant Field Values
-
WIND_NON_ZERO
public static final byte WIND_NON_ZERO
- See Also:
- Constant Field Values
-
WIND_EVEN_ODD
public static final byte WIND_EVEN_ODD
- See Also:
- Constant Field Values
-
MOVE_TO
public static final byte MOVE_TO
- See Also:
- Constant Field Values
-
LINE_TO
public static final byte LINE_TO
- See Also:
- Constant Field Values
-
QUAD_TO
public static final byte QUAD_TO
- See Also:
- Constant Field Values
-
CURVE_TO
public static final byte CURVE_TO
- See Also:
- Constant Field Values
-
CLOSE
public static final byte CLOSE
- See Also:
- Constant Field Values
-
unitRectPath
public static final RMPath unitRectPath
-
-
Method Detail
-
moveTo
public void moveTo(RMPoint p)
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
public void lineTo(RMPoint p)
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
public void quadTo(RMPoint cp, RMPoint p)
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
public void curveTo(RMPoint cp1, RMPoint cp2, RMPoint p)
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
public void relativeMoveTo(RMPoint aPoint)
Adds a MoveTo element to the path for the given point offset from the path's current point.
-
relativeLineTo
public void relativeLineTo(RMPoint aPoint)
Adds a LineTo element to the path for the given point offset from the path's current point.
-
relativeCurveTo
public 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.
-
transformBy
public void transformBy(RMTransform aTransform)
Transforms the points in the path by the given transform.
-
createTransformedPath
public RMPath createTransformedPath(java.awt.geom.AffineTransform aTransform)
Returns a transformed version of this path.
-
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
public java.awt.Rectangle getBounds()
Returns the bounds for the path as an integer rect.- Specified by:
getBounds
in interfacejava.awt.Shape
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D()
Returns the bounds for the path.- Specified by:
getBounds2D
in interfacejava.awt.Shape
-
getBoundsRM
public RMRect getBoundsRM()
Returns the bounds for the path.
-
setBounds
public void setBounds(RMRect bounds)
Sets the bounds that the path is relative to.
-
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
public byte getElement(int anIndex, RMPoint[] points)
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
public RMPoint getPoint(int anIndex)
Returns the point at the given index.
-
getPointLast
public RMPoint 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.
-
getPathInRect
public RMPath getPathInRect(java.awt.geom.Rectangle2D aRect)
Returns a copy of the path scaled to exactly fit in the given rect.
-
contains
public boolean contains(java.awt.geom.Point2D aPoint)
Returns whether the given point is inside the path.- Specified by:
contains
in interfacejava.awt.Shape
-
contains
public boolean contains(double x, double y)
Returns whether the given xy coordinate is inside the path.- Specified by:
contains
in interfacejava.awt.Shape
-
contains
public boolean contains(java.awt.geom.Rectangle2D aRect)
Returns whether the interior of the shape entirely contains the specified rectangular area.- Specified by:
contains
in interfacejava.awt.Shape
-
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.- Specified by:
contains
in interfacejava.awt.Shape
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D aRect)
Returns whether the interior of the path intersects the interior of a specified Rectangle2D.- Specified by:
intersects
in interfacejava.awt.Shape
-
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 interfacejava.awt.Shape
-
intersects
public boolean intersects(RMPoint aPoint, float lineWidth)
Returns whether path is hit by point for a path linewidth.
-
intersects
public boolean intersects(RMLine aLine)
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
public boolean intersects(RMPath aPath, float lineWidth)
Returns whether path drawn with given linewidth is hit by given path.
-
getHitInfo
public RMHitInfo getHitInfo(RMLine aLine, boolean findFirstHit)
Returns the hit info for the given line against this path.
-
getHitInfo
public RMHitInfo getHitInfo(RMBezier aBezier, boolean findFirstHit)
Returns the hit info for the given bezier curve against this path.
-
handleAtPointForBounds
public int handleAtPointForBounds(RMPoint aPoint, RMRect aRect)
Returns the handle index for a given point against this path scaled to the given rect.
-
pointInPathCoordsFromPoint
public RMPoint pointInPathCoordsFromPoint(RMPoint aPoint, RMRect aRect)
Returns the given point converted to path coords for given path bounds.
-
removeLastElement
public void removeLastElement()
Removes the last element from the path.
-
setPoint
public void setPoint(int index, RMPoint point)
Sets the path point at the given index to the given point.
-
setPointStructured
public void setPointStructured(int index, RMPoint point)
Resets the point at the given index to the given point, while preserving something.
-
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform aTransform)
Returns a path iterator for this path and the given transform.- Specified by:
getPathIterator
in interfacejava.awt.Shape
-
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform aTransform, double flatness)
Returns a path iterator for this path and the given transform and flatness.- Specified by:
getPathIterator
in interfacejava.awt.Shape
-
getPathIteratorInRect
public java.awt.geom.PathIterator getPathIteratorInRect(java.awt.geom.Rectangle2D aRect)
Returns a path iterator for the path transformted to be in the given rect.
-
equals
public boolean equals(java.lang.Object anObj)
Standard equals implementation.- Overrides:
equals
in classjava.lang.Object
-
clone
public java.lang.Object clone()
Standard clone implementation.
-
toXML
public RXElement toXML(RXArchiver anArchiver)
XML archival.
-
fromXML
public java.lang.Object fromXML(RXArchiver anArchiver, RXElement anElement)
XML unarchival.
-
initWithArchiver
public java.lang.Object initWithArchiver(RMArchiver anArchiver)
Legacy archival.- Specified by:
initWithArchiver
in interfaceRMArchiver.Archiving
- Overrides:
initWithArchiver
in classRMObject
-
-