Interface Interpolatable<T>
- Type Parameters:
-
T- the interpolatable value type
- All Known Implementing Classes:
-
Background,BackgroundFill,BackgroundImage,BackgroundPosition,BackgroundSize,Border,BorderImage,BorderStroke,BorderWidths,Color,CornerRadii,ImagePattern,Insets,LinearGradient,Paint,Point2D,Point3D,RadialGradient,Stop
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Interpolatable<T>
A value that can be interpolated. It defines a single
Some component types are interpolated in specific ways not covered here. Refer to their respective documentation for more information.
interpolate(Object, double) method, which returns an intermediate value between the value of this Interpolatable and the specified target value. Component values can be interpolated in different ways, depending on the semantics of the component type:
| default | Component types that implement Interpolatable are interpolated by calling the interpolate(Object, double) method. |
| linear | Two components are combined by linear interpolation such that t = 0 produces the start value, t = 1 produces the end value, and 0 < t < 1 produces (1 - t) * start + t * end. This interpolation type is usually applicable for numeric components. |
| discrete | If two components cannot be meaningfully combined, the intermediate component value is equal to the start value for t < 0.5 and equal to the end value for t >= 0.5. |
| pairwise | Two lists are combined by pairwise interpolation. Paired list elements are interpolated with rules as described in this table (substituting "component" for "element"). If the start list has fewer elements than the target list, the missing elements are copied from the target list. If the start list has more elements than the target list, the excess elements are discarded. |
- Since:
- JavaFX 2.0
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
T |
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). |
Method Details
interpolate
T interpolate(T 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.
- Implementation Requirements:
- An implementation is not required to reject interpolation factors less than 0 or larger than 1, but this specification gives no meaning to values returned outside of this range. For example, an implementation might clamp the interpolation factor to [0..1], or it might continue the linear interpolation outside of this range.
- Parameters:
-
endValue- the target value -
t- the interpolation factor - Returns:
- the intermediate value
- Throws:
-
NullPointerException- ifendValueisnull
© 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.