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

public class ShapeNode

  1. Object
  2. ArtNode
  3. ShapeNode
A vector shape: a path with any number of fills and strokes, painted in order.

Constructors

public ShapeNode(GeneralPath path)Creates a shape.

Methods

public static ShapeNode rect(double x, double y, double w, double h, double rx)A rectangle, optionally with rounded corners.
public static ShapeNode ellipse(double cx, double cy, double rx, double ry)An ellipse.
public static ShapeNode line(double x1, double y1, double x2, double y2)A straight line.
public GeneralPath getPath()The outline.
public void setPath(GeneralPath path)Replaces the outline.
public List<ArtPaint> getFills()The fills, painted first to last.
public List<StrokeStyle> getStrokes()The strokes, painted after the fills.
public ShapeNode fill(ArtPaint paint)Adds a fill and returns this shape.
public ShapeNode stroke(StrokeStyle stroke)Adds a stroke and returns this shape.
public double[] getLocalBounds()The bounds of this node’s own content in its own space as x, y, w, h, without effects; null when it has none.
public ArtNode copy()A deep copy.

Inherited methods

Constructor details

ShapeNode

public ShapeNode(GeneralPath path)
Creates a shape.

Parameters

path GeneralPath
its outline, in the shape’s space

Method details

rect

public static ShapeNode rect(double x, double y, double w, double h, double rx)
A rectangle, optionally with rounded corners.

Parameters

x double
left
y double
top
w double
width
h double
height
rx double
corner radius; 0 for square corners

ellipse

public static ShapeNode ellipse(double cx, double cy, double rx, double ry)
An ellipse.

Parameters

cx double
center x
cy double
center y
rx double
horizontal radius
ry double
vertical radius

line

public static ShapeNode line(double x1, double y1, double x2, double y2)
A straight line.

Parameters

x1 double
start x
y1 double
start y
x2 double
end x
y2 double
end y

getPath

public GeneralPath getPath()
The outline.

setPath

public void setPath(GeneralPath path)
Replaces the outline.

Parameters

path GeneralPath
the new outline

getFills

public List<ArtPaint> getFills()
The fills, painted first to last. The list is live.

getStrokes

public List<StrokeStyle> getStrokes()
The strokes, painted after the fills. The list is live.

fill

public ShapeNode fill(ArtPaint paint)
Adds a fill and returns this shape.

Parameters

paint ArtPaint
the fill

stroke

public ShapeNode stroke(StrokeStyle stroke)
Adds a stroke and returns this shape.

Parameters

stroke StrokeStyle
the stroke

getLocalBounds

public double[] getLocalBounds()
The bounds of this node’s own content in its own space as x, y, w, h, without effects; null when it has none.

copy

public ArtNode copy()
A deep copy.