swingx
Version 2005-08-19

org.jdesktop.swingx.painter
Class GlossPainter

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

public class GlossPainter
extends AbstractPainter

A Painter implementation that simulates a gloss effect. The gloss can be positionned at the top or bottom of the drawing area. To fill the gloss, this painter uses a Paint instance which can be used to fill with a color (opaque or translucent), a texture, a gradient...

The following example creates a white gloss at the top of the drawing area:

  GlossPainter p = new GlossPainter();
  p.setPaint(new Color(1.0f, 1.0f, 1.0f, 0.2f);
  p.setPosition(GlossPainter.GlossPosition.TOP);
  panel.setBackgroundPainter(p);
 

The values shown in this examples are the values used by default if they are not specified.


Nested Class Summary
static class GlossPainter.GlossPosition
          Used to define the position of the gloss on the painted area.
 
Constructor Summary
GlossPainter()
          Creates a new gloss painter positionned at the top of the painted area with a 20% translucent white color.
GlossPainter(GlossPainter.GlossPosition position)
          Creates a new gloss painter positionned at the specified position and using a white, 20% translucent paint.
GlossPainter(Paint paint)
          Creates a new gloss painter positionned at the top of the painted area with the specified paint.
GlossPainter(Paint paint, GlossPainter.GlossPosition position)
          Creates a new gloss painter positionned at the specified position and painted with the specified paint.
 
Method Summary
 Paint getPaint()
          Returns the paint currently used by the painter to fill the gloss.
 GlossPainter.GlossPosition getPosition()
          Returns the position at which the gloss is painted.
protected  void paintBackground(Graphics2D g, JComponent component)
          Subclasses should implement this method and perform custom painting operations here.
 void setPaint(Paint paint)
          Changes the paint to be used to fill the gloss.
 void setPosition(GlossPainter.GlossPosition position)
          Changes the position of the gloss in the painted area.
 
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

GlossPainter

public GlossPainter()

Creates a new gloss painter positionned at the top of the painted area with a 20% translucent white color.


GlossPainter

public GlossPainter(Paint paint)

Creates a new gloss painter positionned at the top of the painted area with the specified paint.

Parameters:
paint - The paint to be used when filling the gloss

GlossPainter

public GlossPainter(GlossPainter.GlossPosition position)

Creates a new gloss painter positionned at the specified position and using a white, 20% translucent paint.

Parameters:
position - The position of the gloss on the painted area

GlossPainter

public GlossPainter(Paint paint,
                    GlossPainter.GlossPosition position)

Creates a new gloss painter positionned at the specified position and painted with the specified paint.

Parameters:
paint - The paint to be used when filling the gloss
position - The position of the gloss on the painted area
Method Detail

paintBackground

protected void paintBackground(Graphics2D g,
                               JComponent component)
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.

getPaint

public Paint getPaint()

Returns the paint currently used by the painter to fill the gloss.

Returns:
the current Paint instance used by the painter

setPaint

public void setPaint(Paint paint)

Changes the paint to be used to fill the gloss. When the specified paint is null, nothing is painted. A paint can be an instance of Color.

Parameters:
paint - The Paint instance to be used to fill the gloss

getPosition

public GlossPainter.GlossPosition getPosition()

Returns the position at which the gloss is painted.

Returns:
the position of the gloss in the painted area

setPosition

public void setPosition(GlossPainter.GlossPosition position)

Changes the position of the gloss in the painted area. Only the values defined in the GlossPosition enum are valid.

Parameters:
position - The position at which the gloss is painted

swingx
Version 2005-08-19