All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.GradientPaint
java.lang.Object
|
+----java.awt.GradientPaint
- public class GradientPaint
- extends Object
- implements Paint
This class provides a way to fill a shape with a linear color gradient
pattern.
Given two points in user space, P1 with the color C1 and P2 with the
color C2, the color
on the P1, P2 connecting line is changed from C1 to C2 proportionally to
the distance to P1.
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 through the colors from C1 to C2
and back to C1 again continuously at an even rate.
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 contsant
color C2.
- See Also:
- Paint, setPaint
GradientPaint(float, float, Color, float, float, Color)
- Constructs a simple acyclic GradientPaint object.
GradientPaint(float, float, Color, float, float, Color, boolean)
- Constructs either a cyclic or acyclic GradientPaint object
depending on the boolean parameter.
GradientPaint(Point2D, Color, Point2D, Color)
- Constructs a simple acyclic GradientPaint object.
GradientPaint(Point2D, Color, Point2D, Color, boolean)
- Constructs either a cyclic or acyclic GradientPaint object
depending on the boolean parameter.
createContext(ColorModel, Rectangle, Rectangle2D, AffineTransform)
- Creates and returns a context used to generate the color pattern.
getTransparency()
- Return the transparency mode for this GradientPaint.
GradientPaint
public GradientPaint(float x1,
float y1,
Color color1,
float x2,
float y2,
Color color2)
- Constructs a simple acyclic GradientPaint object.
- Parameters:
- x1,y1 - Coordinates of the 1st point in user space.
- color1 - Color at the 1st point.
- x2,y2 - Coordinates of the 2nd point in user space.
- color2 - Color at the 2nd point.
GradientPaint
public GradientPaint(Point2D pt1,
Color color1,
Point2D pt2,
Color color2)
- Constructs a simple acyclic GradientPaint object.
- Parameters:
- pt1 - Coordinates of the 1st point in user space.
- color1 - Color at the 1st point.
- pt2 - Coordinates of the 2nd point in user space.
- color2 - Color at the 2nd point.
GradientPaint
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.
- Parameters:
- x1,y1 - Coordinates of the 1st point in user space.
- color1 - Color at the 1st point.
- x2,y2 - Coordinates of the 2nd point in user space.
- color2 - Color at the 2nd point.
- cyclic - true if the gradient pattern should cycle
repeatedly between the two colors.
GradientPaint
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.
- Parameters:
- pt1 - Coordinates of the 1st point in user space.
- color1 - Color at the 1st point.
- pt2 - Coordinates of the 2nd point in user space.
- color2 - Color at the 2nd point.
- cyclic - true if the gradient pattern should cycle
repeatedly between the two colors.
createContext
public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform xform)
- Creates and returns a context used to generate the color pattern.
- Parameters:
- cm - ColorModel in which the caller wishes to receive the
paint data. This is used only as a hint.
- deviceBounds - The rectangle describing the bounding box in
device space of the graphics primitive being rendered.
- userBounds - The rectangle describing the bounding box in
user space of the graphics primitive being rendered.
- xform - The Transform from user space into device space.
- Returns:
- The PaintContext for generating color patterns.
- See Also:
- PaintContext
getTransparency
public int getTransparency()
- Return the transparency mode for this GradientPaint.
- See Also:
- Transparency
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature