mxGraph 2.5.0.2


com.mxgraph.util.svg
Class AWTPathProducer

java.lang.Object
  extended by com.mxgraph.util.svg.AWTPathProducer
All Implemented Interfaces:
PathHandler, ShapeProducer

public class AWTPathProducer
extends Object
implements PathHandler, ShapeProducer

This class provides an implementation of the PathHandler that initializes a Shape from the value of a path's 'd' attribute.


Field Summary
protected  float currentX
          The current x position.
protected  float currentY
          The current y position.
protected  ExtendedGeneralPath path
          The temporary value of extendedGeneralPath.
protected  int windingRule
          The winding rule to use to construct the path.
protected  float xCenter
          The reference x point for smooth arcs.
protected  float yCenter
          The reference y point for smooth arcs.
 
Constructor Summary
AWTPathProducer()
           
 
Method Summary
 void arcAbs(float rx, float ry, float xAxisRotation, boolean largeArcFlag, boolean sweepFlag, float x, float y)
          Implements PathHandler.arcAbs(float,float,float,boolean,boolean,float,float).
 void arcRel(float rx, float ry, float xAxisRotation, boolean largeArcFlag, boolean sweepFlag, float x, float y)
          Implements PathHandler.arcRel(float,float,float,boolean,boolean,float,float).
 void closePath()
          Implements PathHandler.closePath().
static Shape createShape(String text, int wr)
          Utility method for creating an ExtendedGeneralPath.
 void curvetoCubicAbs(float x1, float y1, float x2, float y2, float x, float y)
          Implements PathHandler.curvetoCubicAbs(float,float,float,float,float,float).
 void curvetoCubicRel(float x1, float y1, float x2, float y2, float x, float y)
          Implements PathHandler.curvetoCubicRel(float,float,float,float,float,float).
 void curvetoCubicSmoothAbs(float x2, float y2, float x, float y)
          Implements PathHandler.curvetoCubicSmoothAbs(float,float,float,float).
 void curvetoCubicSmoothRel(float x2, float y2, float x, float y)
          Implements PathHandler.curvetoCubicSmoothRel(float,float,float,float).
 void curvetoQuadraticAbs(float x1, float y1, float x, float y)
          Implements PathHandler.curvetoQuadraticAbs(float,float,float,float).
 void curvetoQuadraticRel(float x1, float y1, float x, float y)
          Implements PathHandler.curvetoQuadraticRel(float,float,float,float).
 void curvetoQuadraticSmoothAbs(float x, float y)
          Implements PathHandler.curvetoQuadraticSmoothAbs(float,float).
 void curvetoQuadraticSmoothRel(float x, float y)
          Implements PathHandler.curvetoQuadraticSmoothRel(float,float).
 void endPath()
          Implements PathHandler.endPath().
 Shape getShape()
          Returns the Shape object initialized during the last parsing.
 int getWindingRule()
          Returns the current winding rule.
 void linetoAbs(float x, float y)
          Implements PathHandler.linetoAbs(float,float).
 void linetoHorizontalAbs(float x)
          Implements PathHandler.linetoHorizontalAbs(float).
 void linetoHorizontalRel(float x)
          Implements PathHandler.linetoHorizontalRel(float).
 void linetoRel(float x, float y)
          Implements PathHandler.linetoRel(float,float).
 void linetoVerticalAbs(float y)
          Implements PathHandler.linetoVerticalAbs(float).
 void linetoVerticalRel(float y)
          Implements PathHandler.linetoVerticalRel(float).
 void movetoAbs(float x, float y)
          Implements PathHandler.movetoAbs(float,float).
 void movetoRel(float x, float y)
          Implements PathHandler.movetoRel(float,float).
 void setWindingRule(int i)
          Sets the winding rule used to construct the path.
 void startPath()
          Implements PathHandler.startPath().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

path

protected ExtendedGeneralPath path
The temporary value of extendedGeneralPath.


currentX

protected float currentX
The current x position.


currentY

protected float currentY
The current y position.


xCenter

protected float xCenter
The reference x point for smooth arcs.


yCenter

protected float yCenter
The reference y point for smooth arcs.


windingRule

protected int windingRule
The winding rule to use to construct the path.

Constructor Detail

AWTPathProducer

public AWTPathProducer()
Method Detail

createShape

public static Shape createShape(String text,
                                int wr)
                         throws ParseException
Utility method for creating an ExtendedGeneralPath.

Parameters:
text - The text representation of the path specification.
wr - The winding rule to use for creating the path.
Throws:
ParseException

setWindingRule

public void setWindingRule(int i)
Sets the winding rule used to construct the path.

Specified by:
setWindingRule in interface ShapeProducer

getWindingRule

public int getWindingRule()
Returns the current winding rule.

Specified by:
getWindingRule in interface ShapeProducer

getShape

public Shape getShape()
Returns the Shape object initialized during the last parsing.

Specified by:
getShape in interface ShapeProducer
Returns:
the shape or null if this handler has not been used by a parser.

startPath

public void startPath()
               throws ParseException
Implements PathHandler.startPath().

Specified by:
startPath in interface PathHandler
Throws:
ParseException - if an error occured while processing the path

endPath

public void endPath()
             throws ParseException
Implements PathHandler.endPath().

Specified by:
endPath in interface PathHandler
Throws:
ParseException - if an error occured while processing the path

movetoRel

public void movetoRel(float x,
                      float y)
               throws ParseException
Implements PathHandler.movetoRel(float,float).

Specified by:
movetoRel in interface PathHandler
Parameters:
x - the relative x coordinate for the end point
y - the relative y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

movetoAbs

public void movetoAbs(float x,
                      float y)
               throws ParseException
Implements PathHandler.movetoAbs(float,float).

Specified by:
movetoAbs in interface PathHandler
Parameters:
x - the absolute x coordinate for the end point
y - the absolute y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

closePath

public void closePath()
               throws ParseException
Implements PathHandler.closePath().

Specified by:
closePath in interface PathHandler
Throws:
ParseException - if an error occured while processing the path

linetoRel

public void linetoRel(float x,
                      float y)
               throws ParseException
Implements PathHandler.linetoRel(float,float).

Specified by:
linetoRel in interface PathHandler
Parameters:
x - the relative x coordinates for the end point
y - the relative y coordinates for the end point
Throws:
ParseException - if an error occured while processing the path

linetoAbs

public void linetoAbs(float x,
                      float y)
               throws ParseException
Implements PathHandler.linetoAbs(float,float).

Specified by:
linetoAbs in interface PathHandler
Parameters:
x - the absolute x coordinate for the end point
y - the absolute y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

linetoHorizontalRel

public void linetoHorizontalRel(float x)
                         throws ParseException
Implements PathHandler.linetoHorizontalRel(float).

Specified by:
linetoHorizontalRel in interface PathHandler
Parameters:
x - the relative X coordinate of the end point
Throws:
ParseException - if an error occured while processing the path

linetoHorizontalAbs

public void linetoHorizontalAbs(float x)
                         throws ParseException
Implements PathHandler.linetoHorizontalAbs(float).

Specified by:
linetoHorizontalAbs in interface PathHandler
Parameters:
x - the absolute X coordinate of the end point
Throws:
ParseException - if an error occured while processing the path

linetoVerticalRel

public void linetoVerticalRel(float y)
                       throws ParseException
Implements PathHandler.linetoVerticalRel(float).

Specified by:
linetoVerticalRel in interface PathHandler
Parameters:
y - the relative Y coordinate of the end point
Throws:
ParseException - if an error occured while processing the path

linetoVerticalAbs

public void linetoVerticalAbs(float y)
                       throws ParseException
Implements PathHandler.linetoVerticalAbs(float).

Specified by:
linetoVerticalAbs in interface PathHandler
Parameters:
y - the absolute Y coordinate of the end point
Throws:
ParseException - if an error occured while processing the path

curvetoCubicRel

public void curvetoCubicRel(float x1,
                            float y1,
                            float x2,
                            float y2,
                            float x,
                            float y)
                     throws ParseException
Implements PathHandler.curvetoCubicRel(float,float,float,float,float,float).

Specified by:
curvetoCubicRel in interface PathHandler
Parameters:
x1 - the relative x coordinate for the first control point
y1 - the relative y coordinate for the first control point
x2 - the relative x coordinate for the second control point
y2 - the relative y coordinate for the second control point
x - the relative x coordinate for the end point
y - the relative y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

curvetoCubicAbs

public void curvetoCubicAbs(float x1,
                            float y1,
                            float x2,
                            float y2,
                            float x,
                            float y)
                     throws ParseException
Implements PathHandler.curvetoCubicAbs(float,float,float,float,float,float).

Specified by:
curvetoCubicAbs in interface PathHandler
Parameters:
x1 - the absolute x coordinate for the first control point
y1 - the absolute y coordinate for the first control point
x2 - the absolute x coordinate for the second control point
y2 - the absolute y coordinate for the second control point
x - the absolute x coordinate for the end point
y - the absolute y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

curvetoCubicSmoothRel

public void curvetoCubicSmoothRel(float x2,
                                  float y2,
                                  float x,
                                  float y)
                           throws ParseException
Implements PathHandler.curvetoCubicSmoothRel(float,float,float,float).

Specified by:
curvetoCubicSmoothRel in interface PathHandler
Parameters:
x2 - the relative x coordinate for the second control point
y2 - the relative y coordinate for the second control point
x - the relative x coordinate for the end point
y - the relative y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

curvetoCubicSmoothAbs

public void curvetoCubicSmoothAbs(float x2,
                                  float y2,
                                  float x,
                                  float y)
                           throws ParseException
Implements PathHandler.curvetoCubicSmoothAbs(float,float,float,float).

Specified by:
curvetoCubicSmoothAbs in interface PathHandler
Parameters:
x2 - the absolute x coordinate for the second control point
y2 - the absolute y coordinate for the second control point
x - the absolute x coordinate for the end point
y - the absolute y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

curvetoQuadraticRel

public void curvetoQuadraticRel(float x1,
                                float y1,
                                float x,
                                float y)
                         throws ParseException
Implements PathHandler.curvetoQuadraticRel(float,float,float,float).

Specified by:
curvetoQuadraticRel in interface PathHandler
Parameters:
x1 - the relative x coordinate for the control point
y1 - the relative y coordinate for the control point
x - the relative x coordinate for the end point
y - the relative x coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

curvetoQuadraticAbs

public void curvetoQuadraticAbs(float x1,
                                float y1,
                                float x,
                                float y)
                         throws ParseException
Implements PathHandler.curvetoQuadraticAbs(float,float,float,float).

Specified by:
curvetoQuadraticAbs in interface PathHandler
Parameters:
x1 - the absolute x coordinate for the control point
y1 - the absolute y coordinate for the control point
x - the absolute x coordinate for the end point
y - the absolute x coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

curvetoQuadraticSmoothRel

public void curvetoQuadraticSmoothRel(float x,
                                      float y)
                               throws ParseException
Implements PathHandler.curvetoQuadraticSmoothRel(float,float).

Specified by:
curvetoQuadraticSmoothRel in interface PathHandler
Parameters:
x - the relative x coordinate for the end point
y - the relative y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

curvetoQuadraticSmoothAbs

public void curvetoQuadraticSmoothAbs(float x,
                                      float y)
                               throws ParseException
Implements PathHandler.curvetoQuadraticSmoothAbs(float,float).

Specified by:
curvetoQuadraticSmoothAbs in interface PathHandler
Parameters:
x - the absolute x coordinate for the end point
y - the absolute y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

arcRel

public void arcRel(float rx,
                   float ry,
                   float xAxisRotation,
                   boolean largeArcFlag,
                   boolean sweepFlag,
                   float x,
                   float y)
            throws ParseException
Implements PathHandler.arcRel(float,float,float,boolean,boolean,float,float).

Specified by:
arcRel in interface PathHandler
Parameters:
rx - the X axis radius for the ellipse
ry - the Y axis radius for the ellipse
xAxisRotation - the rotation angle in degrees for the ellipse's X-axis relative to the X-axis
largeArcFlag - the value of the large-arc-flag
sweepFlag - the value of the sweep-flag
x - the relative x coordinate for the end point
y - the relative y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

arcAbs

public void arcAbs(float rx,
                   float ry,
                   float xAxisRotation,
                   boolean largeArcFlag,
                   boolean sweepFlag,
                   float x,
                   float y)
            throws ParseException
Implements PathHandler.arcAbs(float,float,float,boolean,boolean,float,float).

Specified by:
arcAbs in interface PathHandler
Parameters:
rx - the X axis radius for the ellipse
ry - the Y axis radius for the ellipse
xAxisRotation - the rotation angle in degrees for the ellipse's X-axis relative to the X-axis
largeArcFlag - the value of the large-arc-flag
sweepFlag - the value of the sweep-flag
x - the absolute x coordinate for the end point
y - the absolute y coordinate for the end point
Throws:
ParseException - if an error occured while processing the path

mxGraph 2.5.0.2


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.