Java 类javafx.scene.control.SpinnerValueFactory.DoubleSpinnerValueFactory 实例源码

项目:redisfx    文件:DoubleSpinner.java   
private void checkEditorText() {
    DoubleSpinnerValueFactory valueFactory = (DoubleSpinnerValueFactory) getValueFactory();

    try {
        double value = Double.parseDouble(getEditor().getText());
        double min = valueFactory.getMin();
        double max = valueFactory.getMax();

        value = Math.min(Math.max(min, value), max);

        getEditor().setText(String.valueOf(value));
        valueFactory.setValue(value);
    } catch (NumberFormatException e) {
        getEditor().setText(String.valueOf(valueFactory.getValue()));
    }
}
项目:Map-Projections    文件:MapApplication.java   
private void revealParameters(Projection proj) {
    this.suppressListeners.set();
    final String[] paramNames = proj.getParameterNames();
    final double[][] paramValues = proj.getParameterValues();
    paramGrid.getChildren().clear();
    for (int i = 0; i < proj.getNumParameters(); i ++) {
        paramLabels[i].setText(paramNames[i]+":");
        paramSliders[i].setMin(paramValues[i][0]);
        paramSliders[i].setMax(paramValues[i][1]);
        paramSliders[i].setValue(paramValues[i][2]);
        final SpinnerValueFactory.DoubleSpinnerValueFactory paramSpinVF =
                (DoubleSpinnerValueFactory) paramSpinners[i].getValueFactory();
        paramSpinVF.setMin(paramValues[i][0]);
        paramSpinVF.setMax(paramValues[i][1]);
        paramSpinVF.setValue(paramValues[i][2]);
        final Tooltip tt = new Tooltip(
                "Change the "+paramNames[i]+" of the map (default is " + paramValues[i][2]+")");
        paramSliders[i].setTooltip(tt);
        paramSpinners[i].setTooltip(tt);
        paramGrid.addRow(i, paramLabels[i], paramSliders[i], paramSpinners[i]);
    }
    this.suppressListeners.clear();
}
项目:Simulizer    文件:DoubleControl.java   
public DoubleControl(Options o, DoubleSetting setting) {
    setSpacing(3);

    // Option Name
    Label title = new Label(setting.getHumanName());
    title.setFont(new Font(20));
    title.getStyleClass().add("title");
    getChildren().add(title);

    // Option Desc
    if (!setting.getDescription().equals("")) {
        Label desc = new Label(setting.getDescription());
        desc.getStyleClass().add("description");
        desc.setFont(new Font(14));
        desc.setWrapText(true);
        getChildren().add(desc);
    }

    // Option Value
    Spinner<Double> value = new Spinner<>();
    DoubleSpinnerValueFactory factory = new DoubleSpinnerValueFactory(0, 0);
    factory.setMax(setting.getHighBound());
    factory.setMin(setting.getLowBound());
    factory.setValue(setting.getValue());
    double step = (setting.getHighBound() - setting.getLowBound()) / 1000;
    factory.setAmountToStepBy(step <= 20 ? step : 20);
    value.setValueFactory(factory);
    value.setEditable(true);
    value.getStyleClass().add("value");
    value.setPrefWidth(Double.MAX_VALUE);
    value.valueProperty().addListener(e -> {
        if (setting.isValid(value.getValue())) {
            o.madeChanges();
            setting.setValue(value.getValue());
        } else
            value.getValueFactory().setValue(setting.getValue());
    });
    getChildren().add(value);
}
项目:JttDesktop    文件:DualPropertiesPanelTest.java   
@Test public void positionSpinnerShouldBeBound(){
   DoubleSpinnerValueFactory factory = ( DoubleSpinnerValueFactory )systemUnderTest.positionSpinner().getValueFactory();
   assertThat( 
            factory.getMin() ,
            is( closeTo( DualPropertiesPanel.MINIMUM_POSITION, precision() ) ) 
   );
   assertThat( 
            factory.getMax() ,
            is( closeTo( DualPropertiesPanel.MAXIMUM_POSITION, precision() ) ) 
   );
   assertThat( 
            factory.getAmountToStepBy() ,
            is( closeTo( DualPropertiesPanel.POSITION_INTERVAL, precision() ) ) 
   );
}
项目:JttDesktop    文件:DoublePropertySpinnerTest.java   
@Before public void initialiseSystemUnderTest(){
   TestApplication.startPlatform();
   PlatformImpl.runAndWait( () -> {
      systemUnderTest = new DoublePropertySpinner();
      systemUnderTest.setValueFactory( new DoubleSpinnerValueFactory( 0, 100 ) );
   } );
}
项目:3DScanner.RaspberryPi    文件:UIController.java   
private void setUpSpinnerDouble(Spinner<Double> spinner, int pos, double min, double max, double increment, double savedSet){
    DoubleSpinnerValueFactory oswFactory = new SpinnerValueFactory.DoubleSpinnerValueFactory(min, max, savedSet, increment);
    spinner.setValueFactory(oswFactory);
    spinner.valueProperty().addListener((obs, oldValue, newValue) -> {
    System.out.println("New value: "+newValue);
    // hier könnte es rundungsfehler von double auf Number geben
    setValueSettings(pos, newValue);
    });

}
项目:fx-log    文件:PreferencesController.java   
private void configureDoubleSpinner(Spinner<Double> spinner, Property<Double> prop, double min, double max) {
    DoubleSpinnerValueFactory factory = new DoubleSpinnerValueFactory(min, max);
    factory.valueProperty().bindBidirectional(prop);
    spinner.setValueFactory(factory);
}