javafx.util.converter.NumberStringConverter Java Examples
The following examples show how to use
javafx.util.converter.NumberStringConverter.
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: DoubleComponent.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
public DoubleComponent(int inputsize, Double minimum, Double maximum, NumberFormat format) { this.minimum = minimum; this.maximum = maximum; textField = new TextField(); textField.setTextFormatter(new TextFormatter<>(new NumberStringConverter(format))); textField.setPrefWidth(inputsize); // Add an input verifier if any bounds are specified. if (minimum != null || maximum != null) { // textField.setInputVerifier(new MinMaxVerifier()); } getChildren().add(textField); }
Example #2
Source File: MsSpectrumLayersDialogController.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public void initialize() { final ObservableList<MsSpectrumType> renderingChoices = FXCollections.observableArrayList(MsSpectrumType.CENTROIDED, MsSpectrumType.PROFILE); renderingTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(renderingChoices)); colorColumn.setCellFactory(column -> new ColorTableCell<MsSpectrumDataSet>(column)); lineThicknessColumn .setCellFactory(column -> new SpinnerTableCell<MsSpectrumDataSet>(column, 1, 5)); intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn( new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat()))); showDataPointsColumn .setCellFactory(column -> new CheckBoxTableCell<MsSpectrumDataSet, Boolean>() { { tableRowProperty().addListener(e -> { TableRow<?> row = getTableRow(); if (row == null) return; MsSpectrumDataSet dataSet = (MsSpectrumDataSet) row.getItem(); if (dataSet == null) return; disableProperty() .bind(dataSet.renderingTypeProperty().isEqualTo(MsSpectrumType.CENTROIDED)); }); } }); }
Example #3
Source File: FormDemo.java From tornadofx-controls with Apache License 2.0 | 5 votes |
public void start(Stage stage) throws Exception { Customer customer = Customer.createSample(555); DirtyState dirtyState = new DirtyState(customer); Form form = new Form(); form.setPadding(new Insets(20)); Fieldset contactInfo = form.fieldset("Contact Information"); TextField idInput = new TextField(); idInput.textProperty().bindBidirectional(customer.idProperty(), new NumberStringConverter()); contactInfo.field("Id", idInput); TextField usernameInput = new TextField(); usernameInput.textProperty().bindBidirectional(customer.usernameProperty()); contactInfo.field("Username", usernameInput); TextField zipInput = new TextField(); zipInput.textProperty().bindBidirectional(customer.zipProperty()); zipInput.setMinWidth(80); zipInput.setMaxWidth(80); TextField cityInput = new TextField(); cityInput.textProperty().bindBidirectional(customer.cityProperty()); contactInfo.field("Zip/City", zipInput, cityInput); Button saveButton = new Button("Save"); saveButton.disableProperty().bind(dirtyState.not()); saveButton.setOnAction(event -> dirtyState.reset()); Button undoButton = new Button("Undo"); undoButton.setOnAction(event -> dirtyState.undo()); undoButton.visibleProperty().bind(dirtyState); contactInfo.field(saveButton, undoButton); stage.setScene(new Scene(form, 400,-1)); stage.show(); }
Example #4
Source File: PieSkin.java From WorkbenchFX with Apache License 2.0 | 5 votes |
@Override public void setupBindings() { pieSlice.lengthProperty().bind( Bindings.min(getSkinnable().angleProperty().multiply(-1.0), 0.0)); valueField.textProperty().bindBidirectional(getSkinnable().valueProperty(), new NumberStringConverter()); }
Example #5
Source File: EditAxis.java From chart-fx with Apache License 2.0 | 5 votes |
/** * Creates the header for the Axis Editor popup, allowing to configure axis label and unit * * @param axis The axis to be edited * @return pane containing label, label editor and unit editor */ private Node getLabelEditor(final Axis axis, final boolean isHorizontal) { final GridPane header = new GridPane(); header.setAlignment(Pos.BASELINE_LEFT); final TextField axisLabelTextField = new TextField(axis.getName()); axisLabelTextField.textProperty().bindBidirectional(axis.nameProperty()); header.addRow(0, new Label(" axis label: "), axisLabelTextField); final TextField axisUnitTextField = new TextField(axis.getUnit()); axisUnitTextField.setPrefWidth(50.0); axisUnitTextField.textProperty().bindBidirectional(axis.unitProperty()); header.addRow(isHorizontal ? 0 : 1, new Label(" unit: "), axisUnitTextField); final TextField unitScaling = new TextField(); unitScaling.setPrefWidth(80.0); final CheckBox autoUnitScaling = new CheckBox(" auto"); if (axis instanceof DefaultNumericAxis) { autoUnitScaling.selectedProperty() .bindBidirectional(((DefaultNumericAxis) axis).autoUnitScalingProperty()); unitScaling.textProperty().bindBidirectional(((DefaultNumericAxis) axis).unitScalingProperty(), new NumberStringConverter(new DecimalFormat("0.0####E0"))); unitScaling.disableProperty().bind(autoUnitScaling.selectedProperty()); } else { // TODO: consider adding an interface on whether // autoUnitScaling is editable autoUnitScaling.setDisable(true); unitScaling.setDisable(true); } final HBox unitScalingBox = new HBox(unitScaling, autoUnitScaling); unitScalingBox.setAlignment(Pos.BASELINE_LEFT); header.addRow(isHorizontal ? 0 : 2, new Label(" unit scale:"), unitScalingBox); return header; }
Example #6
Source File: ExportCOCOController.java From OpenLabeler with Apache License 2.0 | 5 votes |
private void bindProperties() { ObjectMapper mapper = AppUtils.createJSONMapper(); try { if (!Settings.getToolCOCOJson().isBlank()) { coco = mapper.readValue(Settings.getToolCOCOJson(), COCO.class); } if (coco == null) { coco = new COCO(); } // Fields that can only accept numbers txtInfoYear.setTextFormatter(AppUtils.createNumberTextFormatter()); txtLicenseId.setTextFormatter(AppUtils.createNumberTextFormatter()); // COCO info section Bindings.bindBidirectional(txtInfoYear.textProperty(), coco.info.yearProperty, new NumberStringConverter("#")); txtInfoVersion.textProperty().bindBidirectional(coco.info.versionProperty); txtInfoDescription.textProperty().bindBidirectional(coco.info.descriptionProperty); txtInfoContributor.textProperty().bindBidirectional(coco.info.contributorProperty); txtInfoUrl.textProperty().bindBidirectional(coco.info.urlProperty); datePicker.valueProperty().bindBidirectional(coco.info.dateCreatedProperty); // COCO images rbUsePathInXml.selectedProperty().bindBidirectional(coco.usePathInXmlProperty); rbNameAsId.selectedProperty().bindBidirectional(coco.nameAsIdProperty); dirMedia.disableProperty().bindBidirectional(coco.usePathInXmlProperty); // COCO license section Bindings.bindBidirectional(txtLicenseId.textProperty(), coco.license.idProperty, new NumberStringConverter("#")); txtLicenseName.textProperty().bindBidirectional(coco.license.nameProperty); txtLicenseUrl.textProperty().bindBidirectional(coco.license.urlProperty); // Output chkFormatJSON.selectedProperty().bindBidirectional(coco.formatJSONProperty); fileOutput.textProperty().bindBidirectional(coco.outputProperty); } catch (Exception ex) { LOG.log(Level.WARNING, "Unable to initialize COCO info section", ex); } }
Example #7
Source File: ProductIonFilterSetHighlightDialog.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public ProductIonFilterSetHighlightDialog(@Nonnull Stage parent, ProductIonFilterPlot plot, String command) { this.desktop = MZmineCore.getDesktop(); this.plot = plot; this.rangeType = command; mainPane = new DialogPane(); mainScene = new Scene(mainPane); mainScene.getStylesheets() .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets()); setScene(mainScene); initOwner(parent); String title = "Highlight "; if (command.equals("HIGHLIGHT_PRECURSOR")) { title += "precursor m/z range"; axis = plot.getXYPlot().getDomainAxis(); } else if (command.equals("HIGHLIGHT_NEUTRALLOSS")) { title += "neutral loss m/z range"; axis = plot.getXYPlot().getRangeAxis(); } setTitle(title); Label lblMinMZ = new Label("Minimum m/z"); Label lblMaxMZ = new Label("Maximum m/z"); NumberStringConverter converter = new NumberStringConverter(); fieldMinMZ = new TextField(); fieldMinMZ.setTextFormatter(new TextFormatter<>(converter)); fieldMaxMZ = new TextField(); fieldMaxMZ.setTextFormatter(new TextFormatter<>(converter)); pnlLabelsAndFields = new GridPane(); pnlLabelsAndFields.setHgap(5); pnlLabelsAndFields.setVgap(10); int row = 0; pnlLabelsAndFields.add(lblMinMZ, 0, row); pnlLabelsAndFields.add(fieldMinMZ, 1, row); row++; pnlLabelsAndFields.add(lblMaxMZ, 0, row); pnlLabelsAndFields.add(fieldMaxMZ, 1, row); // Create buttons mainPane.getButtonTypes().add(ButtonType.OK); mainPane.getButtonTypes().add(ButtonType.CANCEL); btnOK = (Button) mainPane.lookupButton(ButtonType.OK); btnOK.setOnAction(e -> { if (highlightDataPoints()) { hide(); } }); btnCancel = (Button) mainPane.lookupButton(ButtonType.CANCEL); btnCancel.setOnAction(e -> hide()); mainPane.setContent(pnlLabelsAndFields); sizeToScene(); centerOnScreen(); setResizable(false); }
Example #8
Source File: CombinedModuleSetHighlightDialog.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public CombinedModuleSetHighlightDialog(@Nonnull Stage parent, @Nonnull CombinedModulePlot plot, @Nonnull String command) { desktop = MZmineCore.getDesktop(); this.plot = plot; rangeType = command; mainPane = new DialogPane(); mainScene = new Scene(mainPane); // Use main CSS mainScene.getStylesheets() .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets()); setScene(mainScene); initOwner(parent); String title = "Highlight "; if (command.equals("HIGHLIGHT_PRECURSOR")) { title += "precursor m/z range"; axis = plot.getXYPlot().getDomainAxis(); } else if (command.equals("HIGHLIGHT_NEUTRALLOSS")) { title += "neutral loss m/z range"; axis = plot.getXYPlot().getRangeAxis(); } setTitle(title); Label lblMinMZ = new Label("Minimum m/z"); Label lblMaxMZ = new Label("Maximum m/z"); NumberStringConverter converter = new NumberStringConverter(); fieldMinMZ = new TextField(); fieldMinMZ.setTextFormatter(new TextFormatter<>(converter)); fieldMaxMZ = new TextField(); fieldMaxMZ.setTextFormatter(new TextFormatter<>(converter)); pnlLabelsAndFields = new GridPane(); pnlLabelsAndFields.setHgap(5); pnlLabelsAndFields.setVgap(10); int row = 0; pnlLabelsAndFields.add(lblMinMZ, 0, row); pnlLabelsAndFields.add(fieldMinMZ, 1, row); row++; pnlLabelsAndFields.add(lblMaxMZ, 0, row); pnlLabelsAndFields.add(fieldMaxMZ, 1, row); // Create buttons mainPane.getButtonTypes().add(ButtonType.OK); mainPane.getButtonTypes().add(ButtonType.CANCEL); btnOK = (Button) mainPane.lookupButton(ButtonType.OK); btnOK.setOnAction(e -> { if (highlightDataPoints()) { hide(); } }); btnCancel = (Button) mainPane.lookupButton(ButtonType.CANCEL); btnCancel.setOnAction(e -> hide()); mainPane.setContent(pnlLabelsAndFields); sizeToScene(); centerOnScreen(); setResizable(false); }
Example #9
Source File: PathfinderV1VarsController.java From Motion_Profile_Generator with MIT License | 4 votes |
/************************************************************************** * initialize * Setup gui stuff here. *************************************************************************/ @FXML private void initialize() { sharedVars = SharedGeneratorVars.getInstance(); vars = PfV1GeneratorVars.getInstance(); // Populate ChoiceBox's choDriveBase.getItems().setAll( DriveBase.values() ); choFitMethod.getItems().setAll( PfV1GeneratorVars.FitMethod.values() ); choUnits.getItems().setAll( Units.values() ); // Formats number typed into TextFields UnaryOperator<TextFormatter.Change> filter = t -> { if( t.isReplaced() ) // If new text isn't a digit if( t.getText().matches("[^0-9]") ) { // Keep original text t.setText( t.getControlText().substring( t.getRangeStart(), t.getRangeEnd() ) ); } if( t.isAdded() ) { // If a period is already present. if ( t.getControlText().contains(".") ) { // If new text isn't a digit if( t.getText().matches("[^0-9]") ) { t.setText(""); } } // If we are adding a period to an empty field, prepend it with a zero. else if( ( t.getControlNewText().length() == 1 ) && ( t.getControlNewText().matches( "\\.") ) ) { t.setText("0."); //t.setCaretPosition( 2 ); } // If new text isn't a digit or a period else if ( t.getText().matches("[^0-9\\.]") ) { t.setText(""); } } return t; }; // Setup formatter to only allow doubles to be typed into these TextFields txtTimeStep .setTextFormatter( new TextFormatter<>( filter ) ); txtVelocity .setTextFormatter( new TextFormatter<>( filter ) ); txtAcceleration .setTextFormatter( new TextFormatter<>( filter ) ); txtJerk .setTextFormatter( new TextFormatter<>( filter ) ); txtWheelBaseW .setTextFormatter( new TextFormatter<>( filter ) ); txtWheelBaseD .setTextFormatter( new TextFormatter<>( filter ) ); // Converts formatted string in TextField to format of bounded property. StringConverter<Number> converter = new NumberStringConverter(); // Setup Bindings choFitMethod .valueProperty().bindBidirectional( vars.fitMethodProperty() ); choDriveBase .valueProperty().bindBidirectional( sharedVars.driveBaseProperty() ); choUnits .valueProperty().bindBidirectional( sharedVars.unitProperty() ); txtTimeStep .textProperty().bindBidirectional( sharedVars.timeStepProperty(), converter ); txtWheelBaseW .textProperty().bindBidirectional( sharedVars.wheelBaseWProperty(), converter ); txtWheelBaseD .textProperty().bindBidirectional( sharedVars.wheelBaseDProperty(), converter ); txtVelocity .textProperty().bindBidirectional( vars.velocityProperty(), converter ); txtAcceleration .textProperty().bindBidirectional( vars.accelProperty(), converter ); txtJerk .textProperty().bindBidirectional( vars.jerkProperty(), converter ); // Disable WheelBaseD for Tank DriveBase sharedVars.driveBaseProperty().addListener( ( o, oldValue, newValue ) -> { boolean dis = newValue == DriveBase.TANK; lblWheelBaseD.disableProperty().setValue( dis ); txtWheelBaseD.disableProperty().setValue( dis ); }); }
Example #10
Source File: DoubleRangeComponent.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public void setNumberFormat(NumberFormat format) { this.format = format; this.formatConverter = new NumberStringConverter(format); minTxtField.setTextFormatter(new TextFormatter<Number>(formatConverter)); maxTxtField.setTextFormatter(new TextFormatter<Number>(formatConverter)); }
Example #11
Source File: ManualZoomDialog.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
@FXML public void initialize() { NumberFormat xAxisFormatter; if (xAxis instanceof NumberAxis) xAxisFormatter = ((NumberAxis) xAxis).getNumberFormatOverride(); else xAxisFormatter = NumberFormat.getNumberInstance(); NumberFormat yAxisFormatter; if (yAxis instanceof NumberAxis) yAxisFormatter = ((NumberAxis) yAxis).getNumberFormatOverride(); else yAxisFormatter = NumberFormat.getNumberInstance(); xAxisLabel.setText(xAxis.getLabel()); yAxisLabel.setText(yAxis.getLabel()); xAxisRangeMin.setTextFormatter(new TextFormatter<>(new NumberStringConverter(xAxisFormatter))); xAxisRangeMin.disableProperty().bind(xAxisAutoRange.selectedProperty()); xAxisRangeMin.setText(String.valueOf(xAxis.getLowerBound())); xAxisRangeMax.setTextFormatter(new TextFormatter<>(new NumberStringConverter(xAxisFormatter))); xAxisRangeMax.disableProperty().bind(xAxisAutoRange.selectedProperty()); xAxisRangeMax.setText(String.valueOf(xAxis.getUpperBound())); xAxisAutoRange.setSelected(xAxis.isAutoRange()); yAxisRangeMin.setTextFormatter(new TextFormatter<>(new NumberStringConverter(yAxisFormatter))); yAxisRangeMin.setText(String.valueOf(yAxis.getLowerBound())); yAxisRangeMin.disableProperty().bind(yAxisAutoRange.selectedProperty()); yAxisRangeMax.setTextFormatter(new TextFormatter<>(new NumberStringConverter(yAxisFormatter))); yAxisRangeMax.setText(String.valueOf(yAxis.getUpperBound())); yAxisRangeMax.disableProperty().bind(yAxisAutoRange.selectedProperty()); yAxisAutoRange.setSelected(yAxis.isAutoRange()); xAxisTickSize.disableProperty().bind(xAxisAutoTickSize.selectedProperty()); xAxisTickSize.setText(String.valueOf(xAxis.getTickUnit().getSize())); xAxisAutoTickSize.setSelected(xAxis.isAutoTickUnitSelection()); yAxisTickSize.setTextFormatter(new TextFormatter<>(new NumberStringConverter(yAxisFormatter))); yAxisTickSize.setText(String.valueOf(yAxis.getTickUnit().getSize())); yAxisTickSize.disableProperty().bind(yAxisAutoTickSize.selectedProperty()); yAxisAutoTickSize.setSelected(yAxis.isAutoTickUnitSelection()); }
Example #12
Source File: NumberValidator.java From JFoenix with Apache License 2.0 | 4 votes |
public NumberValidator(NumberStringConverter numberStringConverter) { this.numberStringConverter = numberStringConverter; }
Example #13
Source File: NumberValidator.java From JFoenix with Apache License 2.0 | 4 votes |
public NumberValidator(String message, NumberStringConverter numberStringConverter) { super(message); this.numberStringConverter = numberStringConverter; }
Example #14
Source File: NumberValidator.java From JFoenix with Apache License 2.0 | 4 votes |
public NumberStringConverter getNumberStringConverter() { return numberStringConverter; }
Example #15
Source File: NumberValidator.java From JFoenix with Apache License 2.0 | 4 votes |
public void setNumberStringConverter(NumberStringConverter numberStringConverter) { this.numberStringConverter = numberStringConverter; }
Example #16
Source File: ConnectViewPresenter.java From jfxvnc with Apache License 2.0 | 4 votes |
@Override public void initialize(URL location, ResourceBundle resources) { ProtocolConfiguration prop = con.getConfiguration(); historyList.setItems(ctx.getHistory()); clearBtn.setOnAction(a -> historyList.getItems().clear()); securityCombo.getItems().addAll(FXCollections.observableArrayList(SecurityType.NONE, SecurityType.VNC_Auth)); securityCombo.getSelectionModel().selectedItemProperty().addListener((l, a, b) -> { prop.securityProperty().set(b != null ? b : SecurityType.UNKNOWN); }); pwdField.disableProperty().bind(Bindings.equal(SecurityType.NONE, securityCombo.getSelectionModel().selectedItemProperty())); prop.hostProperty().bindBidirectional(ipField.textProperty()); StringConverter<Number> converter = new NumberStringConverter("#"); Bindings.bindBidirectional(portField.textProperty(), prop.portProperty(), converter); prop.passwordProperty().bindBidirectional(pwdField.textProperty()); prop.sslProperty().bindBidirectional(sslCB.selectedProperty()); prop.sharedProperty().bindBidirectional(sharedCB.selectedProperty()); forceRfb33CB.setSelected(prop.versionProperty().get() == ProtocolVersion.RFB_3_3); forceRfb33CB.selectedProperty().addListener((l, a, b) -> prop.versionProperty().set(b ? ProtocolVersion.RFB_3_3 : ProtocolVersion.RFB_3_8)); listeningCB.selectedProperty().bindBidirectional(con.listeningModeProperty()); Bindings.bindBidirectional(listeningPortField.textProperty(), con.listeningPortProperty(), converter); listeningPortField.disableProperty().bind(listeningCB.selectedProperty().not()); prop.rawEncProperty().bindBidirectional(rawCB.selectedProperty()); prop.copyRectEncProperty().bindBidirectional(copyrectCB.selectedProperty()); prop.hextileEncProperty().bindBidirectional(hextileCB.selectedProperty()); prop.clientCursorProperty().bindBidirectional(cursorCB.selectedProperty()); prop.desktopSizeProperty().bindBidirectional(desktopCB.selectedProperty()); prop.zlibEncProperty().bindBidirectional(zlibCB.selectedProperty()); portField.textProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null && !newValue.isEmpty() && !newValue.matches("[0-9]+")) { if (!oldValue.matches("[0-9]+")) { ((StringProperty) observable).setValue(""); return; } ((StringProperty) observable).setValue(oldValue); } }); con.connectingProperty().addListener((l, a, b) -> Platform.runLater(() -> ipField.getParent().setDisable(b))); ctx.bind(ipField.textProperty(), "hostField"); ctx.bind(portField.textProperty(), "portField"); ctx.bind(userField.textProperty(), "userField"); ctx.bind(pwdField.textProperty(), "pwdField"); ctx.bind(securityCombo, "authType"); ctx.bind(sslCB.selectedProperty(), "useSSL"); ctx.bind(sharedCB.selectedProperty(), "useSharedView"); ctx.bind(forceRfb33CB.selectedProperty(), "forceRfb33"); ctx.bind(listeningCB.selectedProperty(), "listeningMode"); ctx.bind(listeningPortField.textProperty(), "listeningPortField"); ctx.bind(rawCB.selectedProperty(), "useRaw"); ctx.bind(copyrectCB.selectedProperty(), "useCopyRect"); ctx.bind(hextileCB.selectedProperty(), "useHextile"); ctx.bind(cursorCB.selectedProperty(), "useCursor"); ctx.bind(desktopCB.selectedProperty(), "useDesktopSize"); ctx.bind(zlibCB.selectedProperty(), "useZlib"); if (securityCombo.getSelectionModel().getSelectedIndex() < 0) { securityCombo.getSelectionModel().select(SecurityType.VNC_Auth); } historyList.getSelectionModel().selectedItemProperty().addListener((l, a, b) -> updateData(b)); con.connectInfoProperty().addListener((l, a, b) -> Platform.runLater(() -> addToHistory(b))); }
Example #17
Source File: ChromatogramLayersDialogController.java From old-mzmine3 with GNU General Public License v2.0 | 3 votes |
public void initialize() { colorColumn.setCellFactory(column -> new ColorTableCell<ChromatogramPlotDataSet>(column)); lineThicknessColumn .setCellFactory(column -> new SpinnerTableCell<ChromatogramPlotDataSet>(column, 1, 5)); intensityScaleColumn.setCellFactory(TextFieldTableCell.forTableColumn( new NumberStringConverter(MZmineCore.getConfiguration().getIntensityFormat()))); showDataPointsColumn .setCellFactory(column -> new CheckBoxTableCell<ChromatogramPlotDataSet, Boolean>()); }