Package snap.gfx
Class Stroke
java.lang.Object
snap.props.PropObject
snap.gfx.Stroke
- All Implemented Interfaces:
Cloneable
,PropChange.DoChange
,XMLArchiver.Archivable
A class to describe strokes.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class builds strokes.static enum
static enum
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final double[]
static final String
static final double[][]
static final String[]
static final String
static final Stroke.Cap
static final double[]
static final double
static final Stroke.Join
static final double
static final double
static final String
static final String
static final Stroke
static final Stroke
static final Stroke
static final Stroke
static final Stroke
static final String
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
-
Constructor Summary
ConstructorDescriptionStroke()
Creates a plain, black stroke.Stroke
(double aWidth) Creates a stroke with the given line width.Stroke
(double aWidth, double[] aDashAry, double aDashOffset) Creates a stroke with the given line width, dash array and offset.Stroke
(double aWidth, float[] aDashAry, float aDashOffset) Creates a stroke with the given line width, dash array and offset.Stroke
(double aWidth, Stroke.Cap aCap, Stroke.Join aJoin, double aMiterLimit) Creates a stroke with the given line width, cap, joint, miter-limit.Stroke
(double aWidth, Stroke.Cap aCap, Stroke.Join aJoin, double aMiterLimit, double[] aDashAry, double aDashOffset) Creates a stroke with the given line width, dash array and offset.Stroke
(double aWidth, Stroke.Cap aCap, Stroke.Join aJoin, double aMiterLimit, float[] aDashAry, float aDashOffset) Creates a stroke with the given line width, dash array and offset. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Standard clone implementation.copyForCap
(Stroke.Cap aCap) Returns a copy of this stroke with given width.copyForDashes
(double... theDashAry) Returns a dashed version of this stroke.copyForDashOffset
(double anOffset) Returns a dashed version of this stroke.copyForWidth
(double aWidth) Returns a copy of this stroke with given width.boolean
Standard equals implementation.fromXML
(XMLArchiver anArchiver, XMLElement anElement) XML Unarchival.getCap()
Returns the line cap - how a stroke renders endpoints.double[]
Returns the dash array for this stroke.static double[]
getDashArray
(String aString) Returns a dash array for given dash array string and delimeter.static String
getDashArrayString
(double[] dashArray, String aDelimiter) Returns the dash array for this stroke as a string.static String
getDashArrayString
(Stroke aStroke) Returns the dash array for given border as a string.double
Returns the dash offset.getJoin()
Returns join - how a stroke renders the join between two segements.double
Returns the limit to miter joins.getPropValue
(String aPropName) Returns the value for given prop name.static Stroke
getStroke
(double aLineWidth) Returns a stroke for given line width.static Stroke
getStrokeRound
(double aLineWidth) Returns a stroke for given line width.double
getWidth()
Returns the line width of this stroke.protected void
Initialize Props.toXML
(XMLArchiver anArchiver) XML Archival.Methods inherited from class snap.props.PropObject
addDeepChangeListener, addPropChangeListener, addPropChangeListener, firePropChange, firePropChange, firePropChange, getPropDefault, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, isPropDefault, processPropChange, removeDeepChangeListener, removePropChangeListener, removePropChangeListener, setPropsString, setPropValue, setPropValues, toString, toStringProps
-
Field Details
-
Width_Prop
- See Also:
-
Cap_Prop
- See Also:
-
Join_Prop
- See Also:
-
MiterLimit_Prop
- See Also:
-
DashArray_Prop
- See Also:
-
DashOffset_Prop
- See Also:
-
DEFAULT_WIDTH
public static final double DEFAULT_WIDTH- See Also:
-
DEFAULT_CAP
-
DEFAULT_JOIN
-
DEFAULT_MITER_LIMIT
public static final double DEFAULT_MITER_LIMIT- See Also:
-
DEFAULT_DASH_ARRAY
public static final double[] DEFAULT_DASH_ARRAY -
DEFAULT_DASH_OFFSET
public static final double DEFAULT_DASH_OFFSET- See Also:
-
DASH_SOLID
public static final double[] DASH_SOLID -
DASH_DOT
public static final double[] DASH_DOT -
DASH_DASH
public static final double[] DASH_DASH -
DASH_LONG_DASH
public static final double[] DASH_LONG_DASH -
DASH_DASH_DOT
public static final double[] DASH_DASH_DOT -
DASH_LONG_DASH_DOT
public static final double[] DASH_LONG_DASH_DOT -
DASHES_ALL_NAMES
-
DASHES_ALL
public static final double[][] DASHES_ALL -
Stroke1
-
Stroke2
-
StrokeRound1
-
StrokeRound2
-
StrokeDash1
-
-
Constructor Details
-
Stroke
public Stroke()Creates a plain, black stroke. -
Stroke
public Stroke(double aWidth) Creates a stroke with the given line width. -
Stroke
Creates a stroke with the given line width, cap, joint, miter-limit. -
Stroke
public Stroke(double aWidth, float[] aDashAry, float aDashOffset) Creates a stroke with the given line width, dash array and offset. -
Stroke
public Stroke(double aWidth, double[] aDashAry, double aDashOffset) Creates a stroke with the given line width, dash array and offset. -
Stroke
public Stroke(double aWidth, Stroke.Cap aCap, Stroke.Join aJoin, double aMiterLimit, float[] aDashAry, float aDashOffset) Creates a stroke with the given line width, dash array and offset. -
Stroke
public Stroke(double aWidth, Stroke.Cap aCap, Stroke.Join aJoin, double aMiterLimit, double[] aDashAry, double aDashOffset) Creates a stroke with the given line width, dash array and offset.
-
-
Method Details
-
getWidth
public double getWidth()Returns the line width of this stroke. -
getCap
Returns the line cap - how a stroke renders endpoints. -
getJoin
Returns join - how a stroke renders the join between two segements. -
getMiterLimit
public double getMiterLimit()Returns the limit to miter joins. -
getDashArray
public double[] getDashArray()Returns the dash array for this stroke. -
getDashOffset
public double getDashOffset()Returns the dash offset. -
copyForWidth
Returns a copy of this stroke with given width. -
copyForCap
Returns a copy of this stroke with given width. -
copyForDashes
Returns a dashed version of this stroke. -
copyForDashOffset
Returns a dashed version of this stroke. -
equals
Standard equals implementation. -
clone
Standard clone implementation.- Overrides:
clone
in classPropObject
-
initProps
Initialize Props. Override to support props for this class.- Overrides:
initProps
in classPropObject
-
getPropValue
Returns the value for given prop name.- Overrides:
getPropValue
in classPropObject
-
toXML
XML Archival.- Specified by:
toXML
in interfaceXMLArchiver.Archivable
-
fromXML
XML Unarchival.- Specified by:
fromXML
in interfaceXMLArchiver.Archivable
-
getStroke
Returns a stroke for given line width. -
getStrokeRound
Returns a stroke for given line width. -
getDashArrayString
Returns the dash array for given border as a string. -
getDashArrayString
Returns the dash array for this stroke as a string. -
getDashArray
Returns a dash array for given dash array string and delimeter.
-