Java Code Examples for javafx.scene.control.ScrollPane#getContent()
The following examples show how to use
javafx.scene.control.ScrollPane#getContent() .
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: OnlyScrollPaneSkin.java From oim-fx with MIT License | 6 votes |
/*************************************************************************** * * Layout * * **************************************************************************/ @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { final ScrollPane sp = getSkinnable(); double vsbWidth = computeVsbSizeHint(sp); double minWidth = vsbWidth + snappedLeftInset() + snappedRightInset(); if (sp.getPrefViewportWidth() > 0) { return (sp.getPrefViewportWidth() + minWidth); } else if (sp.getContent() != null) { return (sp.getContent().prefWidth(height) + minWidth); } else { return Math.max(minWidth, DEFAULT_PREF_SIZE); } }
Example 2
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 3
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 4
Source File: OnlyScrollPaneSkin.java From oim-fx with MIT License | 5 votes |
@Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { final ScrollPane sp = getSkinnable(); double hsbHeight = computeHsbSizeHint(sp); double minHeight = hsbHeight + snappedTopInset() + snappedBottomInset(); if (sp.getPrefViewportHeight() > 0) { return (sp.getPrefViewportHeight() + minHeight); } else if (sp.getContent() != null) { return (sp.getContent().prefHeight(width) + minHeight); } else { return Math.max(minHeight, DEFAULT_PREF_SIZE); } }
Example 5
Source File: CodeEditor.java From ARMStrong with Mozilla Public License 2.0 | 5 votes |
private List<Node> getVisibleElements(ScrollPane pane) { List<Node> visibleNodes = new ArrayList<Node>(); Bounds paneBounds = pane.localToScene(pane.getBoundsInParent()); if (pane.getContent() instanceof Parent) { for (Node n : ((Parent) pane.getContent()).getChildrenUnmodifiable()) { Bounds nodeBounds = n.localToScene(n.getBoundsInLocal()); if (paneBounds.intersects(nodeBounds)) { visibleNodes.add(n); } } } return visibleNodes; }