@Test public void getText() throws Throwable { Slider slider = (Slider) getPrimaryStage().getScene().getRoot().lookup(".slider"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); Platform.runLater(new Runnable() { @Override public void run() { slider.setValue(25.0); RFXSlider rfxSlider = new RFXSlider(slider, null, null, lr); rfxSlider.focusLost(null); text.add(rfxSlider.getAttribute("text")); } }); new Wait("Waiting for slider text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("25.0", text.get(0)); }
private Node simulationSpeedSelection( SimulatorSettingDetails settingDetails ) { VBox vBox = new VBox(); Text simulationSpeedLabel = new Text("Simulation Speed (milliseconds / cycle)"); simulationSpeedLabel.setId(UIConstants.TEXT_COLOR); //TODO take in settings for slider Slider simulationSpeedSlider = new Slider(0, 1000, 100); simulationSpeedSlider.setShowTickMarks(true); simulationSpeedSlider.setShowTickLabels(true); simulationSpeedSlider.setMajorTickUnit(100); simulationSpeedSlider.setBlockIncrement(100); simulationSpeedModel = simulationSpeedSlider.valueProperty(); vBox.getChildren().addAll(simulationSpeedLabel, simulationSpeedSlider); return vBox; }
public Son(Clavier clavier) { this.clavier = clavier; slider = new Slider(0, 127, 60); slider.setOrientation(Orientation.VERTICAL); slider.setTranslateY(35); slider.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue o, Object oldVal, Object newVal) { clavier.requestFocus(); } }); ProgressIndicator indicateur = new ProgressIndicator(0.0); indicateur.progressProperty().bind(slider.valueProperty().divide(127.0)); indicateur.setTranslateX(-15); this.getChildren().add(slider); this.getChildren().add(indicateur); this.setTranslateY(260); this.setTranslateX(60); }
@Override public void start(Stage primaryStage) throws Exception { Slider slider = new Slider(); BorderPane root = new BorderPane(slider); Button b = new Button("Start"); root.setBottom(b); Scene s = new Scene(root, 800, 600); primaryStage.setScene(s); primaryStage.show(); RController rController = ServiceUtils.getService(RControllerFactory.class).get().create(s); b.setOnAction(e -> { RNode<Node> rNode = rController.cssFirst(".slider").get(); rNode.click(); rNode.dragBy(Duration.ofMillis(1000), 200, 0); }); }
public void seiInitState(final Pane pane, final Button buttonToOpen, final Button btn_play_video, final Button btn_stop_video, final Button btn_pause_video, final Slider time_slider, final Slider volume_audio_slider, final Label time_lbl) { buttonToOpen.setOnAction(action -> { final File singleFileFromOpenedDialog = getFileChooserForVideo(primaryStage); if (singleFileFromOpenedDialog != null) { try { readFileAndSetInitialStateForVideoItem(singleFileFromOpenedDialog, pane); setupControlButtons(btn_play_video, btn_stop_video, btn_pause_video); setupTimeSliderDependsOnMediaPlayer(time_slider, time_lbl); setupVolumeSliderDependsOnMediaPlayer(volume_audio_slider); } catch (IOException e1) { LOGGER.error("An error: \n" + e1.getCause()); } } }); }
public MagicTabController(final Stage primaryStage, final Button btnOpenCVStartCamera, final CheckBox grayscale, final ComboBox<RecognizingTypeOfDetection> comboBoxForTypeOfDetection, final ComboBox<RecognizingTypeOfClassifier> comboBoxForTypeOfClassifier, final HBox hboxHidden1, final VBox vboxHidden2, final HBox hboxHidden3, final CheckBox canny, final Slider threshold, final CheckBox dilateErode, final CheckBox inverse, final Button btnActivateCamera, final Button btnOpenCVWriteVideo) { this.primaryStage = primaryStage; this.btnOpenCVStartCamera = btnOpenCVStartCamera; this.comboBoxForTypeOfDetection = comboBoxForTypeOfDetection; this.comboBoxForTypeOfClassifier = comboBoxForTypeOfClassifier; this.checkBoxGrayscale = grayscale; //edge detection and hide unappropriated functionality this.hboxHidden1 = hboxHidden1; this.vboxHidden2 = vboxHidden2; this.hboxHidden3 = hboxHidden3; this.canny = canny; this.threshold = threshold; this.dilateErode = dilateErode; this.inverse = inverse; this.btnActivateCamera = btnActivateCamera; //write video with OpenCV this.btnOpenCVWriteVideo = btnOpenCVWriteVideo; }
/** * Initializes the zoom slider which affects the magnification of the authoring environment. */ private void initializeZoom () { Slider zoomControl = new Slider(SLIDER_MIN, SLIDER_MAX, SLIDER_INCREMENT); Text coordinateDisplay = new CustomText(""); contentPane.setOnMouseMoved(e -> { String xCoordinate = new BigDecimal(e.getX() - width * RESIZE_FACTOR) .setScale(INT_RESIZE_FACTOR, RoundingMode.HALF_UP) .toString(); String yCoordinate = new BigDecimal(e.getY() - height * RESIZE_FACTOR) .setScale(INT_RESIZE_FACTOR, RoundingMode.HALF_UP) .toString(); coordinateDisplay.setText(String.format("X: %s Y: %s", xCoordinate, yCoordinate)); }); zoomBar.getItems().addAll(zoomControl, coordinateDisplay); zoomControl.valueProperty().addListener( (obs, old, n) -> { contentPane.setScaleX((double) n); contentPane.setScaleY((double) n); }); }
@Override public Node drawNode() { Slider slider = createSlider(min, max, vertical); slider.setValue(value); if (value > slider.getMax()) { value = slider.getMax(); } if (value < slider.getMin()) { value = slider.getMin(); } if (Double.compare(slider.getMin(), min) != 0) { reportGetterFailure("Slider.getMin()"); } if (Double.compare(slider.getMax(), max) != 0) { reportGetterFailure("Slider.getMax()"); } if (Double.compare(slider.getValue(), value) != 0) { reportGetterFailure("Slider.getValue()"); } return slider; }
@Smoke @Test(timeout = 300000) public void simpleValueSettingTest() throws InterruptedException { assertEquals((new Slider()).valueProperty().getValue(), 0, ASSERT_CMP_PRECISION);//initial value setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.value, 70); checkTextFieldValue(Properties.value, 70); testedControl.mouse().click(1, new Point(testedControl.getClickPoint()).translate(-1, 0)); checkTextFieldValue(Properties.value, 50); testedControl.keyboard().pushKey(KeyboardButtons.END); checkTextFieldValue(Properties.value, 100); testedControl.keyboard().pushKey(KeyboardButtons.HOME); checkTextFieldValue(Properties.value, 0); setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.value, 30); checkTextFieldValue(Properties.value, 30); }
@Smoke @Test(timeout = 300000) public void maxPropertyTest() throws InterruptedException { assertEquals((new Slider()).maxProperty().getValue(), 100, ASSERT_CMP_PRECISION);//initial value setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.max, -10); checkTextFieldValue(Properties.value, -10); checkTextFieldValue(Properties.min, -10); checkTextFieldValue(Properties.max, -10); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.max, 150); setSliderPosition(TESTED_SLIDER_ID, 130, SettingOption.MANUAL); checkTextFieldValue(Properties.value, 130); testedControl.keyboard().pushKey(KeyboardButtons.END); checkTextFieldValue(Properties.value, 150); setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.max, 30); checkTextFieldValue(Properties.min, -10); checkTextFieldValue(Properties.max, 30); checkTextFieldValue(Properties.value, 30); }
@Smoke @Test(timeout = 300000) public void minPropertyTest() throws InterruptedException { assertEquals((new Slider()).minProperty().getValue(), 0, ASSERT_CMP_PRECISION);//initial value setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.min, 150); checkTextFieldValue(Properties.value, 150); checkTextFieldValue(Properties.min, 150); checkTextFieldValue(Properties.max, 150); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.min, 100); setSliderPosition(TESTED_SLIDER_ID, 100, SettingOption.MANUAL); checkTextFieldValue(Properties.value, 100); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.min, -100); requestFocusOnControl(testedControl); testedControl.keyboard().pushKey(KeyboardButtons.HOME); checkTextFieldValue(Properties.value, -100); setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.min, -50); checkTextFieldValue(Properties.min, -50); checkTextFieldValue(Properties.value, 100);//100, because initial value of slider in unidirectional binding is 100. checkTextFieldValue(Properties.max, 150); }
@Smoke @Test(timeout = 300000)//Should fail. public void minorTickCountTest() throws InterruptedException { assertEquals((new Slider()).minorTickCountProperty().getValue(), 3, ASSERT_CMP_PRECISION);//initial value test setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, Properties.snapToTicks); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.majorTickUnit, 100); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.minorTickCount, 1); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.value, 65); checkTextFieldValue(Properties.value, 50); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.minorTickCount, 3); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.value, 15); checkTextFieldValue(Properties.value, 25); setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.minorTickCount, 19); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.value, 35); checkTextFieldValue(Properties.value, 35); setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.minorTickCount, -5); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.value, 19); checkTextFieldValue(Properties.value, 19); }
/** * * Test slider with css : -fx-block-increment */ @Test public void Sliders_BLOCK_INCREMENT() throws InterruptedException { testAdditionalAction(Sliders.name(), "BLOCK-INCREMENT", false); Wrap<? extends Scene> scene = Root.ROOT.lookup(Scene.class).wrap(); Assert.assertNotNull(scene); Parent<Node> sceneParent = scene.as(Parent.class, Node.class); Assert.assertNotNull(sceneParent); final Wrap<? extends Slider> slider = sceneParent.lookup(Slider.class).wrap(); Assert.assertNotNull(slider); Assert.assertEquals(slider.getControl().getValue(), 20.0, 0); Wrap track = sceneParent.lookup(new ByStyleClass<Node>("track")).wrap(); slider.mouse().click(1, new Point(track.getClickPoint().x, slider.getScreenBounds().getHeight() / 2)); slider.keyboard().pushKey(Keyboard.KeyboardButtons.LEFT); Assert.assertEquals(TestUtil.isEmbedded()?(int)0.0:0.0, TestUtil.isEmbedded()?(int)slider.getControl().getValue():slider.getControl().getValue(), 0); slider.keyboard().pushKey(Keyboard.KeyboardButtons.RIGHT); Assert.assertEquals(TestUtil.isEmbedded()?(int)50.0:50.0, TestUtil.isEmbedded()?(int)slider.getControl().getValue():slider.getControl().getValue(), 0); slider.keyboard().pushKey(Keyboard.KeyboardButtons.RIGHT); Assert.assertEquals(TestUtil.isEmbedded()?(int)100.0:100.0, TestUtil.isEmbedded()?(int)slider.getControl().getValue():slider.getControl().getValue(), 0); }
public ImageGenerator() { TextField[] fields = new TextField[] {(TextField) Components.imageSize[1], (TextField) Components.imageSize[2], (TextField) Components.shadowLength[1]}; for(TextField field : fields) { Validate.removeError(field); if(!Validate.isNumber(field)) { error = true; Validate.addError(field); } } if(error) return; this.width = Integer.parseInt(fields[0].getText()); this.height = Integer.parseInt(fields[1].getText()); this.length = Integer.parseInt(fields[2].getText()); javafx.scene.paint.Color color = ((ColorPicker) Components.backgroundColors[1]).getValue(); this.color = new Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue()); this.fading = ((CheckBox) Components.fading[1]).isSelected(); this.opacity = (float) ((Slider) Components.shadowOpacity[1]).getValue() / 100; }
@Test public void shouldUpdateSliderValues() { Equalizer equalizer = new Equalizer(10); for (int i = 0; i < 10; i++) { equalizer.setGain(i, 0.5d); } when(mockMediaManager.getEqualizer()).thenReturn(equalizer); equalizerController.updateSliderValues(); for (int i = 0; i < 10; i++) { Slider slider = (Slider)find("#eq" + i); assertThat("Slider " + i + " should have a value of 0.5", slider.getValue(), equalTo(0.5d)); } }
private HBox criaPainelInferior() { HBox hbBotoes = new HBox(); final Button btnParar = new Button("Parar"); final Button btnTocar = new Button("Tocar"); final Button btnPausar = new Button("Pausar"); final Button btnAjusta = new Button("Ajustar"); sldTempo = new Slider(1, 10, 5); sldTempo.setShowTickLabels(true); sldTempo.setShowTickMarks(true); sldTempo.setMinorTickCount(1); sldTempo.setMajorTickUnit(1); hbBotoes.setAlignment(Pos.CENTER); hbBotoes.setSpacing(20); hbBotoes.getChildren().addAll(btnTocar, btnPausar, btnParar, btnAjusta, new Label("Duração (s):"), sldTempo); // setando as ações. Muito código gasto aqui! Poderíamos ter só uma ação // e setar a mesma em todos os botões ou usar os lambdas no Java 8 btnParar.setOnAction(e -> transicaoAtual.stop()); btnTocar.setOnAction(e -> acaoTocar(btnParar, btnTocar, btnPausar, btnAjusta)); btnPausar.setOnAction(e -> transicaoAtual.pause()); btnAjusta.setOnAction(e -> criaNoAlvo()); return hbBotoes; }
private void addSliderParameter(IntParameter param) { int min = (int)param.getLowerBound(); int max = (int)(param.getUpperBound() + .5); Slider slider = new Slider(min, max, param.getValueOrDefault()); TextField tf = new TextField(); tf.setEditable(false); tf.setText(""+slider.getValue()); tf.setPrefColumnCount(DEFAULT_NUMERIC_TEXT_COLS); ParameterSliderChangeListener listener = new ParameterSliderChangeListener(slider, param, tf); slider.valueProperty().addListener((v, o, n) -> listener.handleSliderUpdate()); // slider.setMinimumSize(new Dimension(slider.getPreferredSize().width, slider.getMinimumSize().height)); BorderPane panel = new BorderPane(); panel.setCenter(slider); panel.setRight(tf); addParamComponent(param, param.getPrompt(), panel); }
private void addSliderParameter(DoubleParameter param) { // double lower = param.getLowerBound(); // double higher = param.getUpperBound(); // int sliderMax; // // Choose a sensible increment // if (higher - lower > 1000) // sliderMax = (int)Math.round((higher - lower)); // else if (higher - lower > 100) // sliderMax = (int)Math.round((higher - lower) * 10); // else // sliderMax = (int)Math.round((higher - lower) * 100); final Slider slider = new Slider(param.getLowerBound(), param.getUpperBound(), param.getValueOrDefault()); TextField tf = new TextField(); tf.setPrefColumnCount(DEFAULT_NUMERIC_TEXT_COLS); setTextFieldFromNumber(tf, param.getValueOrDefault(), param.getUnit()); tf.setEditable(false); ParameterSliderChangeListener listener = new ParameterSliderChangeListener(slider, param, tf); slider.valueProperty().addListener((v, o, n) -> listener.handleSliderUpdate()); // slider.setMinimumSize(new Dimension(slider.getPreferredSize().width, slider.getMinimumSize().height)); BorderPane panel = new BorderPane(); panel.setCenter(slider); panel.setRight(tf); addParamComponent(param, param.getPrompt(), panel); }
static void setSliderRange(final Slider slider, double position, double min, double max) { slider.setMin(min); slider.setMax(max); // int range = (int)(max - min + 0.5); // if (range > 200) { // slider.setMajorTickUnit(50); // slider.setMinorTickCount(10); // } else if (range >= 50) { // slider.setMajorTickUnit(10); // slider.setMinorTickCount(5); // } else if (range >= 10) { // slider.setMajorTickUnit(5); // slider.setMinorTickCount(1); // } else { // slider.setMajorTickUnit(1); // slider.setMinorTickCount(1); // } slider.setMajorTickUnit(1); slider.setSnapToTicks(true); slider.setShowTickMarks(false); slider.setShowTickLabels(false); slider.setValue(position); slider.setOpacity(0.25); slider.setBlockIncrement(1.0); slider.setOnMouseEntered(e -> { slider.setOpacity(1); }); slider.setOnMouseExited(e -> { slider.setOpacity(0.5); }); }
/** * Create a new Slider which runs from 0 to MAXZOOM. * The labeling will be in the opposite direction so MAXZOOM to 0 * * @return the new slider */ private Slider createSlider() { final CustomLabelSlider slider = new CustomLabelSlider(value -> Math .abs(value - maxzoom)); slider.setOrientation(Orientation.VERTICAL); slider.setMin(0); slider.setValue(zoomLevel.intValue()); slider.setMax(maxzoom); slider.setMajorTickUnit(1); slider.setMinorTickCount(0); slider.setShowTickMarks(true); slider.setShowTickLabels(true); slider.setSnapToTicks(true); slider.setMinHeight(Slider.USE_PREF_SIZE); slider.valueChangingProperty().addListener( observable -> slider.setValue(Math.round(slider.getValue()))); return slider; }
@Test public void scrolloneUpSlider() { // Hack because javafx toolkit need to be initialized JFXPanel panel = new JFXPanel(); panel.contains(0, 0); Zoombar toolbar = new Zoombar(5, 10); ToolBar javafxBar = toolbar.getToolBar(); int initZoom = toolbar.getZoomlevel().intValue(); Slider slider = (Slider) javafxBar.getItems().get(1); slider.valueProperty().set(slider.valueProperty().get() + 1); assertEquals(initZoom + 1, toolbar.getZoomlevel().intValue(), 1e-10); }
/** * non funziona: circos non si adatta allo spazio disponibile * @param chart */ private void try2(Circos chart){ // define components: Label title = new Label("This chart is:"); Slider slider = createSlider(1, 10, 0.05); // define layout BorderPane pane = new BorderPane(); HBox center = new HBox(5, chart); pane.setCenter(center); pane.setRight(slider); pane.setTop(title); // define chart bindings: //center.prefHeightProperty().bind(pane.heightProperty()); //center.prefWidthProperty().bind(pane.widthProperty()); //chart.setPrefSize(50, 50); chart.prefHeightProperty().bind(center.heightProperty()); chart.prefWidthProperty().bind(center.widthProperty()); // add all components this.getChildren().add(pane); }
private Slider createSlider(double chartUpperDefault, double chartUpperBound, double chartTickUnit) { Slider slider = new Slider(); slider.setOrientation(Orientation.VERTICAL); slider.setMin(0); slider.setMax(chartUpperBound); slider.setValue(chartUpperDefault); slider.setShowTickLabels(true); slider.setShowTickMarks(true); slider.setMajorTickUnit(chartTickUnit); //slider.setMinorTickCount(0.01); slider.setBlockIncrement(0.01); // otherwise below, we also could delegate mediator, but in this case // it is unnecessary because if the GUI that interacts with itself //slider.valueProperty().addListener(mediator); return slider; }
private Slider createSlider() { Slider slider = new Slider(); slider.setOrientation(Orientation.VERTICAL); slider.setMin(1); slider.setMax(10); slider.setValue(1); slider.setShowTickLabels(true); slider.setShowTickMarks(true); slider.setMajorTickUnit(0.5); //slider.setMinorTickCount(0.01); slider.setBlockIncrement(0.01); slider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { magnificationProperty.set(new_val.doubleValue()); } }); // otherwise below, we also could delegate mediator, but in this case // it is unnecessary because if the GUI that interacts with itself //slider.valueProperty().addListener(mediator); return slider; }
private void prepareSlider() { slider = new Slider(0, nbIteration, 5); slider.setMajorTickUnit(nbIteration); slider.valueProperty().addListener((ov, oldVal, newVal) -> { long lNewVal = newVal.longValue(); if(lNewVal != oldVal.longValue()) System.out.println(lNewVal); }); slider.setBlockIncrement(1); slider.setSnapToTicks(true); if(nbIteration > Integer.MAX_VALUE) { slider.setMinorTickCount(Integer.MAX_VALUE); } else slider.setMinorTickCount((int) nbIteration - 1); // slider.setShowTickLabels(true); // slider.setShowTickMarks(true); }
public SliderMarkers(final Slider slider) { this.slider = slider; Color color = JFXUtil.convert(WidgetColorService.getColor(NamedWidgetColors.ALARM_MAJOR)); lolo_label.setTextFill(color); hihi_label.setTextFill(color); color = JFXUtil.convert(WidgetColorService.getColor(NamedWidgetColors.ALARM_MINOR)); low_label.setTextFill(color); high_label.setTextFill(color); getChildren().addAll(hihi_label, high_label, low_label, lolo_label); // Need to update the markers whenever the slider is resized slider.widthProperty().addListener(width -> update()); slider.heightProperty().addListener(height -> update()); // .. or when the min/max changes slider.minProperty().addListener(min -> update()); slider.maxProperty().addListener(max -> update()); // Also need to update when the slider's font or knob size change, // but there is no obvious listener for that. }
/** * Create a WidthPanel object. */ public WidthPanel() { // Create the GUI. setAlignment(Pos.CENTER); widthSlider = new Slider(0.1, 100.0, Properties.getWidth()); widthLabel = new Label("Width: " + (int) widthSlider.getValue()); widthLabel.setTextFill(Defaults.TEXT_COLOR); // Setup what happens when the slider changes. widthSlider.valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> ov, Number oldVal, Number newVal) { // Make it look good with a format. int val = newVal.intValue(); widthLabel.setText("Width: " + val); Properties.setWidth(val); } }); // Add the Nodes. getChildren().add(widthLabel); getChildren().add(widthSlider); }
@Override public void initComponents() { media = new Media(getClass().getResource(RESOURCES + "videos/" + mediaName).toString()); mediaPlayer = new MediaPlayer(media); mediaView = new MediaView(mediaPlayer); slideIn = new Timeline(); slideOut = new Timeline(); rightTimer = new Label(); rightTimer.setId("lbl-timer"); leftTimer = new Label(); leftTimer.setId("lbl-timer"); vbox = new VBox(5); vbox.setId("fundo-padrao"); test = new StackPane(); timeSlider = new Slider(); btnPlay = new Button(); btnPlay.setGraphic(new ImageView(imgPause)); btnPlay.setId("btn-play"); final HBox hbox = new HBox(); hbox.setAlignment(Pos.CENTER); hbox.getChildren().addAll(leftTimer, btnPlay, rightTimer); vbox.getChildren().addAll(timeSlider, hbox); getChildren().addAll(mediaView, vbox); mediaPlayer.play(); }
private void configure(){ super.setMaxHeight(24); super.setMinWidth(200); super.setAlignment(Pos.CENTER_LEFT); super.setSpacing(5); Slider slider = new Slider(startValue, endValue, value.get()); slider.disableProperty().bind(disabled); //slider.setShowTickLabels(true); IntField intField = new IntField(startValue, endValue, value.get()); intField.disableProperty().bind(disabled); intField.valueProperty().bindBidirectional(slider.valueProperty()); value.bindBidirectional(intField.valueProperty()); intField.setPrefWidth(50); Label label = new Label(); label.setStyle("-fx-font-style:italic;"); label.textProperty().bind(lbl); getChildren().addAll(intField, StackPaneBuilder.create().children(label).prefWidth(30).alignment(Pos.CENTER_LEFT).build(), slider); }
@Override public void setCustomizeLevels(GridPane levelControls) { this.thresholdDBSlider = (Slider) levelControls .lookup ("#MajorThreshold"); this.thresholdTopHatSlider = (Slider) levelControls .lookup ("#MinorThreshold"); this.barWidthSlider = (Slider) levelControls.lookup ("#MajorOffset"); this.topHatHeightSlider = (Slider) levelControls .lookup ("#MinorOffset"); ((Label) levelControls.lookup("#MajorThresholdTxt")).setText("Main Bar Sensitivity"); ((Label) levelControls.lookup("#MinorThresholdTxt")).setText("Accent Bar Sensitivity"); ((Label) levelControls.lookup("#MajorOffsetTxt")).setText("Main Bar Size"); ((Label) levelControls.lookup("#MinorOffsetTxt")).setText("Accent Bar Position"); }
private Slider addSliderControl(final String title, final DoubleProperty prop) { final Slider slider = new Slider(); slider.setValue(prop.get()); prop.bind(slider.valueProperty()); final VBox box = new VBox(); final Text titleText = new Text(title); titleText.textProperty().bind(new StringBinding() { { super.bind(slider.valueProperty()); } @Override protected String computeValue() { return title + " : " + twoDForm.format(slider.getValue()); } }); box.getChildren().addAll(titleText, slider); getChildren().add(box); return slider; }
public FilledSliderSkin(Slider slider) { super(slider, new SliderBehavior(slider)); initialize(); slider.requestLayout(); registerChangeListener(slider.minProperty(), "MIN"); registerChangeListener(slider.maxProperty(), "MAX"); registerChangeListener(slider.valueProperty(), "VALUE"); registerChangeListener(slider.orientationProperty(), "ORIENTATION"); registerChangeListener(slider.showTickMarksProperty(), "SHOW_TICK_MARKS"); registerChangeListener(slider.showTickLabelsProperty(), "SHOW_TICK_LABELS"); registerChangeListener(slider.majorTickUnitProperty(), "MAJOR_TICK_UNIT"); registerChangeListener(slider.minorTickCountProperty(), "MINOR_TICK_COUNT"); registerChangeListener(slider.labelFormatterProperty(), "TICK_LABEL_FORMATTER"); }
/** * 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(); Transition transition = new Transition() { { setCycleDuration(Duration.millis(200)); } @Override protected void interpolate(double frac) { if (!Double.isNaN(startX)) { thumb.setLayoutX(startX + frac * (endX - startX)); } if (!Double.isNaN(startY)) { thumb.setLayoutY(startY + frac * (endY - startY)); } } }; transition.play(); } else { thumb.setLayoutX(endX); thumb.setLayoutY(endY); } }
@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); } }
@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); } }
@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; } } else { return leftInset + Math.max(thumb.prefWidth(-1), track.prefWidth(-1)) + ((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)); } else { return 140; } } }
/** * When user finishes sliding the node height {@link Slider}. * * @param mouseEvent the {@link MouseEvent} */ @FXML void nodeHeightSliderDone(final MouseEvent mouseEvent) { settings.addRunnable(() -> { final double newValue = ((Slider) mouseEvent.getSource()).getValue(); graphVisualizer.getNodeHeightProperty().setValue(newValue); LOGGER.info("Node height has now been set to " + newValue + "."); }); }
/** * When the user finishes sliding the panning sensitivity {@link Slider}. * * @param mouseEvent the {@link MouseEvent} */ @FXML void panningSensitivitySliderDone(final MouseEvent mouseEvent) { settings.addRunnable(() -> { final double newValue = ((Slider) mouseEvent.getSource()).getValue(); graphMovementCalculator.getPanningSensitivityProperty().setValue(newValue); LOGGER.info("Panning sensitivity has been set to " + newValue + "."); }); }
/** * When the user finishes sliding the zooming sensitivity {@link Slider}. * * @param mouseEvent {@link MouseEvent} associated with this event */ @FXML void zoomingSensitivitySliderDone(final MouseEvent mouseEvent) { settings.addRunnable(() -> { final double newValue = ((Slider) mouseEvent.getSource()).getValue(); graphMovementCalculator.getZoomingSensitivityProperty().setValue(newValue); LOGGER.info("Zooming sensitivity has been set to " + newValue + "."); }); }