public class SVGPath
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.StringBuilder |
buf
String buffer for building the path.
|
private char |
lastaction
The last action we did, to not add unnecessary commands
|
static char |
PATH_ARC
Absolute path arc command.
|
static char |
PATH_ARC_RELATIVE
Relative path arc command.
|
static char |
PATH_CLOSE
Close path command.
|
static char |
PATH_CUBIC_TO
Absolute cubic line to command.
|
static char |
PATH_CUBIC_TO_RELATIVE
Relative cubic line to command.
|
static char |
PATH_HORIZONTAL_LINE_TO
Absolute horizontal line to command.
|
static char |
PATH_HORIZONTAL_LINE_TO_RELATIVE
Relative horizontal line to command.
|
static char |
PATH_LINE_TO
Absolute line to command.
|
static char |
PATH_LINE_TO_RELATIVE
Relative line to command.
|
static char |
PATH_MOVE
Absolute move command.
|
static char |
PATH_MOVE_RELATIVE
Relative move command.
|
static char |
PATH_QUAD_TO
Absolute quadratic interpolation to command.
|
static char |
PATH_QUAD_TO_RELATIVE
Relative quadratic interpolation to command.
|
static char |
PATH_SMOOTH_CUBIC_TO
Absolute "smooth cubic to" SVG path command.
|
static char |
PATH_SMOOTH_CUBIC_TO_RELATIVE
Relative smooth cubic to command.
|
static char |
PATH_SMOOTH_QUAD_TO
Absolute smooth quadratic interpolation to
command.
|
static char |
PATH_SMOOTH_QUAD_TO_RELATIVE
Relative smooth quadratic interpolation to
command.
|
static char |
PATH_VERTICAL_LINE_TO
Absolute vertical line to command.
|
static char |
PATH_VERTICAL_LINE_TO_RELATIVE
Relative vertical line to command.
|
Constructor and Description |
---|
SVGPath()
Empty path constructor.
|
SVGPath(double[] xy)
Constructor with initial point.
|
SVGPath(double x,
double y)
Constructor with initial point.
|
SVGPath(Polygon vectors)
Constructor from a double[] collection (e.g. a polygon)
|
Modifier and Type | Method and Description |
---|---|
private SVGPath |
append(char action)
Append an action to the current path.
|
private SVGPath |
append(double x)
Append a value to the current path.
|
SVGPath |
close()
Close the path.
|
SVGPath |
cubicTo(double[] c1xy,
double[] c2xy,
double[] xy)
Cubic Bezier line to the given coordinates.
|
SVGPath |
cubicTo(double c1x,
double c1y,
double c2x,
double c2y,
double x,
double y)
Cubic Bezier line to the given coordinates.
|
SVGPath |
drawTo(double[] xy)
Draw a line given a series of coordinates.
|
SVGPath |
drawTo(double x,
double y)
Draw a line given a series of coordinates.
|
SVGPath |
ellipticalArc(double[] rxy,
double ar,
double la,
double sp,
double[] xy)
Elliptical arc curve to the given coordinates.
|
SVGPath |
ellipticalArc(double rx,
double ry,
double ar,
double la,
double sp,
double[] xy)
Elliptical arc curve to the given coordinates.
|
SVGPath |
ellipticalArc(double rx,
double ry,
double ar,
double la,
double sp,
double x,
double y)
Elliptical arc curve to the given coordinates.
|
SVGPath |
horizontalLineTo(double x)
Draw a horizontal line to the given x coordinate.
|
boolean |
isStarted()
Test whether the path drawing has already started.
|
SVGPath |
lineTo(double[] xy)
Draw a line to the given coordinates.
|
SVGPath |
lineTo(double x,
double y)
Draw a line to the given coordinates.
|
org.w3c.dom.Element |
makeElement(SVGPlot plot)
Turn the path buffer into an SVG element.
|
org.w3c.dom.Element |
makeElement(SVGPlot plot,
java.lang.String cssclass)
Turn the path buffer into an SVG element.
|
SVGPath |
moveTo(double[] xy)
Move to the given coordinates.
|
SVGPath |
moveTo(double x,
double y)
Move to the given coordinates.
|
SVGPath |
quadTo(double[] c1xy,
double[] xy)
Quadratic Bezier line to the given coordinates.
|
SVGPath |
quadTo(double c1x,
double c1y,
double x,
double y)
Quadratic Bezier line to the given coordinates.
|
SVGPath |
relativeCubicTo(double[] c1xy,
double[] c2xy,
double[] xy)
Cubic Bezier line to the given relative coordinates.
|
SVGPath |
relativeCubicTo(double c1x,
double c1y,
double c2x,
double c2y,
double x,
double y)
Cubic Bezier line to the given relative coordinates.
|
SVGPath |
relativeEllipticalArc(double[] rxy,
double ar,
double la,
double sp,
double[] xy)
Elliptical arc curve to the given relative coordinates.
|
SVGPath |
relativeEllipticalArc(double rx,
double ry,
double ar,
double la,
double sp,
double[] xy)
Elliptical arc curve to the given relative coordinates.
|
SVGPath |
relativeEllipticalArc(double rx,
double ry,
double ar,
double la,
double sp,
double x,
double y)
Elliptical arc curve to the given relative coordinates.
|
SVGPath |
relativeHorizontalLineTo(double x)
Draw a horizontal line to the given relative x coordinate.
|
SVGPath |
relativeLineTo(double[] xy)
Draw a line to the given relative coordinates.
|
SVGPath |
relativeLineTo(double x,
double y)
Draw a line to the given relative coordinates.
|
SVGPath |
relativeMoveTo(double[] xy)
Move to the given relative coordinates.
|
SVGPath |
relativeMoveTo(double x,
double y)
Move to the given relative coordinates.
|
SVGPath |
relativeQuadTo(double[] c1xy,
double[] xy)
Quadratic Bezier line to the given relative coordinates.
|
SVGPath |
relativeQuadTo(double c1x,
double c1y,
double x,
double y)
Quadratic Bezier line to the given relative coordinates.
|
SVGPath |
relativeSmoothCubicTo(double[] c2xy,
double[] xy)
Smooth Cubic Bezier line to the given relative coordinates.
|
SVGPath |
relativeSmoothCubicTo(double c2x,
double c2y,
double x,
double y)
Smooth Cubic Bezier line to the given relative coordinates.
|
SVGPath |
relativeSmoothQuadTo(double[] xy)
Smooth quadratic Bezier line to the given relative coordinates.
|
SVGPath |
relativeSmoothQuadTo(double x,
double y)
Smooth quadratic Bezier line to the given relative coordinates.
|
SVGPath |
relativeVerticalLineTo(double y)
Draw a vertical line to the given relative y coordinate.
|
SVGPath |
smoothCubicTo(double[] c2xy,
double[] xy)
Smooth Cubic Bezier line to the given coordinates.
|
SVGPath |
smoothCubicTo(double c2x,
double c2y,
double x,
double y)
Smooth Cubic Bezier line to the given coordinates.
|
SVGPath |
smoothQuadTo(double[] xy)
Smooth quadratic Bezier line to the given coordinates.
|
SVGPath |
smoothQuadTo(double x,
double y)
Smooth quadratic Bezier line to the given coordinates.
|
java.lang.String |
toString()
Return the SVG serialization of the path.
|
SVGPath |
verticalLineTo(double y)
Draw a vertical line to the given y coordinate.
|
private java.lang.StringBuilder buf
private char lastaction
public static final char PATH_CLOSE
public static final char PATH_LINE_TO
public static final char PATH_LINE_TO_RELATIVE
public static final char PATH_MOVE
public static final char PATH_MOVE_RELATIVE
public static final char PATH_HORIZONTAL_LINE_TO
public static final char PATH_HORIZONTAL_LINE_TO_RELATIVE
public static final char PATH_VERTICAL_LINE_TO
public static final char PATH_VERTICAL_LINE_TO_RELATIVE
public static final char PATH_CUBIC_TO
public static final char PATH_CUBIC_TO_RELATIVE
public static final char PATH_SMOOTH_CUBIC_TO
public static final char PATH_SMOOTH_CUBIC_TO_RELATIVE
public static final char PATH_QUAD_TO
public static final char PATH_QUAD_TO_RELATIVE
public static final char PATH_SMOOTH_QUAD_TO
public static final char PATH_SMOOTH_QUAD_TO_RELATIVE
public static final char PATH_ARC
public static final char PATH_ARC_RELATIVE
public SVGPath()
public SVGPath(double x, double y)
x
- initial coordinatesy
- initial coordinatespublic SVGPath(double[] xy)
xy
- initial coordinatespublic SVGPath(Polygon vectors)
vectors
- vectorspublic SVGPath drawTo(double x, double y)
x
- new coordinatesy
- new coordinatespublic SVGPath drawTo(double[] xy)
xy
- new coordinatespublic boolean isStarted()
public SVGPath lineTo(double x, double y)
x
- new coordinatesy
- new coordinatespublic SVGPath lineTo(double[] xy)
xy
- new coordinatespublic SVGPath relativeLineTo(double x, double y)
x
- relative coordinatesy
- relative coordinatespublic SVGPath relativeLineTo(double[] xy)
xy
- new coordinatespublic SVGPath horizontalLineTo(double x)
x
- new coordinatespublic SVGPath relativeHorizontalLineTo(double x)
x
- new coordinatespublic SVGPath verticalLineTo(double y)
y
- new coordinatepublic SVGPath relativeVerticalLineTo(double y)
y
- new coordinatepublic SVGPath moveTo(double x, double y)
x
- new coordinatesy
- new coordinatespublic SVGPath moveTo(double[] xy)
xy
- new coordinatespublic SVGPath relativeMoveTo(double x, double y)
x
- new coordinatesy
- new coordinatespublic SVGPath relativeMoveTo(double[] xy)
xy
- new coordinatespublic SVGPath cubicTo(double c1x, double c1y, double c2x, double c2y, double x, double y)
c1x
- first control point xc1y
- first control point yc2x
- second control point xc2y
- second control point yx
- new coordinatesy
- new coordinatespublic SVGPath cubicTo(double[] c1xy, double[] c2xy, double[] xy)
c1xy
- first control pointc2xy
- second control pointxy
- new coordinatespublic SVGPath relativeCubicTo(double c1x, double c1y, double c2x, double c2y, double x, double y)
c1x
- first control point xc1y
- first control point yc2x
- second control point xc2y
- second control point yx
- new coordinatesy
- new coordinatespublic SVGPath relativeCubicTo(double[] c1xy, double[] c2xy, double[] xy)
c1xy
- first control pointc2xy
- second control pointxy
- new coordinatespublic SVGPath smoothCubicTo(double c2x, double c2y, double x, double y)
c2x
- second control point xc2y
- second control point yx
- new coordinatesy
- new coordinatespublic SVGPath smoothCubicTo(double[] c2xy, double[] xy)
c2xy
- second control pointxy
- new coordinatespublic SVGPath relativeSmoothCubicTo(double c2x, double c2y, double x, double y)
c2x
- second control point xc2y
- second control point yx
- new coordinatesy
- new coordinatespublic SVGPath relativeSmoothCubicTo(double[] c2xy, double[] xy)
c2xy
- second control pointxy
- new coordinatespublic SVGPath quadTo(double c1x, double c1y, double x, double y)
c1x
- first control point xc1y
- first control point yx
- new coordinatesy
- new coordinatespublic SVGPath quadTo(double[] c1xy, double[] xy)
c1xy
- first control pointxy
- new coordinatespublic SVGPath relativeQuadTo(double c1x, double c1y, double x, double y)
c1x
- first control point xc1y
- first control point yx
- new coordinatesy
- new coordinatespublic SVGPath relativeQuadTo(double[] c1xy, double[] xy)
c1xy
- first control pointxy
- new coordinatespublic SVGPath smoothQuadTo(double x, double y)
x
- new coordinatesy
- new coordinatespublic SVGPath smoothQuadTo(double[] xy)
xy
- new coordinatespublic SVGPath relativeSmoothQuadTo(double x, double y)
x
- new coordinatesy
- new coordinatespublic SVGPath relativeSmoothQuadTo(double[] xy)
xy
- new coordinatespublic SVGPath ellipticalArc(double rx, double ry, double ar, double la, double sp, double x, double y)
rx
- x radiusry
- y radiusar
- x-axis-rotationla
- large arc flag, if angle >= 180 degsp
- sweep flag, if arc will be drawn in positive-angle directionx
- new coordinatesy
- new coordinatespublic SVGPath ellipticalArc(double rx, double ry, double ar, double la, double sp, double[] xy)
rx
- x radiusry
- y radiusar
- x-axis-rotationla
- large arc flag, if angle >= 180 degsp
- sweep flag, if arc will be drawn in positive-angle directionxy
- new coordinatespublic SVGPath ellipticalArc(double[] rxy, double ar, double la, double sp, double[] xy)
rxy
- radiusar
- x-axis-rotationla
- large arc flag, if angle >= 180 degsp
- sweep flag, if arc will be drawn in positive-angle directionxy
- new coordinatespublic SVGPath relativeEllipticalArc(double rx, double ry, double ar, double la, double sp, double x, double y)
rx
- x radiusry
- y radiusar
- x-axis-rotationla
- large arc flag, if angle >= 180 degsp
- sweep flag, if arc will be drawn in positive-angle directionx
- new coordinatesy
- new coordinatespublic SVGPath relativeEllipticalArc(double rx, double ry, double ar, double la, double sp, double[] xy)
rx
- x radiusry
- y radiusar
- x-axis-rotationla
- large arc flag, if angle >= 180 degsp
- sweep flag, if arc will be drawn in positive-angle directionxy
- new coordinatespublic SVGPath relativeEllipticalArc(double[] rxy, double ar, double la, double sp, double[] xy)
rxy
- radiusar
- x-axis-rotationla
- large arc flag, if angle >= 180 degsp
- sweep flag, if arc will be drawn in positive-angle directionxy
- new coordinatesprivate SVGPath append(char action)
action
- Current actionprivate SVGPath append(double x)
x
- coordinate.public SVGPath close()
public org.w3c.dom.Element makeElement(SVGPlot plot)
plot
- Plot context (= element factory)public org.w3c.dom.Element makeElement(SVGPlot plot, java.lang.String cssclass)
plot
- Plot context (= element factory)cssclass
- CSS classpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2019 ELKI Development Team. License information.