swingx
Version 2005-08-19

org.jdesktop.swingx.painter
Class ImagePainter

java.lang.Object
  extended by org.jdesktop.swingx.JavaBean
      extended by org.jdesktop.swingx.painter.AbstractPainter
          extended by org.jdesktop.swingx.painter.ImagePainter
All Implemented Interfaces:
Painter
Direct Known Subclasses:
IconPainter

public class ImagePainter
extends AbstractPainter

A Painter instance that paints an image. Any Image is acceptable. This Painter also allows the developer to specify a "Style" -- CENTERED, TILED, SCALED, POSITIONED, and CSS_POSITIONED; with the following meanings:


Nested Class Summary
static class ImagePainter.Style
          An enumeration of Styles supported by the ImagePainter.
 
Constructor Summary
ImagePainter()
          Create a new ImagePainter.
ImagePainter(Image image)
          Create a new ImagePainter with the specified image and the Style Style.CENTERED
ImagePainter(Image image, ImagePainter.Style style)
          Create a new ImagePainter with the specified image and style.
 
Method Summary
 Image getImage()
           
 Point2D getImagePosition()
           
 ImagePainter.Style getStyle()
           
 void paintBackground(Graphics2D g, JComponent component)
          Subclasses should implement this method and perform custom painting operations here.
 void setImage(Image image)
          Sets the image to use for the background of this panel.
 void setImagePosition(Point2D imagePosition)
           
 void setImageScale(double imageScale)
           
 void setStyle(ImagePainter.Style s)
          Sets what style to use when painting the image
 
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

ImagePainter

public ImagePainter()
Create a new ImagePainter. By default there is no image, and the Style is set to Style.CENTERED


ImagePainter

public ImagePainter(Image image)
Create a new ImagePainter with the specified image and the Style Style.CENTERED

Parameters:
image - the image to be painted

ImagePainter

public ImagePainter(Image image,
                    ImagePainter.Style style)
Create a new ImagePainter with the specified image and style.

Parameters:
image - the image to be painted
style - the style of the image
Method Detail

setImage

public void setImage(Image image)
Sets the image to use for the background of this panel. This image is painted whether the panel is opaque or translucent.

Parameters:
image - if null, clears the image. Otherwise, this will set the image to be painted. If the preferred size has not been explicitly set, then the image dimensions will alter the preferred size of the panel.

getImage

public Image getImage()
Returns:
the image used for painting the background of this panel

setStyle

public void setStyle(ImagePainter.Style s)
Sets what style to use when painting the image

Parameters:
s - The style constant to apply to the image.

getStyle

public ImagePainter.Style getStyle()
Returns:
the Style used for drawing the image (CENTERED, TILED, etc).

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.

setImagePosition

public void setImagePosition(Point2D imagePosition)

getImagePosition

public Point2D getImagePosition()

setImageScale

public void setImageScale(double imageScale)

swingx
Version 2005-08-19