Java Code Examples for javafx.scene.control.ScrollPane#getVmax()
The following examples show how to use
javafx.scene.control.ScrollPane#getVmax() .
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: FXEventQueueDevice.java From marathonv5 with Apache License 2.0 | 6 votes |
protected void ensureVisible(Node target) { ScrollPane scrollPane = getParentScrollPane(target); if (scrollPane == null) { return; } Node content = scrollPane.getContent(); Bounds contentBounds = content.localToScene(content.getBoundsInLocal()); Bounds viewportBounds = scrollPane.getViewportBounds(); Bounds nodeBounds = target.localToScene(target.getBoundsInLocal()); if (scrollPane.contains(nodeBounds.getMinX() - contentBounds.getMinX(), nodeBounds.getMinY() - contentBounds.getMinY())) { return; } double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY()) * ((scrollPane.getVmax() - scrollPane.getVmin()) / (contentBounds.getHeight() - viewportBounds.getHeight())); scrollPane.setVvalue(toVScroll); double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX()) * ((scrollPane.getHmax() - scrollPane.getHmin()) / (contentBounds.getWidth() - viewportBounds.getWidth())); scrollPane.setHvalue(toHScroll); }
Example 2
Source File: ScrollPaneSample2.java From marathonv5 with Apache License 2.0 | 6 votes |
private void scrollTo(Node target) { ScrollPane scrollPane = getParentScrollPane(target); if (scrollPane == null) return; Node content = scrollPane.getContent(); Bounds contentBounds = content.localToScene(content.getBoundsInLocal()); Bounds viewportBounds = scrollPane.getViewportBounds(); Bounds nodeBounds = target.localToScene(target.getBoundsInLocal()); double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY()) * ((scrollPane.getVmax() - scrollPane.getVmin()) / (contentBounds.getHeight() - viewportBounds.getHeight())); if (toVScroll >= scrollPane.getVmin() && toVScroll < scrollPane.getVmax()) scrollPane.setVvalue(toVScroll); double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX()) * ((scrollPane.getHmax() - scrollPane.getHmin()) / (contentBounds.getWidth() - viewportBounds.getWidth())); if (toHScroll >= scrollPane.getHmin() && toHScroll < scrollPane.getHmax()) scrollPane.setHvalue(toHScroll); }
Example 3
Source File: ZoomPane.java From java-ml-projects with Apache License 2.0 | 5 votes |
private static Point2D figureScrollOffset(Node scrollContent, ScrollPane scroller) { double extraWidth = scrollContent.getLayoutBounds().getWidth() - scroller.getViewportBounds().getWidth(); double hScrollProportion = (scroller.getHvalue() - scroller.getHmin()) / (scroller.getHmax() - scroller.getHmin()); double scrollXOffset = hScrollProportion * Math.max(0, extraWidth); double extraHeight = scrollContent.getLayoutBounds().getHeight() - scroller.getViewportBounds().getHeight(); double vScrollProportion = (scroller.getVvalue() - scroller.getVmin()) / (scroller.getVmax() - scroller.getVmin()); double scrollYOffset = vScrollProportion * Math.max(0, extraHeight); return new Point2D(scrollXOffset, scrollYOffset); }
Example 4
Source File: JFXRepresentation.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Ctrl-Wheel zoom gesture help function * Store scroll offset of scrollContent (scroll_body Group) in a scroller (model_root ScrollPane) before zoom */ private Point2D figureScrollOffset(final Node scrollContent, final ScrollPane scroller) { double extraWidth = scrollContent.getLayoutBounds().getWidth() - scroller.getViewportBounds().getWidth(); double hScrollProportion = (scroller.getHvalue() - scroller.getHmin()) / (scroller.getHmax() - scroller.getHmin()); double scrollXOffset = hScrollProportion * Math.max(0, extraWidth); double extraHeight = scrollContent.getLayoutBounds().getHeight() - scroller.getViewportBounds().getHeight(); double vScrollProportion = (scroller.getVvalue() - scroller.getVmin()) / (scroller.getVmax() - scroller.getVmin()); double scrollYOffset = vScrollProportion * Math.max(0, extraHeight); return new Point2D(scrollXOffset, scrollYOffset); }