Package com.mxgraph.util.svg
Class AWTPathProducer
- java.lang.Object
-
- com.mxgraph.util.svg.AWTPathProducer
-
- All Implemented Interfaces:
PathHandler
,ShapeProducer
public class AWTPathProducer extends java.lang.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
Fields Modifier and Type Field Description 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
Constructors Constructor Description AWTPathProducer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
arcAbs(float rx, float ry, float xAxisRotation, boolean largeArcFlag, boolean sweepFlag, float x, float y)
void
arcRel(float rx, float ry, float xAxisRotation, boolean largeArcFlag, boolean sweepFlag, float x, float y)
void
closePath()
ImplementsPathHandler.closePath()
.static java.awt.Shape
createShape(java.lang.String text, int wr)
Utility method for creating an ExtendedGeneralPath.void
curvetoCubicAbs(float x1, float y1, float x2, float y2, float x, float y)
void
curvetoCubicRel(float x1, float y1, float x2, float y2, float x, float y)
void
curvetoCubicSmoothAbs(float x2, float y2, float x, float y)
void
curvetoCubicSmoothRel(float x2, float y2, float x, float y)
void
curvetoQuadraticAbs(float x1, float y1, float x, float y)
void
curvetoQuadraticRel(float x1, float y1, float x, float y)
void
curvetoQuadraticSmoothAbs(float x, float y)
void
curvetoQuadraticSmoothRel(float x, float y)
void
endPath()
ImplementsPathHandler.endPath()
.java.awt.Shape
getShape()
Returns the Shape object initialized during the last parsing.int
getWindingRule()
Returns the current winding rule.void
linetoAbs(float x, float y)
ImplementsPathHandler.linetoAbs(float,float)
.void
linetoHorizontalAbs(float x)
ImplementsPathHandler.linetoHorizontalAbs(float)
.void
linetoHorizontalRel(float x)
ImplementsPathHandler.linetoHorizontalRel(float)
.void
linetoRel(float x, float y)
ImplementsPathHandler.linetoRel(float,float)
.void
linetoVerticalAbs(float y)
ImplementsPathHandler.linetoVerticalAbs(float)
.void
linetoVerticalRel(float y)
ImplementsPathHandler.linetoVerticalRel(float)
.void
movetoAbs(float x, float y)
ImplementsPathHandler.movetoAbs(float,float)
.void
movetoRel(float x, float y)
ImplementsPathHandler.movetoRel(float,float)
.void
setWindingRule(int i)
Sets the winding rule used to construct the path.void
startPath()
ImplementsPathHandler.startPath()
.
-
-
-
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.
-
-
Method Detail
-
createShape
public static java.awt.Shape createShape(java.lang.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 interfaceShapeProducer
-
getWindingRule
public int getWindingRule()
Returns the current winding rule.- Specified by:
getWindingRule
in interfaceShapeProducer
-
getShape
public java.awt.Shape getShape()
Returns the Shape object initialized during the last parsing.- Specified by:
getShape
in interfaceShapeProducer
- Returns:
- the shape or null if this handler has not been used by a parser.
-
startPath
public void startPath() throws ParseException
ImplementsPathHandler.startPath()
.- Specified by:
startPath
in interfacePathHandler
- Throws:
ParseException
- if an error occured while processing the path
-
endPath
public void endPath() throws ParseException
ImplementsPathHandler.endPath()
.- Specified by:
endPath
in interfacePathHandler
- Throws:
ParseException
- if an error occured while processing the path
-
movetoRel
public void movetoRel(float x, float y) throws ParseException
ImplementsPathHandler.movetoRel(float,float)
.- Specified by:
movetoRel
in interfacePathHandler
- Parameters:
x
- the relative x coordinate for the end pointy
- 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
ImplementsPathHandler.movetoAbs(float,float)
.- Specified by:
movetoAbs
in interfacePathHandler
- Parameters:
x
- the absolute x coordinate for the end pointy
- the absolute y coordinate for the end point- Throws:
ParseException
- if an error occured while processing the path
-
closePath
public void closePath() throws ParseException
ImplementsPathHandler.closePath()
.- Specified by:
closePath
in interfacePathHandler
- Throws:
ParseException
- if an error occured while processing the path
-
linetoRel
public void linetoRel(float x, float y) throws ParseException
ImplementsPathHandler.linetoRel(float,float)
.- Specified by:
linetoRel
in interfacePathHandler
- Parameters:
x
- the relative x coordinates for the end pointy
- 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
ImplementsPathHandler.linetoAbs(float,float)
.- Specified by:
linetoAbs
in interfacePathHandler
- Parameters:
x
- the absolute x coordinate for the end pointy
- 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
ImplementsPathHandler.linetoHorizontalRel(float)
.- Specified by:
linetoHorizontalRel
in interfacePathHandler
- 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
ImplementsPathHandler.linetoHorizontalAbs(float)
.- Specified by:
linetoHorizontalAbs
in interfacePathHandler
- 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
ImplementsPathHandler.linetoVerticalRel(float)
.- Specified by:
linetoVerticalRel
in interfacePathHandler
- 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
ImplementsPathHandler.linetoVerticalAbs(float)
.- Specified by:
linetoVerticalAbs
in interfacePathHandler
- 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
- Specified by:
curvetoCubicRel
in interfacePathHandler
- Parameters:
x1
- the relative x coordinate for the first control pointy1
- the relative y coordinate for the first control pointx2
- the relative x coordinate for the second control pointy2
- the relative y coordinate for the second control pointx
- the relative x coordinate for the end pointy
- 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
- Specified by:
curvetoCubicAbs
in interfacePathHandler
- Parameters:
x1
- the absolute x coordinate for the first control pointy1
- the absolute y coordinate for the first control pointx2
- the absolute x coordinate for the second control pointy2
- the absolute y coordinate for the second control pointx
- the absolute x coordinate for the end pointy
- 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
- Specified by:
curvetoCubicSmoothRel
in interfacePathHandler
- Parameters:
x2
- the relative x coordinate for the second control pointy2
- the relative y coordinate for the second control pointx
- the relative x coordinate for the end pointy
- 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
- Specified by:
curvetoCubicSmoothAbs
in interfacePathHandler
- Parameters:
x2
- the absolute x coordinate for the second control pointy2
- the absolute y coordinate for the second control pointx
- the absolute x coordinate for the end pointy
- 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
- Specified by:
curvetoQuadraticRel
in interfacePathHandler
- Parameters:
x1
- the relative x coordinate for the control pointy1
- the relative y coordinate for the control pointx
- the relative x coordinate for the end pointy
- 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
- Specified by:
curvetoQuadraticAbs
in interfacePathHandler
- Parameters:
x1
- the absolute x coordinate for the control pointy1
- the absolute y coordinate for the control pointx
- the absolute x coordinate for the end pointy
- 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
- Specified by:
curvetoQuadraticSmoothRel
in interfacePathHandler
- Parameters:
x
- the relative x coordinate for the end pointy
- 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
- Specified by:
curvetoQuadraticSmoothAbs
in interfacePathHandler
- Parameters:
x
- the absolute x coordinate for the end pointy
- 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
- Specified by:
arcRel
in interfacePathHandler
- Parameters:
rx
- the X axis radius for the ellipsery
- the Y axis radius for the ellipsexAxisRotation
- the rotation angle in degrees for the ellipse's X-axis relative to the X-axislargeArcFlag
- the value of the large-arc-flagsweepFlag
- the value of the sweep-flagx
- the relative x coordinate for the end pointy
- 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
- Specified by:
arcAbs
in interfacePathHandler
- Parameters:
rx
- the X axis radius for the ellipsery
- the Y axis radius for the ellipsexAxisRotation
- the rotation angle in degrees for the ellipse's X-axis relative to the X-axislargeArcFlag
- the value of the large-arc-flagsweepFlag
- the value of the sweep-flagx
- the absolute x coordinate for the end pointy
- the absolute y coordinate for the end point- Throws:
ParseException
- if an error occured while processing the path
-
-