List of usage examples for javafx.geometry Bounds contains
public abstract boolean contains(Bounds b);
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * * {@inheritDoc}/*from ww w .ja v a 2s. c o m*/ */ public boolean isMouseInComponent(final Object graphicsComponent) { final Point currMousePos = getCurrentMousePosition(); return EventThreadQueuerJavaFXImpl.invokeAndWait("isMouseInComponent", //$NON-NLS-1$ new Callable<Boolean>() { @Override public Boolean call() throws Exception { if (graphicsComponent instanceof Node) { Node comp = (Node) graphicsComponent; comp.getScene().getRoot().layout(); if (currMousePos == null) { return false; } return NodeBounds.checkIfContains(new Point2D(currMousePos.x, currMousePos.y), comp); } Stage comp = (Stage) graphicsComponent; comp.getScene().getRoot().layout(); Bounds stageBounds = new BoundingBox(comp.getX(), comp.getY(), comp.getWidth(), comp.getHeight()); return stageBounds.contains(new Point2D(currMousePos.x, currMousePos.y)); } }); }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java
@ThreadConfined(type = ThreadType.UI) private void scrollToFileID(final Long newFileID) { if (newFileID == null) { //scrolling to no file doesn't make sense, so abort. return;/* w ww.ja v a 2s. c om*/ } int selectedIndex = grouping.get().fileIds().indexOf(newFileID); if (selectedIndex == -1) { //somehow we got passed a file id that isn't in the curent group. //this should never happen, but if it does everything is going to fail, so abort. return; } Optional<ScrollBar> scrollBarOptional = getScrollBar(); scrollBarOptional.ifPresent((ScrollBar scrollBar) -> { DrawableCell cell = cellMap.get(newFileID); //while there is no tile/cell for the given id, scroll based on index in group while (cell == null) { Integer minIndex = cellMap.keySet().stream().map(grouping.get().fileIds()::indexOf) .min(Integer::compare).get(); Integer maxIndex = cellMap.keySet().stream().map(grouping.get().fileIds()::indexOf) .max(Integer::compare).get(); if (selectedIndex < minIndex) { scrollBar.decrement(); } else if (selectedIndex > maxIndex) { scrollBar.increment(); } else { //sometimes the cellMap isn't up to date, so move the position arbitrarily to update the cellMap //TODO: this is clunky and slow, find a better way to do this scrollBar.adjustValue(.5); } cell = cellMap.get(newFileID); } final Bounds gridViewBounds = gridView.localToScene(gridView.getBoundsInLocal()); Bounds tileBounds = cell.localToScene(cell.getBoundsInLocal()); //while the cell is not within the visisble bounds of the gridview, scroll based on screen coordinates int i = 0; while (gridViewBounds.contains(tileBounds) == false && (i++ < 100)) { if (tileBounds.getMinY() < gridViewBounds.getMinY()) { scrollBar.decrement(); } else if (tileBounds.getMaxY() > gridViewBounds.getMaxY()) { scrollBar.increment(); } tileBounds = cell.localToScene(cell.getBoundsInLocal()); } }); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.drawableviews.GroupPane.java
@ThreadConfined(type = ThreadType.JFX) private void scrollToFileID(final Long newFileID) { if (newFileID == null) { return; //scrolling to no file doesn't make sense, so abort. }// w w w . ja v a 2 s .co m final ObservableList<Long> fileIds = gridView.getItems(); int selectedIndex = fileIds.indexOf(newFileID); if (selectedIndex == -1) { //somehow we got passed a file id that isn't in the curent group. //this should never happen, but if it does everything is going to fail, so abort. return; } getScrollBar().ifPresent(scrollBar -> { DrawableCell cell = cellMap.get(newFileID); //while there is no tile/cell for the given id, scroll based on index in group while (isNull(cell)) { //TODO: can we maintain a cached mapping from fileID-> index to speed up performance //get the min and max index of files that are in the cellMap Integer minIndex = cellMap.keySet().stream().mapToInt(fileID -> fileIds.indexOf(fileID)).min() .getAsInt(); Integer maxIndex = cellMap.keySet().stream().mapToInt(fileID -> fileIds.indexOf(fileID)).max() .getAsInt(); //[minIndex, maxIndex] is the range of indexes in the fileIDs list that are currently displayed if (selectedIndex < minIndex) { scrollBar.decrement(); } else if (selectedIndex > maxIndex) { scrollBar.increment(); } else { //sometimes the cellMap isn't up to date, so move the position arbitrarily to update the cellMap //TODO: this is clunky and slow, find a better way to do this scrollBar.adjustValue(.5); } cell = cellMap.get(newFileID); } final Bounds gridViewBounds = gridView.localToScene(gridView.getBoundsInLocal()); Bounds tileBounds = cell.localToScene(cell.getBoundsInLocal()); //while the cell is not within the visisble bounds of the gridview, scroll based on screen coordinates int i = 0; while (gridViewBounds.contains(tileBounds) == false && (i++ < 100)) { if (tileBounds.getMinY() < gridViewBounds.getMinY()) { scrollBar.decrement(); } else if (tileBounds.getMaxY() > gridViewBounds.getMaxY()) { scrollBar.increment(); } tileBounds = cell.localToScene(cell.getBoundsInLocal()); } }); }