|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.JavaBean
org.jdesktop.swingx.painter.AbstractPainter
org.jdesktop.swingx.painter.gradient.AbstractGradientPainter
public abstract class AbstractGradientPainter
An abstract base class from which the various gradient oriented painter classes extend. Gradient based painters perform an important task beyond what a MattePainter with a GradientPaint will do -- they resize the gradient to fit the Component regardless of its dimensions.
AbstractGradientPainter has a resize property of type Resize that specifies whether the gradient should be resized horizontally, vertically, in both directions or not at all (in which case you should really probably be using MattePainter). Subclasses must implement calculateSizedPaint to return a new gradient paint instance that is resized in the proper ways. If no Paint is returned from this method call, then nothing is painted.
By default, the resize property is set to BOTH.
In order for resizing to work properly with GradientPaint, LinearGradientPaint, and RadialGradientPaint, it is necessary that the various control points used in these paints be specified in such a manner that they can be reliably resized. For example, BasicGradientPainter takes GradientPaints who's point1 and point2 properties are specified between 0 and 1, representing at what percentage of the distance from the origin the gradient begins and ends. Thus, if I created a GradientPaint like this:
GradientPaint gp = new GradientPaint(
new Point2D.Double(.2d, 0),
Color.BLUE,
new Point2D.Double(.8d, 0),
Color.WHITE);
then when painted, the gradient will start with a BLUE at 20% of the width of
the component, and finish with WHITE at 80% of the width of the component.
See the various subclasses for more detailed examples.
Constructor Summary | |
---|---|
AbstractGradientPainter()
Creates a new instance of AbstractGradientPainter |
Method Summary | |
---|---|
protected abstract Paint |
calculateSizedPaint(int width,
int height)
|
Resize |
getResize()
|
protected boolean |
isResizeHorizontal()
|
protected boolean |
isResizeVertical()
|
void |
paintBackground(Graphics2D g,
JComponent component)
Subclasses should implement this method and perform custom painting operations here. |
void |
setResize(Resize resize)
Specifies how the paint will be resized based on the component dimensions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractGradientPainter()
Method Detail |
---|
public void paintBackground(Graphics2D g, JComponent component)
AbstractPainter
paintBackground
in class AbstractPainter
g
- The Graphics2D object in which to paintcomponent
- The JComponent that the Painter is delegate for.protected abstract Paint calculateSizedPaint(int width, int height)
width
- the width used to calculate the new paint sizeheight
- the height used to calculate the new paint size
public Resize getResize()
public void setResize(Resize resize)
resize
- the new Resize value. May be null. If null, set to Resize.BOTH.protected boolean isResizeHorizontal()
protected boolean isResizeVertical()
|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |