Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.swingx.painter
Class CheckerboardPainter

    java.lang.Object
      org.jdesktop.beans.AbstractBean
          org.jdesktop.swingx.painter.AbstractPainter<java.lang.Object>
              org.jdesktop.swingx.painter.CheckerboardPainter

All Implemented Interfaces:
  Painter<java.lang.Object>

    public class CheckerboardPainter

extends AbstractPainter<java.lang.Object>

A Painter implementation that paints a checkerboard pattern. The light and dark colors (Paint instances) are configurable, as are the size of the squares (squareSize).

To configure a checkerboard pattern that used a gradient for the dark tiles and Color.WHITE for the light tiles, you could:

      GradientPaint gp = new GradientPaint(
          new Point2D.Double(0, 0),
          Color.BLACK,
          new Point2D.Double(0, 32),
          Color.GRAY);
      CheckerboardPainter p = new CheckerboardPainter();
      p.setDarkPaint(gp);
      p.setLightPaint(Color.WHITE);
      p.setSquareSize(32);
      panel.seBackgroundPainter(p);

Note that in this example, the "32" in the GradientPaint matches the "32" set for the squareSize. This is necessary because GradientPaints don't readjust themselves for the size of the square. They are fixed and immutable at the time of creation.

Author:
  rbair

Nested Class Summary

Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractPainter
`AbstractPainter.Interpolation`

Constructor Summary
`CheckerboardPainter()` Create a new CheckerboardPainter.
`CheckerboardPainter(java.awt.Paint darkPaint, java.awt.Paint lightPaint)` Create a new CheckerboardPainter with the specified light and dark paints.
`CheckerboardPainter(java.awt.Paint darkPaint, java.awt.Paint lightPaint, double squareSize)` Create a new CheckerboardPainter with the specified light and dark paints and the specified square size.

Method Summary
`protected void` | `doPaint(java.awt.Graphics2D g, java.lang.Object t, int width, int height)` Subclasses must implement this method and perform custom painting operations here.
`java.awt.Paint` | `getDarkPaint()` Gets the current dark paint.
`java.awt.Paint` | `getLightPaint()` gets the current light paint
`double` | `getSquareSize()` Gets the current square length.
`void` | `setDarkPaint(java.awt.Paint color)` Specifies the paint to use for dark tiles.
`void` | `setLightPaint(java.awt.Paint color)` Specifies the paint to use for light tiles.
`void` | `setSquareSize(double squareSize)` Specifies the squareSize of the squares.

Methods inherited from class org.jdesktop.swingx.painter.AbstractPainter
`clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validate`

Methods inherited from class org.jdesktop.beans.AbstractBean
`addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CheckerboardPainter

    public CheckerboardPainter()

  Create a new CheckerboardPainter. By default the light color is Color.WHITE, the dark color is a light gray, and the square length is 8.

### CheckerboardPainter

    public CheckerboardPainter(java.awt.Paint darkPaint,
                               java.awt.Paint lightPaint)

  Create a new CheckerboardPainter with the specified light and dark paints. By default the square length is 8.

  Parameters:
    `darkPaint` - the paint used to draw the dark squares
    `lightPaint` - the paint used to draw the light squares

### CheckerboardPainter

    public CheckerboardPainter(java.awt.Paint darkPaint,
                               java.awt.Paint lightPaint,
                               double squareSize)

  Create a new CheckerboardPainter with the specified light and dark paints and the specified square size.

  Parameters:
    `darkPaint` - the paint used to draw the dark squares
    `lightPaint` - the paint used to draw the light squares
    `squareSize` - the squareSize of the checker board squares

Method Detail

### setSquareSize

    public void setSquareSize(double squareSize)

  Specifies the squareSize of the squares. By default, it is 8. A squareSize of <= 0 will cause an IllegalArgumentException to be thrown.

  Parameters:
    `squareSize` - the squareSize of one side of a square tile. Must be > 0.

### getSquareSize

    public double getSquareSize()

  Gets the current square length.

  Returns:
    the squareSize. Will be > 0

### setDarkPaint

    public void setDarkPaint(java.awt.Paint color)

  Specifies the paint to use for dark tiles. This is a Paint and may be anything, including a TexturePaint for painting images. If null, the background color of the component is used.

  Parameters:
    `color` - the Paint to use for painting the "dark" tiles. May be null.

### getDarkPaint

    public java.awt.Paint getDarkPaint()

  Gets the current dark paint.

  Returns:
    the Paint used for painting the "dark" tiles. May be null

### setLightPaint

    public void setLightPaint(java.awt.Paint color)

  Specifies the paint to use for light tiles. This is a Paint and may be anything, including a TexturePaint for painting images. If null, the foreground color of the component is used.

  Parameters:
    `color` - the Paint to use for painting the "light" tiles. May be null.

### getLightPaint

    public java.awt.Paint getLightPaint()

  gets the current light paint

  Returns:
    the Paint used for painting the "light" tiles. May be null

### doPaint

    protected void doPaint(java.awt.Graphics2D g,
                           java.lang.Object t,
                           int width,
                           int height)

  Subclasses must implement this method and perform custom painting operations here.

  Specified by:
    `doPaint` in class `AbstractPainter<java.lang.Object>`
  Parameters:
    `g` - The Graphics2D object in which to paint

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010. All Rights Reserved.