javafx.util.converter.DoubleStringConverter Java Examples

The following examples show how to use javafx.util.converter.DoubleStringConverter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InterpolatingLookupPaintScaleSetupDialogController.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
@FXML
private void initialize() {

    tableLookupValues.setEditable(true);
    valueColumn.setCellValueFactory(cell-> new ReadOnlyObjectWrapper<>(cell.getValue().getKey()));
    valueColumn.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));
    valueColumn.setOnEditCommit(event -> {
        Double newKey = event.getNewValue();
        Double oldKey = event.getOldValue();
        lookupTable.put(newKey,lookupTable.get(oldKey));
        lookupTable.remove(oldKey);
        updateOBList(lookupTable);
    });

    colorColumn.setCellValueFactory(cell-> new ReadOnlyObjectWrapper<>(cell.getValue().getValue()));
    colorColumn.setCellFactory(column -> new ColorTableCell<InterpolatingLookupPaintScaleRow>(column));
    colorColumn.setOnEditCommit(event -> {
        Color newColor = event.getNewValue();
        Double key =  event.getRowValue().getKey();
        lookupTable.put(key,newColor);
        updateOBList(lookupTable);
    });

}
 
Example #2
Source File: TableViewer.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
private void updateEditableState() {
    this.setEditable(false);
    this.setOnEditCommit(null);
    if (!(ds instanceof EditableDataSet) || (type != ColumnType.X && type != ColumnType.Y)) {
        // can edit only 'EditableDataSet's and (X or Y) columns
        return;
    }
    final EditableDataSet editableDataSet = (EditableDataSet) ds;
    final EditConstraints editConstraints = editableDataSet.getEditConstraints();

    if (type == ColumnType.X && editConstraints != null && !editConstraints.isEditable(DIM_X)) {
        // editing of x coordinate is excluded
        return;
    }
    if (type == ColumnType.Y && editConstraints != null && !editConstraints.isEditable(DIM_Y)) {
        // editing of y coordinate is excluded
        return;
    }

    // column can theoretically be edited as long as 'canChange(index)' is true for the selected index
    // and isAcceptable(index, double, double) is also true
    this.setEditable(true);
    this.setCellFactory(TextFieldTableCell.forTableColumn(new DoubleStringConverter()));

    this.setOnEditCommit(e -> {
        DataSetsRow rowValue = e.getRowValue();
        if (rowValue == null) {
            LOGGER.atError().log("DataSet row should not be null");
            return;
        }
        final int row = rowValue.getRow();
        final double oldX = editableDataSet.get(DIM_X, row);
        final double oldY = editableDataSet.get(DIM_Y, row);

        if (editConstraints != null && !editConstraints.canChange(row)) {
            // may not edit value, revert to old value (ie. via rewriting old value)
            editableDataSet.set(row, oldX, oldY);
            return;
        }

        final double newVal = e.getNewValue();
        switch (type) {
        case X:
            if (editConstraints != null && !editConstraints.isAcceptable(row, newVal, oldY)) {
                // may not edit x
                editableDataSet.set(row, oldX, oldY);
                break;
            }
            editableDataSet.set(row, newVal, oldY);
            break;
        case Y:
            if (editConstraints != null && !editConstraints.isAcceptable(row, oldX, newVal)) {
                // may not edit y
                editableDataSet.set(row, oldX, oldY);
                break;
            }
            editableDataSet.set(row, oldX, newVal);
            break;
        default:
            // Errors are not editable, as there is no interface for manipulating them
            editableDataSet.set(row, oldX, oldY);
            break;
        }
    });
}
 
Example #3
Source File: AddWaypointDialogController.java    From Motion_Profile_Generator with MIT License 4 votes vote down vote up
@FXML
private void initialize() {
    txtWX.setTextFormatter( new TextFormatter<>( new DoubleStringConverter() ) );
    txtWY.setTextFormatter( new TextFormatter<>( new DoubleStringConverter() ) );
    txtWA.setTextFormatter( new TextFormatter<>( new DoubleStringConverter() ) );
}
 
Example #4
Source File: FormFxmlDemo.java    From tornadofx-controls with Apache License 2.0 4 votes vote down vote up
public void initialize(URL location, ResourceBundle resources) {
    wrapAt.textProperty().bindBidirectional(responsiveFieldset.wrapWidthProperty(), new DoubleStringConverter());
}