Node node = ... Point2D screenCoordiantes = node.localToScreen(localX, localY);
public Collection<? extends HoverTarget> findHoverTargets(Point2D localLocation) { return this.usedNodes.entrySet().stream() .filter(e->e.getValue().getBoundsInParent().contains(localLocation)) .map(e->{ TextAnnotation annotation = e.getKey(); Bounds bounds = e.getValue().getBoundsInLocal(); Point2D anchor = new Point2D(bounds.getMinX(), bounds.getMaxY()); HoverTarget annotationTarget = new HoverTarget(annotation, toGlobal(annotation.getRange()), e.getValue().localToScreen(anchor), e.getValue().localToScreen(bounds)); return annotationTarget; }) .collect(Collectors.toList()); }
public <T extends Node & Caret> Bounds getCaretBoundsOnScreen(T caret) { layout(); // ensure layout, is a no-op if not dirty checkWithinParagraph(caret); Bounds localBounds = caret.getBoundsInLocal(); return caret.localToScreen(localBounds); }
private void show(@Nonnull Node parent) { Bounds bounds = parent.localToScreen(parent.getLayoutBounds()); show(parent, bounds.getMinX() + 5, bounds.getMinY() + bounds.getHeight() + 5); }
@Override public RNode<T> moveTo(Duration d, double x, double y) { Bounds bounds = node.localToScreen(node.getBoundsInLocal()); controller.run(Move.to(d,bounds.getMinX() + x, bounds.getMinY() + y)); return null; }
@Override public RNode<T> moveTo(double x, double y) { Bounds bounds = node.localToScreen(node.getBoundsInLocal()); controller.run(Move.to(bounds.getMinX() + x, bounds.getMinY() + y)); return this; }
@Override public RNode<T> dragTo(double x, double y) { Bounds bounds = node.localToScreen(node.getBoundsInLocal()); controller.run(Drag.to(bounds.getWidth() / 2, bounds.getHeight() / 2, x, y)); return this; }
@Override public RNode<T> dragTo(Duration d, double x, double y) { Bounds bounds = node.localToScreen(node.getBoundsInLocal()); controller.run(Drag.to(d, bounds.getWidth() / 2, bounds.getHeight() / 2, x, y)); return this; }
@Override public Point2D center() { Bounds bounds = node.localToScreen(node.getBoundsInLocal()); return new Point2D(bounds.getMinX() + bounds.getWidth()/2, bounds.getMinY() + bounds.getHeight()/2); }
@Override public RNode<T> dragBy(double dx, double dy) { Bounds bounds = node.localToScreen(node.getBoundsInLocal()); controller.run(Drag.by( bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY() + bounds.getHeight() / 2, dx, dy)); return this; }
@Override public RNode<T> dragBy(Duration d, double dx, double dy) { Bounds bounds = node.localToScreen(node.getBoundsInLocal()); controller.run(Drag.by(d, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY() + bounds.getHeight() / 2, dx, dy)); return this; }
/** * Sets up the code to fire a {@code BEGIN} event when the mouse becomes stationary over the node and has not * moved for the given amount of time ({@code delay}), and to fire a {@code END} event when the stationary * mouse moves again. Note: any previously installed delays will be removed without creating memory leaks. */ public void install(Duration delay) { if(installed != null) { installed.unsubscribe(); } installed = events(delay).<Event>map(either -> either.unify( pos -> MouseStationaryEvent.beginAt(node.localToScreen(pos)), stop -> MouseStationaryEvent.end())) .subscribe(evt -> Event.fireEvent(node, evt)); }
double y; Bounds bounds = node.localToScreen(node.getBoundsInLocal()); switch (position.getHpos()) { case CENTER:
double y; Bounds bounds = node.localToScreen(node.getBoundsInLocal()); switch (referencePoint.getHpos()) { case CENTER:
double y; Bounds bounds = node.localToScreen(node.getBoundsInLocal()); switch (referencePoint.getHpos()) { case CENTER:
/** * Updates the location when the effective size is known. */ protected void updateLocation() { Bounds linkedNodeBounds = linkedNode.localToScreen(linkedNode.getBoundsInLocal()); Point2D linkedNodeLocation = linkedNode.localToScreen(0.0, 0.0); if (linkedNodeBounds != null && linkedNodeLocation != null) { switch (note.getPosition()) { case BOTTOM: note.setAnchorX(linkedNodeLocation.getX() + linkedNodeBounds.getWidth() / 2 - note.getWidth() / 2); note.setAnchorY(linkedNodeLocation.getY() + linkedNodeBounds.getHeight() - CIRCLE_RADIUS); break; case TOP: note.setAnchorX(linkedNodeLocation.getX() + linkedNodeBounds.getWidth() / 2 - note.getWidth() / 2); note.setAnchorY(linkedNodeLocation.getY() - note.getHeight() + CIRCLE_RADIUS); break; case LEFT: note.setAnchorX(linkedNodeLocation.getX() - note.getWidth() + CIRCLE_RADIUS); note.setAnchorY(linkedNodeLocation.getY() + linkedNodeBounds.getHeight() / 2 - note.getHeight() / 2); break; default: // RIGHT note.setAnchorX(linkedNodeLocation.getX() + linkedNodeBounds.getWidth() - CIRCLE_RADIUS); note.setAnchorY(linkedNodeLocation.getY() + linkedNodeBounds.getHeight() / 2 - note.getHeight() / 2); } } }
requireNonNull(owner); Bounds bounds = owner.localToScreen(owner.getBoundsInLocal());