< prev index next >
src/java.desktop/share/classes/java/awt/GradientPaint.java
Print this page
*** 30,44 ****
import java.awt.geom.AffineTransform;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
! * The <code>GradientPaint</code> class provides a way to fill
* a {@link Shape} with a linear color gradient pattern.
! * If {@link Point} P1 with {@link Color} C1 and <code>Point</code> P2 with
! * <code>Color</code> C2 are specified in user space, the
! * <code>Color</code> 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.
--- 30,44 ----
import java.awt.geom.AffineTransform;
import java.awt.image.ColorModel;
import java.beans.ConstructorProperties;
/**
! * The {@code GradientPaint} class provides a way to fill
* a {@link Shape} with a linear color gradient pattern.
! * If {@link Point} P1 with {@link Color} C1 and {@code Point} P2 with
! * {@code Color} C2 are specified in user space, the
! * {@code 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.
*** 46,57 ****
* <li>
* 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.
* <li>
* If the gradient is acyclic then points on the P1 side of the segment
! * have the constant <code>Color</code> C1 while points on the P2 side
! * have the constant <code>Color</code> C2.
* </ul>
*
* @see Paint
* @see Graphics2D#setPaint
* @version 10 Feb 1997
--- 46,57 ----
* <li>
* 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.
* <li>
* If the gradient is acyclic then points on the P1 side of the segment
! * have the constant {@code Color} C1 while points on the P2 side
! * have the constant {@code Color} C2.
* </ul>
*
* @see Paint
* @see Graphics2D#setPaint
* @version 10 Feb 1997
*** 63,85 ****
Color color1;
Color color2;
boolean cyclic;
/**
! * Constructs a simple acyclic <code>GradientPaint</code> object.
* @param x1 x coordinate of the first specified
! * <code>Point</code> in user space
* @param y1 y coordinate of the first specified
! * <code>Point</code> in user space
! * @param color1 <code>Color</code> at the first specified
! * <code>Point</code>
* @param x2 x coordinate of the second specified
! * <code>Point</code> in user space
* @param y2 y coordinate of the second specified
! * <code>Point</code> in user space
! * @param color2 <code>Color</code> at the second specified
! * <code>Point</code>
* @throws NullPointerException if either one of colors is null
*/
public GradientPaint(float x1,
float y1,
Color color1,
--- 63,85 ----
Color color1;
Color color2;
boolean cyclic;
/**
! * Constructs a simple acyclic {@code GradientPaint} object.
* @param x1 x coordinate of the first specified
! * {@code Point} in user space
* @param y1 y coordinate of the first specified
! * {@code Point} in user space
! * @param color1 {@code Color} at the first specified
! * {@code Point}
* @param x2 x coordinate of the second specified
! * {@code Point} in user space
* @param y2 y coordinate of the second specified
! * {@code Point} in user space
! * @param color2 {@code Color} at the second specified
! * {@code Point}
* @throws NullPointerException if either one of colors is null
*/
public GradientPaint(float x1,
float y1,
Color color1,
*** 95,111 ****
this.color1 = color1;
this.color2 = color2;
}
/**
! * Constructs a simple acyclic <code>GradientPaint</code> object.
! * @param pt1 the first specified <code>Point</code> in user space
! * @param color1 <code>Color</code> at the first specified
! * <code>Point</code>
! * @param pt2 the second specified <code>Point</code> in user space
! * @param color2 <code>Color</code> at the second specified
! * <code>Point</code>
* @throws NullPointerException if either one of colors or points
* is null
*/
public GradientPaint(Point2D pt1,
Color color1,
--- 95,111 ----
this.color1 = color1;
this.color2 = color2;
}
/**
! * Constructs a simple acyclic {@code GradientPaint} object.
! * @param pt1 the first specified {@code Point} in user space
! * @param color1 {@code Color} at the first specified
! * {@code Point}
! * @param pt2 the second specified {@code Point} in user space
! * @param color2 {@code Color} at the second specified
! * {@code Point}
* @throws NullPointerException if either one of colors or points
* is null
*/
public GradientPaint(Point2D pt1,
Color color1,
*** 121,146 ****
this.color1 = color1;
this.color2 = color2;
}
/**
! * Constructs either a cyclic or acyclic <code>GradientPaint</code>
! * object depending on the <code>boolean</code> parameter.
* @param x1 x coordinate of the first specified
! * <code>Point</code> in user space
* @param y1 y coordinate of the first specified
! * <code>Point</code> in user space
! * @param color1 <code>Color</code> at the first specified
! * <code>Point</code>
* @param x2 x coordinate of the second specified
! * <code>Point</code> in user space
* @param y2 y coordinate of the second specified
! * <code>Point</code> in user space
! * @param color2 <code>Color</code> at the second specified
! * <code>Point</code>
! * @param cyclic <code>true</code> if the gradient pattern should cycle
! * repeatedly between the two colors; <code>false</code> otherwise
*/
public GradientPaint(float x1,
float y1,
Color color1,
float x2,
--- 121,146 ----
this.color1 = color1;
this.color2 = color2;
}
/**
! * Constructs either a cyclic or acyclic {@code GradientPaint}
! * object depending on the {@code boolean} parameter.
* @param x1 x coordinate of the first specified
! * {@code Point} in user space
* @param y1 y coordinate of the first specified
! * {@code Point} in user space
! * @param color1 {@code Color} at the first specified
! * {@code Point}
* @param x2 x coordinate of the second specified
! * {@code Point} in user space
* @param y2 y coordinate of the second specified
! * {@code Point} in user space
! * @param color2 {@code Color} at the second specified
! * {@code Point}
! * @param cyclic {@code true} if the gradient pattern should cycle
! * repeatedly between the two colors; {@code false} otherwise
*/
public GradientPaint(float x1,
float y1,
Color color1,
float x2,
*** 150,171 ****
this (x1, y1, color1, x2, y2, color2);
this.cyclic = cyclic;
}
/**
! * Constructs either a cyclic or acyclic <code>GradientPaint</code>
! * object depending on the <code>boolean</code> parameter.
! * @param pt1 the first specified <code>Point</code>
* in user space
! * @param color1 <code>Color</code> at the first specified
! * <code>Point</code>
! * @param pt2 the second specified <code>Point</code>
* in user space
! * @param color2 <code>Color</code> at the second specified
! * <code>Point</code>
! * @param cyclic <code>true</code> if the gradient pattern should cycle
! * repeatedly between the two colors; <code>false</code> otherwise
* @throws NullPointerException if either one of colors or points
* is null
*/
@ConstructorProperties({ "point1", "color1", "point2", "color2", "cyclic" })
public GradientPaint(Point2D pt1,
--- 150,171 ----
this (x1, y1, color1, x2, y2, color2);
this.cyclic = cyclic;
}
/**
! * Constructs either a cyclic or acyclic {@code GradientPaint}
! * object depending on the {@code boolean} parameter.
! * @param pt1 the first specified {@code Point}
* in user space
! * @param color1 {@code Color} at the first specified
! * {@code Point}
! * @param pt2 the second specified {@code Point}
* in user space
! * @param color2 {@code Color} at the second specified
! * {@code Point}
! * @param cyclic {@code true} if the gradient pattern should cycle
! * repeatedly between the two colors; {@code false} otherwise
* @throws NullPointerException if either one of colors or points
* is null
*/
@ConstructorProperties({ "point1", "color1", "point2", "color2", "cyclic" })
public GradientPaint(Point2D pt1,
*** 179,227 ****
/**
* Returns a copy of the point P1 that anchors the first color.
* @return a {@link Point2D} object that is a copy of the point
* that anchors the first color of this
! * <code>GradientPaint</code>.
*/
public Point2D getPoint1() {
return new Point2D.Float(p1.x, p1.y);
}
/**
* Returns the color C1 anchored by the point P1.
! * @return a <code>Color</code> object that is the color
* anchored by P1.
*/
public Color getColor1() {
return color1;
}
/**
* Returns a copy of the point P2 which anchors the second color.
* @return a {@link Point2D} object that is a copy of the point
* that anchors the second color of this
! * <code>GradientPaint</code>.
*/
public Point2D getPoint2() {
return new Point2D.Float(p2.x, p2.y);
}
/**
* Returns the color C2 anchored by the point P2.
! * @return a <code>Color</code> object that is the color
* anchored by P2.
*/
public Color getColor2() {
return color2;
}
/**
! * Returns <code>true</code> if the gradient cycles repeatedly
* between the two colors C1 and C2.
! * @return <code>true</code> if the gradient cycles repeatedly
! * between the two colors; <code>false</code> otherwise.
*/
public boolean isCyclic() {
return cyclic;
}
--- 179,227 ----
/**
* Returns a copy of the point P1 that anchors the first color.
* @return a {@link Point2D} object that is a copy of the point
* that anchors the first color of this
! * {@code GradientPaint}.
*/
public Point2D getPoint1() {
return new Point2D.Float(p1.x, p1.y);
}
/**
* Returns the color C1 anchored by the point P1.
! * @return a {@code Color} object that is the color
* anchored by P1.
*/
public Color getColor1() {
return color1;
}
/**
* Returns a copy of the point P2 which anchors the second color.
* @return a {@link Point2D} object that is a copy of the point
* that anchors the second color of this
! * {@code GradientPaint}.
*/
public Point2D getPoint2() {
return new Point2D.Float(p2.x, p2.y);
}
/**
* Returns the color C2 anchored by the point P2.
! * @return a {@code Color} object that is the color
* anchored by P2.
*/
public Color getColor2() {
return color2;
}
/**
! * Returns {@code true} if the gradient cycles repeatedly
* between the two colors C1 and C2.
! * @return {@code true} if the gradient cycles repeatedly
! * between the two colors; {@code false} otherwise.
*/
public boolean isCyclic() {
return cyclic;
}
*** 262,273 ****
return new GradientPaintContext(cm, p1, p2, xform,
color1, color2, cyclic);
}
/**
! * Returns the transparency mode for this <code>GradientPaint</code>.
! * @return an integer value representing this <code>GradientPaint</code>
* object's transparency mode.
* @see Transparency
*/
public int getTransparency() {
int a1 = color1.getAlpha();
--- 262,273 ----
return new GradientPaintContext(cm, p1, p2, xform,
color1, color2, cyclic);
}
/**
! * Returns the transparency mode for this {@code GradientPaint}.
! * @return an integer value representing this {@code GradientPaint}
* object's transparency mode.
* @see Transparency
*/
public int getTransparency() {
int a1 = color1.getAlpha();
< prev index next >