private boolean scrolledAllToTheRight() { return clip.getX() >= imgView.getImage().getWidth() - clip.getWidth(); }
private void focusOnPoint(Point2D focus) { double totalwidth = imgView.getImage().getWidth(); double focusX = focus.getX(); double clipX = clip.getX(); double clipWidth = clip.getWidth(); double centerX = clipX + clipWidth/2; if (clipX == 0.0 && focusX < centerX) { // we are all to the left } else if (clipX + clipWidth >= totalwidth) { // we are all to the right } else { double x = Math.min(focusX - clipWidth/2, totalwidth - clipWidth); resetClipXPosition(x); } }
/** * 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 adapterRectangle = new Rectangle(ADAPTER_WIDTH, ADAPTER_HEIGHT); adapterRectangle.setFill(ADAPTER_COLOR); adapterRectangle.setArcHeight(25); adapterRectangle.setArcWidth(25); final Text adapterText = new Text(id); adapterText.setFontSmoothingType(FontSmoothingType.LCD); adapterText.setX(adapterRectangle.getWidth() / 2-adapterText.getBoundsInLocal().getWidth() / 2); adapterText.setY(-5); pane.getChildren().add(adapterRectangle); pane.getChildren().add(adapterText); return pane; }
@Override public Node createVisualRepresentation() { Pane pane = new Pane(); final Rectangle workflowRectangle = new Rectangle(WIDTH + 20, EventAnimationBase.EVENT_HEIGHT + 15); workflowRectangle.setFill(WORKFLOW_COLOR); workflowRectangle.setArcHeight(25); workflowRectangle.setArcWidth(25); final Text classText = new Text(workflowClass); classText.setFontSmoothingType(FontSmoothingType.LCD); classText.setX(workflowRectangle.getWidth() / 2-classText.getBoundsInLocal().getWidth() / 2); classText.setY(-16); final Text instanceIdText = new Text(id); instanceIdText.setFont(Font.font(Font.getDefault().getName(), 10)); instanceIdText.setFontSmoothingType(FontSmoothingType.LCD); instanceIdText.setX(workflowRectangle.getWidth() / 2-classText.getBoundsInLocal().getWidth() / 2); instanceIdText.setY(-3); pane.getChildren().add(workflowRectangle); pane.getChildren().add(classText); pane.getChildren().add(instanceIdText); return pane; }
@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; } }
clip.widthProperty().addListener((observable, oldValue, newValue) -> { slaveClip.setWidth(newValue.doubleValue()); scrollRight.setX(newValue.doubleValue() - scrollRight.getWidth()); }); clip.heightProperty().addListener((observable, oldValue, newValue) -> { scrollRight.setHeight(newValue.doubleValue()); }); resetImage(mapImage, slaveClip.getWidth(), slaveClip.getHeight(), scale.doubleValue()); imgView.setClip(clip); shipCanvas.setClip(slaveClip);
Rectangle trace = new Rectangle(Math.abs(newWidth - innerBar.getWidth()), height.get() - 6); trace.setArcWidth(innerBar.getArcWidth()); trace.setArcHeight(innerBar.getArcHeight()); trace.setTranslateX(innerBar.getWidth() < newWidth ? innerBar.getWidth() : newWidth); trace.setTranslateY(3); trace.setFill(traceFill); trace.setEffect(new Glow(0.5)); if (trace.getWidth() > 50) { barGroup.getChildren().add(trace);
Rectangle trace = new Rectangle(Math.abs(newWidth - innerBar.getWidth()), height.get() - 6); trace.setArcWidth(innerBar.getArcWidth()); trace.setArcHeight(innerBar.getArcHeight()); trace.setTranslateX(innerBar.getWidth() < newWidth ? innerBar.getWidth() : newWidth); trace.setTranslateY(3); trace.setFill(traceFill); trace.setEffect(new Glow(0.5)); if (trace.getWidth() > 50) { barGroup.getChildren().add(trace);
time.setLayoutX(ph.getWidth() - spacing - 32); dateTxt.setLayoutX(time.getLayoutX() - spacing - dateTxt.getBoundsInLocal().getWidth()); dateTxt.setTextOrigin(VPos.BASELINE);
if ( selectRect.getWidth() == 0.0 || selectRect.getHeight() == 0.0 ) { selecting.set( false );