java.lang.Objectjava.awt.GradientPaint
GradientPaint 类提供了使用线性颜色渐变模式填充 Shape 的方法。如果在用户空间指定了 Point P1 的 Color 为 C1,Point P2 的 Color 为 C2,则 P1、P2 连接线上的 Color 是逐渐地从 C1 变化到 C2 的。任何不在 P1、P2 延长线上的点 P 都具有点 P' 的颜色,P' 是 P1、P2 延长线上点 P 的垂直投影。P1、P2 段以外的延长线上的点可以按以下两种方式之一进行着色。
Color C1,而 P2 一边的点有固定的 Color C2。
| 字段摘要 |
|---|
| 从接口 java.awt.Transparency 继承的字段 |
|---|
BITMASK, OPAQUE, TRANSLUCENT |
| 构造方法摘要 | |
|---|---|
GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2) 构造一个简单的非周期性 GradientPaint 对象。 |
|
GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic) 根据 boolean 参数构造一个周期性或非周期性的 GradientPaint 对象。 |
|
GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2) 构造一个简单的非周期性 GradientPaint 对象。 |
|
GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic) 根据 boolean 参数构造一个周期性或非周期性的 GradientPaint 对象。 |
|
| 方法摘要 | |
|---|---|
PaintContext |
createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) 创建并返回用来生成颜色模式的上下文。 |
Color |
getColor1() 返回点 P1 的颜色 C1。 |
Color |
getColor2() 返回点 P2 的颜色 C2。 |
Point2D |
getPoint1() 返回着第一种颜色的点 P1 的副本。 |
Point2D |
getPoint2() 返回着第二种颜色的点 P2 的副本。 |
int |
getTransparency() 返回此 GradientPaint 的透明度模式。 |
boolean |
isCyclic() 如果渐变在两种颜色 C1 和 C2 之间重复循环,则返回 true。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public GradientPaint(float x1,
float y1,
Color color1,
float x2,
float y2,
Color color2)
GradientPaint 对象。
x1 - 用户空间中第一个指定
Point 的 x 坐标
y1 - 用户空间中第一个指定
Point 的 y 坐标
color1 - 第一个指定
Point 处的
Color
x2 - 用户空间中第二个指定
Point 的 x 坐标
y2 - 用户空间中第二个指定
Point 的 y 坐标
color2 - 第二个指定
Point 处的
Color
NullPointerException - 如果任何一个 color 为 null
public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2)
GradientPaint 对象。
pt1 - 用户空间中第一个指定的
Point
color1 - 第一个指定
Point 处的
Color
pt2 - 用户空间中第二个指定的
Point
color2 - 第二个指定
Point 处的
Color
NullPointerException - 如果任何一个 color 或 point 为 null
public GradientPaint(float x1,
float y1,
Color color1,
float x2,
float y2,
Color color2,
boolean cyclic)
boolean 参数构造一个周期性或非周期性的
GradientPaint 对象。
x1 - 用户空间中第一个指定
Point 的 x 坐标
y1 - 用户空间中第一个指定
Point 的 y 坐标
color1 - 第一个指定
Point 处的
Color
x2 - 用户空间中第二个指定
Point 的 x 坐标
y2 - 用户空间中第二个指定
Point 的 y 坐标
color2 - 第二个指定
Point 处的
Color
cyclic - 如果渐变模式在两种颜色之间重复循环,则为
true;否则为
false。
public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic)
boolean 参数构造一个周期性或非周期性的
GradientPaint 对象。
pt1 - 用户空间中第一个指定的
Point
color1 - 第一个指定
Point 处的
Color
pt2 - 用户空间中第二个指定的
Point
color2 - 第二个指定
Point 处的
Color
cyclic - 如果渐变模式在两种颜色之间重复循环,则为
true;否则为
false。
| 方法详细信息 |
|---|
public Point2D getPoint1()
Point2D 对象,它是着
GradientPaint 的第一种颜色的点的副本。
public Color getColor1()
Color 对象,P1 的颜色。
public Point2D getPoint2()
Point2D 对象,它是着
GradientPaint 的第二种颜色的点的副本。
public Color getColor2()
Color 对象,P2 的颜色。
public boolean isCyclic()
true。
true;否则返回
false。
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
Paint 中的
createContext
cm - 接收
Paint 数据的
ColorModel。这仅作为提示使用。
deviceBounds - 正在呈现的图形图元的设备空间边界框
userBounds - 正在呈现的图形图元的用户空间边界框
xform - 从用户空间到设备空间的
AffineTransform
hints - context 对象用于选择所呈现内容的提示
PaintContext。
PaintContext
public int getTransparency()
GradientPaint 的透明度模式。
Transparency 中的
getTransparency
GradientPaint 对象的透明度模式。
Transparency