Class StrokeStyle

java.lang.Object
com.codename1.art.StrokeStyle

public final class StrokeStyle extends Object
How a shape's outline is drawn: paint, width, caps, joins, dashes and alignment.
  • Field Details

    • CAP_BUTT

      public static final int CAP_BUTT
      Flat ends at the path's end points.
      See Also:
    • CAP_ROUND

      public static final int CAP_ROUND
      Rounded ends.
      See Also:
    • CAP_SQUARE

      public static final int CAP_SQUARE
      Square ends that extend half the width past the end points.
      See Also:
    • JOIN_MITER

      public static final int JOIN_MITER
      Sharp corners, cut to a bevel past the miter limit.
      See Also:
    • JOIN_ROUND

      public static final int JOIN_ROUND
      Rounded corners.
      See Also:
    • JOIN_BEVEL

      public static final int JOIN_BEVEL
      Cut corners.
      See Also:
    • ALIGN_CENTER

      public static final int ALIGN_CENTER
      The stroke is centered on the path.
      See Also:
    • ALIGN_INSIDE

      public static final int ALIGN_INSIDE
      The stroke lies inside the shape.
      See Also:
    • ALIGN_OUTSIDE

      public static final int ALIGN_OUTSIDE
      The stroke lies outside the shape.
      See Also:
  • Constructor Details

    • StrokeStyle

      public StrokeStyle(ArtPaint paint, float width)

      Creates a stroke.

      Parameters
      • paint: what fills the outline
      • width: width in the shape's units
  • Method Details

    • copy

      public StrokeStyle copy()
      A deep copy.
    • getPaint

      public ArtPaint getPaint()
      The paint.
    • setPaint

      public void setPaint(ArtPaint paint)

      Sets the paint.

      Parameters
      • paint: the new paint
    • getWidth

      public float getWidth()
      The width.
    • setWidth

      public void setWidth(float width)

      Sets the width.

      Parameters
      • width: the new width
    • getCap

      public int getCap()
      One of the CAP_ constants.
    • setCap

      public void setCap(int cap)

      Sets the cap.

      Parameters
      • cap: one of the CAP_ constants
    • getJoin

      public int getJoin()
      One of the JOIN_ constants.
    • setJoin

      public void setJoin(int join)

      Sets the join.

      Parameters
      • join: one of the JOIN_ constants
    • getMiterLimit

      public float getMiterLimit()
      The miter limit.
    • setMiterLimit

      public void setMiterLimit(float miterLimit)

      Sets the miter limit.

      Parameters
      • miterLimit: the ratio past which a miter becomes a bevel
    • getDash

      public float[] getDash()
      The dash pattern, as a copy, or null for a solid line.
    • setDash

      public void setDash(float[] dash)

      Sets the dash pattern.

      Parameters
      • dash: alternating on and off lengths; null for solid
    • getDashOffset

      public float getDashOffset()
      The dash offset.
    • setDashOffset

      public void setDashOffset(float dashOffset)

      Sets the dash offset.

      Parameters
      • dashOffset: how far into the pattern the line starts
    • getAlignment

      public int getAlignment()
      One of the ALIGN_ constants.
    • setAlignment

      public void setAlignment(int alignment)

      Sets the alignment.

      Parameters
      • alignment: one of the ALIGN_ constants
    • isEnabled

      public boolean isEnabled()
      False when the stroke is kept but not drawn, as Sketch allows.
    • setEnabled

      public void setEnabled(boolean enabled)

      Turns the stroke on or off.

      Parameters
      • enabled: true to draw it