swingx
Version 2005-08-19

org.jdesktop.swingx.painter.gradient
Class RadialGradientPainter

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.RadialGradientPainter
All Implemented Interfaces:
Painter

public class RadialGradientPainter
extends AbstractGradientPainter

A Gradient based painter used for painting "multi-stop" radial 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 centerPoint, radius, and focusPoint of the RadialGradientPainter 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".

In addition, the resize behavior of the radius is specified in the resizeRadius property. If HORIZONTAL, then the width of the component is used to calculate the new radius. If VERTICAL then the height of the component is used. If BOTH, then the Math.min(width, height) is used. If NONE, then no resize occurs for the radius.

NOTE: RadialGradientPainter 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


Constructor Summary
RadialGradientPainter()
          Creates a new instance of RadialGradientPainter
RadialGradientPainter(org.apache.batik.ext.awt.RadialGradientPaint paint)
          Creates a new instance of RadialGradientPainter with the given RadialGradientPaint
 
Method Summary
protected  Paint calculateSizedPaint(int width, int height)
           
 org.apache.batik.ext.awt.RadialGradientPaint getGradientPaint()
           
 Resize getResizeRadius()
           
 void setGradientPaint(org.apache.batik.ext.awt.RadialGradientPaint paint)
          Set the gradient paint to use.
 void setResizeRadius(Resize r)
          Specifies the resize behavior for the radius of the RadialGradientPaint.
 
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
 

Constructor Detail

RadialGradientPainter

public RadialGradientPainter()
Creates a new instance of RadialGradientPainter


RadialGradientPainter

public RadialGradientPainter(org.apache.batik.ext.awt.RadialGradientPaint paint)
Creates a new instance of RadialGradientPainter with the given RadialGradientPaint

Parameters:
paint - the RadialGradientPaint to use
Method Detail

setGradientPaint

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

Parameters:
paint - the RadialGradientPaint to use

getGradientPaint

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

setResizeRadius

public void setResizeRadius(Resize r)
Specifies the resize behavior for the radius of the RadialGradientPaint. If HORIZONTAL, then the width of the component is used to calculate the new radius. If VERTICAL then the height of the component is used. If BOTH, then the Math.min(width, height) is used. If NONE, then no resize occurs for the radius.

Parameters:
r - the Resize behavior for the radius

getResizeRadius

public Resize getResizeRadius()
Returns:
the resize behavior for the radius

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