RadialGradient class 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 proportional
variable 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. The Stop#offset variable 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.
| Modifier and Type | Field and Description |
|---|---|
| private double | |
| private double | |
| private CycleMethod | |
| private double | |
| private double | |
| private int | hash
The cached hash code, used to improve performance in situations where we cache gradients, such as in the CSS routines. |
| private final boolean | |
| private Object | platformPaint
A cached reference to the platform paint, no point recomputing twice |
| private boolean | |
| private double | |
| private List |
| Access | Constructor and Description |
|---|---|
| public | RadialGradient(double
the angle in degrees from the center of the gradient
to the focus point to which the first color is mapped focusAngle, double the distance from the center of the gradient to the
focus point to which the first color is mapped focusDistance, double the X coordinate of the center point of the gradient's circle centerX, double the Y coordinate of the center point of the gradient's circle centerY, double the radius of the circle defining the extents of the color gradient radius, boolean whether the coordinates and sizes are proportional
to the shape which this gradient fills proportional, CycleMethod cycle method applied to the gradient cycleMethod, Stop... the gradient's color specification stops)Creates a new instance of RadialGradient. |
| public | RadialGradient(double
the angle in degrees from the center of the gradient
to the focus point to which the first color is mapped focusAngle, double the distance from the center of the gradient to the
focus point to which the first color is mapped focusDistance, double the X coordinate of the center point of the gradient's circle centerX, double the Y coordinate of the center point of the gradient's circle centerY, double the radius of the circle defining the extents of the color gradient radius, boolean whether the coordinates and sizes are proportional
to the shape which this gradient fills proportional, CycleMethod cycle method applied to the gradient cycleMethod, List<Stop> the gradient's color specification stops)Creates a new instance of RadialGradient. |
| private | RadialGradient(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, List<Stop> stops, int ignored)
Private constructor accepting a stop list that is already normalized. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Object | |
| private boolean | |
| public boolean | Returns: true if this object is equal to the obj argument; false otherwise.the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public final double | Returns: the X coordinate of the center point of the circle defining the gradientDefines the X coordinate of the center point of the circle defining the gradient. |
| public final double | Returns: the X coordinate of the center point of the circle defining the gradientDefines the X coordinate of the center point of the circle defining the gradient. |
| public final CycleMethod | Returns: the cycle method applied to this radial gradientDefines the cycle method applied
to the |
| public final double | Returns: the angle in degrees from the center of the gradient to the focus point to which the first color is mappedDefines the angle in degrees from the center of the gradient to the focus point to which the first color is mapped. |
| public final double | Returns: the distance from the center of the gradient to the focus point to which the first color is mappedDefines the distance from the center of the gradient to the focus point to which the first color is mapped. |
| public final double | Returns: the radius of the circle defining the extents of the color gradientSpecifies the radius of the circle defining the extents of the color gradient. |
| public final List | Returns: the list of Stop valuesA sequence of 2 or more |
| public int | Returns: a hash code for thisRadialGradient object.Overrides java. Returns a hash code for this |
| public RadialGradient | Returns: the intermediate valuethe target value endValue, double the interpolation factor t)Implements javafx. Returns an intermediate value between the value of this |
| public Paint | interpolate(Paint endValue, double t)
Implements javafx. Returns an intermediate value between the value of this |
| public final boolean | isOpaque()
Implements abstract javafx. Gets whether this Paint is completely opaque. |
| public final boolean | Returns: true if the center and radius values are proportional, otherwise absoluteIndicates whether the center and radius values are proportional or absolute. |
| private boolean | isSame(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, List<Stop> stops)
|
| public String | Returns: a string representation of thisRadialGradient object.Overrides java. Returns a string representation of this |
| public static RadialGradient | Returns: aRadialGradient object holding the value represented
by the string argument.the string to convert value)Hides javafx. Creates a radial gradient value from a string representation. |
| centerX | back to summary |
|---|---|
| private double centerX | |
| centerY | back to summary |
|---|---|
| private double centerY | |
| cycleMethod | back to summary |
|---|---|
| private CycleMethod cycleMethod | |
| focusAngle | back to summary |
|---|---|
| private double focusAngle | |
| focusDistance | back to summary |
|---|---|
| private double focusDistance | |
| hash | back to summary |
|---|---|
| private int hash The cached hash code, used to improve performance in situations where we cache gradients, such as in the CSS routines. | |
| opaque | back to summary |
|---|---|
| private final boolean opaque | |
| platformPaint | back to summary |
|---|---|
| private Object platformPaint A cached reference to the platform paint, no point recomputing twice | |
| proportional | back to summary |
|---|---|
| private boolean proportional | |
| radius | back to summary |
|---|---|
| private double radius | |
| stops | back to summary |
|---|---|
| private List<Stop> stops | |
| RadialGradient | back to summary |
|---|---|
| public RadialGradient(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, Stop... stops) Creates a new instance of RadialGradient.
| |
| RadialGradient | back to summary |
|---|---|
| public 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 | back to summary |
|---|---|
| private RadialGradient(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, List<Stop> stops, int ignored) Private constructor accepting a stop list that is already normalized.
This constructor is only called from the | |
| acc_getPlatformPaint | back to summary |
|---|---|
| pack-priv Object acc_getPlatformPaint() Implements abstract javafx.
| |
| determineOpacity | back to summary |
|---|---|
| private boolean determineOpacity() Iterate over all the stops. If any one of them has a transparent color, then we return false. If there are no stops, we return false. Otherwise, we return true. Note that this is called AFTER Stop.normalize, which ensures that we always have at least 2 stops.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Indicates whether some other object is "equal to" this one. | |
| getCenterX | back to summary |
|---|---|
| public 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 shape that the gradient fills. The last color of the gradient is mapped to the perimeter of this circle.
| |
| getCenterY | back to summary |
|---|---|
| public 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.
| |
| getCycleMethod | back to summary |
|---|---|
| public final CycleMethod getCycleMethod() Defines the cycle method applied
to the
| |
| getFocusAngle | back to summary |
|---|---|
| public 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.
| |
| getFocusDistance | back to summary |
|---|---|
| public 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.
| |
| getRadius | back to summary |
|---|---|
| public 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.
| |
| getStops | back to summary |
|---|---|
| public final List A sequence of 2 or more 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
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hash code for this
| |
| interpolate | back to summary |
|---|---|
| public RadialGradient interpolate(RadialGradient endValue, double t) Implements javafx. Returns an intermediate value between the value of this
| |
| interpolate | back to summary |
|---|---|
| public Paint interpolate(Paint endValue, double t) Implements javafx. Doc from javafx. Returns an intermediate value between the value of this The returned value might not be a new instance; the implementation might also return one of the two existing instances if the intermediate value would be equal to one of the existing values. However, this is an optimization and applications should not assume any particular identity of the returned value.
| |
| isOpaque | back to summary |
|---|---|
| public final boolean isOpaque() Implements abstract javafx. Doc from javafx. 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.
| |
| isProportional | back to summary |
|---|---|
| public 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
| |
| isSame | back to summary |
|---|---|
| private boolean isSame(double focusAngle, double focusDistance, double centerX, double centerY, double radius, boolean proportional, CycleMethod cycleMethod, List<Stop> stops) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this | |
| valueOf | back to summary |
|---|---|
| public static RadialGradient valueOf(String value) Hides javafx. 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 omitted.
Format of color representation is the one used in
| |