Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class StrokeStyle

  1. Object
  2. StrokeStyle
How a shape’s outline is drawn: paint, width, caps, joins, dashes and alignment.

Fields

public static final int CAP_BUTT = 0Flat ends at the path’s end points.
public static final int CAP_ROUND = 1Rounded ends.
public static final int CAP_SQUARE = 2Square ends that extend half the width past the end points.
public static final int JOIN_MITER = 0Sharp corners, cut to a bevel past the miter limit.
public static final int JOIN_ROUND = 1Rounded corners.
public static final int JOIN_BEVEL = 2Cut corners.
public static final int ALIGN_CENTER = 0The stroke is centered on the path.
public static final int ALIGN_INSIDE = 1The stroke lies inside the shape.
public static final int ALIGN_OUTSIDE = 2The stroke lies outside the shape.

Constructors

public StrokeStyle(ArtPaint paint, float width)Creates a stroke.

Methods

public StrokeStyle copy()A deep copy.
public ArtPaint getPaint()The paint.
public void setPaint(ArtPaint paint)Sets the paint.
public float getWidth()The width.
public void setWidth(float width)Sets the width.
public int getCap()One of the CAP_ constants.
public void setCap(int cap)Sets the cap.
public int getJoin()One of the JOIN_ constants.
public void setJoin(int join)Sets the join.
public float getMiterLimit()The miter limit.
public void setMiterLimit(float miterLimit)Sets the miter limit.
public float[] getDash()The dash pattern, as a copy, or null for a solid line.
public void setDash(float[] dash)Sets the dash pattern.
public float getDashOffset()The dash offset.
public void setDashOffset(float dashOffset)Sets the dash offset.
public int getAlignment()One of the ALIGN_ constants.
public void setAlignment(int alignment)Sets the alignment.
public boolean isEnabled()False when the stroke is kept but not drawn, as Sketch allows.
public void setEnabled(boolean enabled)Turns the stroke on or off.

Inherited methods

Field details

CAP_BUTT

public static final int CAP_BUTT = 0
Flat ends at the path’s end points.

CAP_ROUND

public static final int CAP_ROUND = 1
Rounded ends.

CAP_SQUARE

public static final int CAP_SQUARE = 2
Square ends that extend half the width past the end points.

JOIN_MITER

public static final int JOIN_MITER = 0
Sharp corners, cut to a bevel past the miter limit.

JOIN_ROUND

public static final int JOIN_ROUND = 1
Rounded corners.

JOIN_BEVEL

public static final int JOIN_BEVEL = 2
Cut corners.

ALIGN_CENTER

public static final int ALIGN_CENTER = 0
The stroke is centered on the path.

ALIGN_INSIDE

public static final int ALIGN_INSIDE = 1
The stroke lies inside the shape.

ALIGN_OUTSIDE

public static final int ALIGN_OUTSIDE = 2
The stroke lies outside the shape.

Constructor details

StrokeStyle

public StrokeStyle(ArtPaint paint, float width)
Creates a stroke.

Parameters

paint ArtPaint
what fills the outline
width float
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 ArtPaint
the new paint

getWidth

public float getWidth()
The width.

setWidth

public void setWidth(float width)
Sets the width.

Parameters

width float
the new width

getCap

public int getCap()
One of the CAP_ constants.

setCap

public void setCap(int cap)
Sets the cap.

Parameters

cap int
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 int
one of the JOIN_ constants

getMiterLimit

public float getMiterLimit()
The miter limit.

setMiterLimit

public void setMiterLimit(float miterLimit)
Sets the miter limit.

Parameters

miterLimit float
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 float[]
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 float
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 int
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 boolean
true to draw it