Class ShapeNode

java.lang.Object
com.codename1.art.ArtNode
com.codename1.art.ShapeNode

public class ShapeNode extends ArtNode
A vector shape: a path with any number of fills and strokes, painted in order.
  • Constructor Details

    • ShapeNode

      public ShapeNode(GeneralPath path)

      Creates a shape.

      Parameters
      • path: 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: left
      • y: top
      • w: width
      • h: height
      • rx: corner radius; 0 for square corners
    • ellipse

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

      An ellipse.

      Parameters
      • cx: center x
      • cy: center y
      • rx: horizontal radius
      • ry: vertical radius
    • line

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

      A straight line.

      Parameters
      • x1: start x
      • y1: start y
      • x2: end x
      • y2: end y
    • getPath

      public GeneralPath getPath()
      The outline.
    • setPath

      public void setPath(GeneralPath path)

      Replaces the outline.

      Parameters
      • path: 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: the fill
    • stroke

      public ShapeNode stroke(StrokeStyle stroke)

      Adds a stroke and returns this shape.

      Parameters
      • stroke: the stroke
    • getLocalBounds

      public double[] getLocalBounds()
      Description copied from class: ArtNode
      The bounds of this node's own content in its own space as x, y, w, h, without effects; null when it has none.
      Specified by:
      getLocalBounds in class ArtNode
    • copy

      public ArtNode copy()
      Description copied from class: ArtNode
      A deep copy.
      Specified by:
      copy in class ArtNode