public final class RadialGradientPaint extends MultipleGradientPaint
RadialGradientPaint
类提供了一种方式来填补一个形状有圆形径向颜色梯度模式。用户可以指定2个或更多的渐变色,这种油漆将提供每个颜色之间的内插。
用户必须指定的圆控制的梯度模式,这是所描述的一个中心点和半径。用户还可以在该圆中指定一个单独的焦点点,该点控制梯度的第一颜色的位置。默认情况下,焦点将被设置为圆的中心。
该涂料将映射到焦点的第一个颜色的颜色,和最后一个颜色的圆周长,平滑内插在由用户指定的颜色之间的任何一个。从焦点到圆周的任何一条线将跨越所有的渐变色。
指定外圆半径的一个焦点,将导致环的梯度图案,以中心的点上的边缘内的圆的焦点的方向上。渲染将内部使用这个修改后的位置,因为如果它是指定的焦点。
用户必须提供一个浮动的数组,指定如何沿梯度分布的颜色。这些值的范围从0到1,像沿梯度的关键帧(他们的标志在梯度应该完全是一个特别的颜色)。
如果在用户没有设置第一个关键帧的值等于0和/或最后一个关键帧的值等于1,关键帧将在这些位置创建的第一个和最后一个颜色将被复制在。所以,如果一个用户指定下列数组来构建一个梯度:
{红},color.blue,颜色。{。3F、7F }。这将被转换为一个具有以下关键帧梯度:
{ color.blue、Color.BLUE、Color.red,颜色。红},{ 0F,。3F,7F,1F }。
用户也可以选择RadialGradientPaint
对象采取什么行动的时候是填充空间外圆的半径设置CycleMethod
要么REFLECTION
或REPEAT
。从聚焦点绘制的任何一条特定的线的梯度颜色比例是相等的。下面的图显示的距离AB等于BC的距离,而距离广告的距离相等的。
NO_CYCLE
将默认选择,这意味着最后一个关键帧的颜色将被用来填补剩余的地区。
在色彩参数允许用户指定的色彩插值应该执行,默认的sRGB或线性化RGB。
下面的代码演示了RadialGradientPaint
的典型用法,其中的中心和焦点都是一样的:
point2d中心=新point2d浮子(50,50);浮动半径= 25;浮动[ ]距离= { 0.0f,0.2F,1.0f };颜色[ ]颜色= { Color.red,color.white,颜色蓝};radialgradientpaint P =新的radialgradientpaint(中心、半径、距离、颜色);
此图像显示上面的示例代码,默认(中心)为三个周期的方法的焦点:
它也可以指定一个非中心的焦点,如在下面的代码:
point2d中心=新point2d浮子(50,50);浮动半径= 25;point2d焦点=新point2d浮子(40,40);浮动[ ]距离= { 0.0f,0.2F,1.0f };颜色[ ]颜色= { Color.red,color.white,颜色蓝};radialgradientpaint P =新的radialgradientpaint(中心、半径、焦点,距离,颜色,周期no_cycle);
此图像显示了前面的示例代码,三个周期方法中的每一个都是非中心的焦点:
Paint
,
Graphics2D.setPaint(java.awt.Paint)
MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod
BITMASK, OPAQUE, TRANSLUCENT
Constructor and Description |
---|
RadialGradientPaint(float cx, float cy, float radius, float[] fractions, Color[] colors)
构建一个与默认
NO_CYCLE 重复法和
SRGB 颜色空间
RadialGradientPaint ,使用中心对焦点。
|
RadialGradientPaint(float cx, float cy, float radius, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
构建一个与默认
SRGB 颜色空间
RadialGradientPaint ,使用中心对焦点。
|
RadialGradientPaint(float cx, float cy, float radius, float fx, float fy, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
构建一个与默认
SRGB 颜色空间
RadialGradientPaint 。
|
RadialGradientPaint(Point2D center, float radius, float[] fractions, Color[] colors)
构建一个与默认
NO_CYCLE 重复法和
SRGB 颜色空间
RadialGradientPaint ,使用中心对焦点。
|
RadialGradientPaint(Point2D center, float radius, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
构建一个与默认
SRGB 颜色空间
RadialGradientPaint ,使用中心对焦点。
|
RadialGradientPaint(Point2D center, float radius, Point2D focus, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
构建一个与默认
SRGB 颜色空间
RadialGradientPaint 。
|
RadialGradientPaint(Point2D center, float radius, Point2D focus, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, AffineTransform gradientTransform)
构建了一个
RadialGradientPaint 。
|
RadialGradientPaint(Rectangle2D gradientBounds, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
构建一个与默认
SRGB 颜色空间
RadialGradientPaint 。
|
Modifier and Type | Method and Description |
---|---|
PaintContext |
createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform transform, RenderingHints hints)
创建并返回一个用来生成一个圆形径向颜色梯度模式
PaintContext 。
|
Point2D |
getCenterPoint()
返回径向梯度的中心点的副本。
|
Point2D |
getFocusPoint()
返回径向梯度的焦点点的副本。
|
float |
getRadius()
返回定义径向梯度的圆的半径。
|
getColors, getColorSpace, getCycleMethod, getFractions, getTransform, getTransparency
public RadialGradientPaint(float cx, float cy, float radius, float[] fractions, Color[] colors)
NO_CYCLE
重复法和
SRGB
颜色空间
RadialGradientPaint
,使用中心对焦点。
cx
- x坐标在用户空间的中心点的圆圈定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
cy
- Y坐标在用户空间的中心点的圆圈定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
radius
-圆的半径定义颜色渐变的程度
fractions
数从0到1的指定沿渐变的颜色分布
colors
-颜色数组使用梯度。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
NullPointerException
-如果
fractions
数组为空,或
colors
数组是空的
IllegalArgumentException
-如果
radius
是非积极的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
public RadialGradientPaint(Point2D center, float radius, float[] fractions, Color[] colors)
NO_CYCLE
重复法和
SRGB
颜色空间
RadialGradientPaint
,使用中心对焦点。
center
的中心点,在用户空间中,圆的定义梯度
radius
-圆的半径定义颜色渐变的程度
fractions
数从0到1的指定沿渐变的颜色分布
colors
-颜色数组使用梯度。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
NullPointerException
-如果
center
点是无效的,或者
fractions
数组为空,或
colors
数组是空的
IllegalArgumentException
-如果
radius
是非积极的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
public RadialGradientPaint(float cx, float cy, float radius, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
SRGB
颜色空间
RadialGradientPaint
,使用中心对焦点。
cx
- x坐标在用户空间的中心点的圆圈定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
cy
- Y坐标在用户空间的中心点的圆圈定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
radius
-圆的半径定义颜色渐变的程度
fractions
数从0到1的指定沿渐变的颜色分布
colors
-使用渐变的颜色。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
cycleMethod
-
NO_CYCLE
,
REFLECT
,或
REPEAT
NullPointerException
-如果
fractions
数组为空,或
colors
数组为空,或
cycleMethod
是空的
IllegalArgumentException
-如果
radius
是非积极的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
public RadialGradientPaint(Point2D center, float radius, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
SRGB
颜色空间
RadialGradientPaint
,使用中心对焦点。
center
的中心点,在用户空间中,圆的定义梯度
radius
-圆的半径定义颜色渐变的程度
fractions
数从0到1的指定沿渐变的颜色分布
colors
-颜色数组使用梯度。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
cycleMethod
-
NO_CYCLE
,
REFLECT
,或
REPEAT
NullPointerException
-如果
center
点是无效的,或者
fractions
数组为空,或
colors
数组为空,或
cycleMethod
是空的
IllegalArgumentException
-如果
radius
是非积极的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
public RadialGradientPaint(float cx, float cy, float radius, float fx, float fy, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
SRGB
颜色空间
RadialGradientPaint
。
cx
- x坐标在用户空间的中心点的圆圈定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
cy
- Y坐标在用户空间的中心点的圆圈定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
radius
-圆的半径定义颜色渐变的程度
fx
- x坐标在用户空间中的点,第一个颜色映射
fy
- Y坐标在用户空间中的点,第一个颜色映射
fractions
数从0到1的指定沿渐变的颜色分布
colors
-颜色数组使用梯度。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
cycleMethod
-
NO_CYCLE
,
REFLECT
,或
REPEAT
NullPointerException
-如果
fractions
数组为空,或
colors
数组为空,或
cycleMethod
是空的
IllegalArgumentException
-如果
radius
是非积极的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
public RadialGradientPaint(Point2D center, float radius, Point2D focus, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
SRGB
颜色空间
RadialGradientPaint
。
center
的中心点,在用户空间中,圆的定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
radius
-圆的半径定义颜色渐变的程度
focus
-在用户空间中的点,第一个颜色映射
fractions
数从0到1的指定沿渐变的颜色分布
colors
-颜色数组使用梯度。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
cycleMethod
-
NO_CYCLE
,
REFLECT
,或
REPEAT
NullPointerException
-如果一个点是空的,或
fractions
数组为空,或
colors
数组为空,或
cycleMethod
是空的
IllegalArgumentException
-如果
radius
是非积极的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
@ConstructorProperties(value={"centerPoint","radius","focusPoint","fractions","colors","cycleMethod","colorSpace","transform"}) public RadialGradientPaint(Point2D center, float radius, Point2D focus, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, AffineTransform gradientTransform)
RadialGradientPaint
。
center
的中心点在用户空间中圆的定义梯度。的最后一个颜色的梯度被映射到这个圆的周长。
radius
-圆的半径定义颜色渐变的程度
focus
-在用户空间中的点,第一个颜色映射
fractions
数从0到1的指定沿渐变的颜色分布
colors
-颜色数组使用梯度。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
cycleMethod
-
NO_CYCLE
,
REFLECT
,或
REPEAT
colorSpace
-使用插值颜色空间,要么
SRGB
或
LINEAR_RGB
gradientTransform
变换应用于梯度
NullPointerException
-如果一个点是空的,或
fractions
数组为空,或
colors
数组为空,或
cycleMethod
是无效的,或者
colorSpace
是无效的,或者
gradientTransform
是空的
IllegalArgumentException
-如果
radius
是非积极的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
public RadialGradientPaint(Rectangle2D gradientBounds, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)
SRGB
颜色空间
RadialGradientPaint
。该
RadialGradientPaint
梯度圈是由给定的包围盒的定义。
这个构造函数是表达以下一个更方便的方法(等效)代码:
双gradientbounds getwidth() GW =;双gradientbounds getheight() GH =;双gradientbounds getcenterx() CX =;双gradientbounds getcentery() CY =;point2d中心=新point2d双(CX,CY);点gradienttransform =新affinetransform();gradienttransform翻译(CX,CY);gradienttransform。规模(GW / 2,GH/2);gradienttransform。翻译(—cx,cy);radialgradientpaint GP =新的radialgradientpaint(中心,1.0f,中心,分数,颜色,周期,ColorSpaceType.SRGB,gradienttransform);
gradientBounds
的包围盒,在用户空间中,圆的定义梯度最外层的程度
fractions
数从0到1的指定沿渐变的颜色分布
colors
-颜色数组使用梯度。第一种颜色是用在焦点点上,最后一个颜色围绕着圆的周长。
cycleMethod
-
NO_CYCLE
,
REFLECT
,或
REPEAT
NullPointerException
-如果
gradientBounds
是无效的,或者
fractions
数组为空,或
colors
数组为空,或
cycleMethod
是空的
IllegalArgumentException
-如果
gradientBounds
是空的,或
fractions.length != colors.length
,或
colors
小于2的大小,或
fractions
值小于0或大于1,或
fractions
不是严格递增的顺序设置
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform transform, RenderingHints hints)
PaintContext
。看到零参数处理信息的
createContext
的描述方法。
cm
-代表对方接收像素数据的首选
ColorModel
最方便的格式,或
null
如果没有偏好。
deviceBounds
-设备空间包围盒的图元被渲染。
userBounds
-用户空间包围盒的图元被渲染。
transform
-
AffineTransform
从用户空间到设备空间。
hints
-提示上下文对象可以使用之间的替代选择设置渲染。
PaintContext
。
Paint
,
PaintContext
,
ColorModel
,
Rectangle
,
Rectangle2D
,
AffineTransform
,
RenderingHints
public Point2D getCenterPoint()
Point2D
对象是一个副本的中心点
public Point2D getFocusPoint()
Point2D
对象是一个副本的焦点
public float getRadius()
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.