Provides classes that create and operate on a Binding
that calculates a value that depends on one or more sources.
Bindings are assembled from one or more sources, usually called their dependencies. A binding observes its dependencies for changes and updates its own value according to changes in the dependencies.
Almost all bindings defined in this library require
implementations of javafx. for their
dependencies. There are two types of implementations already provided,
the properties in the package javafx. and the
observable collections (javafx. and
javafx.). Bindings also implement
Observable and can again serve as sources for other bindings
allowing to construct very complex bindings from simple ones.
Bindings in our implementation are always calculated lazily. That means, if a dependency changes, the result of a binding is not immediately recalculated, but it is marked as invalid. Next time the value of an invalid binding is requested, it is recalculated.
The Binding API is roughly divided in two parts, the High Level Binding API and the Low Level Binding API. The High Level Binding API allows to construct simple bindings in an easy to use fashion. Defining a binding with the High Level API should be straightforward, especially when used in an IDE that provides code completion. Unfortunately it has its limitation and at that point the Low Level API comes into play. Experienced Java developers can use the Low Level API to define bindings, if the functionality of the High Level API is not sufficient or to improve the performance. The main goals of the Low Level API are fast execution and small memory footprint.
Following is an example of how both APIs can be used. Assuming
we have four instances of javafx. a, b, c , and d, we can define a binding that calculates a*b
+ c*d with the High Level API for example like this:
NumberBinding result = Bindings.add (a.multiply(b),
c.multiply(d));
Defining the same binding using the Low Level API could be done like this:
DoubleBinding foo = new DoubleBinding() {
{
super.bind(a, b, c, d);
}
@Override
protected double computeValue() {
return a.getValue() * b.getValue() + c.getValue() * d.getValue();
}
};
| Modifier and Type | Interface and Description |
|---|---|
| public interface | Binding<
the type of the wrapped value T>A |
| public interface | NumberBinding
A tagging interface to mark all Bindings that wrap a number-value. |
| public interface | NumberExpression
|
| Modifier and Type | Class and Description |
|---|---|
| public class | Bindings
Bindings is a helper class with a lot of utility functions to create simple bindings. |
| public abstract class | BooleanBinding
Base class that provides most of the functionality needed to implement a
|
| public abstract class | BooleanExpression
|
| public abstract class | DoubleBinding
Base class that provides most of the functionality needed to implement a
|
| public abstract class | DoubleExpression
|
| public abstract class | FloatBinding
Base class that provides most of the functionality needed to implement a
|
| public abstract class | FloatExpression
|
| public abstract class | IntegerBinding
Base class that provides most of the functionality needed to implement a
|
| public abstract class | IntegerExpression
|
| public abstract class | ListBinding<
the type of the E>List elementBase class that provides most of the functionality needed to implement a
|
| public abstract class | ListExpression<
the type of the E>List elements.
|
| public abstract class | LongBinding
Base class that provides most of the functionality needed to implement a
|
| public abstract class | LongExpression
|
| public abstract class | MapBinding<
the type of the key elements K, the type of the value elements V>Base class that provides most of the functionality needed to implement a
|
| public abstract class | MapExpression<
the type of the key elements K, the type of the value elements V>
|
| public abstract class | NumberExpressionBase
|
| public abstract class | ObjectBinding<
the type of the wrapped T>ObjectBase class that provides most of the functionality needed to implement a
|
| public abstract class | ObjectExpression<
the type of expression value T>
|
| public abstract class | SetBinding<
the type of the E>Set elementsBase class that provides most of the functionality needed to implement a
|
| public abstract class | SetExpression<
the type of the E>Set elements
|
| public abstract class | StringBinding
Base class that provides most of the functionality needed to implement a
|
| public abstract class | StringExpression
|
| public class | When
Starting point for a binding that calculates a ternary expression. |