Class Shape

All Implemented Interfaces:
IFigure
Direct Known Subclasses:
AbstractPointListShape, Ellipse, RectangleFigure, RoundedRectangle, Triangle

public abstract class Shape extends Figure
Provides abstract support for a variety of shapes.

When customizing shapes, you shouldn't override paintFigure(). Override fillShape() and outlineShape() methods instead.

  • Field Details

  • Constructor Details

    • Shape

      public Shape()
      Default constructor.
      Since:
      2.0
  • Method Details

    • fillShape

      protected abstract void fillShape(Graphics graphics)
      Fills the interior of the shape with the background color.
      Parameters:
      graphics - the graphics object
    • outlineShape

      protected abstract void outlineShape(Graphics graphics)
      Outlines this shape using the foreground color.
      Parameters:
      graphics - the graphics object
    • paintFigure

      public void paintFigure(Graphics graphics)
      Paints the shape. Each shape has an outline to draw, and a region to fill within that outline. Disabled shapes must visually depict the disabled state.
      Overrides:
      paintFigure in class Figure
      Parameters:
      graphics - The Graphics used to paint
      See Also:
    • setFill

      public void setFill(boolean b)
      Sets whether this shape should fill its region or not. It repaints this figure.
      Parameters:
      b - fill state
      Since:
      2.0
    • setFillXOR

      public void setFillXOR(boolean b)
      Sets whether XOR based fill should be used by the shape. It repaints this figure.
      Parameters:
      b - XOR fill state
      Since:
      2.0
    • setOutline

      public void setOutline(boolean b)
      Sets whether the outline should be drawn for this shape.
      Parameters:
      b - true if the shape should be outlined
      Since:
      2.0
    • setOutlineXOR

      public void setOutlineXOR(boolean b)
      Sets whether XOR based outline should be used for this shape.
      Parameters:
      b - true if the outline should be XOR'ed
      Since:
      2.0
    • setXOR

      public void setXOR(boolean b)
      Sets whether XOR based fill and XOR based outline should be used for this shape.
      Parameters:
      b - true if the outline and fill should be XOR'ed
      Since:
      2.0
    • getAlpha

      public Integer getAlpha()
      Since:
      3.5
    • getAntialias

      public Integer getAntialias()
      Since:
      3.5
    • getLineAttributes

      public LineAttributes getLineAttributes()
      Returns line attributes used when drawing this shape.
      Returns:
      current line attributes
      Since:
      3.5
      See Also:
    • getLineWidth

      public int getLineWidth()
      Returns the line width of this shape's outline.
      Returns:
      the line width
    • getLineWidthFloat

      public float getLineWidthFloat()
      Returns the line width of this shape's outline.
      Since:
      3.5
      See Also:
    • getLineJoin

      public int getLineJoin()
      Returns the line join style of this shape's outline.
      Since:
      3.5
      See Also:
    • getLineCap

      public int getLineCap()
      Returns the line cap style of this shape's outline.
      Since:
      3.5
      See Also:
    • getLineStyle

      public int getLineStyle()
      Returns the line style of this shape's outline.
      Returns:
      the line style
      See Also:
    • getLineDash

      public float[] getLineDash()
      Returns the line dash style of this shape's outline.
      Since:
      3.5
      See Also:
    • getLineDashOffset

      public float getLineDashOffset()
      Returns the line dash offset of this shape's outline.
      Since:
      3.5
      See Also:
    • getLineMiterLimit

      public float getLineMiterLimit()
      Returns the line dash miter limit of this shape's outline.
      Since:
      3.5
      See Also:
    • setAlpha

      public void setAlpha(Integer value)
      Since:
      3.5
    • setAlpha

      public void setAlpha(int value)
      Since:
      3.5
    • setAntialias

      public void setAntialias(Integer value)
      Parameters:
      value -
      Since:
      3.5
      See Also:
    • setAntialias

      public void setAntialias(int value)
      Since:
      3.5
    • setLineAttributes

      public void setLineAttributes(LineAttributes la)
      Sets all line attributes at once.
      Parameters:
      la -
      Since:
      3.5
      See Also:
    • setLineWidth

      public void setLineWidth(int w)
      Sets the line width to be used to outline the shape.
      Parameters:
      w - the new width
      Since:
      2.0
    • setLineWidthFloat

      public void setLineWidthFloat(float value)
      Sets the line width of this shape's outline.
      Parameters:
      value -
      Since:
      3.5
      See Also:
    • setLineJoin

      public void setLineJoin(int join)
      Sets the line join style of this shape's outline.
      Parameters:
      join -
      Since:
      3.5
      See Also:
    • setLineCap

      public void setLineCap(int cap)
      Sets the line cap style of this shape's outline.
      Parameters:
      cap -
      Since:
      3.5
      See Also:
    • setLineStyle

      public void setLineStyle(int style)
      Sets the line style of this shape's outline.
      Parameters:
      style - the new line style
      Since:
      2.0
      See Also:
    • setLineDash

      public void setLineDash(float[] dash)
      Sets the line dash style of this shape's outline.
      Parameters:
      dash -
      Since:
      3.5
      See Also:
    • setLineDashOffset

      public void setLineDashOffset(float dashOffset)
      Sets the line dash offset of this shape's outline.
      Parameters:
      dashOffset -
      Since:
      3.5
      See Also:
    • setLineMiterLimit

      public void setLineMiterLimit(float miterLimit)
      Sets the line dash miter limit of this shape's outline.
      Parameters:
      miterLimit -
      Since:
      3.5
      See Also: