Binding of a double value.
DoubleBinding provides a simple invalidation-scheme. An extending
class can register dependencies by calling bind(Observable..
If One of the registered dependencies becomes invalid, this
DoubleBinding is marked as invalid. With
unbind(Observable. listening to dependencies can be stopped.
To provide a concrete implementation of this class, the method
computeValue() has to be implemented to calculate the value of this
binding based on the current state of the dependencies. It is called when
get() is called for an invalid binding.
Below is a simple example of a DoubleBinding calculating the square-
root of a javafx. moo.
final ObservableDoubleValue moo = ...;
DoubleBinding foo = new DoubleBinding() {
{
super.bind(moo);
}
@Override
protected double computeValue() {
return Math.sqrt(moo.getValue());
}
};
Following is the same example with implementations for the optional methods
Binding#getDependencies() and Binding#dispose().
final ObservableDoubleValue moo = ...;
DoubleBinding foo = new DoubleBinding() {
{
super.bind(moo);
}
@Override
protected double computeValue() {
return Math.sqrt(moo.getValue());
}
@Override
public ObservableList<?> getDependencies() {
return FXCollections.singletonObservableList(moo);
}
@Override
public void dispose() {
super.unbind(moo);
}
};
Binding, NumberBinding, javafx.beans.binding.DoubleExpression
| Modifier and Type | Field and Description |
|---|---|
| private ExpressionHelper | |
| private BindingHelperObserver | observer
Invalidation listener used for observing dependencies. |
| private boolean | |
| private double |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addListener(InvalidationListener
The listener to register listener)Implements javafx. Adds an |
| public void | addListener(ChangeListener<? super Number>
The listener to register listener)Implements javafx. Adds a |
| protected final void | bind(Observable...
the dependencies to observe dependencies)Start observing the dependencies for changes. |
| protected abstract double | |
| public void | dispose()
Implements javafx. A default implementation of |
| public final double | Returns: the current valueImplements javafx. Returns the result of |
| public ObservableList | Returns: an emptyObservableListImplements javafx. A default implementation of |
| public final void | |
| public final boolean | |
| protected void | onInvalidating()
The method onInvalidating() can be overridden by extending classes to react, if this binding becomes invalid. |
| public void | removeListener(InvalidationListener
The listener to remove listener)Implements javafx. Removes the given listener from the list of listeners, that are notified
whenever the value of the |
| public void | removeListener(ChangeListener<? super Number>
The listener to remove listener)Implements javafx. Removes the given listener from the list of listeners that are notified
whenever the value of the |
| public String | Returns: a string representation of thisDoubleBinding object.Overrides java. Returns a string representation of this |
| protected final void | unbind(Observable...
the dependencies to stop observing dependencies)Stop observing the dependencies for changes. |
| helper | back to summary |
|---|---|
| private ExpressionHelper<Number> helper | |
| observer | back to summary |
|---|---|
| private BindingHelperObserver observer Invalidation listener used for observing dependencies. This
is never cleared once created as there is no way to determine
when all dependencies that were previously bound were removed
in one or more calls to | |
| valid | back to summary |
|---|---|
| private boolean valid | |
| value | back to summary |
|---|---|
| private double value | |
| DoubleBinding | back to summary |
|---|---|
| public DoubleBinding() Creates a default | |
| addListener | back to summary |
|---|---|
| public void addListener(InvalidationListener listener) Implements javafx. Doc from javafx. Adds an
Note that the same actual
The
| |
| addListener | back to summary |
|---|---|
| public void addListener(ChangeListener<? super Number> listener) Implements javafx. Doc from javafx. Adds a
Note that the same actual
The
| |
| bind | back to summary |
|---|---|
| protected final void bind(Observable... dependencies) Start observing the dependencies for changes. If the value of one of the dependencies changes, the binding is marked as invalid.
| |
| computeValue | back to summary |
|---|---|
| protected abstract double computeValue() Calculates the current value of this binding.
Classes extending
| |
| dispose | back to summary |
|---|---|
| public void dispose() Implements javafx. A default implementation of
| |
| get | back to summary |
|---|---|
| public final double get() Implements javafx. Returns the result of
| |
| getDependencies | back to summary |
|---|---|
| public ObservableList Implements javafx. A default implementation of
| |
| invalidate | back to summary |
|---|---|
| public final void invalidate() Implements javafx. Doc from javafx. Mark a binding as invalid. This forces the recalculation of the value of
the
| |
| isValid | back to summary |
|---|---|
| public final boolean isValid() Implements javafx. Doc from javafx. Checks if a binding is valid.
| |
| onInvalidating | back to summary |
|---|---|
| protected void onInvalidating() The method onInvalidating() can be overridden by extending classes to react, if this binding becomes invalid. The default implementation is empty. | |
| removeListener | back to summary |
|---|---|
| public void removeListener(InvalidationListener listener) Implements javafx. Doc from javafx. Removes the given listener from the list of listeners, that are notified
whenever the value of the If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.
| |
| removeListener | back to summary |
|---|---|
| public void removeListener(ChangeListener<? super Number> listener) Implements javafx. Doc from javafx. Removes the given listener from the list of listeners that are notified
whenever the value of the If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this | |
| unbind | back to summary |
|---|---|
| protected final void unbind(Observable... dependencies) Stop observing the dependencies for changes.
| |