GradientPaint class provides a way to fill
a Shape with a linear color gradient pattern.
If Point P1 with Color C1 and Point P2 with
Color C2 are specified in user space, the
Color on the P1, P2 connecting line is proportionally
changed from C1 to C2. Any point P not on the extended P1, P2
connecting line has the color of the point P' that is the perpendicular
projection of P on the extended P1, P2 connecting line.
Points on the extended line outside of the P1, P2 segment can be colored
in one of two ways.
Color C1 while points on the P2 side
have the constant Color C2.
Paint, Graphics2D#setPaint
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Color | |
| pack-priv Color | |
| pack-priv boolean | |
| pack-priv Point2D. | |
| pack-priv Point2D. |
| Access | Constructor and Description |
|---|---|
| public | GradientPaint(float
x coordinate of the first specified
x1, float Point in user spacey coordinate of the first specified
y1, Color Point in user spaceColor at the first specified
Pointx coordinate of the second specified
x2, float Point in user spacey coordinate of the second specified
y2, Color Point in user spaceColor at the second specified
PointConstructs a simple acyclic |
| public | GradientPaint(Point2D
the first specified pt1, Color Point in user spaceColor at the first specified
Pointthe second specified pt2, Color Point in user spaceColor at the second specified
PointConstructs a simple acyclic |
| public | GradientPaint(float
x coordinate of the first specified
x1, float Point in user spacey coordinate of the first specified
y1, Color Point in user spaceColor at the first specified
Pointx coordinate of the second specified
x2, float Point in user spacey coordinate of the second specified
y2, Color Point in user spaceColor at the second specified
Pointtrue if the gradient pattern should cycle
repeatedly between the two colors; false otherwiseConstructs either a cyclic or acyclic |
| public | GradientPaint(Point2D
the first specified pt1, Color Point
in user spaceColor at the first specified
Pointthe second specified pt2, Color Point
in user spaceColor at the second specified
Pointtrue if the gradient pattern should cycle
repeatedly between the two colors; false otherwiseConstructs either a cyclic or acyclic |
| Modifier and Type | Method and Description |
|---|---|
| public PaintContext | Returns: thePaintContext for
generating color patterns.the preferred cm, Rectangle ColorModel which represents the most convenient
format for the caller to receive the pixel data, or null
if there is no preference.the device space bounding box
of the graphics primitive being rendered. deviceBounds, Rectangle2D the user space bounding box
of the graphics primitive being rendered. userBounds, AffineTransform the xform, RenderingHints AffineTransform from user
space into device space.the set of hints that the context object can use to
choose between rendering alternatives. hints)Implements java. Creates and returns a |
| public Color | Returns: aColor object that is the color
anchored by P1.Returns the color C1 anchored by the point P1. |
| public Color | Returns: aColor object that is the color
anchored by P2.Returns the color C2 anchored by the point P2. |
| public Point2D | |
| public Point2D | |
| public int | Returns: an integer value representing thisGradientPaint
object's transparency mode.Implements java. Returns the transparency mode for this |
| public boolean | Returns: true if the gradient cycles repeatedly
between the two colors; false otherwise.Returns |
| color1 | back to summary |
|---|---|
| pack-priv Color color1 | |
| color2 | back to summary |
|---|---|
| pack-priv Color color2 | |
| cyclic | back to summary |
|---|---|
| pack-priv boolean cyclic | |
| p1 | back to summary |
|---|---|
| pack-priv Point2D. | |
| p2 | back to summary |
|---|---|
| pack-priv Point2D. | |
| GradientPaint | back to summary |
|---|---|
| public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2) Constructs a simple acyclic
| |
| GradientPaint | back to summary |
|---|---|
| public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2) Constructs a simple acyclic
| |
| GradientPaint | back to summary |
|---|---|
| public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic) Constructs either a cyclic or acyclic
| |
| GradientPaint | back to summary |
|---|---|
| public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic) Constructs either a cyclic or acyclic
| |
| createContext | back to summary |
|---|---|
| public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) Implements java. Creates and returns a
| |
| getColor1 | back to summary |
|---|---|
| public Color getColor1() Returns the color C1 anchored by the point P1.
| |
| getColor2 | back to summary |
|---|---|
| public Color getColor2() Returns the color C2 anchored by the point P2.
| |
| getPoint1 | back to summary |
|---|---|
| public Point2D getPoint1() Returns a copy of the point P1 that anchors the first color. | |
| getPoint2 | back to summary |
|---|---|
| public Point2D getPoint2() Returns a copy of the point P2 which anchors the second color. | |
| getTransparency | back to summary |
|---|---|
| public int getTransparency() Implements java. Returns the transparency mode for this
| |
| isCyclic | back to summary |
|---|---|
| public boolean isCyclic() Returns
| |