|
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
org.jdesktop.swingx.painter.gradient.BasicGradientPainter
public class BasicGradientPainter
A Gradient based Painter that uses GradientPaint to paint the gradient. Simply specify the GradientPaint to use.
In order for resizing to work properly with GradientPaint 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.
Various built in gradients also exist as public static final properties. They are defined as GradientPaints rather than BasicGradientPainters because BasicGradientPainter is mutable and thus don't make very reliable public static final defaults. To use:
panel.setBackgroundPainter(new BasicGradientPainter(BasicGradientPainter.BLUE_EXPERIENCE));
Field Summary | |
---|---|
static GradientPaint |
AERITH
|
static GradientPaint |
BLUE_EXPERIENCE
|
static GradientPaint |
GRAY
|
static GradientPaint |
MAC_OSX
|
static GradientPaint |
MAC_OSX_SELECTED
|
static GradientPaint |
NIGHT_GRAY
|
static GradientPaint |
NIGHT_GRAY_LIGHT
|
static GradientPaint |
RED_XP
|
Constructor Summary | |
---|---|
BasicGradientPainter()
Creates a new instance of BasicGradientPainter |
|
BasicGradientPainter(float x1,
float y1,
Color startColor,
float x2,
float y2,
Color endColor)
Constructs a simple acyclic BasicGradientPainter object. |
|
BasicGradientPainter(float x1,
float y1,
Color startColor,
float x2,
float y2,
Color endColor,
boolean cyclic)
Constructs either a cyclic or acyclic BasicGradientPainter
object depending on the boolean parameter. |
|
BasicGradientPainter(GradientPaint paint)
Creates a new instance of BasicGradientPainter |
|
BasicGradientPainter(Point2D startPoint,
Color startColor,
Point2D endPoint,
Color endColor)
Constructs a simple acyclic BasicGradientPainter object. |
|
BasicGradientPainter(Point2D startPoint,
Color startColor,
Point2D endPoint,
Color endColor,
boolean cyclic)
Constructs either a cyclic or acyclic BasicGradientPainter
object depending on the boolean parameter. |
Method Summary | |
---|---|
protected Paint |
calculateSizedPaint(int width,
int height)
|
GradientPaint |
getGradientPaint()
|
void |
setGradientPaint(GradientPaint 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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final GradientPaint BLUE_EXPERIENCE
public static final GradientPaint MAC_OSX_SELECTED
public static final GradientPaint MAC_OSX
public static final GradientPaint AERITH
public static final GradientPaint GRAY
public static final GradientPaint RED_XP
public static final GradientPaint NIGHT_GRAY
public static final GradientPaint NIGHT_GRAY_LIGHT
Constructor Detail |
---|
public BasicGradientPainter()
public BasicGradientPainter(GradientPaint paint)
public BasicGradientPainter(float x1, float y1, Color startColor, float x2, float y2, Color endColor)
BasicGradientPainter
object.
x1
- x coordinate of the first specified
Point
in user spacey1
- y coordinate of the first specified
Point
in user spacestartColor
- Color
at the first specified
Point
x2
- x coordinate of the second specified
Point
in user spacey2
- y coordinate of the second specified
Point
in user spaceendColor
- Color
at the second specified
Point
NullPointerException
- if either one of colors is nullpublic BasicGradientPainter(Point2D startPoint, Color startColor, Point2D endPoint, Color endColor)
BasicGradientPainter
object.
startPoint
- the first specified Point
in user spacestartColor
- Color
at the first specified
Point
endPoint
- the second specified Point
in user spaceendColor
- Color
at the second specified
Point
NullPointerException
- if either one of colors or points
is nullpublic BasicGradientPainter(float x1, float y1, Color startColor, float x2, float y2, Color endColor, boolean cyclic)
BasicGradientPainter
object depending on the boolean
parameter.
x1
- x coordinate of the first specified
Point
in user spacey1
- y coordinate of the first specified
Point
in user spacestartColor
- Color
at the first specified
Point
x2
- x coordinate of the second specified
Point
in user spacey2
- y coordinate of the second specified
Point
in user spaceendColor
- Color
at the second specified
Point
cyclic
- true
if the gradient pattern should cycle
repeatedly between the two colors; false
otherwisepublic BasicGradientPainter(Point2D startPoint, Color startColor, Point2D endPoint, Color endColor, boolean cyclic)
BasicGradientPainter
object depending on the boolean
parameter.
startPoint
- the first specified Point
in user spacestartColor
- Color
at the first specified
Point
endPoint
- the second specified Point
in user spaceendColor
- Color
at the second specified
Point
cyclic
- true
if the gradient pattern should cycle
repeatedly between the two colors; false
otherwise
NullPointerException
- if either one of colors or points
is nullMethod Detail |
---|
public void setGradientPaint(GradientPaint paint)
paint
- the GradientPaint to usepublic GradientPaint getGradientPaint()
protected Paint calculateSizedPaint(int width, int height)
calculateSizedPaint
in class AbstractGradientPainter
width
- the width used to calculate the new paint sizeheight
- the height used to calculate the new paint size
|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |