Class RectanglePainter

All Implemented Interfaces:
Painter<Object>

@JavaBean public class RectanglePainter extends AbstractAreaPainter<Object>
A painter which paints square and rounded rectangles
  • Field Details

    • rounded

      private boolean rounded
    • roundWidth

      private int roundWidth
    • roundHeight

      private int roundHeight
    • width

      private int width
    • height

      private int height
  • Constructor Details

    • RectanglePainter

      public RectanglePainter()
      Creates a new instance of RectanglePainter
    • RectanglePainter

      public RectanglePainter(int top, int left, int bottom, int right)
    • RectanglePainter

      public RectanglePainter(int top, int left, int bottom, int right, int roundWidth, int roundHeight)
    • RectanglePainter

      public RectanglePainter(int top, int left, int bottom, int right, int roundWidth, int roundHeight, boolean rounded, Paint fillPaint, float strokeWidth, Paint borderPaint)
    • RectanglePainter

      public RectanglePainter(Color fillPaint, Color borderPaint)
    • RectanglePainter

      public RectanglePainter(Paint fillPaint, Paint borderPaint, float borderWidth, AbstractAreaPainter.Style style)
    • RectanglePainter

      public RectanglePainter(int width, int height, int cornerRadius, Paint fillPaint)
    • RectanglePainter

      public RectanglePainter(Insets insets, int width, int height, int roundWidth, int roundHeight, boolean rounded, Paint fillPaint, float strokeWidth, Paint borderPaint)
  • Method Details

    • isRounded

      public boolean isRounded()
      Indicates if the rectangle is rounded
      Returns:
      if the rectangle is rounded
    • setRounded

      public void setRounded(boolean rounded)
      sets if the rectangle should be rounded
      Parameters:
      rounded - if the rectangle should be rounded
    • getRoundWidth

      public int getRoundWidth()
      gets the round width of the rectangle
      Returns:
      the current round width
    • setRoundWidth

      public void setRoundWidth(int roundWidth)
      sets the round width of the rectangle
      Parameters:
      roundWidth - a new round width
    • getRoundHeight

      public int getRoundHeight()
      gets the round height of the rectangle
      Returns:
      the current round height
    • setRoundHeight

      public void setRoundHeight(int roundHeight)
      sets the round height of the rectangle
      Parameters:
      roundHeight - a new round height
    • calculateShape

      protected RectangularShape calculateShape(int width, int height)
    • doPaint

      protected void doPaint(Graphics2D g, Object component, int width, int height)
      Description copied from class: AbstractPainter
      Subclasses must implement this method and perform custom painting operations here.
      Specified by:
      doPaint in class AbstractPainter<Object>
      Parameters:
      g - The Graphics2D object in which to paint
      component -
      width -
      height -
    • drawBorder

      private void drawBorder(Graphics2D g, Shape shape, int width, int height)
    • drawBackground

      private void drawBackground(Graphics2D g, Shape shape, int width, int height)
    • provideShape

      protected Shape provideShape(Graphics2D g, Object comp, int width, int height)
      Description copied from class: AbstractAreaPainter
      Returns the outline shape of this painter. Subclasses must implement this method. This shape will be used for filling, stroking, and clipping.
      Specified by:
      provideShape in class AbstractAreaPainter<Object>
      Parameters:
      g - graphics
      comp - The Object this painter will be painted on.
      width - the width to paint
      height - the height to paint
      Returns:
      the outline shape of this painter