com.javadocking.drag.painter
Class DefaultRectanglePainter

java.lang.Object
  extended by com.javadocking.drag.painter.DefaultRectanglePainter
All Implemented Interfaces:
RectanglePainter

public class DefaultRectanglePainter
extends java.lang.Object
implements RectanglePainter

This rectangle painter paints the border of a rectangle and it can fill the rectangle.

By setting the line width the rectangle is painted multiple times.

It is possible to give a stroke and a color to the painter.

It is possible to set the arc width and arc height to paint rounded rectangles.

Author:
Heidi Rakels.

Constructor Summary
DefaultRectanglePainter()
           
 
Method Summary
 int getArcHeight()
          Gets the height of the angle arc.
 int getArcWidth()
          Gets the width of the angle arc.
 java.awt.Color getBorderColor()
           Gets the color that is used for painting the border.
 int getBorderCount()
           Gets the number of times the border is painted.
 int getBorderShift()
           Gets the number of pixels the border is shifted, each time it is painted.
 java.awt.Color getFillColor()
          Gets the fill color for the rectangle.
 java.lang.String getLabel()
          Gets the label that will be painted in the middle of the rectangle.
 java.awt.Color getLabelBackground()
          Gets the label back ground color.
 java.awt.Color getLabelBorderColor()
          Gets the label border.
 java.awt.Color getLabelForeground()
          Gets the label fore ground color.
 java.awt.Stroke getStroke()
          Gets the stroke that is used for painting the border.
 void paintRectangle(java.awt.Graphics graphics, int x, int y, int width, int height)
          Paints a rectangle on the given graphics.
 void setArcHeight(int arcHeight)
          Sets the height of the angle arc.
 void setArcWidth(int arcWidth)
          Sets the width of the angle arc.
 void setBorderColor(java.awt.Color color)
          Sets the color that is used for painting the border.
 void setBorderCount(int borderCount)
          Sets the number of times the border is painted.
 void setBorderShift(int borderShift)
          Sets the number of pixels the border is shifted, each time it is painted.
 void setFillColor(java.awt.Color fillColor)
          Sets the fill color for the rectangle.
 void setLabel(java.lang.String label)
          Sets the label that will be painted in the middle of the rectangle.
 void setLabelBackground(java.awt.Color labelBackground)
          Gets the label back ground color.
 void setLabelBorderColor(java.awt.Color labelBorderColor)
          Sets the label border.
 void setLabelForeground(java.awt.Color labelForeground)
          Sets the label fore ground color.
 void setStroke(java.awt.Stroke stroke)
          Sets the stroke that is used for painting the border.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRectanglePainter

public DefaultRectanglePainter()
Method Detail

paintRectangle

public void paintRectangle(java.awt.Graphics graphics,
                           int x,
                           int y,
                           int width,
                           int height)
Description copied from interface: RectanglePainter
Paints a rectangle on the given graphics.

Specified by:
paintRectangle in interface RectanglePainter
Parameters:
graphics - The graphics on which the rectangle should be painted.
x - The x-position of the rectangle on the graphics.
y - The y-position of the rectangle on the graphics.
width - The width of the rectangle.
height - The height of the rectangle.

getBorderCount

public int getBorderCount()

Gets the number of times the border is painted.

The default is 4.

Returns:
The number of times the border is painted.

setBorderCount

public void setBorderCount(int borderCount)
Sets the number of times the border is painted.

Parameters:
borderCount - The number of times the border is painted.

getBorderShift

public int getBorderShift()

Gets the number of pixels the border is shifted, each time it is painted.

The default is 1.

Returns:
The number of pixels the border is shifted, each time it is painted.

setBorderShift

public void setBorderShift(int borderShift)
Sets the number of pixels the border is shifted, each time it is painted.

Parameters:
borderShift - The number of pixels the border is shifted, each time it is painted.

getBorderColor

public java.awt.Color getBorderColor()

Gets the color that is used for painting the border.

The default is (10, 80, 255).

Returns:
The color that is used for painting the border.

setBorderColor

public void setBorderColor(java.awt.Color color)
Sets the color that is used for painting the border.

Parameters:
color - The color that is used for painting the border.

getStroke

public java.awt.Stroke getStroke()
Gets the stroke that is used for painting the border. If it is null, a normal line is painted.

Returns:
The stroke that is used for painting the border. If it is null, a normal line is painted.

setStroke

public void setStroke(java.awt.Stroke stroke)
Sets the stroke that is used for painting the border. If it is null, a normal line is painted.

Parameters:
stroke - The stroke that is used for painting the border. If it is null, a normal line is painted.

getArcHeight

public int getArcHeight()
Gets the height of the angle arc. The default value is 0.

Returns:
The height of the angle arc.

setArcHeight

public void setArcHeight(int arcHeight)
Sets the height of the angle arc.

Parameters:
arcHeight - The height of the angle arc.

getArcWidth

public int getArcWidth()
Gets the width of the angle arc. The default value is 0.

Returns:
The width of the angle arc.

setArcWidth

public void setArcWidth(int arcWidth)
Sets the width of the angle arc.

Parameters:
arcWidth - The width of the angle arc.

getFillColor

public java.awt.Color getFillColor()
Gets the fill color for the rectangle. The default is null.

Returns:
The fill color for the rectangle.

setFillColor

public void setFillColor(java.awt.Color fillColor)
Sets the fill color for the rectangle.

Parameters:
fillColor - The fill color for the rectangle.

getLabel

public java.lang.String getLabel()
Gets the label that will be painted in the middle of the rectangle.

Returns:
The label that will be painted in the middle of the rectangle.

setLabel

public void setLabel(java.lang.String label)
Sets the label that will be painted in the middle of the rectangle.

Specified by:
setLabel in interface RectanglePainter
Parameters:
label - The label that will be painted in the middle of the rectangle.

getLabelBackground

public java.awt.Color getLabelBackground()
Gets the label back ground color.

Returns:
The label back ground color.

setLabelBackground

public void setLabelBackground(java.awt.Color labelBackground)
Gets the label back ground color.

Parameters:
labelBackground - The label back ground color.

getLabelBorderColor

public java.awt.Color getLabelBorderColor()
Gets the label border.

Returns:
The label border.

setLabelBorderColor

public void setLabelBorderColor(java.awt.Color labelBorderColor)
Sets the label border.

Parameters:
labelBorderColor - The label border.

getLabelForeground

public java.awt.Color getLabelForeground()
Gets the label fore ground color.

Returns:
The label fore ground color.

setLabelForeground

public void setLabelForeground(java.awt.Color labelForeground)
Sets the label fore ground color.

Parameters:
labelForeground - The label fore ground color.