Search in sources :

Example 1 with DoubleBinding

use of javafx.beans.binding.DoubleBinding in project JFoenix by jfoenixadmin.

the class GenericEditableTreeTableCell method createEditorNode.

private void createEditorNode() {
    EventHandler<KeyEvent> keyEventsHandler = new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                commitHelper(false);
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            } else if (t.getCode() == KeyCode.TAB) {
                commitHelper(false);
                TreeTableColumn nextColumn = getNextColumn(!t.isShiftDown());
                if (nextColumn != null) {
                    getTreeTableView().edit(getIndex(), nextColumn);
                }
            }
        }
    };
    ChangeListener<Boolean> focusChangeListener = new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            //of stopping the double commit.
            if (!newValue && editorNode != null) {
                commitHelper(true);
            }
        }
    };
    DoubleBinding minWidthBinding = Bindings.createDoubleBinding(() -> {
        return this.getWidth() - this.getGraphicTextGap() * 2 - this.getBaselineOffset();
    }, this.widthProperty(), this.graphicTextGapProperty());
    editorNode = builder.createNode(getValue(), minWidthBinding, keyEventsHandler, focusChangeListener);
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) JFXTreeTableColumn(com.jfoenix.controls.JFXTreeTableColumn) TreeTableColumn(javafx.scene.control.TreeTableColumn) DoubleBinding(javafx.beans.binding.DoubleBinding) ObservableValue(javafx.beans.value.ObservableValue) EventHandler(javafx.event.EventHandler) ChangeListener(javafx.beans.value.ChangeListener)

Example 2 with DoubleBinding

use of javafx.beans.binding.DoubleBinding in project NMEAParser by tvesalainen.

the class CurrentArrowCanvas method bind.

@Override
public void bind(ViewerPreferences preferences, PropertyStore propertyStore, BooleanProperty active) {
    super.bind(preferences, propertyStore, active);
    ObservableNumberValue currentAngleOverGround = propertyStore.getBinding("currentAngleOverGround");
    // fix current direction
    DoubleBinding fixed = Bindings.createDoubleBinding(() -> Navis.normalizeAngle(currentAngleOverGround.doubleValue() + 180), currentAngleOverGround);
    angleProperty().bind(fixed);
    valueProperty().bind(propertyStore.getBinding("currentSpeedOverGround"));
    disableProperty().bind(propertyStore.getDisableBind("currentAngleOverGround", "currentSpeedOverGround"));
}
Also used : ObservableNumberValue(javafx.beans.value.ObservableNumberValue) DoubleBinding(javafx.beans.binding.DoubleBinding)

Aggregations

DoubleBinding (javafx.beans.binding.DoubleBinding)2 JFXTreeTableColumn (com.jfoenix.controls.JFXTreeTableColumn)1 ChangeListener (javafx.beans.value.ChangeListener)1 ObservableNumberValue (javafx.beans.value.ObservableNumberValue)1 ObservableValue (javafx.beans.value.ObservableValue)1 EventHandler (javafx.event.EventHandler)1 TreeTableColumn (javafx.scene.control.TreeTableColumn)1 KeyEvent (javafx.scene.input.KeyEvent)1