swingx
Version 2005-08-19

org.jdesktop.swingx.painter
Class MattePainter

java.lang.Object
  extended by org.jdesktop.swingx.JavaBean
      extended by org.jdesktop.swingx.painter.AbstractPainter
          extended by org.jdesktop.swingx.painter.MattePainter
All Implemented Interfaces:
Painter

public class MattePainter
extends AbstractPainter

A Painter implementation that uses a Paint to fill the entire background area using that Paint. For example, if I wanted to paint the entire background in Color.GREEN, I would:


  MattePainter p = new MattePainter(Color.GREEN);
  panel.setBackgroundPainter(p);
 

Since it accepts a Paint, it is also possible to paint a texture or use other more exotic Paint implementations. To paint a BufferedImage texture as the background:


  TexturePaint paint = new TexturePaint(bufferedImage, 
      new Rectangle2D.Double(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight()));
  MattePainter p = new MattePainter(paint);
  panel.setBackgroundPainter(p);
 

If no paint is specified, then nothing is painted


Constructor Summary
MattePainter()
          Creates a new MattePainter with "null" as the paint used
MattePainter(Color color)
          Create a new MattePainter that uses the given color.
MattePainter(Paint paint)
          Create a new MattePainter for the given Paint.
 
Method Summary
 Paint getPaint()
           
 void paintBackground(Graphics2D g, JComponent component)
          Subclasses should implement this method and perform custom painting operations here.
 void setPaint(Paint p)
          Sets the Paint to use.
 
Methods inherited from class org.jdesktop.swingx.painter.AbstractPainter
getAlphaInterpolation, getAntialiasing, getClip, getColorRendering, getComposite, getDithering, getEffects, getFractionalMetrics, getInterpolation, getRendering, getRenderingHint, getRenderingHints, getResizeClip, getStrokeControl, getTextAntialiasing, isUseCache, paint, restoreState, saveState, setAlphaInterpolation, setAntialiasing, setClip, setColorRendering, setComposite, setDithering, setEffects, setEffects, setFractionalMetrics, setInterpolation, setRendering, setRenderingHint, setRenderingHints, setResizeClip, setStrokeControl, setTextAntialiasing, setUseCache
 
Methods inherited from class org.jdesktop.swingx.JavaBean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MattePainter

public MattePainter()
Creates a new MattePainter with "null" as the paint used


MattePainter

public MattePainter(Color color)
Create a new MattePainter that uses the given color. This is only a convenience constructor since Color is a Paint, and thus the other constructor is perfectly suited for specify a color as well

Parameters:
color - Color to fill with

MattePainter

public MattePainter(Paint paint)
Create a new MattePainter for the given Paint. This can be a GradientPaint (though not recommended because the gradient will not grow when the component becomes larger), TexturePaint, Color, or other Paint instance.

Parameters:
paint - Paint to fill with
Method Detail

setPaint

public void setPaint(Paint p)
Sets the Paint to use. If null, nothing is painted

Parameters:
p - the Paint to use

getPaint

public Paint getPaint()
Returns:
Gets the Paint being used. May be null

paintBackground

public void paintBackground(Graphics2D g,
                            JComponent component)
Description copied from class: AbstractPainter
Subclasses should implement this method and perform custom painting operations here. Common behavior, such as setting the clip and composite, saving and restoring state, is performed in the "paint" method automatically, and then delegated here.

Specified by:
paintBackground in class AbstractPainter
Parameters:
g - The Graphics2D object in which to paint
component - The JComponent that the Painter is delegate for.

swingx
Version 2005-08-19