- java.lang.Object
- 
- javafx.scene.paint.Paint
- 
- javafx.scene.paint.RadialGradient
 
 
- 
 public final class RadialGradient extends Paint TheRadialGradientclass provides a way to fill a shape with a circular radial color gradient pattern. The user may specify 2 or more gradient colors, and this paint will provide an interpolation between each color.The user must specify the circle controlling the gradient pattern, which is defined by a center point and a radius. The user can also specify a separate focus point within that circle, which controls the location of the first color of the gradient. By default the focus is set to be the center of the circle. The center and radius are specified relative to a unit square, unless the proportionalvariable is false. By default proportional is true, and the gradient will be scaled to fill whatever shape it is applied to. The focus point is always specified relative to the center point by an angle and a distance relative to the radius.This paint will map the first color of the gradient to the focus point, and the last color to the perimeter of the circle, interpolating smoothly for any in-between colors specified by the user. Any line drawn from the focus point to the circumference will thus span all of the gradient colors. The focus distance will be clamped to the range (-1, 1)so that the focus point is always strictly inside the circle.The application provides an array of Stops specifying how to distribute the colors along the gradient. TheStop#offsetvariable must be the range 0.0 to 1.0 and act like keyframes along the gradient. They mark where the gradient should be exactly a particular color.- Since:
- JavaFX 2.0
 
- 
- 
Constructor SummaryConstructors Constructor Description RadialGradient(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, List<Stop> stops)Creates a new instance of RadialGradient.RadialGradient(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, Stop... stops)Creates a new instance of RadialGradient.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Indicates whether some other object is "equal to" this one.doublegetCenterX()Defines the X coordinate of the center point of the circle defining the gradient.doublegetCenterY()Defines the X coordinate of the center point of the circle defining the gradient.CycleMethodgetCycleMethod()Defines the cycle method applied to theRadialGradient.doublegetFocusAngle()Defines the angle in degrees from the center of the gradient to the focus point to which the first color is mapped.doublegetFocusDistance()Defines the distance from the center of the gradient to the focus point to which the first color is mapped.doublegetRadius()Specifies the radius of the circle defining the extents of the color gradient.List<Stop>getStops()A sequence of 2 or moreStopvalues specifying how to distribute the colors along the gradient.inthashCode()Returns a hash code for thisRadialGradientobject.booleanisOpaque()Gets whether this Paint is completely opaque.booleanisProportional()Indicates whether the center and radius values are proportional or absolute.StringtoString()Returns a string representation of thisRadialGradientobject.static RadialGradientvalueOf(String value)Creates a radial gradient value from a string representation.
 
- 
- 
- 
Constructor Detail- 
RadialGradientpublic RadialGradient(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, Stop... stops)Creates a new instance of RadialGradient.- Parameters:
- focusAngle- the angle in degrees from the center of the gradient to the focus point to which the first color is mapped
- focusDistance- the distance from the center of the gradient to the focus point to which the first color is mapped
- centerX- the X coordinate of the center point of the gradient's circle
- centerY- the Y coordinate of the center point of the gradient's circle
- radius- the radius of the circle defining the extents of the color gradient
- proportional- whether the coordinates and sizes are proportional to the shape which this gradient fills
- cycleMethod- cycle method applied to the gradient
- stops- the gradient's color specification
 
 - 
RadialGradientpublic RadialGradient(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, List<Stop> stops)Creates a new instance of RadialGradient.- Parameters:
- focusAngle- the angle in degrees from the center of the gradient to the focus point to which the first color is mapped
- focusDistance- the distance from the center of the gradient to the focus point to which the first color is mapped
- centerX- the X coordinate of the center point of the gradient's circle
- centerY- the Y coordinate of the center point of the gradient's circle
- radius- the radius of the circle defining the extents of the color gradient
- proportional- whether the coordinates and sizes are proportional to the shape which this gradient fills
- cycleMethod- cycle method applied to the gradient
- stops- the gradient's color specification
 
 
- 
 - 
Method Detail- 
getFocusAnglepublic final double getFocusAngle() Defines the angle in degrees from the center of the gradient to the focus point to which the first color is mapped.- Returns:
- the angle in degrees from the center of the gradient to the focus point to which the first color is mapped
 
 - 
getFocusDistancepublic final double getFocusDistance() Defines the distance from the center of the gradient to the focus point to which the first color is mapped. A distance of 0.0 will be at the center of the gradient circle. A distance of 1.0 will be on the circumference of the gradient circle.- Returns:
- the distance from the center of the gradient to the focus point to which the first color is mapped
 
 - 
getCenterXpublic final double getCenterX() Defines the X coordinate of the center point of the circle defining the gradient. If proportional is true (the default), this value specifies a point on a unit square that will be scaled to match the size of the the shape that the gradient fills. The last color of the gradient is mapped to the perimeter of this circle.- Default value:
- 0.0
- Returns:
- the X coordinate of the center point of the circle defining the gradient
 
 - 
getCenterYpublic final double getCenterY() Defines the X coordinate of the center point of the circle defining the gradient. If proportional is true (the default), this value specifies a point on a unit square that will be scaled to match the size of the the shape that the gradient fills. The last color of the gradient is mapped to the perimeter of this circle.- Default value:
- 0.0
- Returns:
- the X coordinate of the center point of the circle defining the gradient
 
 - 
getRadiuspublic final double getRadius() Specifies the radius of the circle defining the extents of the color gradient. If proportional is true (the default), this value specifies a size relative to unit square that will be scaled to match the size of the the shape that the gradient fills.- Default value:
- 1.0
- Returns:
- the radius of the circle defining the extents of the color gradient
 
 - 
isProportionalpublic final boolean isProportional() Indicates whether the center and radius values are proportional or absolute. If this flag is true, the center point and radius are defined in a coordinate space where coordinates in the range[0..1]are scaled to map onto the bounds of the shape that the gradient fills. If this flag is false, then the center coordinates and the radius are specified in the local coordinate system of the node.- Default value:
- true
- Returns:
- true if the center and radius values are proportional, otherwise absolute
 
 - 
getCycleMethodpublic final CycleMethod getCycleMethod() Defines the cycle method applied to theRadialGradient. One of:CycleMethod.NO_CYCLE,CycleMethod.REFLECT, orCycleMethod.REPEAT.- Default value:
- NO_CYCLE
- Returns:
- the cycle method applied to this radial gradient
 
 - 
getStopspublic final List<Stop> getStops() A sequence of 2 or moreStopvalues specifying how to distribute the colors along the gradient. These values must be in the range 0.0 to 1.0. They act like keyframes along the gradient: they mark where the gradient should be exactly a particular color.Each stop in the sequence must have an offset that is greater than the previous stop in the sequence. The list is unmodifiable and will throw UnsupportedOperationExceptionon each modification attempt.- Default value:
- empty
- Returns:
- the list of Stop values
 
 - 
isOpaquepublic final boolean isOpaque() Gets whether this Paint is completely opaque. An opaque paint is one that has no alpha component in any of its colors. It may be possible for a Paint to be opaque and yet return false, if it cannot be easily determined whether the paint is actually opaque. For example, the ImagePattern may not be able to cheaply determine its opacity.
 - 
equalspublic boolean equals(Object obj) Indicates whether some other object is "equal to" this one.
 - 
hashCodepublic int hashCode() Returns a hash code for thisRadialGradientobject.
 - 
toStringpublic String toString() Returns a string representation of thisRadialGradientobject.
 - 
valueOfpublic static RadialGradient valueOf(String value) Creates a radial gradient value from a string representation.The format of the string representation is based on JavaFX CSS specification for radial gradient which is radial-gradient([focus-angle <angle>, ]? [focus-distance <percentage>, ]? [center <point>, ]? radius [<length> | <percentage>], [[repeat | reflect],]? <color-stop>[, <color-stop>]+)where<point> = [ [ <length> <length> ] | [ <percentage> | <percentage> ] ] <color-stop> = [ <color> [ <percentage> | <length>]? ] Currently length can be only specified in px, the specification of unit can be omited. Format of color representation is the one used in Examples:Color.web(String color). The radial-gradient keyword can be omited. For additional information about the format of string representation, see the CSS Reference Guide.RadialGradient g = RadialGradient.valueOf("radial-gradient(center 100px 100px, radius 200px, red 0%, blue 30%, black 100%)"); RadialGradient g = RadialGradient.valueOf("center 100px 100px, radius 200px, red 0%, blue 30%, black 100%"); RadialGradient g = RadialGradient.valueOf("radial-gradient(center 50% 50%, radius 50%, cyan, violet 75%, magenta)"); RadialGradient g = RadialGradient.valueOf("center 50% 50%, radius 50%, cyan, violet 75%, magenta");- Parameters:
- value- the string to convert
- Returns:
- a RadialGradientobject holding the value represented by the string argument.
- Throws:
- NullPointerException- if the- valueis- null
- IllegalArgumentException- if the- valuecannot be parsed
- Since:
- JavaFX 2.1
 
 
- 
 
-