| java.lang.Object java.awt.GradientPaint
GradientPaint | public class GradientPaint implements Paint(Code) | | The 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.
-
If the gradient is cyclic then the points on the extended P1, P2
connecting line cycle back and forth between the colors C1 and C2.
-
If the gradient is acyclic then points on the P1 side of the segment
have the constant
Color C1 while points on the P2 side
have the constant Color C2.
See Also: Paint See Also: Graphics2D.setPaint version: 10 Feb 1997 |
Constructor Summary | |
public | GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2) Constructs a simple acyclic GradientPaint object. | public | GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2) Constructs a simple acyclic GradientPaint object. | public | GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic) Constructs either a cyclic or acyclic GradientPaint
object depending on the boolean parameter. | public | GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic) Constructs either a cyclic or acyclic GradientPaint
object depending on the boolean parameter. |
GradientPaint | public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2)(Code) | | Constructs a simple acyclic GradientPaint object.
Parameters: x1 - x coordinate of the first specifiedPoint in user space Parameters: y1 - y coordinate of the first specifiedPoint in user space Parameters: color1 - Color at the first specified Point Parameters: x2 - x coordinate of the second specifiedPoint in user space Parameters: y2 - y coordinate of the second specifiedPoint in user space Parameters: color2 - Color at the second specified Point throws: NullPointerException - if either one of colors is null |
GradientPaint | public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2)(Code) | | Constructs a simple acyclic GradientPaint object.
Parameters: pt1 - the first specified Point in user space Parameters: color1 - Color at the first specified Point Parameters: pt2 - the second specified Point in user space Parameters: color2 - Color at the second specified Point throws: NullPointerException - if either one of colors or points is null |
GradientPaint | public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic)(Code) | | Constructs either a cyclic or acyclic GradientPaint
object depending on the boolean parameter.
Parameters: x1 - x coordinate of the first specifiedPoint in user space Parameters: y1 - y coordinate of the first specifiedPoint in user space Parameters: color1 - Color at the first specified Point Parameters: x2 - x coordinate of the second specifiedPoint in user space Parameters: y2 - y coordinate of the second specifiedPoint in user space Parameters: color2 - Color at the second specified Point Parameters: cyclic - true if the gradient pattern should cyclerepeatedly between the two colors; false otherwise |
GradientPaint | public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic)(Code) | | Constructs either a cyclic or acyclic GradientPaint
object depending on the boolean parameter.
Parameters: pt1 - the first specified Point in user space Parameters: color1 - Color at the first specified Point Parameters: pt2 - the second specified Point in user space Parameters: color2 - Color at the second specified Point Parameters: cyclic - true if the gradient pattern should cyclerepeatedly between the two colors; false otherwise throws: NullPointerException - if either one of colors or points is null |
createContext | public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)(Code) | | Creates and returns a context used to generate the color pattern.
Parameters: cm - ColorModel that receivesthe Paint data. This is used only as a hint. Parameters: deviceBounds - the device space bounding box of the graphics primitive being rendered Parameters: userBounds - the user space bounding box of the graphics primitive being rendered Parameters: xform - the AffineTransform from userspace into device space Parameters: hints - the hints that the context object uses to choosebetween rendering alternatives the PaintContext that generates color patterns. See Also: PaintContext |
getColor1 | public Color getColor1()(Code) | | Returns the color C1 anchored by the point P1.
a Color object that is the coloranchored by P1. |
getColor2 | public Color getColor2()(Code) | | Returns the color C2 anchored by the point P2.
a Color object that is the coloranchored by P2. |
getPoint1 | public Point2D getPoint1()(Code) | | Returns a copy of the point P1 that anchors the first color.
a Point2D object that is a copy of the pointthat anchors the first color of this GradientPaint . |
getPoint2 | public Point2D getPoint2()(Code) | | Returns a copy of the point P2 which anchors the second color.
a Point2D object that is a copy of the pointthat anchors the second color of thisGradientPaint . |
getTransparency | public int getTransparency()(Code) | | Returns the transparency mode for this GradientPaint .
an integer value representing this GradientPaint object's transparency mode. See Also: Transparency |
isCyclic | public boolean isCyclic()(Code) | | Returns true if the gradient cycles repeatedly
between the two colors C1 and C2.
true if the gradient cycles repeatedlybetween the two colors; false otherwise. |
|
|