Java Code Examples for javafx.scene.control.Slider#setMajorTickUnit()

The following examples show how to use javafx.scene.control.Slider#setMajorTickUnit() . 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: ContentZoomPane.java    From JavaFXSmartGraph with MIT License 6 votes vote down vote up
private Node createSlider() {

        Slider slider = new Slider(MIN_SCALE, MAX_SCALE, MIN_SCALE);
        slider.setOrientation(Orientation.VERTICAL);
        slider.setShowTickMarks(true);
        slider.setShowTickLabels(true);
        slider.setMajorTickUnit(SCROLL_DELTA);
        slider.setMinorTickCount(1);
        slider.setBlockIncrement(0.125f);
        slider.setSnapToTicks(true);

        Text label = new Text("Zoom");

        VBox paneSlider = new VBox(slider, label);

        paneSlider.setPadding(new Insets(10, 10, 10, 10));
        paneSlider.setSpacing(10);

        slider.valueProperty().bind(this.scaleFactorProperty());

        return paneSlider;
    }
 
Example 2
Source File: ColorPicker.java    From mcaselector with MIT License 5 votes vote down vote up
private Slider createSlider(int min, int max, int steps, int init) {
	Slider slider = new Slider(min, max, init);
	slider.setMajorTickUnit(steps);
	slider.setMinorTickCount(0);
	slider.setBlockIncrement(steps);
	return slider;
}
 
Example 3
Source File: SliderSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public SliderSample() {
    VBox root = new VBox();
    Slider slider = new Slider();
    slider.setMin(0);
    slider.setMax(100);
    slider.setValue(40);
    slider.setShowTickLabels(true);
    slider.setShowTickMarks(true);
    slider.setMajorTickUnit(50);
    slider.setMinorTickCount(5);
    slider.setBlockIncrement(10);
    root.getChildren().addAll(slider, new Button("Click me!!"));
    getChildren().add(root);
}
 
Example 4
Source File: YOLOApp.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
private HBox buildBottomPane() {
	sldThreshold = new Slider(0.1f, 1.0f, DEFAULT_THRESHOLD);
	sldThreshold.setShowTickLabels(true);
	sldThreshold.setMajorTickUnit(0.1);
	sldThreshold.setBlockIncrement(0.01);
	sldThreshold.setShowTickMarks(true);
	sldThreshold.valueProperty().addListener(v -> update());
	MenuButton mbLoadImage = new MenuButton("Load Image");
	MenuItem mnLocalImage = new MenuItem("From Computer");
	mbLoadImage.getItems().add(mnLocalImage);
	MenuItem mnUrl = new MenuItem("Enter URL");
	mnUrl.setOnAction(e -> {
		Optional<String> imgUrl = AppUtils.askInputFromUser("Enter an URL", "Enter an image URL:");
		AppUtils.doBlockingAsyncWork(scene, () -> {
			imgUrl.ifPresent(this::checkAndLoadImage);
		});

	});
	mnLocalImage.setOnAction(e -> {
		FileChooser fc = new FileChooser();
		fc.getExtensionFilters().add(new ExtensionFilter("PNG Files", "*.png"));
		fc.getExtensionFilters().add(new ExtensionFilter("JPG Files", "*.jpg"));
		File selectedFile = fc.showOpenDialog(sldThreshold.getScene().getWindow());
		if (selectedFile != null) {
			checkAndLoadImage(selectedFile);
		}
	});
	mbLoadImage.getItems().add(mnUrl);
	HBox hbBottom = new HBox(10, new Label("Threshold: "), sldThreshold, mbLoadImage);
	hbBottom.setAlignment(Pos.CENTER);
	return hbBottom;
}
 
Example 5
Source File: SettingsPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public SliderEditor(Option<Number> option, int min, int max) {
    slider = new Slider(min, max, option.valueProperty().getValue().doubleValue());
    slider.setSnapToTicks(true);
    slider.setMajorTickUnit(1);
    slider.setMinorTickCount(0);
    valueProperty().bindBidirectional(option.valueProperty());
}
 
Example 6
Source File: SettingsPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public SliderEditor(Option<Number> option, int min, int max) {
    slider = new Slider(min, max, option.valueProperty().getValue().doubleValue());
    slider.setSnapToTicks(true);
    slider.setMajorTickUnit(1);
    slider.setMinorTickCount(0);
    valueProperty().bindBidirectional(option.valueProperty());
}
 
Example 7
Source File: SettingsPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public SliderEditor(Option<Number> option, int min, int max) {
    slider = new Slider(min, max, option.valueProperty().getValue().doubleValue());
    slider.setSnapToTicks(true);
    slider.setMajorTickUnit(1);
    slider.setMinorTickCount(0);
    valueProperty().bindBidirectional(option.valueProperty());
}
 
Example 8
Source File: View.java    From SynchronizeFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create an instance of the View.
 */
public View() {
    setSpacing(20);
    setPadding(new Insets(20));

    final Text header = new Text("SynchronizeFX Example");
    header.setFill(Color.DIMGRAY);
    header.setStyle("-fx-font-size:24");

    slider = new Slider();
    slider.setMin(0);
    slider.setMax(100);
    slider.setShowTickLabels(true);
    slider.setShowTickMarks(true);
    slider.setMajorTickUnit(20);
    slider.setMinorTickCount(5);
    slider.setSnapToTicks(true);


    final Label valueLabel = new Label();
    valueLabel.setTextFill(Color.DIMGRAY);
    valueLabel.setStyle("-fx-font-size:15");

    valueLabel.textProperty()
            .bind(Bindings.format("Current Value: %1$.1f",
                    slider.valueProperty()));

    getChildren().addAll(header, slider, valueLabel);
}
 
Example 9
Source File: SnowFlakeSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    final XYChart chart1 = getChristmasChart(false);
    final XYChart chart2 = getChristmasChart(true);

    final CheckBox cbTransposed = new CheckBox("flip tree");
    cbTransposed.setTooltip(new Tooltip("press to flip tree"));
    cbTransposed.setGraphic(new Glyph(FONT_AWESOME, FONT_SYMBOL_TRANSPOSE).size(FONT_SIZE));
    cbTransposed.selectedProperty().bindBidirectional(flipProperty);

    final CheckBox cbSnow = new CheckBox("snow");
    cbSnow.setTooltip(new Tooltip("press to switch on/off snow"));
    cbSnow.setGraphic(new Glyph(FONT_AWESOME, FONT_SYMBOL_SNOW).size(FONT_SIZE));
    cbSnow.selectedProperty().bindBidirectional(snowProperty);

    Slider nFlakeSpeed = new Slider(0.0, 2, velocityProperty.get());
    nFlakeSpeed.setBlockIncrement(0.1);
    nFlakeSpeed.setMajorTickUnit(0.1);
    velocityProperty.bind(nFlakeSpeed.valueProperty());

    Spinner<Integer> nSnowFlakes = new Spinner<>(10, 1000, 200, numberOfFlakesProperty.get());
    numberOfFlakesProperty.bind(nSnowFlakes.valueProperty());

    Spinner<Double> meanFlakeSize = new Spinner<>(0.1, 20.0, meanSizeProperty.get(), 0.1);
    meanSizeProperty.bind(meanFlakeSize.valueProperty());

    Spinner<Double> rmsFlakeSize = new Spinner<>(0.1, 20.0, rmsSizeProperty.get(), 0.1);
    rmsSizeProperty.bind(rmsFlakeSize.valueProperty());

    final ToolBar toolBar = new ToolBar(cbTransposed, cbSnow, new Label("speed:"), nFlakeSpeed, //
            new Label("n-flakes:"), nSnowFlakes, new Label("mean-size:"), meanFlakeSize, //
            new Label("rms-size:"), rmsFlakeSize);
    final HBox hBox = new HBox(chart1, chart2);

    VBox.setVgrow(hBox, Priority.ALWAYS);
    final Scene scene = new Scene(new VBox(toolBar, hBox), WIDTH, HEIGHT);

    primaryStage.setTitle(SnowFlakeSample.class.getSimpleName());
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.setScene(scene);
    primaryStage.show();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.atDebug().log("scene initialised");
    }
}
 
Example 10
Source File: SliderDemo.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void start(final Stage stage)
{
    final Slider slider = new Slider();
    slider.setOrientation(Orientation.HORIZONTAL);
    slider.setShowTickLabels(true);
    slider.setShowTickMarks(true);
    slider.setMajorTickUnit(20.0);
    slider.setMin(-100.0);
    slider.setMax(100.0);
    slider.setValue(10.0);

    slider.valueProperty().addListener((observable, old, value)->
    {
        System.out.println("Value: " + value);
    });

    final SliderMarkers markers = new SliderMarkers(slider);
    markers.setAlarmMarkers(-100, -10, 70, 90);

    final String font = "-fx-font-size: 30px";
    slider.setStyle(font);
    markers.setStyle(font);

    final GridPane layout = new GridPane();
    layout.add(markers, 0, 0);
    layout.getChildren().add(slider);
    if (slider.getOrientation() == Orientation.VERTICAL)
    {
        GridPane.setConstraints(slider, 1, 0);
        GridPane.setVgrow(slider, Priority.ALWAYS);
    }
    else
    {
        GridPane.setConstraints(slider, 0, 1);
        GridPane.setHgrow(slider, Priority.ALWAYS);
    }
    final Scene scene = new Scene(layout, 800, 700);
    stage.setScene(scene);
    stage.setTitle("Slider Demo");

    stage.show();
    markers.update();
}