private void initialize() { getStyleClass().add(DEFAULT_STYLE_CLASS); }
@Override public void start(Stage stage) { JFXSlider horLeftSlider = new JFXSlider(); horLeftSlider.setMinWidth(500); JFXSlider horRightSlider = new JFXSlider(); horRightSlider.setMinWidth(500); horRightSlider.setIndicatorPosition(IndicatorPosition.RIGHT); JFXSlider verLeftSlider = new JFXSlider(); verLeftSlider.setMinHeight(500); verLeftSlider.setOrientation(Orientation.VERTICAL); JFXSlider verRightSlider = new JFXSlider(); verRightSlider.setMinHeight(500); verRightSlider.setOrientation(Orientation.VERTICAL); verRightSlider.setIndicatorPosition(IndicatorPosition.RIGHT); HBox hbox = new HBox(); hbox.setSpacing(450); hbox.getChildren().addAll(verRightSlider, verLeftSlider); VBox vbox = new VBox(); vbox.getChildren().addAll(horRightSlider, horLeftSlider, hbox); vbox.setSpacing(100); vbox.setPadding(new Insets(100, 50, 50, 150)); Scene scene = new Scene(new Group()); ((Group) scene.getRoot()).getChildren().add(vbox); scene.getStylesheets().add(SliderDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setScene(scene); stage.setWidth(900); stage.setHeight(900); stage.show(); stage.setTitle("JFX Slider Demo"); }
@Override public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() { if (STYLEABLES == null) { final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>( Control.getClassCssMetaData()); styleables.addAll(getClassCssMetaData()); styleables.addAll(Slider.getClassCssMetaData()); STYLEABLES = Collections.unmodifiableList(styleables); } return STYLEABLES; }
private void initSliders() { for (final UpdateRate elem : UpdateRate.values()) { this.udpateRateCombo.getItems().add(elem); } this.udpateRateCombo.getSelectionModel().selectedItemProperty().addListener( (observable, oldValue, newValue) -> this.setUpdateRate(newValue)); this.sliderRadius.valueProperty().addListener( (observable, oldValue, newValue) -> this.setDtwRadius(newValue.doubleValue() / 10)); this.sliderMinThreshold.valueProperty().addListener( (observable, oldValue, newValue) -> this.setMinDtwThreashold(newValue.intValue())); this.sliderMaxThreshold.valueProperty().addListener( (observable, oldValue, newValue) -> this.setMaxDtwThreashold(newValue.intValue())); this.sliderTimeSeparation.valueProperty().addListener( (observable, oldValue, newValue) -> this.setMinTimeSeparation(newValue.intValue())); this.sliderMatchNumber.valueProperty().addListener( (observable, oldValue, newValue) -> this.setMatchNumber(newValue.intValue())); // CHECKSTYLE:OFF this.elevationSlider = new JFXSlider(0, 30, 10); this.elevationSlider.setMajorTickUnit(5); this.elevationSlider.setSnapToTicks(true); this.elevationSlider.setMinorTickCount(0); this.elevationSlider.setMinHeight(50); this.elevationSlider.valueProperty().addListener((oservable, oldValue, newValue) -> { new Thread(() -> { this.setSensorElevation(newValue.intValue()); }).start(); }); // CHECKSTYLE:ON }
sizeLabel.setAlignment(Pos.BASELINE_RIGHT); sizeSlider.setIndicatorPosition(IndicatorPosition.RIGHT); sizeSlider.getStyleClass().add("svg-slider"); HBox sizeControl = new HBox(5, sizeLabel, sizeSlider); sizeControl.prefWidthProperty().bind(colorPicker.widthProperty()); details.addRow(3, new Label("Size"), sizeControl); sizeLabel.textProperty().bind(sizeSlider.valueProperty().asString("%.0f"));
/** * sets custom string binding for the slider text value * * @param valueFactory a callback to create the string value binding */ public final void setValueFactory(final Callback<JFXSlider, StringBinding> valueFactory) { this.valueFactoryProperty().set(valueFactory); }
/** * {@inheritDoc} */ public JFXSlider() { super(0, 100, 50); initialize(); }
private void initializeVariables() { shifting = 30 + thumb.getWidth(); if (getSkinnable().getOrientation() != Orientation.HORIZONTAL) { horizontalRotation = -90; } if (((JFXSlider) getSkinnable()).getIndicatorPosition() != IndicatorPosition.LEFT) { indicatorRotation = 180; shifting = -shifting; } final double rotationAngle = 45; sliderValue.setRotate(rotationAngle + indicatorRotation + 3 * horizontalRotation); animatedThumb.setRotate(-rotationAngle + indicatorRotation + horizontalRotation); }
private void refreshView() { if (glyph.getValue() == null) { idLabel.setText(""); nameLabel.setText(""); return; } sizeSlider.valueProperty().addListener(observable -> glyph.get().setSize(sizeSlider.getValue())); idLabel.setText(String.format("%04d", glyph.get().getGlyphId())); nameLabel.setText(glyph.get().getName()); glyph.get().setFill(colorPicker.getValue()); glyph.get().fillProperty().bind(colorPicker.valueProperty()); centeredGlyph.getChildren().setAll(glyph.get()); }
@Override public StyleableProperty<IndicatorPosition> getStyleableProperty(JFXSlider control) { return control.indicatorPositionProperty(); } };
private void refreshSliderValueBinding() { sliderValue.textProperty().unbind(); if (((JFXSlider) getSkinnable()).getValueFactory() != null) { sliderValue.textProperty() .bind(((JFXSlider) getSkinnable()).getValueFactory().call((JFXSlider) getSkinnable())); } else { sliderValue.textProperty().bind(Bindings.createStringBinding(() -> { if (getSkinnable().getLabelFormatter() != null) { return getSkinnable().getLabelFormatter().toString(getSkinnable().getValue()); } else { return String.valueOf(Math.round(getSkinnable().getValue())); } }, getSkinnable().valueProperty())); } }
public JFXSliderSkin(JFXSlider slider) { super(slider); track = (StackPane) getSkinnable().lookup(".track"); thumb = (StackPane) getSkinnable().lookup(".thumb"); coloredTrack = new StackPane(); coloredTrack.getStyleClass().add("colored-track"); coloredTrack.setMouseTransparent(true); sliderValue = new Text(); sliderValue.getStyleClass().setAll("slider-value"); animatedThumb = new StackPane(); animatedThumb.getStyleClass().add("animated-thumb"); animatedThumb.getChildren().add(sliderValue); animatedThumb.setMouseTransparent(true); animatedThumb.setScaleX(0); animatedThumb.setScaleY(0); getChildren().add(getChildren().indexOf(thumb), coloredTrack); getChildren().add(getChildren().indexOf(thumb), animatedThumb); getChildren().add(0, mouseHandlerPane); registerChangeListener(slider.valueFactoryProperty(), "VALUE_FACTORY"); initListeners(); }
/** * {@inheritDoc} */ public JFXSlider(double min, double max, double value) { super(min, max, value); initialize(); }
if (((JFXSlider) getSkinnable()).getIndicatorPosition() == IndicatorPosition.RIGHT) { thumbPos = thumb.getLayoutY() - thumb.getHeight(); thumbNewPos = thumbPos - shifting; if (((JFXSlider) getSkinnable()).getIndicatorPosition() == IndicatorPosition.RIGHT) { thumbPos = thumb.getLayoutX() - thumb.getWidth(); thumbNewPos = thumbPos - shifting;
@Override public StyleableProperty<IndicatorPosition> getStyleableProperty(JFXSlider control) { return control.indicatorPositionProperty(); } };
private void refreshSliderValueBinding() { sliderValue.textProperty().unbind(); if (((JFXSlider) getSkinnable()).getValueFactory() != null) { sliderValue.textProperty() .bind(((JFXSlider) getSkinnable()).getValueFactory().call((JFXSlider) getSkinnable())); } else { sliderValue.textProperty().bind(Bindings.createStringBinding(() -> { if (getSkinnable().getLabelFormatter() != null) { return getSkinnable().getLabelFormatter().toString(getSkinnable().getValue()); } else { return String.valueOf(Math.round(getSkinnable().getValue())); } }, getSkinnable().valueProperty())); } }
private void initialize() { getStyleClass().add(DEFAULT_STYLE_CLASS); }
/** * sets custom string binding for the slider text value * * @param valueFactory a callback to create the string value binding */ public final void setValueFactory(final Callback<JFXSlider, StringBinding> valueFactory) { this.valueFactoryProperty().set(valueFactory); }
/** * {@inheritDoc} */ public JFXSlider(double min, double max, double value) { super(min, max, value); initialize(); }
private void initializeVariables() { shifting = 30 + thumb.getWidth(); if (getSkinnable().getOrientation() != Orientation.HORIZONTAL) { horizontalRotation = -90; } if (((JFXSlider) getSkinnable()).getIndicatorPosition() != IndicatorPosition.LEFT) { indicatorRotation = 180; shifting = -shifting; } final double rotationAngle = 45; sliderValue.setRotate(rotationAngle + indicatorRotation + 3 * horizontalRotation); animatedThumb.setRotate(-rotationAngle + indicatorRotation + horizontalRotation); }