cox.jmatt.java.MathTools.markup.svg
Class PathTag

java.lang.Object
  extended by cox.jmatt.java.MathTools.markup.Tag
      extended by cox.jmatt.java.MathTools.markup.svg.StyleTag
          extended by cox.jmatt.java.MathTools.markup.svg.PathTag

public class PathTag
extends StyleTag

This class encapsulates the SVG <path> tag. It provides a quick way to set the path explicitly and commands to add elements to it. Each command comes in a relative and absolute flavor. The relative versions start with lowercase letters and the absolute versions with uppercase. The arguments for each flavor are the same.


Nested Class Summary
 
Nested classes/interfaces inherited from class cox.jmatt.java.MathTools.markup.svg.StyleTag
StyleTag.TagKeys
 
Field Summary
 
Fields inherited from class cox.jmatt.java.MathTools.markup.Tag
myTagName
 
Constructor Summary
PathTag()
          Automatically constructs a <path> tag.
 
Method Summary
 PathTag arcTo(double pRadX, double pRadY, double pXRot, boolean pLargeArc, boolean pSweep, double pEndX, double pEndY)
          Draw an elliptical arc, relative version.
 PathTag ArcTo(double pRadX, double pRadY, double pXRot, boolean pLargeArc, boolean pSweep, double pEndX, double pEndY)
          Draw an elliptical arc, absolute version.
 PathTag cCurveTo(double pC1X, double pC1Y, double pC2X, double pC2Y, double pX, double pY)
          Draw a cubic bezier curve to the specified endpoint relative to the current location.
 PathTag CCurveTo(double pC1X, double pC1Y, double pC2X, double pC2Y, double pX, double pY)
          Absolute version of the cubic curve.
 PathTag closePath()
          Close the current (sub-) path.
 PathTag copyOf()
          Create a copy of this tag.
 PathTag hLineTo(double pEnd)
          Draw a horizontal line to the specified point, relative version.
 PathTag HLineTo(double pEnd)
          Draw a horizontal line to the specified point, absolute version.
 PathTag lineTo(double pX, double pY)
          Draw a line to the specified point relative to the current location.
 PathTag LineTo(double pX, double pY)
          Draw a line to the specified point, absolute version.
 PathTag moveTo(double pX, double pY)
          Move to the specified point relative to the current location.
 PathTag MoveTo(double pX, double pY)
          Move to the specified point, absolute coordinates.
 PathTag qCurveTo(double pCX, double pCY, double pX, double pY)
          Draw a quadratic bezier curve to the specified endpoint relative to the current location.
 PathTag QCurveTo(double pCX, double pCY, double pX, double pY)
          Draw a quatratic curve, absolute version.
 void reset()
          Overridden to clear out any path data.
 PathTag sCurveTo(double pCX, double pCY, double pX, double pY)
          Add a smooth cubic polybezier curve.
 PathTag SCurveTo(double pCX, double pCY, double pX, double pY)
          Smooth cubic polybezier curve, absolute version.
 PathTag setPath(java.lang.String pPath)
          Set the path to the String supplied, or clear it with null or blank.
 PathTag tCurveTo(double pX, double pY)
          Draw a smooth quadratic polybezier curve; only the endpoint is required, the control point is calcuated automatically.
 PathTag TCurveTo(double pX, double pY)
          Draw a smooth quadratic polybezier curve, absolute version.
 java.lang.String toString()
          Overridden to add the actual path to the tag at the last instant.
 PathTag vLineTo(double pEnd)
          Draw a vertical line to the specified point, relative version.
 PathTag VLineTo(double pEnd)
          Draw a vertical line to the specified point, absolute version.
 
Methods inherited from class cox.jmatt.java.MathTools.markup.svg.StyleTag
_configureTag, _enableCopy, canHaveDefs, isInDefs, setDefaultPen, setDefaultStyle, setDefaultTransform, setPen, setStyle, setTransform
 
Methods inherited from class cox.jmatt.java.MathTools.markup.Tag
_addAttribute, _addAttributes, _addNAttribute, _asBoolean, _asDouble, _asInt, _attributes, _clampNAttribute, _clampNAttribute, _content, _fixKey, _setContent, _setEnableXMLTag, badPizza, closeTag, configureTag, configureTagFromGlobalPizza, makeTag, openTag, setID, validString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathTag

public PathTag()
Automatically constructs a <path> tag.

Method Detail

reset

public void reset()
Overridden to clear out any path data. Returns a self-reference.

Overrides:
reset in class Tag

copyOf

public PathTag copyOf()
Create a copy of this tag.


toString

public java.lang.String toString()
Overridden to add the actual path to the tag at the last instant.

Overrides:
toString in class Tag

setPath

public PathTag setPath(java.lang.String pPath)
Set the path to the String supplied, or clear it with null or blank. IMPORTANT NOTE: Calling this method clears all previous path data.


closePath

public PathTag closePath()
Close the current (sub-) path. There is no absolute version of this command.


moveTo

public PathTag moveTo(double pX,
                      double pY)
Move to the specified point relative to the current location.

Parameters:
pX - The X-coordinate of the destination.
pY - The destination Y-cooridnate.
Returns:
A reference to this.

MoveTo

public PathTag MoveTo(double pX,
                      double pY)
Move to the specified point, absolute coordinates.

Parameters:
pX - The X-coordinate of the destination.
pY - The destination Y-cooridnate.
Returns:
A reference to this.

lineTo

public PathTag lineTo(double pX,
                      double pY)
Draw a line to the specified point relative to the current location.

Parameters:
pX - The X-coordinate of the endpoint.
pY - The Y-coordinate of the endpoint.
Returns:
A self-reference.

LineTo

public PathTag LineTo(double pX,
                      double pY)
Draw a line to the specified point, absolute version.

Parameters:
pX - The X-coordinate of the endpoint.
pY - The Y-coordinate of the endpoint.
Returns:
A self-reference.

hLineTo

public PathTag hLineTo(double pEnd)
Draw a horizontal line to the specified point, relative version.

Parameters:
pEnd - The (relative) endpoint of the horizontal segment.

HLineTo

public PathTag HLineTo(double pEnd)
Draw a horizontal line to the specified point, absolute version.

Parameters:
pEnd - The (absolute) endpoint of the horizontal segment.

vLineTo

public PathTag vLineTo(double pEnd)
Draw a vertical line to the specified point, relative version.

Parameters:
pEnd - The (relative) endpoint of the vertical segment.

VLineTo

public PathTag VLineTo(double pEnd)
Draw a vertical line to the specified point, absolute version.

Parameters:
pEnd - The (absolute) endpoint of the vertical segment.

arcTo

public PathTag arcTo(double pRadX,
                     double pRadY,
                     double pXRot,
                     boolean pLargeArc,
                     boolean pSweep,
                     double pEndX,
                     double pEndY)
Draw an elliptical arc, relative version.

Parameters:
pRadX - The X-radius of the arc.
pRadY - The Y-radius of the arc.
pXRot - The X-axis rotation.
pLargeArc - false (0) if the arc is less than 180 degrees, true (1) if it is greater.
pSweep - false (0) to draw in the negative angle direction, true (1) for the positive angle direction.
pEndX - The X-coordinate of the endpoint.
pEndY - The Y-coordinate of the endpoint.
Returns:
A reference to this.

ArcTo

public PathTag ArcTo(double pRadX,
                     double pRadY,
                     double pXRot,
                     boolean pLargeArc,
                     boolean pSweep,
                     double pEndX,
                     double pEndY)
Draw an elliptical arc, absolute version. Arguments are per the relative flavor.


qCurveTo

public PathTag qCurveTo(double pCX,
                        double pCY,
                        double pX,
                        double pY)
Draw a quadratic bezier curve to the specified endpoint relative to the current location.

Parameters:
pCX - The X-coordinate of the control point.
pCY - The Y-coordinate of the control point.
pX - The X-coordinate of the endpoint.
pY - The Y-coordinate of the endpoint.
Returns:
A reference to this.

QCurveTo

public PathTag QCurveTo(double pCX,
                        double pCY,
                        double pX,
                        double pY)
Draw a quatratic curve, absolute version. Arguments are per the relative method.


tCurveTo

public PathTag tCurveTo(double pX,
                        double pY)
Draw a smooth quadratic polybezier curve; only the endpoint is required, the control point is calcuated automatically. This is the 't' command.

Parameters:
pX - The endpoint X-coordinate.
pY - The endpoint Y-coordinate.
Returns:
A reference to this to allow easy chaining.

TCurveTo

public PathTag TCurveTo(double pX,
                        double pY)
Draw a smooth quadratic polybezier curve, absolute version. The 'T' command.


cCurveTo

public PathTag cCurveTo(double pC1X,
                        double pC1Y,
                        double pC2X,
                        double pC2Y,
                        double pX,
                        double pY)
Draw a cubic bezier curve to the specified endpoint relative to the current location.

Parameters:
pC1X - The X-coordinate of the first control point.
pC1Y - The Y-coordinate of the first control point.
pC2X - The X-coordinate of the second control point.
pC2Y - The Y-coordinate of the second control point.
pX - The X-coordinate of the endpoint.
pY - The Y-coordinate of the endpoint.
Returns:
A reference to this.

CCurveTo

public PathTag CCurveTo(double pC1X,
                        double pC1Y,
                        double pC2X,
                        double pC2Y,
                        double pX,
                        double pY)
Absolute version of the cubic curve. Same arguments as the relative version.


sCurveTo

public PathTag sCurveTo(double pCX,
                        double pCY,
                        double pX,
                        double pY)
Add a smooth cubic polybezier curve. Only the second control and endpoint are required. The 's' command, relative version.

Parameters:
pCX - The control point X-coordinate.
pCY - The control point Y-coordinate.
pX - The X-coordinate for the endpoint.
pY - The Y-coordinate of the endpoint.
Returns:
A reference to this for method chaining.

SCurveTo

public PathTag SCurveTo(double pCX,
                        double pCY,
                        double pX,
                        double pY)
Smooth cubic polybezier curve, absolute version. The 'S' command.