public abstract class AbstractRegionPainter extends Object implements Painter<JComponent>
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractRegionPainter.PaintContext
一个在绘画时有用的类封装状态。
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractRegionPainter()
创建一个新的abstractregionpainter
|
Modifier and Type | Method and Description |
---|---|
protected void |
configureGraphics(Graphics2D g)
配置了Graphics2D。
|
protected float |
decodeAnchorX(float x, float dx)
解码并返回表示实际像素位置的锚点给出编码的x值的控制点的浮动值,并且偏移距离从控制点锚。
|
protected float |
decodeAnchorY(float y, float dy)
解码并返回表示实际像素位置的锚点给出编码的Y值的控制点的浮动值,并且偏移距离从控制点锚。
|
protected Color |
decodeColor(Color color1, Color color2, float midPoint)
解码并返回一个颜色,这是来自一个偏移的另外两种颜色之间。
|
protected Color |
decodeColor(String key, float hOffset, float sOffset, float bOffset, int aOffset)
解码并返回一个颜色,这是来自一个UI默认底色。
|
protected LinearGradientPaint |
decodeGradient(float x1, float y1, float x2, float y2, float[] midpoints, Color[] colors)
创建一个lineargradientpaint给定参数,此方法将创建并返回一个线性渐变油漆。
|
protected RadialGradientPaint |
decodeRadialGradient(float x, float y, float r, float[] midpoints, Color[] colors)
创建RadialGradientPaint给出的参数,此方法将创建并返回一个径向渐变油漆。
|
protected float |
decodeX(float x)
解码并返回一个表示该编码的X值的实际像素位置的浮点值。
|
protected float |
decodeY(float y)
解码并返回一个表示该编码的Y值的实际像素位置的浮点值。
|
protected abstract void |
doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys)
实际执行喷漆操作。
|
protected Color |
getComponentColor(JComponent c, String property, Color defaultColor, float saturationOffset, float brightnessOffset, int alphaOffset)
从给定的组件得到颜色属性。
|
protected Object[] |
getExtendedCacheKeys(JComponent c)
获得额外的属性,画家实现想包括在图像高速缓存查找。
|
protected abstract AbstractRegionPainter.PaintContext |
getPaintContext()
获取此操作的paintcontext。
|
void |
paint(Graphics2D g, JComponent c, int w, int h)
对于给定的
Graphics2D 对象。
|
protected AbstractRegionPainter()
public final void paint(Graphics2D g, JComponent c, int w, int h)
对于给定的Graphics2D
对象。此方法的实现可以在Graphics2D
修改状态,而不需要恢复的状态完成后。在大多数情况下,建议在一个划痕图形对象中调用调用方。Graphics2D
绝不是空的。
对图形对象的状态可能被paint
方法,但不得。例如,设置抗锯齿渲染提示图形可能或不可能实现的Painter
尊敬。
所提供的对象参数作为一个可选的配置参数。例如,它可以Component
型,预期它可以从Component
读状态和使用状态的绘画Painter
。例如,一个实现可能读的底色和使用。
一般来说,为了提高可重用性,最标准的Painter
s忽略此参数。因此,他们可以在任何上下文中重用。object
可能是空的。实现必须不若对象参数为空抛出一个NullPointerException。
最后,该width
和height
参数指定的Painter
应漆成的宽度和高度。更具体地说,指定的宽度和高度指示画家,它应该画在这个宽度和高度。任何指定的夹在g
参数将进一步限制区。
例如,假设我有一个Painter
实施使梯度。梯度从白到黑。它“延伸”,以填补画的区域。因此,如果我用这Painter
画一个500×500的区域,左边是黑色,右边是白色的,和一个平滑的梯度会画之间。然后我可以,无需修改,使用Painter
油漆是20x20大小区。这一区域也将是黑色的左边,白色的右边,和一个光滑的梯度之间画的。
paint
接口
Painter<JComponent>
g
- Graphics2D渲染。这不能为空。
c
可选配置参数。这可能是空的。
w
的宽度画。
h
地区的高度画。
protected Object[] getExtendedCacheKeys(JComponent c)
c
调用组件
protected abstract AbstractRegionPainter.PaintContext getPaintContext()
获取此操作的paintcontext。这种方法被称为在每一个油漆,所以应该是快速,不会产生垃圾。的paintcontext包含的信息,如缓存提示。它也包含解码点运行的必要数据,如拉伸镶,画布大小的编码点的定义,以及是否拉伸的小图是倒。
这种方法允许子类可能具有不同的画布大小等不同国家的绘画包,到一个abstractregionpainter实施。
protected void configureGraphics(Graphics2D g)
配置了Graphics2D。经常,渲染暗示或合成规则应用到之前画一个Graphics2D对象,将影响所有后续的绘画操作。此方法提供了一个方便的钩子来配置图形对象在渲染之前,无论渲染操作是否执行到中间缓冲区或直接到显示。
g
-配置Graphics2D对象。不会是空的。
protected abstract void doPaint(Graphics2D g, JComponent c, int width, int height, Object[] extendedCacheKeys)
height
width
。出于性能原因,你可能想从Graphics2D对象读卡只渲染在空间。
g
- Graphics2D表面涂料
c
-绘图事件相关的组件。例如,如果该地区呈现
c
按钮,然后将一个JButton。如果该区域被画的是ScrollBarSlider,那么组件将使用。此值可能为空。
width
区域的油漆宽度。请注意,在画面的前景的情况下,这个值可能不同于getwidth() C.。
height
区域的高度画。请注意,在画面的前景的情况下,这个值可能不同于getheight() C.。
extendedCacheKeys
-调用的结果getextendedcachekeys()
protected final float decodeX(float x)
x
-编码的x值(0…1,2,或2或1……3)
IllegalArgumentException
-如果
x < 0
或
x > 3
protected final float decodeY(float y)
y
-编码的Y值(0…1,2,或2或1……3)
IllegalArgumentException
-如果
y < 0
或
y > 3
protected final float decodeAnchorX(float x, float dx)
x
-编码的X值的Bezier控制点(0…1,2,或2或1……3)
dx
-偏移距离的锚从控制点X
IllegalArgumentException
-如果
x < 0
或
x > 3
protected final float decodeAnchorY(float y, float dy)
y
-编码的Y值的Bezier控制点(0…1,2,或2或1……3)
dy
-偏移距离控制点Y锚
IllegalArgumentException
-如果
y < 0
或
y > 3
protected final Color decodeColor(String key, float hOffset, float sOffset, float bOffset, int aOffset)
key
-一个键所对应的值在UI默认表”在基地的颜色定义
hOffset
-色相偏移用于推导。
sOffset
-饱和度偏用于推导。
bOffset
-亮度偏移用于推导。
aOffset
-阿尔法偏移用于推导。在0……255
protected final Color decodeColor(Color color1, Color color2, float midPoint)
color1
-第一个颜色
color2
-第二颜色
midPoint
1色和色之间的偏移值2,0是1,1是颜色2色;
protected final LinearGradientPaint decodeGradient(float x1, float y1, float x2, float y2, float[] midpoints, Color[] colors)
x1
—
y1
—
x2
—
y2
—
midpoints
—
colors
—
NullPointerException
-如果
midpoints
数组为空,或
colors
数组是空的,
IllegalArgumentException
如果起点和终点是同一点,或
midpoints.length != colors.length
,或
colors
小于2的大小,或
midpoints
值小于0或大于1,或
midpoints
不是严格递增的顺序设置
protected final RadialGradientPaint decodeRadialGradient(float x, float y, float r, float[] midpoints, Color[] colors)
x
—
y
—
r
—
midpoints
—
colors
—
NullPointerException
-如果
midpoints
数组为空,或
colors
数组是空的
IllegalArgumentException
-如果
r
是非积极的,或
midpoints.length != colors.length
,或
colors
小于2的大小,或
midpoints
值小于0或大于1,或
midpoints
不是严格递增的顺序设置
protected final Color getComponentColor(JComponent c, String property, Color defaultColor, float saturationOffset, float brightnessOffset, int alphaOffset)
getXXX()
方法如果失败,一个关键
property
客户端性能检查。如果仍然不能返回一个颜色然后
defaultColor
返回。
c
-从颜色属性的组件
property
-一个bean样式属性或客户财产
defaultColor
的颜色如果从组件没有得到返色。
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.