Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.awt
Class GradientPaint  view GradientPaint download GradientPaint.java

java.lang.Object
  extended byjava.awt.GradientPaint
All Implemented Interfaces:
Paint, Transparency

public class GradientPaint
extends java.lang.Object
implements Paint

A paint object that can be used to color a region by blending two colors. Instances of this class are immutable.


Field Summary
private  Color c1
           
private  Color c2
           
private  boolean cyclic
           
private  float x1
           
private  float x2
           
private  float y1
           
private  float y2
           
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
GradientPaint(float x1, float y1, Color c1, float x2, float y2, Color c2)
          Creates a new acyclic GradientPaint.
GradientPaint(float x1, float y1, Color c1, float x2, float y2, Color c2, boolean cyclic)
          Creates a new cyclic or acyclic GradientPaint.
GradientPaint(java.awt.geom.Point2D p1, Color c1, java.awt.geom.Point2D p2, Color c2)
          Creates a new acyclic GradientPaint.
GradientPaint(java.awt.geom.Point2D p1, Color c1, java.awt.geom.Point2D p2, Color c2, boolean cyclic)
          Creates a new cyclic or acyclic GradientPaint.
 
Method Summary
 PaintContext createContext(java.awt.image.ColorModel cm, Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform xform, RenderingHints hints)
          Returns the PaintContext used to generate the color pattern.
 Color getColor1()
          Returns the first color.
 Color getColor2()
          Returns the second color.
 java.awt.geom.Point2D getPoint1()
          Returns a point with the same coordinates as the anchor point for color 1.
 java.awt.geom.Point2D getPoint2()
          Returns a point with the same coordinates as the anchor point for color 2.
 int getTransparency()
          Returns the transparency code for this GradientPaint instance.
 boolean isCyclic()
          Returns true if this GradientPaint instance is cyclic, and false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x1

private final float x1

y1

private final float y1

c1

private final Color c1

x2

private final float x2

y2

private final float y2

c2

private final Color c2

cyclic

private final boolean cyclic
Constructor Detail

GradientPaint

public GradientPaint(float x1,
                     float y1,
                     Color c1,
                     float x2,
                     float y2,
                     Color c2)
Creates a new acyclic GradientPaint.


GradientPaint

public GradientPaint(java.awt.geom.Point2D p1,
                     Color c1,
                     java.awt.geom.Point2D p2,
                     Color c2)
Creates a new acyclic GradientPaint.


GradientPaint

public GradientPaint(float x1,
                     float y1,
                     Color c1,
                     float x2,
                     float y2,
                     Color c2,
                     boolean cyclic)
Creates a new cyclic or acyclic GradientPaint.


GradientPaint

public GradientPaint(java.awt.geom.Point2D p1,
                     Color c1,
                     java.awt.geom.Point2D p2,
                     Color c2,
                     boolean cyclic)
Creates a new cyclic or acyclic GradientPaint.

Method Detail

getPoint1

public java.awt.geom.Point2D getPoint1()
Returns a point with the same coordinates as the anchor point for color 1. Note that if you modify this point, the GradientPaint remains unchanged.


getColor1

public Color getColor1()
Returns the first color.


getPoint2

public java.awt.geom.Point2D getPoint2()
Returns a point with the same coordinates as the anchor point for color 2. Note that if you modify this point, the GradientPaint remains unchanged.


getColor2

public Color getColor2()
Returns the second color.


isCyclic

public boolean isCyclic()
Returns true if this GradientPaint instance is cyclic, and false otherwise.


createContext

public PaintContext createContext(java.awt.image.ColorModel cm,
                                  Rectangle deviceBounds,
                                  java.awt.geom.Rectangle2D userBounds,
                                  java.awt.geom.AffineTransform xform,
                                  RenderingHints hints)
Returns the PaintContext used to generate the color pattern.

Specified by:
createContext in interface Paint

getTransparency

public int getTransparency()
Returns the transparency code for this GradientPaint instance. This is derived from the two Color objects used in creating this object: if both colors are opaque, this method returns Transparency.OPAQUE 55 , otherwise it returns Transparency.TRANSLUCENT 55 .

Specified by:
getTransparency in interface Transparency