Class Stop
java.lang.Object
javafx.scene.paint.Stop
- All Implemented Interfaces:
Interpolatable<Stop>
public final class Stop extends Object implements Interpolatable<Stop>
Defines one element of the ramp of colors to use on a gradient. For more information see
javafx.scene.paint.LinearGradient and javafx.scene.paint.RadialGradient. Example:
// object bounding box relative (proportional:true, default)
Stop[] stops = { new Stop(0, Color.WHITE), new Stop(1, Color.BLACK)};
LinearGradient lg = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
Rectangle r = new Rectangle();
r.setFill(lg);
- Since:
- JavaFX 2.0
Constructor Summary
| Constructor | Description |
|---|---|
Stop |
Creates a new instance of Stop. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
final Color |
getColor() |
Gets the color of the gradient at this offset. |
final double |
getOffset() |
Gets a number ranging from 0 to 1 that indicates where this gradient stop is placed. |
int |
hashCode() |
Returns a hash code for this Stop object. |
Stop |
interpolate |
Returns an intermediate value between the value of this Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive). |
String |
toString() |
Returns a string representation of this Stop object. |
Constructor Details
Stop
public Stop(double offset, Color color)
Creates a new instance of Stop.
- Parameters:
-
offset- Stop's position (ranging from0to1 -
color- Stop's color
Method Details
getOffset
public final double getOffset()
Gets a number ranging from
0 to 1 that indicates where this gradient stop is placed. For linear gradients, the offset variable represents a location along the gradient vector. For radial gradients, it represents a percentage distance from the focus point to the edge of the outermost/largest circle.- Interpolation Type:
- linear
- Returns:
- position of the Stop within the gradient (ranging from
0to1)
getColor
public final Color getColor()
Gets the color of the gradient at this offset.
- Interpolation Type:
- linear
- Returns:
- the color of the gradient at this offset
interpolate
public Stop interpolate(Stop endValue, double t)
Returns an intermediate value between the value of this
Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive). 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.
- Specified by:
-
interpolatein interfaceInterpolatable<Stop> - Parameters:
-
endValue- the target value -
t- the interpolation factor - Returns:
- the intermediate value
- Throws:
-
NullPointerException- ifendValueisnull - Since:
- 24
equals
hashCode
toString
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.