Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class 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
From ArtNode
getAttribute, setAttribute, getAttributes, getId, setId, getName, setName, isVisible, setVisible, isLocked, setLocked, getOpacity, setOpacity, getBlendMode, setBlendMode, getTransform, setTransform, getClipPath, setClipPath, getMask, setMask, isKnockout, setKnockout, isLuminanceMask, getEffects, copyBase, getBounds
Constructor details
ShapeNode
public ShapeNode(GeneralPath path)Creates a shape.
Parameters
pathGeneralPath- 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
xdouble- left
ydouble- top
wdouble- width
hdouble- height
rxdouble- corner radius; 0 for square corners
ellipse
public static ShapeNode ellipse(double cx, double cy, double rx, double ry)An ellipse.
Parameters
cxdouble- center x
cydouble- center y
rxdouble- horizontal radius
rydouble- vertical radius
line
public static ShapeNode line(double x1, double y1, double x2, double y2)A straight line.
Parameters
x1double- start x
y1double- start y
x2double- end x
y2double- end y
getPath
public GeneralPath getPath()The outline.
setPath
public void setPath(GeneralPath path)Replaces the outline.
Parameters
pathGeneralPath- 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
paintArtPaint- the fill
stroke
public ShapeNode stroke(StrokeStyle stroke)Adds a stroke and returns this shape.
Parameters
strokeStrokeStyle- 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.