ReportMill 7.0 API

com.reportmill.graphics
Class RMPath

java.lang.Object
  extended bycom.reportmill.foundation.RMObject
      extended bycom.reportmill.graphics.RMPath
All Implemented Interfaces:
java.lang.Cloneable, com.reportmill.foundation.RMArchiver.Archiving

public class RMPath
extends com.reportmill.foundation.RMObject

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
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
RMPath()
          Creates an empty path.
 
Method Summary
 RMPath appendOval(RMRect aRect, float startAngle, float sweep, boolean connect)
          Adds elements describing an oval in the given rect to this path.
 RMPath appendPath(RMPath aPath)
          Adds the elements from the given path to this path.
 RMPath appendRect(RMRect aRect)
          Adds elements describing the perimeter of the given rect to this path.
 java.awt.geom.GeneralPath awt()
          Returns an AWT compatible version of RMPath.
 java.lang.Object clone()
          Standard clone implementation.
 void closePath()
          Adds a Close element to the given path.
 void curveTo(double px, double py, double cp1x, double cp1y, double cp2x, double cp2y)
          Adds a CurveTo element to the path for the given point and control points.
 void curveTo(RMPoint p, RMPoint cp1, RMPoint cp2)
          Adds a CurveTo element to the path for the given point and control points.
 float distanceToPoint(RMPoint aPoint)
           
 int elementIndexForPointIndex(int index)
           
 boolean equals(java.lang.Object anObj)
          Standard equals implementation.
static RMPath fromAwt(java.awt.Shape aShape)
          Returns a new path from an AWT shape.
 java.lang.Object fromXML(com.ribs.RXArchiver anArchiver, com.ribs.RXElement anElement)
          XML unarchival.
 RMRect getBounds()
          Returns the bounds for the path.
 RMRect getBounds(boolean skipConsecutiveMoveTos)
          Returns the bounds for the path with an option to ignore orphaned (consecutive) moveTos.
 byte getCurrentElement()
          Returns the last element.
 RMPoint getCurrentPoint()
          Returns the last point in 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).
 byte getElement(int anIndex, RMPoint[] points, RMRect aRect)
          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.
 RMPoint getPoint(int anIndex)
          Returns the point at the given index.
 int getPointCount()
          Returns the number of points in the path.
 java.util.Vector getPoints()
          Returns the points list used to store points internally.
 byte getWindingRule()
          Returns the winding rule which describes how inner path perimeters are filled and clipped.
 int handleAtPointForBounds(RMPoint point, RMRect rect)
           
 boolean hasCubics()
           
 boolean hitByLine(com.reportmill.graphics.RMLine aLine)
           
 boolean hitByPathForLineWidth(RMPath aPath, float lineWidth)
           
 boolean hitByPointForLineWidth(RMPoint aPoint, float lineWidth)
          Hit Detection
 boolean hitByRectForLineWidth(RMRect aRect, float lineWidth)
           
 com.reportmill.graphics.RMHitInfo hitInfoForBezier(com.reportmill.graphics.RMBezier aBezier, boolean findFirstHit)
           
 com.reportmill.graphics.RMHitInfo hitInfoForLine(com.reportmill.graphics.RMLine aLine, boolean findFirstHit)
           
 java.lang.Object initWithArchiver(com.reportmill.foundation.RMArchiver anArchiver)
          Legacy archival.
 RMPoint lastMoveToPointForElementIndex(int anIndex)
           
 RMPoint lastPointForElementIndex(int anIndex)
           
 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.
 RMPath pathInRect(RMRect aRect)
           
 RMPath pathWithFlattendCubics()
           
 int pointIndexForElementIndex(int index)
           
 RMPoint pointInPathCoordsFromPoint(RMPoint point, RMRect rect)
           
 boolean pointInsidePath(RMPoint p1)
           
 void quadraticCurveToPoint(RMPoint aPoint, RMPoint cp1, RMPoint cp2)
          I found a C++ version of this on http://homepages.tig.com.au/~dkl/swf/ - Jeff Martin.
 void quadTo(double px, double py, double cpx, double cpy)
          Adds a QuadTo element to the path for the given point and control point.
 void quadTo(RMPoint p, RMPoint cp)
          Adds a QuadTo element to the path for the given point and control point.
 void relativeCurveTo(RMPoint point, RMPoint cp1, RMPoint cp2)
          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()
           
 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)
           
 void setWindingRule(byte windingRule)
          Sets the winding rule which describes how inner path perimeters are filled and clipped.
 float signedDistanceToPoint(RMPoint aPoint)
           
 void structuredSetPoint(int index, RMPoint point)
           
 com.ribs.RXElement toXML(com.ribs.RXArchiver anArchiver)
          XML archival.
 void transformBy(com.reportmill.graphics.RMTransform aTransform)
           
 
Methods inherited from class com.reportmill.foundation.RMObject
archiverClassName, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

RMPath

public RMPath()
Creates an empty path.

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 p,
                   RMPoint cp)
Adds a QuadTo element to the path for the given point and control point.


quadTo

public void quadTo(double px,
                   double py,
                   double cpx,
                   double cpy)
Adds a QuadTo element to the path for the given point and control point.


curveTo

public void curveTo(RMPoint p,
                    RMPoint cp1,
                    RMPoint cp2)
Adds a CurveTo element to the path for the given point and control points.


curveTo

public void curveTo(double px,
                    double py,
                    double cp1x,
                    double cp1y,
                    double cp2x,
                    double cp2y)
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 point,
                            RMPoint cp1,
                            RMPoint cp2)
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.


getBounds

public RMRect getBounds()
Returns the bounds for the path.


getBounds

public RMRect getBounds(boolean skipConsecutiveMoveTos)
Returns the bounds for the path with an option to ignore orphaned (consecutive) moveTos.


setBounds

public void setBounds(RMRect bounds)
Sets the bounds that the path is relative to.


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).


getElement

public byte getElement(int anIndex,
                       RMPoint[] points,
                       RMRect aRect)
Returns the element type at the given index and its associated points (returned in the given point array).


getElementCount

public int getElementCount()
Returns the number of elements in this path.


getCurrentElement

public byte getCurrentElement()
Returns the last element.


getPoint

public RMPoint getPoint(int anIndex)
Returns the point at the given index.


getPointCount

public int getPointCount()
Returns the number of points in the path.


getCurrentPoint

public RMPoint getCurrentPoint()
Returns the last point in the path.


getPoints

public java.util.Vector getPoints()
Returns the points list used to store points internally.


pointIndexForElementIndex

public int pointIndexForElementIndex(int index)

elementIndexForPointIndex

public int elementIndexForPointIndex(int index)

lastPointForElementIndex

public RMPoint lastPointForElementIndex(int anIndex)

lastMoveToPointForElementIndex

public RMPoint lastMoveToPointForElementIndex(int anIndex)

pathInRect

public RMPath pathInRect(RMRect aRect)

hasCubics

public boolean hasCubics()

pathWithFlattendCubics

public RMPath pathWithFlattendCubics()

equals

public boolean equals(java.lang.Object anObj)
Standard equals implementation.


clone

public java.lang.Object clone()
Standard clone implementation.


initWithArchiver

public java.lang.Object initWithArchiver(com.reportmill.foundation.RMArchiver anArchiver)
Legacy archival.


toXML

public com.ribs.RXElement toXML(com.ribs.RXArchiver anArchiver)
XML archival.


fromXML

public java.lang.Object fromXML(com.ribs.RXArchiver anArchiver,
                                com.ribs.RXElement anElement)
XML unarchival.


hitByPointForLineWidth

public boolean hitByPointForLineWidth(RMPoint aPoint,
                                      float lineWidth)
Hit Detection


hitByLine

public boolean hitByLine(com.reportmill.graphics.RMLine aLine)

hitByRectForLineWidth

public boolean hitByRectForLineWidth(RMRect aRect,
                                     float lineWidth)

hitByPathForLineWidth

public boolean hitByPathForLineWidth(RMPath aPath,
                                     float lineWidth)

pointInsidePath

public boolean pointInsidePath(RMPoint p1)

distanceToPoint

public float distanceToPoint(RMPoint aPoint)

signedDistanceToPoint

public float signedDistanceToPoint(RMPoint aPoint)

hitInfoForLine

public com.reportmill.graphics.RMHitInfo hitInfoForLine(com.reportmill.graphics.RMLine aLine,
                                                        boolean findFirstHit)

hitInfoForBezier

public com.reportmill.graphics.RMHitInfo hitInfoForBezier(com.reportmill.graphics.RMBezier aBezier,
                                                          boolean findFirstHit)

handleAtPointForBounds

public int handleAtPointForBounds(RMPoint point,
                                  RMRect rect)

pointInPathCoordsFromPoint

public RMPoint pointInPathCoordsFromPoint(RMPoint point,
                                          RMRect rect)

removeLastElement

public void removeLastElement()

setPoint

public void setPoint(int index,
                     RMPoint point)

transformBy

public void transformBy(com.reportmill.graphics.RMTransform aTransform)

appendPath

public RMPath appendPath(RMPath aPath)
Adds the elements from the given path to this path.


appendRect

public RMPath appendRect(RMRect aRect)
Adds elements describing the perimeter of the given rect to this path.


appendOval

public RMPath appendOval(RMRect aRect,
                         float startAngle,
                         float sweep,
                         boolean connect)
Adds elements describing an oval in the given rect to this path.


quadraticCurveToPoint

public void quadraticCurveToPoint(RMPoint aPoint,
                                  RMPoint cp1,
                                  RMPoint cp2)
I found a C++ version of this on http://homepages.tig.com.au/~dkl/swf/ - Jeff Martin. It illustrates how to approximate 4-point cubic Beziers with 3-point quadratic Beziers. PostScript (and most apps) use cubics, Flash uses quadratics.


structuredSetPoint

public void structuredSetPoint(int index,
                               RMPoint point)

awt

public java.awt.geom.GeneralPath awt()
Returns an AWT compatible version of RMPath.


fromAwt

public static RMPath fromAwt(java.awt.Shape aShape)
Returns a new path from an AWT shape.


ReportMill 7.0 API