swingx
Version 2005-08-19

org.jdesktop.swingx.painter.gradient
Class LinearGradientPainter

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

public class LinearGradientPainter
extends AbstractGradientPainter

A Gradient based painter used for painting "multi-stop" gradients. These are gradients that imploys more than 2 colors, where each color is defined along with a float value between 0 and 1 indicating at what point along the gradient the new color is used.

As with BasicGradienPainter and mentioned in AbstractGradientPainter, the values given to the startPoint and endPoint of the LinearGradientPainter are crucial. They represent what distance from the origin the gradient should begin and end at, depending on the size of the component. That is, they must be specified as values between 0 and 1, where 0 means "all the way on the left/top" and 1 means "all the way on the right/bottom".

NOTE: LinearGradientPainter relies on LinearGradientPaint, which is included in the optional jar MultipleGradientPaint.jar. Be sure to have this jar on your classpath if you use this class


Field Summary
static org.apache.batik.ext.awt.LinearGradientPaint BLACK_PERSPECTIVE
           
static org.apache.batik.ext.awt.LinearGradientPaint BLACK_STAR
           
static org.apache.batik.ext.awt.LinearGradientPaint ORANGE_DELIGHT
           
 
Constructor Summary
LinearGradientPainter()
          Creates a new instance of LinearGradientPainter
LinearGradientPainter(org.apache.batik.ext.awt.LinearGradientPaint paint)
          Creates a new instance of LinearGradientPainter with the given LinearGradientPaint as input
 
Method Summary
protected  Paint calculateSizedPaint(int width, int height)
           
 org.apache.batik.ext.awt.LinearGradientPaint getGradientPaint()
           
 void setGradientPaint(org.apache.batik.ext.awt.LinearGradientPaint paint)
          Set the gradient paint to use.
 
Methods inherited from class org.jdesktop.swingx.painter.gradient.AbstractGradientPainter
getResize, isResizeHorizontal, isResizeVertical, paintBackground, setResize
 
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
 

Field Detail

ORANGE_DELIGHT

public static final org.apache.batik.ext.awt.LinearGradientPaint ORANGE_DELIGHT

BLACK_STAR

public static final org.apache.batik.ext.awt.LinearGradientPaint BLACK_STAR

BLACK_PERSPECTIVE

public static final org.apache.batik.ext.awt.LinearGradientPaint BLACK_PERSPECTIVE
Constructor Detail

LinearGradientPainter

public LinearGradientPainter()
Creates a new instance of LinearGradientPainter


LinearGradientPainter

public LinearGradientPainter(org.apache.batik.ext.awt.LinearGradientPaint paint)
Creates a new instance of LinearGradientPainter with the given LinearGradientPaint as input

Parameters:
paint - the Paint to use
Method Detail

setGradientPaint

public void setGradientPaint(org.apache.batik.ext.awt.LinearGradientPaint paint)
Set the gradient paint to use. This may be null. If null, nothing is painted

Parameters:
paint - the LinearGradientPaint to use

getGradientPaint

public org.apache.batik.ext.awt.LinearGradientPaint getGradientPaint()
Returns:
the LinearGradientPaint used for painting. This may be null

calculateSizedPaint

protected Paint calculateSizedPaint(int width,
                                    int height)
Specified by:
calculateSizedPaint in class AbstractGradientPainter
Parameters:
width - the width used to calculate the new paint size
height - the height used to calculate the new paint size
Returns:
a calculated Paint that fits within the given width/height. May be null.

swingx
Version 2005-08-19