public class GradientPaint extends Object implements Paint
GradientPaint课程提供了一种以线性颜色渐变模式填充Shape的方法。
如果Point P1与Color C1和Point P2与Color C2在用户空间中Color ,则P1,P2连接线上的Color按比例从C1更改为C2。
扩展P1,P2连接线上的任何点P都不具有在扩展P1,P2连接线上的P的垂直投影点P'的颜色。
P1,P2段外的扩展线上的点可以以两种方式之一进行着色。
Color C1,而P2侧的点具有常数Color C2。 Paint , Graphics2D.setPaint(java.awt.Paint)
BITMASK, OPAQUE, TRANSLUCENT| Constructor and Description |
|---|
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)
环状的或者无环的构造
GradientPaint对象取决于
boolean参数。
|
GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2)
构造一个简单的无环
GradientPaint对象。
|
GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic)
环状的或者无环的构造
GradientPaint对象取决于
boolean参数。
|
| Modifier and Type | Method and Description |
|---|---|
PaintContext |
createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
创建并返回一个 PaintContext,用于生成线性颜色渐变模式。
|
Color |
getColor1()
返回由点P1锚定的颜色C1。
|
Color |
getColor2()
返回由点P2锚定的颜色C2。
|
Point2D |
getPoint1()
返回锚点第一个颜色的点P1的副本。
|
Point2D |
getPoint2()
返回固定第二种颜色的点P2的副本。
|
int |
getTransparency()
返回此透明度模式
GradientPaint 。
|
boolean |
isCyclic()
如果梯度在两种颜色C1和C2之间
true循环,则返回
true 。
|
public GradientPaint(float x1,
float y1,
Color color1,
float x2,
float y2,
Color color2)
GradientPaint对象。
x1 - 用户空间中第一个指定的
Point x坐标
y1 - 用户空间中第一个指定的
Point y坐标
color1 -
Color在第一个指定的
Point
x2 - 用户空间中第二个指定的
Point坐标
y2 - 用户空间中第二个指定的
Point y坐标
color2 -
Color在第二个指定的
Point
NullPointerException - 如果任何一种颜色为空
public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2)
GradientPaint对象。
pt1 - 用户空间中第一个指定的
Point
color1 -
Color在第一个指定的
Point
pt2 - 第二个用户空间中指定的
Point
color2 -
Color在第二个指定的
Point
NullPointerException - 如果颜色或点中的任一个为空
public GradientPaint(float x1,
float y1,
Color color1,
float x2,
float y2,
Color color2,
boolean cyclic)
GradientPaint对象取决于
boolean参数。
x1 - 用户空间中第一个指定的
Point x坐标
y1 - 用户空间中第一个指定的
Point y坐标
color1 -
Color在第一个指定的
Point
x2 -第二的x坐标指定
Point在用户空间
y2 - 用户空间中第二个指定的
Point y坐标
color2 -
Color在第二个指定的
Point
cyclic - true如果渐变图案应该在两种颜色之间重复循环;
false否则
@ConstructorProperties(value={"point1","color1","point2","color2","cyclic"}) public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic)
GradientPaint对象取决于
boolean参数。
pt1 - 用户空间中第一个指定的
Point
color1 -
Color在第一个指定的
Point
pt2 - 第二个用户空间中指定的
Point
color2 -
Color在第二个指定的
Point
cyclic - true如果梯度图案应该在两种颜色之间重复循环;
false否则
NullPointerException - 如果颜色或点中的任一个为空
public Color getColor1()
Color对象,是由P1锚定的颜色。
public Point2D getPoint2()
Point2D对象,它是锚定此GradientPaint的第二个颜色的点的副本。
public Color getColor2()
Color对象,是由P2锚定的颜色。
public boolean isCyclic()
true循环,则返回
true 。
true如果梯度在两种颜色之间true循环;
false否则。
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
PaintContext 。
有关空参数处理的信息,请参阅Paint接口中的specification方法。
createContext在界面
Paint
cm -优选ColorModel表示用于呼叫者接收的像素数据,或最方便的格式null如果没有偏好。
deviceBounds - 要呈现的图形基元的设备空间边界框。
userBounds - 呈现的图形基元的用户空间边界框。
xform - 从用户空间到设备空间的AffineTransform 。
hints - 上下文对象可用于在呈现替代方案之间进行选择的一组提示。
PaintContext 。
Paint , PaintContext , ColorModel , Rectangle , Rectangle2D , AffineTransform , RenderingHints
public int getTransparency()
GradientPaint 。
getTransparency在界面
Transparency
GradientPaint对象的透明度模式。
Transparency
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.