Example usage for javafx.beans.value ChangeListener ChangeListener

List of usage examples for javafx.beans.value ChangeListener ChangeListener

Introduction

In this page you can find the example usage for javafx.beans.value ChangeListener ChangeListener.

Prototype

ChangeListener

Source Link

Usage

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXDelDepListPane.java

public CFBamJavaFXDelDepListPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema,
        ICFLibAnyObj argContainer, ICFBamDelDepObj argFocus, Collection<ICFBamDelDepObj> argDataCollection,
        ICFRefreshCallback refreshCallback, boolean sortByChain) {
    super();/*from  www.ja  v a2s .  c  o  m*/
    final String S_ProcName = "construct-schema-focus";
    if (formManager == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "formManager");
    }
    cfFormManager = formManager;
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 2,
                "argSchema");
    }
    // argFocus is optional; focus may be set later during execution as
    // conditions of the runtime change.
    javafxSchema = argSchema;
    javaFXFocus = argFocus;
    javafxContainer = argContainer;
    javafxRefreshCallback = refreshCallback;
    javafxSortByChain = sortByChain;
    setJavaFXDataCollection(argDataCollection);
    dataTable = new TableView<ICFBamDelDepObj>();
    tableColumnObjKind = new TableColumn<ICFBamDelDepObj, String>("Class Code");
    tableColumnObjKind.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamDelDepObj, String>, ObservableValue<String>>() {
                @Override
                public ObservableValue<String> call(CellDataFeatures<ICFBamDelDepObj, String> p) {
                    ICFBamDelDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        String classCode = obj.getClassCode();
                        ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>();
                        observable.setValue(classCode);
                        return (observable);
                    }
                }
            });
    tableColumnObjKind.setCellFactory(
            new Callback<TableColumn<ICFBamDelDepObj, String>, TableCell<ICFBamDelDepObj, String>>() {
                @Override
                public TableCell<ICFBamDelDepObj, String> call(TableColumn<ICFBamDelDepObj, String> arg) {
                    return new CFStringTableCell<ICFBamDelDepObj>();
                }
            });
    dataTable.getColumns().add(tableColumnObjKind);
    tableColumnId = new TableColumn<ICFBamDelDepObj, Long>("Id");
    tableColumnId.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamDelDepObj, Long>, ObservableValue<Long>>() {
                public ObservableValue<Long> call(CellDataFeatures<ICFBamDelDepObj, Long> p) {
                    ICFBamScopeObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        long value = obj.getRequiredId();
                        Long wrapped = new Long(value);
                        ReadOnlyObjectWrapper<Long> observable = new ReadOnlyObjectWrapper<Long>();
                        observable.setValue(wrapped);
                        return (observable);
                    }
                }
            });
    tableColumnId.setCellFactory(
            new Callback<TableColumn<ICFBamDelDepObj, Long>, TableCell<ICFBamDelDepObj, Long>>() {
                @Override
                public TableCell<ICFBamDelDepObj, Long> call(TableColumn<ICFBamDelDepObj, Long> arg) {
                    return new CFInt64TableCell<ICFBamDelDepObj>();
                }
            });
    dataTable.getColumns().add(tableColumnId);
    tableColumnLookupRelation = new TableColumn<ICFBamDelDepObj, ICFBamRelationObj>("Relation");
    tableColumnLookupRelation.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamDelDepObj, ICFBamRelationObj>, ObservableValue<ICFBamRelationObj>>() {
                public ObservableValue<ICFBamRelationObj> call(
                        CellDataFeatures<ICFBamDelDepObj, ICFBamRelationObj> p) {
                    ICFBamDelDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        ICFBamRelationObj ref = obj.getRequiredLookupRelation();
                        ReadOnlyObjectWrapper<ICFBamRelationObj> observable = new ReadOnlyObjectWrapper<ICFBamRelationObj>();
                        observable.setValue(ref);
                        return (observable);
                    }
                }
            });
    tableColumnLookupRelation.setCellFactory(
            new Callback<TableColumn<ICFBamDelDepObj, ICFBamRelationObj>, TableCell<ICFBamDelDepObj, ICFBamRelationObj>>() {
                @Override
                public TableCell<ICFBamDelDepObj, ICFBamRelationObj> call(
                        TableColumn<ICFBamDelDepObj, ICFBamRelationObj> arg) {
                    return new CFReferenceTableCell<ICFBamDelDepObj, ICFBamRelationObj>();
                }
            });
    dataTable.getColumns().add(tableColumnLookupRelation);
    tableColumnLookupDefSchema = new TableColumn<ICFBamDelDepObj, ICFBamSchemaDefObj>(
            "Defining Schema Definition");
    tableColumnLookupDefSchema.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamDelDepObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() {
                public ObservableValue<ICFBamSchemaDefObj> call(
                        CellDataFeatures<ICFBamDelDepObj, ICFBamSchemaDefObj> p) {
                    ICFBamDelDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        ICFBamSchemaDefObj ref = obj.getOptionalLookupDefSchema();
                        ReadOnlyObjectWrapper<ICFBamSchemaDefObj> observable = new ReadOnlyObjectWrapper<ICFBamSchemaDefObj>();
                        observable.setValue(ref);
                        return (observable);
                    }
                }
            });
    tableColumnLookupDefSchema.setCellFactory(
            new Callback<TableColumn<ICFBamDelDepObj, ICFBamSchemaDefObj>, TableCell<ICFBamDelDepObj, ICFBamSchemaDefObj>>() {
                @Override
                public TableCell<ICFBamDelDepObj, ICFBamSchemaDefObj> call(
                        TableColumn<ICFBamDelDepObj, ICFBamSchemaDefObj> arg) {
                    return new CFReferenceTableCell<ICFBamDelDepObj, ICFBamSchemaDefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnLookupDefSchema);
    dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamDelDepObj>() {
        @Override
        public void changed(ObservableValue<? extends ICFBamDelDepObj> observable, ICFBamDelDepObj oldValue,
                ICFBamDelDepObj newValue) {
            setJavaFXFocus(newValue);
        }
    });

    scrollMenu = new ScrollPane();
    scrollMenu.setVbarPolicy(ScrollBarPolicy.NEVER);
    scrollMenu.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
    scrollMenu.setFitToHeight(true);
    scrollMenu.setContent(getPanelHBoxMenu());

    setTop(scrollMenu);
    setCenter(dataTable);
    javafxIsInitializing = false;
    if (observableListOfDelDep != null) {
        dataTable.setItems(observableListOfDelDep);
    }
    adjustListButtons();
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXPopDepListPane.java

public CFBamJavaFXPopDepListPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema,
        ICFLibAnyObj argContainer, ICFBamPopDepObj argFocus, Collection<ICFBamPopDepObj> argDataCollection,
        ICFRefreshCallback refreshCallback, boolean sortByChain) {
    super();//from w w w.  j av  a2s.c  o m
    final String S_ProcName = "construct-schema-focus";
    if (formManager == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "formManager");
    }
    cfFormManager = formManager;
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 2,
                "argSchema");
    }
    // argFocus is optional; focus may be set later during execution as
    // conditions of the runtime change.
    javafxSchema = argSchema;
    javaFXFocus = argFocus;
    javafxContainer = argContainer;
    javafxRefreshCallback = refreshCallback;
    javafxSortByChain = sortByChain;
    setJavaFXDataCollection(argDataCollection);
    dataTable = new TableView<ICFBamPopDepObj>();
    tableColumnObjKind = new TableColumn<ICFBamPopDepObj, String>("Class Code");
    tableColumnObjKind.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamPopDepObj, String>, ObservableValue<String>>() {
                @Override
                public ObservableValue<String> call(CellDataFeatures<ICFBamPopDepObj, String> p) {
                    ICFBamPopDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        String classCode = obj.getClassCode();
                        ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>();
                        observable.setValue(classCode);
                        return (observable);
                    }
                }
            });
    tableColumnObjKind.setCellFactory(
            new Callback<TableColumn<ICFBamPopDepObj, String>, TableCell<ICFBamPopDepObj, String>>() {
                @Override
                public TableCell<ICFBamPopDepObj, String> call(TableColumn<ICFBamPopDepObj, String> arg) {
                    return new CFStringTableCell<ICFBamPopDepObj>();
                }
            });
    dataTable.getColumns().add(tableColumnObjKind);
    tableColumnId = new TableColumn<ICFBamPopDepObj, Long>("Id");
    tableColumnId.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamPopDepObj, Long>, ObservableValue<Long>>() {
                public ObservableValue<Long> call(CellDataFeatures<ICFBamPopDepObj, Long> p) {
                    ICFBamScopeObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        long value = obj.getRequiredId();
                        Long wrapped = new Long(value);
                        ReadOnlyObjectWrapper<Long> observable = new ReadOnlyObjectWrapper<Long>();
                        observable.setValue(wrapped);
                        return (observable);
                    }
                }
            });
    tableColumnId.setCellFactory(
            new Callback<TableColumn<ICFBamPopDepObj, Long>, TableCell<ICFBamPopDepObj, Long>>() {
                @Override
                public TableCell<ICFBamPopDepObj, Long> call(TableColumn<ICFBamPopDepObj, Long> arg) {
                    return new CFInt64TableCell<ICFBamPopDepObj>();
                }
            });
    dataTable.getColumns().add(tableColumnId);
    tableColumnLookupRelation = new TableColumn<ICFBamPopDepObj, ICFBamRelationObj>("Relation");
    tableColumnLookupRelation.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamPopDepObj, ICFBamRelationObj>, ObservableValue<ICFBamRelationObj>>() {
                public ObservableValue<ICFBamRelationObj> call(
                        CellDataFeatures<ICFBamPopDepObj, ICFBamRelationObj> p) {
                    ICFBamPopDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        ICFBamRelationObj ref = obj.getRequiredLookupRelation();
                        ReadOnlyObjectWrapper<ICFBamRelationObj> observable = new ReadOnlyObjectWrapper<ICFBamRelationObj>();
                        observable.setValue(ref);
                        return (observable);
                    }
                }
            });
    tableColumnLookupRelation.setCellFactory(
            new Callback<TableColumn<ICFBamPopDepObj, ICFBamRelationObj>, TableCell<ICFBamPopDepObj, ICFBamRelationObj>>() {
                @Override
                public TableCell<ICFBamPopDepObj, ICFBamRelationObj> call(
                        TableColumn<ICFBamPopDepObj, ICFBamRelationObj> arg) {
                    return new CFReferenceTableCell<ICFBamPopDepObj, ICFBamRelationObj>();
                }
            });
    dataTable.getColumns().add(tableColumnLookupRelation);
    tableColumnLookupDefSchema = new TableColumn<ICFBamPopDepObj, ICFBamSchemaDefObj>(
            "Defining Schema Definition");
    tableColumnLookupDefSchema.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamPopDepObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() {
                public ObservableValue<ICFBamSchemaDefObj> call(
                        CellDataFeatures<ICFBamPopDepObj, ICFBamSchemaDefObj> p) {
                    ICFBamPopDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        ICFBamSchemaDefObj ref = obj.getOptionalLookupDefSchema();
                        ReadOnlyObjectWrapper<ICFBamSchemaDefObj> observable = new ReadOnlyObjectWrapper<ICFBamSchemaDefObj>();
                        observable.setValue(ref);
                        return (observable);
                    }
                }
            });
    tableColumnLookupDefSchema.setCellFactory(
            new Callback<TableColumn<ICFBamPopDepObj, ICFBamSchemaDefObj>, TableCell<ICFBamPopDepObj, ICFBamSchemaDefObj>>() {
                @Override
                public TableCell<ICFBamPopDepObj, ICFBamSchemaDefObj> call(
                        TableColumn<ICFBamPopDepObj, ICFBamSchemaDefObj> arg) {
                    return new CFReferenceTableCell<ICFBamPopDepObj, ICFBamSchemaDefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnLookupDefSchema);
    dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamPopDepObj>() {
        @Override
        public void changed(ObservableValue<? extends ICFBamPopDepObj> observable, ICFBamPopDepObj oldValue,
                ICFBamPopDepObj newValue) {
            setJavaFXFocus(newValue);
        }
    });

    scrollMenu = new ScrollPane();
    scrollMenu.setVbarPolicy(ScrollBarPolicy.NEVER);
    scrollMenu.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
    scrollMenu.setFitToHeight(true);
    scrollMenu.setContent(getPanelHBoxMenu());

    setTop(scrollMenu);
    setCenter(dataTable);
    javafxIsInitializing = false;
    if (observableListOfPopDep != null) {
        dataTable.setItems(observableListOfPopDep);
    }
    adjustListButtons();
}

From source file:boundary.GraphPane.java

private HBox addTransformingModeOptions() {
    HBox hBox = new HBox();

    hBox.setPadding(new Insets(15, 12, 15, 12));
    hBox.setSpacing(10);/*from  w  ww.  j a  va2 s  .c o m*/
    hBox.setStyle("-fx-background-color: #66FFFF;");

    final ToggleGroup optionGroup = new ToggleGroup();

    Label lblMouseMode = new Label("Mouse Mode: ");
    lblMouseMode.setPrefSize(100, 20);

    RadioButton rbTransform = new RadioButton("Pan & Zoom");
    rbTransform.setPrefSize(100, 20);
    rbTransform.setToggleGroup(optionGroup);
    rbTransform.setUserData("T");
    rbTransform.setSelected(true);

    RadioButton rbPick = new RadioButton("Picking");
    rbPick.setPrefSize(100, 20);
    rbPick.setUserData("P");
    rbPick.setToggleGroup(optionGroup);

    optionGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {

        @Override
        public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
            if (optionGroup.getSelectedToggle() != null) {
                DefaultModalGraphMouse dmg = (DefaultModalGraphMouse) vv.getGraphMouse();

                if (optionGroup.getSelectedToggle().getUserData().equals("T")) {
                    dmg.setMode(Mode.TRANSFORMING);
                } else if (optionGroup.getSelectedToggle().getUserData().equals("P")) {
                    dmg.setMode(Mode.PICKING);
                }
            }

        }
    });

    hBox.getChildren().addAll(lblMouseMode, rbTransform, rbPick);

    return hBox;

}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXClearDepListPane.java

public CFBamJavaFXClearDepListPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema,
        ICFLibAnyObj argContainer, ICFBamClearDepObj argFocus, Collection<ICFBamClearDepObj> argDataCollection,
        ICFRefreshCallback refreshCallback, boolean sortByChain) {
    super();/*from w  ww.  j  a va  2 s  .  c  o  m*/
    final String S_ProcName = "construct-schema-focus";
    if (formManager == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "formManager");
    }
    cfFormManager = formManager;
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 2,
                "argSchema");
    }
    // argFocus is optional; focus may be set later during execution as
    // conditions of the runtime change.
    javafxSchema = argSchema;
    javaFXFocus = argFocus;
    javafxContainer = argContainer;
    javafxRefreshCallback = refreshCallback;
    javafxSortByChain = sortByChain;
    setJavaFXDataCollection(argDataCollection);
    dataTable = new TableView<ICFBamClearDepObj>();
    tableColumnObjKind = new TableColumn<ICFBamClearDepObj, String>("Class Code");
    tableColumnObjKind.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamClearDepObj, String>, ObservableValue<String>>() {
                @Override
                public ObservableValue<String> call(CellDataFeatures<ICFBamClearDepObj, String> p) {
                    ICFBamClearDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        String classCode = obj.getClassCode();
                        ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>();
                        observable.setValue(classCode);
                        return (observable);
                    }
                }
            });
    tableColumnObjKind.setCellFactory(
            new Callback<TableColumn<ICFBamClearDepObj, String>, TableCell<ICFBamClearDepObj, String>>() {
                @Override
                public TableCell<ICFBamClearDepObj, String> call(TableColumn<ICFBamClearDepObj, String> arg) {
                    return new CFStringTableCell<ICFBamClearDepObj>();
                }
            });
    dataTable.getColumns().add(tableColumnObjKind);
    tableColumnId = new TableColumn<ICFBamClearDepObj, Long>("Id");
    tableColumnId.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamClearDepObj, Long>, ObservableValue<Long>>() {
                public ObservableValue<Long> call(CellDataFeatures<ICFBamClearDepObj, Long> p) {
                    ICFBamScopeObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        long value = obj.getRequiredId();
                        Long wrapped = new Long(value);
                        ReadOnlyObjectWrapper<Long> observable = new ReadOnlyObjectWrapper<Long>();
                        observable.setValue(wrapped);
                        return (observable);
                    }
                }
            });
    tableColumnId.setCellFactory(
            new Callback<TableColumn<ICFBamClearDepObj, Long>, TableCell<ICFBamClearDepObj, Long>>() {
                @Override
                public TableCell<ICFBamClearDepObj, Long> call(TableColumn<ICFBamClearDepObj, Long> arg) {
                    return new CFInt64TableCell<ICFBamClearDepObj>();
                }
            });
    dataTable.getColumns().add(tableColumnId);
    tableColumnLookupRelation = new TableColumn<ICFBamClearDepObj, ICFBamRelationObj>("Relation");
    tableColumnLookupRelation.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamClearDepObj, ICFBamRelationObj>, ObservableValue<ICFBamRelationObj>>() {
                public ObservableValue<ICFBamRelationObj> call(
                        CellDataFeatures<ICFBamClearDepObj, ICFBamRelationObj> p) {
                    ICFBamClearDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        ICFBamRelationObj ref = obj.getRequiredLookupRelation();
                        ReadOnlyObjectWrapper<ICFBamRelationObj> observable = new ReadOnlyObjectWrapper<ICFBamRelationObj>();
                        observable.setValue(ref);
                        return (observable);
                    }
                }
            });
    tableColumnLookupRelation.setCellFactory(
            new Callback<TableColumn<ICFBamClearDepObj, ICFBamRelationObj>, TableCell<ICFBamClearDepObj, ICFBamRelationObj>>() {
                @Override
                public TableCell<ICFBamClearDepObj, ICFBamRelationObj> call(
                        TableColumn<ICFBamClearDepObj, ICFBamRelationObj> arg) {
                    return new CFReferenceTableCell<ICFBamClearDepObj, ICFBamRelationObj>();
                }
            });
    dataTable.getColumns().add(tableColumnLookupRelation);
    tableColumnLookupDefSchema = new TableColumn<ICFBamClearDepObj, ICFBamSchemaDefObj>(
            "Defining Schema Definition");
    tableColumnLookupDefSchema.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamClearDepObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() {
                public ObservableValue<ICFBamSchemaDefObj> call(
                        CellDataFeatures<ICFBamClearDepObj, ICFBamSchemaDefObj> p) {
                    ICFBamClearDepObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        ICFBamSchemaDefObj ref = obj.getOptionalLookupDefSchema();
                        ReadOnlyObjectWrapper<ICFBamSchemaDefObj> observable = new ReadOnlyObjectWrapper<ICFBamSchemaDefObj>();
                        observable.setValue(ref);
                        return (observable);
                    }
                }
            });
    tableColumnLookupDefSchema.setCellFactory(
            new Callback<TableColumn<ICFBamClearDepObj, ICFBamSchemaDefObj>, TableCell<ICFBamClearDepObj, ICFBamSchemaDefObj>>() {
                @Override
                public TableCell<ICFBamClearDepObj, ICFBamSchemaDefObj> call(
                        TableColumn<ICFBamClearDepObj, ICFBamSchemaDefObj> arg) {
                    return new CFReferenceTableCell<ICFBamClearDepObj, ICFBamSchemaDefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnLookupDefSchema);
    dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamClearDepObj>() {
        @Override
        public void changed(ObservableValue<? extends ICFBamClearDepObj> observable, ICFBamClearDepObj oldValue,
                ICFBamClearDepObj newValue) {
            setJavaFXFocus(newValue);
        }
    });

    scrollMenu = new ScrollPane();
    scrollMenu.setVbarPolicy(ScrollBarPolicy.NEVER);
    scrollMenu.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
    scrollMenu.setFitToHeight(true);
    scrollMenu.setContent(getPanelHBoxMenu());

    setTop(scrollMenu);
    setCenter(dataTable);
    javafxIsInitializing = false;
    if (observableListOfClearDep != null) {
        dataTable.setItems(observableListOfClearDep);
    }
    adjustListButtons();
}

From source file:nl.mvdr.umvc3replayanalyser.controller.Umvc3ReplayManagerController.java

/** Intialises the table view. */
private void initTableView() {
    List<Replay> replaysView = new ArrayList<>(replays);
    replayTableView.setItems(FXCollections.observableList(replaysView));

    // Set default sort order.
    replayTableView.getSortOrder().add(replayTableView.getColumns().get(0));

    // Set listener for item selection.
    replayTableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Replay>() {
        /** {@inheritDoc} */
        @Override//  ww w . j a  v a2 s .co m
        public void changed(ObservableValue<? extends Replay> observable, Replay oldValue, Replay newValue) {
            handleSelectedReplayChanged(newValue);
        }
    });
}

From source file:com.rockhoppertech.symchords.fx.SymChordsController.java

@FXML
void initialize() {
    assert IntervalsTextField != null : "fx:id=\"IntervalsTextField\" was not injected: check your FXML file 'symchords.fxml'.";
    assert baseOctaveCombo != null : "fx:id=\"baseOctaveCombo\" was not injected: check your FXML file 'symchords.fxml'.";
    assert basePitchCombo != null : "fx:id=\"basePitchCombo\" was not injected: check your FXML file 'symchords.fxml'.";
    assert octavesSlider != null : "fx:id=\"octavesSlider\" was not injected: check your FXML file 'symchords.fxml'.";
    assert patternTextField != null : "fx:id=\"patternTextField\" was not injected: check your FXML file 'symchords.fxml'.";
    assert relationshipGroup != null : "fx:id=\"relationshipGroup\" was not injected: check your FXML file 'symchords.fxml'.";
    assert relativeRadio != null : "fx:id=\"relativeRadio\" was not injected: check your FXML file 'symchords.fxml'.";
    assert unitSlider != null : "fx:id=\"unitSlider\" was not injected: check your FXML file 'symchords.fxml'.";

    grandStaff.setFontSize(24d);/*from w w w. j a  va  2s  . co  m*/
    grandStaff.drawShapes();
    patternStaff.setFontSize(24d);
    patternStaff.drawShapes();

    baseOctaveCombo.getSelectionModel().select(5);
    basePitchCombo.getSelectionModel().select(0);

    pitchProperty.bindBidirectional(pitchSlider.valueProperty());

    // sliderText.setText(Math.round(pitchSlider.getValue()) + "");
    PitchFormat.getInstance().setWidth(4);
    sliderText.setText(PitchFormat.getInstance().format((int) pitchSlider.getValue()));
    pitchSlider.valueProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldValue,
                Number newValue) {
            if (newValue == null) {
                sliderText.setText("");
                return;
            }
            basePitchCombo.setValue(PitchFormat.getPitchString(newValue.intValue()));
            baseOctaveCombo.setValue("" + newValue.intValue() / 12);
            sliderText.setText(PitchFormat.getInstance().format(newValue.intValue()));

            // sliderText.setText(Math.round(newValue.intValue()) + "");
        }
    });

    basePitchCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue) {

            int pitch = PitchFactory.getPitch(newValue + "0").getMidiNumber();
            int oct = Integer.parseInt(baseOctaveCombo.getSelectionModel().getSelectedItem());
            pitchProperty.set(pitch + (oct * 12));
        }
    });
    baseOctaveCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue) {
            int oct = Integer.parseInt(newValue);
            int pitch = PitchFactory.getPitch(basePitchCombo.getSelectionModel().getSelectedItem() + "0")
                    .getMidiNumber();
            pitchProperty.set(pitch + (oct * 12));
        }
    });

    // java 8
    // basePitchCombo.getSelectionModel().selectedItemProperty().addListener(
    // (ObservableValue<? extends String> ov, String oldValue, String
    // newValue) -> {
    // int pitch = Integer.parseInt(newValue);
    // int oct =
    // Integer.parseInt(baseOctaveCombo.getSelectionModel().getSelectedItem());
    // pitchProperty.set(pitch + oct);
    // });
    // baseOctaveCombo.getSelectionModel().selectedItemProperty().addListener(
    // (ObservableValue<? extends String> ov, String oldValue, String
    // newValue) -> {
    // int oct = Integer.parseInt(newValue);
    // int pitch =
    // Integer.parseInt(basePitchCombo.getSelectionModel().getSelectedItem());
    // pitchProperty.set(pitch + oct);
    // });

    model = new SymModel();

    model.absoluteProperty().bind(this.absoluteRadio.selectedProperty());
    // model.relativeProperty().bind(this.relativeRadio.selectedProperty());
    model.basePitchProperty().bind(this.pitchProperty);
    model.nOctavesProperty().bind(this.octavesSlider.valueProperty());
    model.unitProperty().bind(this.unitSlider.valueProperty());

    // set up initial value
    ObservableList<Integer> ol = FXCollections.observableArrayList();
    ol.add(1);
    setIntervals(ol);
    // now handle input. turn the string into an array.
    this.IntervalsTextField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue) {
            String[] a = newValue.split("\\s+");
            ObservableList<Integer> ol = FXCollections.observableArrayList();
            for (final String ss : a) {
                ol.add(Integer.parseInt(ss));
            }
            setIntervals(ol);
        }
    });
    model.intervalsProperty().bind(this.intervalsProperty);

    this.resetPattern();

    this.patternTextField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue) {
            logger.debug("new value '{}'", newValue);
            newValue = newValue.replaceAll("\\{", "");
            newValue = newValue.replaceAll("\\}", "");
            newValue = newValue.replaceAll(",", " ");
            logger.debug("new value '{}'", newValue);

            String[] a = newValue.split("\\s+");
            ObservableList<Integer> ol = FXCollections.observableArrayList();
            for (final String ss : a) {
                ol.add(Integer.parseInt(ss));
            }
            // setIntervals(ol);
        }
    });

    patternListView.setCellFactory(new Callback<ListView<int[]>, ListCell<int[]>>() {
        @Override
        public ListCell<int[]> call(ListView<int[]> list) {
            return new PatternListCell();
        }
    });
    updatePatternList();

    patternListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<int[]>() {
        @Override
        public void changed(ObservableValue<? extends int[]> observable, int[] oldValue, int[] newValue) {
            pattern = newValue;
            patternCalculate();
            patternTextField.setText(ArrayUtils.toString(pattern));
        }
    });

    setupDragonDrop();

    trackList.setCellFactory(new Callback<ListView<MIDITrack>, ListCell<MIDITrack>>() {
        @Override
        public ListCell<MIDITrack> call(ListView<MIDITrack> list) {
            return new TrackListCell();
        }
    });
    trackList.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<MIDITrack>() {

        @Override
        public void changed(ObservableValue<? extends MIDITrack> observable, MIDITrack oldValue,
                MIDITrack newValue) {

            model.setMIDITrack(newValue);

            // SymParams params = model.getParamsForTrack(newValue);
            SymParams params = (SymParams) newValue.getUserData();
            logger.debug("params {}", params);
            if (params != null) {
                int pitch = params.getBasePitch() % 12;
                String ps = PitchFormat.getPitchString(pitch);
                basePitchCombo.setValue(ps);

                String oct = "" + params.getBasePitch() / 12;
                baseOctaveCombo.setValue(oct);

                String intervals = ListUtils.asIntString(params.getIntervals());
                IntervalsTextField.setText(intervals);

                octavesSlider.setValue(params.getnOctaves());
                unitSlider.setValue(params.getUnit());
                relativeRadio.setSelected(params.isRelative());
                absoluteRadio.setSelected(!params.isRelative());

            }
        }
    });

    model.midiTrackProperty().addListener(new ChangeListener<MIDITrack>() {
        @Override
        public void changed(ObservableValue<? extends MIDITrack> arg0, MIDITrack arg1, MIDITrack newTrack) {

            if (durationModifierCB.isSelected()) {
                modifierValuesTextField.setText(MIDITrack.getDurationsAsString(newTrack));
            }
            if (pitchModifierCB.isSelected()) {
                modifierValuesTextField.setText(MIDITrack.getPitchesMIDINumbersAsString(newTrack));
            }
            if (startBeatModifierCB.isSelected()) {
                modifierValuesTextField.setText(MIDITrack.getStartBeatsAsString(newTrack));
            }

            logger.debug("midi track property changed {}", newTrack);
            grandStaff.setTrack(newTrack);
            grandStaff.drawShapes();
        }
    });

}

From source file:ch.unibas.fittingwizard.presentation.fitting.FitResultPage.java

private void initializeMolecules() {
    cbMolecules.getItems().add(new MoleculeViewModel(null));

    ArrayList<Molecule> molecules = moleculeRepository.loadAll();
    for (Molecule molecule : molecules) {
        cbMolecules.getItems().add(new MoleculeViewModel(molecule));
    }/* ww w.  j av a2 s .com*/
    cbMolecules.getSelectionModel().select(0);
    cbMolecules.autosize();

    cbMolecules.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<MoleculeViewModel>() {
        @Override
        public void changed(ObservableValue<? extends MoleculeViewModel> observableValue,
                MoleculeViewModel molOld, MoleculeViewModel molNew) {
            logger.info("Molecule selection changed to " + (molNew != null ? molNew : "nothing"));
            Molecule molecule = molNew != null ? molNew.getMolecule() : null;
            selectedMolecule = molecule;
            filterTable(molecule);
            updateVisualization();
        }
    });
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXSchemaRefListPane.java

public CFBamJavaFXSchemaRefListPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema,
        ICFBamSchemaDefObj argContainer, ICFBamSchemaRefObj argFocus,
        Collection<ICFBamSchemaRefObj> argDataCollection, ICFRefreshCallback refreshCallback,
        boolean sortByChain) {
    super();/*from   w  w w .j  a  va 2  s  . c  o  m*/
    final String S_ProcName = "construct-schema-focus";
    if (formManager == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "formManager");
    }
    cfFormManager = formManager;
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 2,
                "argSchema");
    }
    // argFocus is optional; focus may be set later during execution as
    // conditions of the runtime change.
    javafxSchema = argSchema;
    javaFXFocus = argFocus;
    javafxContainer = argContainer;
    javafxRefreshCallback = refreshCallback;
    javafxSortByChain = sortByChain;
    setJavaFXDataCollection(argDataCollection);
    dataTable = new TableView<ICFBamSchemaRefObj>();
    tableColumnId = new TableColumn<ICFBamSchemaRefObj, Long>("Id");
    tableColumnId.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamSchemaRefObj, Long>, ObservableValue<Long>>() {
                public ObservableValue<Long> call(CellDataFeatures<ICFBamSchemaRefObj, Long> p) {
                    ICFBamScopeObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        long value = obj.getRequiredId();
                        Long wrapped = new Long(value);
                        ReadOnlyObjectWrapper<Long> observable = new ReadOnlyObjectWrapper<Long>();
                        observable.setValue(wrapped);
                        return (observable);
                    }
                }
            });
    tableColumnId.setCellFactory(
            new Callback<TableColumn<ICFBamSchemaRefObj, Long>, TableCell<ICFBamSchemaRefObj, Long>>() {
                @Override
                public TableCell<ICFBamSchemaRefObj, Long> call(TableColumn<ICFBamSchemaRefObj, Long> arg) {
                    return new CFInt64TableCell<ICFBamSchemaRefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnId);
    tableColumnName = new TableColumn<ICFBamSchemaRefObj, String>("Name");
    tableColumnName.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamSchemaRefObj, String>, ObservableValue<String>>() {
                public ObservableValue<String> call(CellDataFeatures<ICFBamSchemaRefObj, String> p) {
                    ICFBamSchemaRefObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        String value = obj.getRequiredName();
                        ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>();
                        observable.setValue(value);
                        return (observable);
                    }
                }
            });
    tableColumnName.setCellFactory(
            new Callback<TableColumn<ICFBamSchemaRefObj, String>, TableCell<ICFBamSchemaRefObj, String>>() {
                @Override
                public TableCell<ICFBamSchemaRefObj, String> call(TableColumn<ICFBamSchemaRefObj, String> arg) {
                    return new CFStringTableCell<ICFBamSchemaRefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnName);
    tableColumnRefModelName = new TableColumn<ICFBamSchemaRefObj, String>("Ref. Model Name");
    tableColumnRefModelName.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamSchemaRefObj, String>, ObservableValue<String>>() {
                public ObservableValue<String> call(CellDataFeatures<ICFBamSchemaRefObj, String> p) {
                    ICFBamSchemaRefObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        String value = obj.getRequiredRefModelName();
                        ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>();
                        observable.setValue(value);
                        return (observable);
                    }
                }
            });
    tableColumnRefModelName.setCellFactory(
            new Callback<TableColumn<ICFBamSchemaRefObj, String>, TableCell<ICFBamSchemaRefObj, String>>() {
                @Override
                public TableCell<ICFBamSchemaRefObj, String> call(TableColumn<ICFBamSchemaRefObj, String> arg) {
                    return new CFStringTableCell<ICFBamSchemaRefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnRefModelName);
    tableColumnIncludeRoot = new TableColumn<ICFBamSchemaRefObj, String>("Include Root");
    tableColumnIncludeRoot.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamSchemaRefObj, String>, ObservableValue<String>>() {
                public ObservableValue<String> call(CellDataFeatures<ICFBamSchemaRefObj, String> p) {
                    ICFBamSchemaRefObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        String value = obj.getRequiredIncludeRoot();
                        ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>();
                        observable.setValue(value);
                        return (observable);
                    }
                }
            });
    tableColumnIncludeRoot.setCellFactory(
            new Callback<TableColumn<ICFBamSchemaRefObj, String>, TableCell<ICFBamSchemaRefObj, String>>() {
                @Override
                public TableCell<ICFBamSchemaRefObj, String> call(TableColumn<ICFBamSchemaRefObj, String> arg) {
                    return new CFStringTableCell<ICFBamSchemaRefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnIncludeRoot);
    tableColumnLookupRefSchema = new TableColumn<ICFBamSchemaRefObj, ICFBamSchemaDefObj>("Referenced Schema");
    tableColumnLookupRefSchema.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamSchemaRefObj, ICFBamSchemaDefObj>, ObservableValue<ICFBamSchemaDefObj>>() {
                public ObservableValue<ICFBamSchemaDefObj> call(
                        CellDataFeatures<ICFBamSchemaRefObj, ICFBamSchemaDefObj> p) {
                    ICFBamSchemaRefObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        ICFBamSchemaDefObj ref = obj.getOptionalLookupRefSchema();
                        ReadOnlyObjectWrapper<ICFBamSchemaDefObj> observable = new ReadOnlyObjectWrapper<ICFBamSchemaDefObj>();
                        observable.setValue(ref);
                        return (observable);
                    }
                }
            });
    tableColumnLookupRefSchema.setCellFactory(
            new Callback<TableColumn<ICFBamSchemaRefObj, ICFBamSchemaDefObj>, TableCell<ICFBamSchemaRefObj, ICFBamSchemaDefObj>>() {
                @Override
                public TableCell<ICFBamSchemaRefObj, ICFBamSchemaDefObj> call(
                        TableColumn<ICFBamSchemaRefObj, ICFBamSchemaDefObj> arg) {
                    return new CFReferenceTableCell<ICFBamSchemaRefObj, ICFBamSchemaDefObj>();
                }
            });
    dataTable.getColumns().add(tableColumnLookupRefSchema);
    dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamSchemaRefObj>() {
        @Override
        public void changed(ObservableValue<? extends ICFBamSchemaRefObj> observable,
                ICFBamSchemaRefObj oldValue, ICFBamSchemaRefObj newValue) {
            setJavaFXFocus(newValue);
        }
    });

    scrollMenu = new ScrollPane();
    scrollMenu.setVbarPolicy(ScrollBarPolicy.NEVER);
    scrollMenu.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
    scrollMenu.setFitToHeight(true);
    scrollMenu.setContent(getPanelHBoxMenu());

    setTop(scrollMenu);
    setCenter(dataTable);
    javafxIsInitializing = false;
    if (observableListOfSchemaRef != null) {
        dataTable.setItems(observableListOfSchemaRef);
    }
    adjustListButtons();
}

From source file:net.rptools.tokentool.controller.TokenTool_Controller.java

@FXML
void initialize() {
    // Note: A Pane is added to the compositeTokenPane so the ScrollPane doesn't consume the mouse events
    assert fileManageOverlaysMenu != null : "fx:id=\"fileManageOverlaysMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileSaveAsMenu != null : "fx:id=\"fileSaveAsMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileExitMenu != null : "fx:id=\"fileExitMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert editCaptureScreenMenu != null : "fx:id=\"editCaptureScreenMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editCopyImageMenu != null : "fx:id=\"editCopyImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editPasteImageMenu != null : "fx:id=\"editPasteImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert helpAboutMenu != null : "fx:id=\"helpAboutMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert saveOptionsPane != null : "fx:id=\"saveOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayOptionsPane != null : "fx:id=\"overlayOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert backgroundOptionsPane != null : "fx:id=\"backgroundOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert zoomOptionsPane != null : "fx:id=\"zoomOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert compositeTokenPane != null : "fx:id=\"compositeTokenPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert tokenPreviewPane != null : "fx:id=\"tokenPreviewPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitScrollPane != null : "fx:id=\"portraitScrollPane\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert compositeGroup != null : "fx:id=\"compositeGroup\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert overlayTreeView != null : "fx:id=\"overlayTreeview\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert portraitImageView != null : "fx:id=\"portraitImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert maskImageView != null : "fx:id=\"maskImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayImageView != null : "fx:id=\"overlayImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert tokenImageView != null : "fx:id=\"tokenImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert useFileNumberingCheckbox != null : "fx:id=\"useFileNumberingCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayUseAsBaseCheckbox != null : "fx:id=\"overlayUseAsBaseCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert clipPortraitCheckbox != null : "fx:id=\"clipPortraitCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert fileNameTextField != null : "fx:id=\"fileNameTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameSuffixLabel != null : "fx:id=\"fileNameSuffixLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameSuffixTextField != null : "fx:id=\"fileNameSuffixTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayNameLabel != null : "fx:id=\"overlayNameLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert backgroundColorPicker != null : "fx:id=\"backgroundColorPicker\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayAspectToggleButton != null : "fx:id=\"overlayAspectToggleButton\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert portraitTransparencySlider != null : "fx:id=\"portraitTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitBlurSlider != null : "fx:id=\"portraitBlurSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitGlowSlider != null : "fx:id=\"portraitGlowSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert overlayTransparencySlider != null : "fx:id=\"overlayTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert overlayWidthSpinner != null : "fx:id=\"overlayWidthSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayHeightSpinner != null : "fx:id=\"overlayHeightSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";

    assert overlayTreeProgressBar != null : "fx:id=\"overlayTreeProgressIndicator\" was not injected: check your FXML file 'ManageOverlays.fxml'.";

    executorService = Executors.newCachedThreadPool(runable -> {
        loadOverlaysThread = Executors.defaultThreadFactory().newThread(runable);
        loadOverlaysThread.setDaemon(true);
        return loadOverlaysThread;
    });//from www.jav a  2  s.com

    overlayTreeView.setShowRoot(false);
    overlayTreeView.getSelectionModel().selectedItemProperty().addListener(
            (observable, oldValue, newValue) -> updateCompositImageView((TreeItem<Path>) newValue));

    addPseudoClassToLeafs(overlayTreeView);

    // Bind color picker to compositeTokenPane background fill
    backgroundColorPicker.setValue(Color.TRANSPARENT);
    ObjectProperty<Background> background = compositeTokenPane.backgroundProperty();
    background.bind(Bindings.createObjectBinding(() -> {
        BackgroundFill fill = new BackgroundFill(backgroundColorPicker.getValue(), CornerRadii.EMPTY,
                Insets.EMPTY);
        return new Background(fill);
    }, backgroundColorPicker.valueProperty()));

    // Bind transparency slider to portraitImageView opacity
    portraitTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            portraitImageView.setOpacity(new_val.doubleValue());
            updateTokenPreviewImageView();
        }
    });

    // // Restrict text field to valid filename characters
    // Pattern validDoubleText = Pattern.compile("[^a-zA-Z0-9\\\\._ \\\\/`~!@#$%\\\\^&\\\\(\\\\)\\\\-\\\\=\\\\+\\\\[\\\\]\\\\{\\\\}',\\\\\\\\:]");
    // Pattern validText = Pattern.compile("[^a-zA-Z0-9 ]");
    // TextFormatter<> textFormatter = new TextFormatter<>(
    // change -> {
    // String newText = change.getControlNewText();
    // if (validText.matcher(newText).matches()) {
    // return change;
    // } else
    // return null;
    // });

    // UnaryOperator<TextFormatter.Change> filter = new UnaryOperator<TextFormatter.Change>() {
    // @Override
    // public TextFormatter.Change apply(TextFormatter.Change t) {
    // String validText = "[^a-zA-Z0-9]";
    //
    // if (t.isReplaced())
    // if (t.getText().matches(validText))
    // t.setText(t.getControlText().substring(t.getRangeStart(), t.getRangeEnd()));
    //
    // if (t.isAdded()) {
    // if (t.getText().matches(validText)) {
    // return null;
    // }
    // }
    //
    // return t;
    // }
    // };

    UnaryOperator<Change> filter = change -> {
        String text = change.getText();

        if (text.matches(AppConstants.VALID_FILE_NAME_PATTERN)) {
            return change;
        } else {
            change.setText(FileSaveUtil.cleanFileName(text));
            ;
            return change;
        }
        //
        // return null;
    };
    TextFormatter<String> textFormatter = new TextFormatter<>(filter);
    fileNameTextField.setTextFormatter(textFormatter);

    // Effects
    GaussianBlur gaussianBlur = new GaussianBlur(0);
    Glow glow = new Glow(0);
    gaussianBlur.setInput(glow);

    // Bind blur slider to portraitImageView opacity
    portraitBlurSlider.valueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            gaussianBlur.setRadius(new_val.doubleValue());
            portraitImageView.setEffect(gaussianBlur);
            updateTokenPreviewImageView();
        }
    });

    // Bind glow slider to portraitImageView opacity
    portraitGlowSlider.valueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            glow.setLevel(new_val.doubleValue());
            portraitImageView.setEffect(gaussianBlur);
            updateTokenPreviewImageView();
        }
    });

    // Bind transparency slider to overlayImageView opacity
    overlayTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            overlayImageView.setOpacity(new_val.doubleValue());
            updateTokenPreviewImageView();
        }
    });

    // Bind width/height spinners to overlay width/height
    overlayWidthSpinner.getValueFactory().valueProperty()
            .bindBidirectional(overlayHeightSpinner.getValueFactory().valueProperty());
    overlayWidthSpinner.valueProperty().addListener(
            (observable, oldValue, newValue) -> overlayWidthSpinner_onTextChanged(oldValue, newValue));
    overlayHeightSpinner.valueProperty().addListener(
            (observable, oldValue, newValue) -> overlayHeightSpinner_onTextChanged(oldValue, newValue));
}

From source file:FeeBooster.java

private GridPane cpfpGrid(Transaction tx) {
    // Setup Grid
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);//w  w w .ja v  a2 s .c  om
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));
    int gridheight = 0;

    // Add outputs to table
    Label outputHdrLbl = new Label("Outputs");
    grid.add(outputHdrLbl, 1, gridheight);
    gridheight++;
    ToggleGroup outputGroup = new ToggleGroup();
    for (int i = 0; i < tx.getOutputs().size(); i++) {
        // Add output to table
        TxOutput out = tx.getOutputs().get(i);
        Text outputTxt = new Text("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress());
        outputTxt.setUserData(i);
        grid.add(outputTxt, 0, gridheight);

        // Add radio button to table
        RadioButton radio = new RadioButton();
        radio.setUserData(i);
        radio.setToggleGroup(outputGroup);
        radio.setSelected(true);
        grid.add(radio, 1, gridheight);
        gridheight++;
    }

    // Fee
    Text fee = new Text("Fee to Pay: " + tx.getFee() + " Satoshis");
    grid.add(fee, 0, gridheight);

    // Recommended fee from bitcoinfees.21.co
    JSONObject apiResult = Utils.getFromAnAPI("http://bitcoinfees.21.co/api/v1/fees/recommended", "GET");
    int fastestFee = apiResult.getInt("fastestFee");
    long recommendedFee = fastestFee * tx.getSize() + fastestFee * 300;
    Text recFeeTxt = new Text("Recommended Fee: " + recommendedFee + " Satoshis");
    grid.add(recFeeTxt, 1, gridheight);
    gridheight += 2;

    // Instructions
    Text instructions = new Text("Choose an output to spend from. Set the total transaction fee below.");
    grid.add(instructions, 0, gridheight, 3, 1);
    gridheight++;

    // Fee spinner
    Spinner feeSpin = new Spinner((double) tx.getFee(), (double) tx.getTotalAmt(), (double) tx.getFee());
    feeSpin.setEditable(true);
    grid.add(feeSpin, 0, gridheight);
    feeSpin.valueProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            double oldVal = (double) oldValue;
            double newVal = (double) newValue;
            Double step = newVal - oldVal;
            tx.setFee(tx.getFee() + step.longValue());
            fee.setText("Fee to Pay: " + tx.getFee() + " Satoshis");
        }
    });

    // Set to recommended fee button
    Button recFeeBtn = new Button("Set fee to recommended");
    grid.add(recFeeBtn, 1, gridheight);
    gridheight++;
    recFeeBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            long prevFee = tx.getFee();
            long step = recommendedFee - prevFee;
            feeSpin.increment((int) step);
        }
    });

    // Output address
    Label recvAddr = new Label("Address to pay to");
    grid.add(recvAddr, 0, gridheight);
    TextField outAddr = new TextField();
    grid.add(outAddr, 1, gridheight);
    gridheight++;

    // Next Button
    Button nextBtn = new Button("Next");
    nextBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {

            if (sceneCursor == scenes.size() - 1) {
                // Referenced output
                int output = (int) outputGroup.getSelectedToggle().getUserData();
                TxOutput refout = tx.getOutputs().get(output);

                // Create output for CPFP transaction
                TxOutput out = null;
                long outval = refout.getValue() - ((Double) feeSpin.getValue()).longValue();
                if (Utils.validateAddress(outAddr.getText())) {
                    byte[] decodedAddr = Utils.base58Decode(outAddr.getText());
                    boolean isP2SH = decodedAddr[0] == 0x00;
                    byte[] hash160 = Arrays.copyOfRange(decodedAddr, 1, decodedAddr.length - 4);
                    if (isP2SH) {
                        byte[] script = new byte[hash160.length + 3];
                        script[0] = (byte) 0xa9;
                        script[1] = (byte) 0x14;
                        System.arraycopy(hash160, 0, script, 2, hash160.length);
                        script[script.length - 1] = (byte) 0x87;
                        out = new TxOutput(outval, script);
                    } else {
                        byte[] script = new byte[hash160.length + 5];
                        script[0] = (byte) 0x76;
                        script[1] = (byte) 0xa9;
                        script[2] = (byte) 0x14;
                        System.arraycopy(hash160, 0, script, 3, hash160.length);
                        script[script.length - 2] = (byte) 0x88;
                        script[script.length - 1] = (byte) 0xac;
                        out = new TxOutput(outval, script);
                    }
                } else {
                    Alert alert = new Alert(Alert.AlertType.ERROR, "Invalid Address");
                    alert.showAndWait();
                    return;
                }

                // Create CPFP Transaction
                Transaction cpfpTx = new Transaction();
                TxInput in = new TxInput(tx.getHash(), output, new byte[] { (0x00) }, 0xffffffff);
                cpfpTx.addOutput(out);
                cpfpTx.addInput(in);

                // Create Scene
                Scene scene = new Scene(unsignedTxGrid(cpfpTx), 900, 500);
                scenes.add(scene);
                sceneCursor++;
                stage.setScene(scene);
            } else {
                sceneCursor++;
                stage.setScene(scenes.get(sceneCursor));
            }
        }
    });
    HBox btnHbox = new HBox(10);

    // Back Button
    Button backBtn = new Button("Back");
    backBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            sceneCursor--;
            stage.setScene(scenes.get(sceneCursor));
        }
    });
    btnHbox.getChildren().add(backBtn);
    btnHbox.getChildren().add(nextBtn);

    // Cancel Button
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setOnAction(cancelEvent);
    btnHbox.getChildren().add(cancelBtn);
    grid.add(btnHbox, 1, gridheight);

    return grid;
}