public interface Paint
此 Paint 接口定义如何为 Graphics2D 操作生成颜色模式。将实现 Paint 接口的类添加到 Graphics2D 上下文中,以便定义 draw 和 fill 方法所使用的颜色模式。
实现 Paint 的类的实例必须是只读的,因为将这些对象作为 setPaint 方法的属性来设置时,或者 Graphics2D 对象本身被复制时,Graphics2D 并不复制这些对象。
| 字段摘要 |
|---|
| 从接口 java.awt.Transparency 继承的字段 |
|---|
BITMASK, OPAQUE, TRANSLUCENT |
| 方法摘要 | |
|---|---|
PaintContext |
createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) 创建并返回用来生成颜色模式的 PaintContext。 |
| 从接口 java.awt.Transparency 继承的方法 |
|---|
getTransparency |
| 方法详细信息 |
|---|
PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
PaintContext。因为传递给 createContext 的 ColorModel 参数只是一个提示,所以 Paint 的实现应该接受 ColorModel 的 null 参数。注意,如果应用程序没有首选的特定 ColorModel,则为 null 的 ColorModel 参数将给予 Paint 实现完全的选择余地,使其在光栅处理中使用其首选最高效的 ColorModel。
因为 API 文档在 1.4 版本之前没有关于此项的具体描述,因此可能有一些 Paint 实现不能接受 null ColorModel 参数。如果开发人员正在编写代码将 null ColorModel 参数从任意源传递给 Paint 对象的 createContext 方法,则为了实现安全的编码,应该为这些对象构造一个非 null ColorModel,使其抛出 NullPointerException。
cm - 接收
Paint 数据的
ColorModel。这只用作一个提示。
deviceBounds - 正在呈现的图形图元的设备空间边界框
userBounds - 正在呈现的图形图元的用户空间边界框
xform - 从用户空间到设备空间的
AffineTransform
hints - 上下文对象用于选择所呈现内容的提示
PaintContext
PaintContext