/** * Ensures that the scrollbar below the xAxis can only be used within the range of the shown data * and that the scrollbar position and shown range are always synchronized. */ private void initxScrollbar() { ScrollBar scrollBar = view.getXscrollBar(); NumberAxis globalxAxis = view.getXaxis(); scrollBar.setMin(0); visibleRange.bind(globalxAxis.upperBoundProperty().subtract(globalxAxis.lowerBoundProperty())); scrollBar.maxProperty().bind(visibleRange.multiply(-1).add(totalCycleCount)); globalxAxis.lowerBoundProperty().addListener(change -> { scrollBar.setValue(globalxAxis.getLowerBound()); }); // I don't know, why it need to be divided by 2 but it seems to work very good this way scrollBar.visibleAmountProperty().bind(visibleRange.divide(2)); scrollBar.valueProperty().addListener(change -> { globalxAxis.setUpperBound(scrollBar.getValue() + visibleRange.get()); globalxAxis.setLowerBound(scrollBar.getValue()); }); }
private static ScrollBar findScrollBar(TableView tableView, Orientation orientation) { return tableView.lookupAll(".scroll-bar") .stream() .filter(n -> n instanceof ScrollBar) .map(n -> (ScrollBar) n) .filter(sb -> sb.getOrientation() == orientation) .findFirst() .orElse(null); }
public TPSChart() { final NumberAxis yAxis = new NumberAxis(); this.xAxis = new NumberAxis( 0, 512, 1000 ); this.xAxis.setAutoRanging( false ); this.chart = new LineChart<>( xAxis, yAxis ); this.chart.setAnimated( false ); this.chart.setCreateSymbols( false ); this.chart.setLegendVisible( false ); this.fullTimeSeries = new XYChart.Series<>(); this.actualTimeSeries = new XYChart.Series<>(); this.averageTimeSeries = new XYChart.Series<>(); this.scrollBar = new ScrollBar(); this.scrollBar.valueProperty().addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue ) { currentDataStart = (int) ( newValue.floatValue() * ( TimeUnit.SECONDS.toNanos( 1 ) / tickNanos ) * 60 ); updateChart(); } } ); }
@Override public Node drawNode() { ScrollBar scroll = new ScrollBar(); if (Double.compare(scroll.getValue(), 0) != 0) { reportGetterFailure("ScrollBar.getValue()"); } if (Double.compare(scroll.getMin(), 0) != 0) { reportGetterFailure("ScrollBar.getMin()"); } if (Double.compare(scroll.getMax(), 100) != 0) { reportGetterFailure("ScrollBar.getMax()"); } if (Double.compare(scroll.getBlockIncrement(), 10) != 0) { reportGetterFailure("ScrollBar.getBlockIncrement()"); } if (Double.compare(scroll.getUnitIncrement(), 1) != 0) { reportGetterFailure("ScrollBar.isVertical()"); } if (scroll.getOrientation() != Orientation.HORIZONTAL) { reportGetterFailure("ScrollBar.isVertical()"); } if (Double.compare(scroll.getVisibleAmount(), 15) != 0) { reportGetterFailure("ScrollBar.isVertical()"); } return scroll; }
protected void checkScrollingState(final double scrollValue, boolean beginVisible, boolean endVisible, int size) { testedControl.waitState(new State() { public Object reached() { Wrap<? extends ScrollBar> sb = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true); if (Math.abs(sb.getControl().getValue() - scrollValue) < 0.01) { return true; } else { return null; } } }); if (beginVisible) { assertTrue(isCellShown(0)); } if (endVisible) { assertTrue(isCellShown(size - 1)); } }
private static AbstractScroll getScroll(final Wrap<? extends Control> testedControl, final boolean vertical) { Lookup<ScrollBar> lookup = testedControl.as(Parent.class, Node.class).lookup(ScrollBar.class, new LookupCriteria<ScrollBar>() { @Override public boolean check(ScrollBar control) { return control.isVisible() && (control.getOrientation() == Orientation.VERTICAL) == vertical; } }); int count = lookup.size(); if (count == 0) { return null; } else if (count == 1) { return lookup.as(AbstractScroll.class); } else { return null; } }
@Smoke @Test(timeout = 300000) public void adjustValueTest() throws InterruptedException { Wrap<? extends ScrollBar> testedScrollBar = parent.lookup(ScrollBar.class, new ByID<ScrollBar>(TESTED_SCROLLBAR_ID)).wrap(); //Block - aboutclick over free space, Unit - about click on arrow. setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.blockIncrement, 50); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.unitIncrement, 75); testedScrollBar.mouse().click(); //knob in center clickLess(testedScrollBar); checkTextFieldValue(Properties.value, 0); setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.blockIncrement, 150); testedScrollBar.mouse().click(); checkTextFieldValue(Properties.value, 50); testedScrollBar.keyboard().pushKey(KeyboardButtons.LEFT); checkTextFieldValue(Properties.value, 0); testedScrollBar.keyboard().pushKey(KeyboardButtons.RIGHT); checkTextFieldValue(Properties.value, 100); }
private void checkScrollingState(final double scrollValue, boolean beginVisible, boolean endVisible, int size, final Orientation orientation) { //assertEquals(findScrollBar(testedControl.as(Parent.class, Node.class), orientation, true).getControl().getValue(), scrollValue, 0.01); testedControl.waitState(new State() { public Object reached() { Wrap<? extends ScrollBar> sb = findScrollBar(testedControl.as(Parent.class, Node.class), orientation, true); if (Math.abs(sb.getControl().getValue() - scrollValue) < 0.01) { return true; } else { return null; } } }); if (beginVisible) { assertTrue(isCellShown(0, orientation)); } if (endVisible) { assertTrue(isCellShown(size, orientation)); } }
@Test public void ScrollBars_UNIT_INCREMENT() throws InterruptedException { testAdditionalAction(ScrollBars.name(), "UNIT-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); Wrap<? extends ScrollBar> scrollWrap = sceneParent.lookup(ScrollBar.class).wrap(); Wrap decrementArrow = sceneParent.lookup(new ByStyleClass<Node>("decrement-arrow")).wrap(); Wrap incrementArrow = sceneParent.lookup(new ByStyleClass<Node>("increment-arrow")).wrap(); Assert.assertNotNull(decrementArrow); decrementArrow.mouse().click(); Assert.assertEquals(scrollWrap.getControl().getValue(), 0, 0); incrementArrow.mouse().click(); Assert.assertEquals(50.0d, scrollWrap.getControl().getValue(), 0); incrementArrow.mouse().click(); Assert.assertEquals(100.0d, scrollWrap.getControl().getValue(), 0); }
@Override public HBox getControlPane() { HBox cPane = new HBox(); VBox radiusBox = new VBox(); radiusScroll = new ScrollBar(); radiusScroll.setMin(0); radiusScroll.setMax(6); radiusScroll.setValue(sphere.getRadius()); radiusScroll.valueProperty().bindBidirectional(sphere.radiusProperty()); radiusBox.getChildren().addAll(new Label("Radius"), radiusScroll); cPane.getChildren().add(radiusBox); return cPane; }
@Override protected VBox getControlsForSubScene(SubScene ss) { GroupMover targetMover; if(ss.getRoot() == rootDLMV.getGroup()){ targetMover = rootDLMV; }else if(ss.getRoot() == rootTLMV.getGroup()){ targetMover = rootTLMV; }else if(ss.getRoot() == rootTRMV.getGroup()){ targetMover = rootTRMV; }else{ throw new IllegalArgumentException("SubScene does not applicable to this application"); } ScrollBar rotYBar = new ScrollBar(); VBox controls = new VBox(new HBox(new Label("Rotate"),rotYBar)); rotYBar.setMin(-360); rotYBar.setMax(360); rotYBar.setValue(targetMover.rotateYProperty().get()); rotYBar.valueProperty().bindBidirectional(targetMover.rotateYProperty()); return controls; }
@SuppressWarnings("unchecked") private void checkScroll() { if (scroll == null) { final boolean vertical = vertical(); final Parent<Node> parent = as(Parent.class, Node.class); Lookup<ScrollBar> lookup = parent.lookup(ScrollBar.class, control -> (control.getOrientation() == Orientation.VERTICAL) == vertical); int count = lookup.size(); if (count == 0) { scroll = null; } else if (count == 1) { scroll = lookup.wrap(0).as(AbstractScroll.class); } else { throw new JemmyException("There are more than 1 " + (vertical ? "vertical" : "horizontal") + " ScrollBars in this ListView"); } } }
/** * Obtains wrap for scrollbar * * @param vertical * @return */ private AbstractScroll getScroll(final boolean vertical) { final Parent<Node> parent = control.as(Parent.class, Node.class); Lookup<ScrollBar> lookup = parent.lookup(ScrollBar.class, control -> (control.getOrientation() == Orientation.VERTICAL) == vertical && control.isVisible()); int count = lookup.size(); if (count == 0) { return null; } else if (count == 1) { return lookup.as(AbstractScroll.class); } else { throw new JemmyException("There are more than 1 " + (vertical ? "vertical" : "horizontal") + " ScrollBars in this TableView"); } }
@Deprecated private void setTextAreaHeight() { // elements Region content = (Region) messageText.lookup(".content"); ScrollBar scrollBarv = (ScrollBar) messageText.lookup(".scroll-bar:vertical"); // get the height of content double height = MINIMUM_HEIGHT; if (messageText.getText().length() > 10) { Insets padding = messageText.getPadding(); height = content.getHeight() + padding.getTop() + padding.getBottom(); } // set height height = Math.max(MINIMUM_HEIGHT, height); height = Math.min(MAXIMUM_HEIGHT, height); messageText.setMinHeight(height); messageText.setPrefHeight(height); // enable or the scroll bar scrollBarv.setVisibleAmount(MAXIMUM_HEIGHT); }
/** * Gets the horizontal and vertical {@link ScrollBar} and saves them in the * class members. * * @see #horizontalScrollBar * @see #verticalScrollBar */ private void getScrollBars() { for (Node node : lookupAll(".scroll-pane *.scroll-bar")) { if (node instanceof ScrollBar) { ScrollBar scrollBar = (ScrollBar)node; if (scrollBar.getOrientation() == Orientation.HORIZONTAL) { horizontalScrollBar = scrollBar; } else { verticalScrollBar = scrollBar; } } } }
private boolean isVerticalScrollVisible(){ Set<Node> sbs = (Set<Node>)table.lookupAll(".scroll-bar"); if(sbs.size()>0){ for (Node node : sbs) { if(node instanceof ScrollBar){ ScrollBar scroll = (ScrollBar)node; if(scroll.getOrientation() == Orientation.VERTICAL){ if(scroll.isVisible()){ return true; } }// eo Orientation } // eo instanceof }// eo for }// eo if return false; }
private void initializeScrollListener() { threadService.runActionLater(() -> { this.treeView = controller.getFileSystemView(); Set<Node> nodes = this.treeView.lookupAll(".scroll-bar"); for (Node node : nodes) { ScrollBar scrollBar = (ScrollBar) node; if (scrollBar.getOrientation() == Orientation.VERTICAL) { verticalScrollState.updateState(scrollBar); scrollBar.valueProperty().addListener((observable, oldValue, newValue) -> { verticalScrollState.updateState(scrollBar, newValue); }); } else if (scrollBar.getOrientation() == Orientation.HORIZONTAL) { horizontalScrollState.updateState(scrollBar); scrollBar.valueProperty().addListener((observable, oldValue, newValue) -> { horizontalScrollState.updateState(scrollBar, newValue); }); } } }); }
private void restoreTreeScrollState() { threadService.schedule(() -> { // run after some ms threadService.runActionLater(() -> { // run in ui thread Set<Node> nodes = this.treeView.lookupAll(".scroll-bar"); for (Node node : nodes) { ScrollBar scrollBar = (ScrollBar) node; if (scrollBar.getOrientation() == Orientation.VERTICAL) { verticalScrollState.restoreState(scrollBar); } else if (scrollBar.getOrientation() == Orientation.HORIZONTAL) { horizontalScrollState.restoreState(scrollBar); } } }); }, 50, TimeUnit.MILLISECONDS); }
private ScrollBar horizontalScrollBar(double minw, double minh, double prefw, double prefh, double maxw, double maxh) { final ScrollBar scrollBar = new ScrollBar(); scrollBar.setMinSize(minw, minh); scrollBar.setPrefSize(prefw, prefh); scrollBar.setMaxSize(maxw, maxh); scrollBar.setVisibleAmount(50); scrollBar.setMax(xBarWidth-(2*circleRadius)); return scrollBar; }
private ScrollBar verticalScrollBar(double minw, double minh, double prefw, double prefh, double maxw, double maxh) { final ScrollBar scrollBar = new ScrollBar(); scrollBar.setMinSize(minw, minh); scrollBar.setPrefSize(prefw, prefh); scrollBar.setMaxSize(maxw, maxh); scrollBar.setVisibleAmount(50); scrollBar.setMax(yBarHeight-(2*circleRadius)); return scrollBar; }
private ScrollBar getListViewScrollBar(ListView listView, Orientation orientation) { for(Node node : listView.lookupAll(".scroll-bar")) { if(node instanceof ScrollBar && ((ScrollBar)node).getOrientation() == orientation) { return (ScrollBar)node; } } return null; }
@Override public Node getPanel(Stage stage) { TimeScaleView view = new TimeScaleView(); final DayViewScrollPane scrollPane = new DayViewScrollPane(view, new ScrollBar()); scrollPane.setPrefHeight(2000); return wrap(scrollPane); }
@Override public Node getPanel(Stage stage) { Calendar dirk = new Calendar("Dirk"); Calendar katja = new Calendar("Katja"); Calendar philip = new Calendar("Philip"); Calendar jule = new Calendar("Jule"); Calendar armin = new Calendar("Armin"); dirk.setStyle(Style.STYLE1); katja.setStyle(Style.STYLE2); philip.setStyle(Style.STYLE3); jule.setStyle(Style.STYLE4); armin.setStyle(Style.STYLE5); CalendarSource calendarSource = new CalendarSource(); calendarSource.getCalendars().add(dirk); calendarSource.getCalendars().add(katja); calendarSource.getCalendars().add(philip); calendarSource.getCalendars().add(jule); calendarSource.getCalendars().add(armin); weekView.getCalendarSources().setAll(calendarSource); DayViewScrollPane scroll = new DayViewScrollPane(weekView, new ScrollBar()); scroll.setStyle("-fx-background-color: white;"); return scroll; }
private boolean isScrollBar(Node node) { boolean result = false; if (node instanceof ScrollBar) { result = true; } else if (node.getParent() != null) { return isScrollBar(node.getParent()); } return result; }
private void bindScrollBars() { final Set<Node> nodes = lookupAll("VirtualScrollBar"); for (Node node : nodes) { if (node instanceof ScrollBar) { ScrollBar bar = (ScrollBar) node; if (bar.getOrientation().equals(Orientation.VERTICAL)) { bindScrollBars(vBar, bar); } else if (bar.getOrientation().equals(Orientation.HORIZONTAL)) { bindScrollBars(hBar, bar); } } } }
private void bindScrollBars(ScrollBar scrollBarA, ScrollBar scrollBarB) { scrollBarA.valueProperty().bindBidirectional(scrollBarB.valueProperty()); scrollBarA.minProperty().bindBidirectional(scrollBarB.minProperty()); scrollBarA.maxProperty().bindBidirectional(scrollBarB.maxProperty()); scrollBarA.visibleAmountProperty().bindBidirectional(scrollBarB.visibleAmountProperty()); scrollBarA.unitIncrementProperty().bindBidirectional(scrollBarB.unitIncrementProperty()); scrollBarA.blockIncrementProperty().bindBidirectional(scrollBarB.blockIncrementProperty()); }
public GesturePane() { super(); getStyleClass().setAll(DEFAULT_STYLE_CLASS); target.addListener((o, p, n) -> { if (n == null) return; content.set(null); runLaterOrNowIfOnFXThread(() -> { // TODO what if n is null? getChildren().removeIf(x -> !(x instanceof ScrollBar)); n.setTransform(affine); targetWidth.set(n.width()); targetHeight.set(n.height()); }); }); final ChangeListener<Bounds> layoutBoundsListener = (o, p, n) -> { targetWidth.set(n.getWidth()); targetHeight.set(n.getHeight()); }; content.addListener((o, p, n) -> { if (p != null) p.layoutBoundsProperty().removeListener(layoutBoundsListener); if (n == null) return; target.set(null); runLaterOrNowIfOnFXThread(() -> { // TODO what if n is null? getChildren().add(0, n); n.getTransforms().add(affine); n.layoutBoundsProperty().addListener(layoutBoundsListener); targetWidth.set(n.getLayoutBounds().getWidth()); targetHeight.set(n.getLayoutBounds().getHeight()); }); }); }
private static Condition<Node> createBarCondition(Orientation orientation, boolean visible) { return new Condition<>(n -> { if (n instanceof ScrollBar) { ScrollBar bar = (ScrollBar) n; return ((ScrollBar) n).getOrientation() == orientation && visible == bar.isManaged() && visible == bar.isVisible(); } else return false; }, "Is ScrollBar " + orientation + " and " + (visible ? "visible" : "hidden")); }
/** * Disable the scroll bar in the command area when it appears. */ private void disableScrollBarCmd() { cmdArea.textProperty().addListener((observable, oldValue, newValue) -> { if (cmdArea.lookup(".scroll-bar") != null) { ScrollBar scrollBarv = (ScrollBar) cmdArea.lookup(".scroll-bar"); scrollBarv.setDisable(false); scrollBarv.setId("command-scroll-bar"); } }); }
protected ScrollBar createVScrollBar() { ScrollBar s = new ScrollBar(); s.setOrientation(Orientation.VERTICAL); s.setManaged(true); s.setMin(0.0); s.setMax(1.0); s.valueProperty().addListener((src,old,val) -> setAbsolutePositionVertical(val.doubleValue())); s.addEventFilter(ScrollEvent.ANY, (ev) -> ev.consume()); return s; }
protected ScrollBar createHScrollBar() { ScrollBar s = new ScrollBar(); s.setOrientation(Orientation.HORIZONTAL); s.setManaged(true); s.setMin(0.0); s.setMax(1.0); s.valueProperty().addListener((src,old,val) -> setAbsolutePositionHorizontal(val.doubleValue())); s.addEventFilter(ScrollEvent.ANY, (ev) -> ev.consume()); return s; }
/** * Find the scrollbar of the given table. * * @param node * @return */ public static ScrollBar findScrollBar(Node node, Orientation orientation) { Set<Node> below = node.lookupAll(".scroll-bar"); for (final Node nodeBelow : below) { if (nodeBelow instanceof ScrollBar) { ScrollBar sb = (ScrollBar) nodeBelow; if (sb.getOrientation() == orientation) { return sb; } } } return null; }
private void bindScrollBars() { ScrollBar plainTextScrollBar = plainTextList.lookupAll(".scroll-bar").stream().map(e -> (ScrollBar) e).filter(e -> e.getOrientation().equals(Orientation.HORIZONTAL)).findFirst().orElse(null); ScrollBar decryptedTextScrollBar = decryptedTextList.lookupAll(".scroll-bar").stream().map(e -> (ScrollBar) e).filter(e -> e.getOrientation().equals(Orientation.HORIZONTAL)).findFirst().orElse(null); if (plainTextScrollBar != null && decryptedTextScrollBar != null) { plainTextScrollBar.valueProperty().bindBidirectional(decryptedTextScrollBar.valueProperty()); } else { LOGGER.error("couldn't find scrollbars"); } }
@Override public Node drawNode() { ScrollBar scroll = createScroll(0, 100, vertical); scroll.setValue(50); scroll.setBlockIncrement(20); double new_value = scroll.getValue(); double desired = scroll.getMin() + position * (scroll.getMax() - scroll.getMin()); int direction = Double.compare(new_value, desired); scroll.adjustValue(position); if (direction != 0 && !Double.isNaN(position)) { double increment = scroll.getBlockIncrement(); if (Math.abs(desired - new_value) < increment) { new_value = desired; } else { if (direction == 1) { new_value -= increment; } else { new_value += increment; } } if (new_value < scroll.getMin()) { new_value = scroll.getMin(); } if (new_value > scroll.getMax()) { new_value = scroll.getMax(); } if (Double.compare(scroll.getValue(), new_value) != 0) { reportGetterFailure("ScrollBar.adjustValue()"); } } return scroll; }
@Override public Node drawNode() { ScrollBar scroll = createScroll(0, 100, vertical); scroll.setValue(50); scroll.setUnitIncrement(step); if (Double.compare(scroll.getUnitIncrement(), step) != 0) { reportGetterFailure("ScrollBar.getBlockIncrement()"); } for (int i = 0; i < count; i++) { double val = scroll.getValue(); if (decrement) { scroll.decrement(); val -= step; } else { scroll.increment(); val += step; } if (val < scroll.getMin()) { val = scroll.getMin(); } if (val > scroll.getMax()) { val = scroll.getMax(); } if (Double.compare(scroll.getValue(), val) != 0) { reportGetterFailure("ScrollBar.decrement()"); } } return scroll; }
@Override public Node drawNode() { ScrollBar scroll = createScroll(min, max, vertical); scroll.setValue(value); if (Double.compare(scroll.getMin(), min) != 0) { reportGetterFailure("Slider.getMin()"); } if (Double.compare(scroll.getMax(), max) != 0) { reportGetterFailure("Slider.getMax()"); } if (Double.compare(scroll.getValue(), value) != 0) { reportGetterFailure("Slider.getValue()"); } return scroll; }
@Override public Node drawNode() { ScrollBar scroll = createScroll(0, 100, vertical); scroll.setVisibleAmount(amount); if (Double.compare(scroll.getVisibleAmount(), amount) != 0) { reportGetterFailure("Slider.getVisibleAmount()"); } return scroll; }
protected ScrollBar createScroll(double min, double max, boolean vertical) { ScrollBar scroll = new ScrollBar(); scroll.setOrientation(vertical ? Orientation.VERTICAL : Orientation.HORIZONTAL); scroll.setMin(min); scroll.setMax(max); return scroll; }