/** * Gets the rectangle at the specified coordinates if there is one. The coordinates may even point in the middle of a rectangle to be found. Searches from the background to the foreground which means that rectangles behind other rectangles will be preferred. * <br> * <b>Only finds Rectangles, no other shapes</b> * * @param x The x-coordinate of the point to look for. * @param y The y-coordinate of the point to look for. * @return The rectangle that was found or {@code null} if none was found. */ public Rectangle getRectangleByCoordinatesPreferBack(double x, double y) { for (Node node : this.getChildren()) { if (node instanceof Rectangle) { Rectangle rectangle = (Rectangle) node; if (x >= rectangle.getX() && x <= (rectangle.getX() + rectangle.getWidth()) && y >= rectangle.getY() && y <= (rectangle.getY() + rectangle.getHeight())) { // region is correct return rectangle; } } } // nothing found, return null return null; }
@Override public Node createVisualRepresentation() { Pane pane = new Pane(); final Rectangle rectangle = new Rectangle(EVENT_WIDTH, EVENT_HEIGHT); rectangle.setFill(color); rectangle.setArcHeight(20); rectangle.setArcWidth(20); final Text text = new Text(getDisplayText()); text.setFontSmoothingType(FontSmoothingType.LCD); final double textWidth = text.getBoundsInLocal().getWidth(); final double testHeight = text.getBoundsInLocal().getHeight(); text.setX((rectangle.getWidth() / 2)-textWidth / 2); text.setY(rectangle.getHeight() / 2+testHeight / 4); pane.getChildren().add(rectangle); pane.getChildren().add(text); return pane; }
private void selectIntersectingNodes(Parent root, boolean deselect) { List<Node> selectableNodes = root.getChildrenUnmodifiable(). filtered(n -> n instanceof SelectableNode); boolean rectBigEnough = rectangle.getWidth() > 1 || rectangle.getHeight() > 1; for (Node n : selectableNodes) { boolean selectN = rectangle.intersects( rectangle.parentToLocal( n.localToParent(n.getBoundsInLocal()))); SelectableNode sn = (SelectableNode) n; if ((deselect || potentiallySelected(sn)) || (selectN && rectBigEnough)) { WindowUtil.getDefaultClipboard().select( sn, (selectN && rectBigEnough)); } } }
/** * Gets the rectangle at the specified coordinates if there is one. The coordinates may even point in the middle of a rectangle to be found. Searches from the foreground to the background which means that rectangles in front of other rectangles will be preferred. * <br> * <b>Only finds Rectangles, no other shapes</b> * * @param x The x-coordinate of the point to look for. * @param y The y-coordinate of the point to look for. * @return The rectangle that was found or {@code null} if none was found. */ public Rectangle getRectangleByCoordinatesPreferFront(double x, double y) { for (int i = this.getChildren().size() - 1; i >= 0; i--) { Node node = this.getChildren().get(i); if (node instanceof Rectangle) { Rectangle rectangle = (Rectangle) node; if (x >= rectangle.getX() && x <= (rectangle.getX() + rectangle.getWidth()) && y >= rectangle.getY() && y <= (rectangle.getY() + rectangle.getHeight())) { // region is correct return rectangle; } } } // nothing found, return null return null; } }
boolean heightChange = clip.getHeight() != height;
scrollRight.setHeight(newValue.doubleValue()); }); resetImage(mapImage, slaveClip.getWidth(), slaveClip.getHeight(), scale.doubleValue()); imgView.setClip(clip); shipCanvas.setClip(slaveClip);
@SuppressWarnings("MethodDoesntCallSuperMethod") @Override protected void layoutChildren() { double width = getWidth(); double height = getHeight(); double labelPrefWidth = label.prefWidth(height); double labelPrefHeight = label.prefHeight(width); rectangle.setX(0); rectangle.setY(0); rectangle.setWidth(labelPrefWidth + 10); rectangle.setHeight(labelPrefHeight + 6); label.resizeRelocate(5, 3, labelPrefWidth, labelPrefHeight); line.setStartX(width / 2.0); line.setEndX(line.getStartX()); line.setStartY(rectangle.getHeight()); line.setEndY(height); }
selectRect.getHeight() == 0.0 ) { selecting.set( false ); return;