Package javafx.scene.control

Examples of javafx.scene.control.Slider


      }
      // personPA.bindBidirectional(path, lv.itemsProperty(),
      // (Class<T>) choices[0].getClass());
      ctrl = lv;
    } else if (controlType == Slider.class) {
      Slider sl = new Slider();
      sl.setShowTickLabels(true);
      sl.setShowTickMarks(true);
      sl.setMajorTickUnit(maxChars / 2);
      sl.setMinorTickCount(7);
      sl.setBlockIncrement(1);
      sl.setMax(maxChars + 1);
      sl.setSnapToTicks(true);
      // POJO binding magic...
      personPA.bindBidirectional(path, sl.valueProperty());
      ctrl = sl;
    } else if (controlType == PasswordField.class) {
      final PasswordField tf = new PasswordField() {
        @Override
        public void replaceText(int start, int end, String text) {
View Full Code Here


        }
    };

    private void setShowTickMarks(boolean ticksVisible, boolean labelsVisible) {
        showTickMarks = (ticksVisible || labelsVisible);
        Slider slider = getSkinnable();
        if (showTickMarks) {
            if (tickLine == null) {
                tickLine = new NumberAxis();
                tickLine.setAutoRanging(false);
                tickLine.setSide(slider.getOrientation() == Orientation.VERTICAL ? Side.RIGHT : (slider.getOrientation() == null) ? Side.RIGHT: Side.BOTTOM);
                tickLine.setUpperBound(slider.getMax());
                tickLine.setLowerBound(slider.getMin());
                tickLine.setTickUnit(slider.getMajorTickUnit());
                tickLine.setTickMarkVisible(ticksVisible);
                tickLine.setTickLabelsVisible(labelsVisible);
                tickLine.setMinorTickVisible(ticksVisible);
                // add 1 to the slider minor tick count since the axis draws one
                // less minor ticks than the number given.
                tickLine.setMinorTickCount(Math.max(slider.getMinorTickCount(),0) + 1);
                if (slider.getLabelFormatter() != null) {
                    tickLine.setTickLabelFormatter(stringConverterWrapper);
                }
                getChildren().clear();
                getChildren().addAll(tickLine, track, fill, thumb);
            } else {
View Full Code Here

        getSkinnable().requestLayout();
    }

    @Override protected void handleControlPropertyChanged(String p) {
        super.handleControlPropertyChanged(p);
        Slider slider = getSkinnable();
        if ("ORIENTATION".equals(p)) {
            if (showTickMarks && tickLine != null) {
                tickLine.setSide(slider.getOrientation() == Orientation.VERTICAL ? Side.RIGHT : (slider.getOrientation() == null) ? Side.RIGHT: Side.BOTTOM);
            }
            getSkinnable().requestLayout();
        } else if ("VALUE".equals(p)) {
            // only animate thumb if the track was clicked - not if the thumb is dragged
            positionThumb(trackClicked);
        } else if ("MIN".equals(p) ) {
            if (showTickMarks && tickLine != null) {
                tickLine.setLowerBound(slider.getMin());
            }
            getSkinnable().requestLayout();
        } else if ("MAX".equals(p)) {
            if (showTickMarks && tickLine != null) {
                tickLine.setUpperBound(slider.getMax());
            }
            getSkinnable().requestLayout();
        } else if ("SHOW_TICK_MARKS".equals(p) || "SHOW_TICK_LABELS".equals(p)) {
            setShowTickMarks(slider.isShowTickMarks(), slider.isShowTickLabels());
        else if ("MAJOR_TICK_UNIT".equals(p)) {
            if (tickLine != null) {
                tickLine.setTickUnit(slider.getMajorTickUnit());
                getSkinnable().requestLayout();
            }
        } else if ("MINOR_TICK_COUNT".equals(p)) {
            if (tickLine != null) {
                tickLine.setMinorTickCount(Math.max(slider.getMinorTickCount(),0) + 1);
                getSkinnable().requestLayout();
            }
        } else if ("TICK_LABEL_FORMATTER".equals(p)) {
            if (tickLine != null) {
                if (slider.getLabelFormatter() == null) {
                    tickLine.setTickLabelFormatter(null);
                } else {
                    tickLine.setTickLabelFormatter(stringConverterWrapper);
                    tickLine.requestAxisLayout();
                }
View Full Code Here

    /**
     * Called when ever either min, max or value changes, so thumb's layoutX, Y is recomputed.
     */
    void positionThumb(final boolean animate) {
        Slider s = getSkinnable();
        if (s.getValue() > s.getMax()) return;// this can happen if we are bound to something
        boolean horizontal = s.getOrientation() == Orientation.HORIZONTAL;
        final double endX = (horizontal) ? trackStart + (((trackLength * ((s.getValue() - s.getMin()) /
                (s.getMax() - s.getMin()))) - thumbWidth/2)) : thumbLeft;
        final double endY = (horizontal) ? thumbTop :
                snappedTopInset() + trackLength - (trackLength * ((s.getValue() - s.getMin()) /
                        (s.getMax() - s.getMin()))); //  - thumbHeight/2

        if (animate) {
            // lets animate the thumb transition
            final double startX = thumb.getLayoutX();
            final double startY = thumb.getLayoutY();
View Full Code Here

    double minTrackLength() {
        return 2*thumb.prefWidth(-1);
    }

    @Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
        final Slider s = getSkinnable();
        if (s.getOrientation() == Orientation.HORIZONTAL) {
            return (leftInset + minTrackLength() + thumb.minWidth(-1) + rightInset);
        } else {
            return(leftInset + thumb.prefWidth(-1) + rightInset);
        }
    }
View Full Code Here

            return(leftInset + thumb.prefWidth(-1) + rightInset);
        }
    }

    @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
        final Slider s = getSkinnable();
        if (s.getOrientation() == Orientation.HORIZONTAL) {
            return(topInset + thumb.prefHeight(-1) + bottomInset);
        } else {
            return(topInset + minTrackLength() + thumb.prefHeight(-1) + bottomInset);
        }
    }
View Full Code Here

            return(topInset + minTrackLength() + thumb.prefHeight(-1) + bottomInset);
        }
    }

    @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
        final Slider s = getSkinnable();
        if (s.getOrientation() == Orientation.HORIZONTAL) {
            if(showTickMarks) {
                return Math.max(140, tickLine.prefWidth(-1));
            } else {
                return 140;
            }
View Full Code Here

                    ((showTickMarks) ? (trackToTickGap+tickLine.prefWidth(-1)) : 0) + rightInset;
        }
    }

    @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
        final Slider s = getSkinnable();
        if (s.getOrientation() == Orientation.HORIZONTAL) {
            return topInset + Math.max(thumb.prefHeight(-1), track.prefHeight(-1)) +
                    ((showTickMarks) ? (trackToTickGap+tickLine.prefHeight(-1)) : 0+ bottomInset;
        } else {
            if(showTickMarks) {
                return Math.max(140, tickLine.prefHeight(-1));
View Full Code Here

       
        Label brightnessLabel = new Label("Brightness:");
        brightnessLabel.setMinWidth(Control.USE_PREF_SIZE);
        GridPane.setConstraints(brightnessLabel, 0, 0);
       
        Slider brightnessSlider = SliderBuilder.create().min(0).max(100).id("BrightnessSlider").build();
        brightnessSlider.valueProperty().bindBidirectional(bright);
        GridPane.setConstraints(brightnessSlider, 1, 0);
       
        IntegerField brightnessField = new IntegerField();
        brightnessField.valueProperty().bindBidirectional(bright);
        brightnessField.setPrefColumnCount(7);
        GridPane.setConstraints(brightnessField, 2, 0);
       
        Label saturationLabel = new Label("Saturation:");
        saturationLabel.setMinWidth(Control.USE_PREF_SIZE);
        GridPane.setConstraints(saturationLabel, 0, 1);
       
        Slider saturationSlider = SliderBuilder.create().min(0).max(100).id("SaturationSlider").build();
        saturationSlider.valueProperty().bindBidirectional(sat);
        GridPane.setConstraints(saturationSlider, 1, 1);
       
        saturationSlider.styleProperty().bind(new StringBinding() {
            { bind(color); }
            @Override protected String computeValue() {
                return "picker-color: hsb("+hue.get()+",100%,100%);";
            }
        });
View Full Code Here

    final DoubleProperty cellSizeRatio = new SimpleDoubleProperty(0.6);

    GridPane gridPane = new GridPane();

    gridPane.add(new Label("Alignment (0.0 - 1.0)"), 1, 1);
    gridPane.add(new Slider(0.0, 1.0, 0.8) {{
      valueProperty().bindBidirectional(alignment);
      setBlockIncrement(0.1);
    }}, 2, 1);
    gridPane.add(new Label() {{
      textProperty().bind(alignment.asString("%4.2f"));
    }}, 3, 1);

    gridPane.add(new CheckBox("Reflection?") {{
      selectedProperty().bindBidirectional(reflectionEnabled);
    }}, 2, 2);

    gridPane.add(new CheckBox("Clip Reflections?") {{
      selectedProperty().bindBidirectional(clipReflections);
    }}, 2, 3);

    gridPane.add(new Label("fieldOfViewRatio (0.0 - 2.0)"), 1, 4);
    gridPane.add(new Slider(0.0, 2.0, 0.5) {{
      valueProperty().bindBidirectional(fieldOfViewRatio);
      setBlockIncrement(0.1);
    }}, 2, 4);
    gridPane.add(new Label() {{
      textProperty().bind(fieldOfViewRatio.asString("%4.2f"));
    }}, 3, 4);

    gridPane.add(new Label("radiusRatio (0.0 - 2.0)"), 1, 5);
    gridPane.add(new Slider(0.0, 2.0, 0.5) {{
      valueProperty().bindBidirectional(radiusRatio);
      setBlockIncrement(0.1);
    }}, 2, 5);
    gridPane.add(new Label() {{
      textProperty().bind(radiusRatio.asString("%4.2f"));
    }}, 3, 5);

    gridPane.add(new Label("viewDistanceRatio (0.0 - 4.0)"), 1, 6);
    gridPane.add(new Slider(0.0, 4.0, 0.5) {{
      valueProperty().bindBidirectional(viewDistanceRatio);
      setBlockIncrement(0.1);
    }}, 2, 6);
    gridPane.add(new Label() {{
      textProperty().bind(viewDistanceRatio.asString("%4.2f"));
    }}, 3, 6);

    gridPane.add(new Label("density (0.001 - 0.1)"), 1, 7);
    gridPane.add(new Slider(0.001, 0.1, 0.01) {{
      valueProperty().bindBidirectional(density);
      setBlockIncrement(0.0025);
    }}, 2, 7);
    gridPane.add(new Label() {{
      textProperty().bind(density.asString("%6.4f"));
    }}, 3, 7);

    gridPane.add(new Label("cellSizeRatio (0.1 - 1.0)"), 1, 8);
    gridPane.add(new Slider(0.1, 1.0, 0.6) {{
      valueProperty().bindBidirectional(cellSizeRatio);
      setBlockIncrement(0.05);
    }}, 2, 8);
    gridPane.add(new Label() {{
      textProperty().bind(cellSizeRatio.asString("%4.2f"));
View Full Code Here

TOP

Related Classes of javafx.scene.control.Slider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.