Java Platform 1.2
Beta 4

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, Graphics2D.setPaint(java.awt.Paint)

Constructor Summary
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.
GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2)
          Constructs a simple acyclic GradientPaint object.
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(Point2D pt1, Color color1, Point2D pt2, Color color2)
          Constructs a simple acyclic GradientPaint object.
 
Method Summary
 PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
          Creates and returns a context used to generate the color pattern.
 int getTransparency()
          Return the transparency mode for this GradientPaint.
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Constructor Detail

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.
Method Detail

createContext

public PaintContext createContext(ColorModel cm,
                                  Rectangle deviceBounds,
                                  Rectangle2D userBounds,
                                  AffineTransform xform,
                                  RenderingHints hints)
Creates and returns a context used to generate the color pattern.
Specified by:
createContext in interface Paint
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

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.