Package snap.gfx

Class Stroke

All Implemented Interfaces:
Cloneable, PropChange.DoChange, XMLArchiver.Archivable

public class Stroke extends PropObject implements Cloneable, XMLArchiver.Archivable
A class to describe strokes.
  • Field Details

    • Width_Prop

      public static final String Width_Prop
      See Also:
    • Cap_Prop

      public static final String Cap_Prop
      See Also:
    • Join_Prop

      public static final String Join_Prop
      See Also:
    • MiterLimit_Prop

      public static final String MiterLimit_Prop
      See Also:
    • DashArray_Prop

      public static final String DashArray_Prop
      See Also:
    • DashOffset_Prop

      public static final String DashOffset_Prop
      See Also:
    • DEFAULT_WIDTH

      public static final double DEFAULT_WIDTH
      See Also:
    • DEFAULT_CAP

      public static final Stroke.Cap DEFAULT_CAP
    • DEFAULT_JOIN

      public static final Stroke.Join 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

      public static final String[] DASHES_ALL_NAMES
    • DASHES_ALL

      public static final double[][] DASHES_ALL
    • Stroke1

      public static final Stroke Stroke1
    • Stroke2

      public static final Stroke Stroke2
    • StrokeRound1

      public static final Stroke StrokeRound1
    • StrokeRound2

      public static final Stroke StrokeRound2
    • StrokeDash1

      public static final Stroke 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

      public Stroke(double aWidth, Stroke.Cap aCap, Stroke.Join aJoin, double aMiterLimit)
      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

      public Stroke.Cap getCap()
      Returns the line cap - how a stroke renders endpoints.
    • getJoin

      public Stroke.Join 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

      public Stroke copyForWidth(double aWidth)
      Returns a copy of this stroke with given width.
    • copyForCap

      public Stroke copyForCap(Stroke.Cap aCap)
      Returns a copy of this stroke with given width.
    • copyForDashes

      public Stroke copyForDashes(double... theDashAry)
      Returns a dashed version of this stroke.
    • copyForDashOffset

      public Stroke copyForDashOffset(double anOffset)
      Returns a dashed version of this stroke.
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • clone

      public Stroke clone()
      Standard clone implementation.
      Overrides:
      clone in class PropObject
    • initProps

      protected void initProps(PropSet aPropSet)
      Initialize Props. Override to support props for this class.
      Overrides:
      initProps in class PropObject
    • getPropValue

      public Object getPropValue(String aPropName)
      Returns the value for given prop name.
      Overrides:
      getPropValue in class PropObject
    • toXML

      public XMLElement toXML(XMLArchiver anArchiver)
      XML Archival.
      Specified by:
      toXML in interface XMLArchiver.Archivable
    • fromXML

      public Stroke fromXML(XMLArchiver anArchiver, XMLElement anElement)
      XML Unarchival.
      Specified by:
      fromXML in interface XMLArchiver.Archivable
    • getStroke

      public static Stroke getStroke(double aLineWidth)
      Returns a stroke for given line width.
    • getStrokeRound

      public static Stroke getStrokeRound(double aLineWidth)
      Returns a stroke for given line width.
    • getDashArrayString

      public static String getDashArrayString(Stroke aStroke)
      Returns the dash array for given border as a string.
    • getDashArrayString

      public static String getDashArrayString(double[] dashArray, String aDelimiter)
      Returns the dash array for this stroke as a string.
    • getDashArray

      public static double[] getDashArray(String aString)
      Returns a dash array for given dash array string and delimeter.