@Override public final void drag( final Point2D _start, final Point2D cur, final double dx, final double dy) { if (dragging == null) return; // dx and dy do not change final Point2D pos = RenderpassPainter.getPositionFromCanvas(dragging, cur); dragging.drag(start, pos, dx, dy); }
/** * Checks whether the given render pass accepts the drag. When the render pass accepts the drag * everything is set up properly. * * @param r The render pass to check. * @param position The position in canvas coordinates. * @param e The mouse event. * @return Whether the drag was accepted. * @see #acceptDrag(Point2D, MouseEvent) */ private boolean acceptDrag(final Renderpass r, final Point2D position, final MouseEvent e) { if (!r.isVisible()) return false; final Rectangle2D bbox = new Rectangle2D.Double(); r.getBoundingBox(bbox); final Point2D pos = RenderpassPainter.getPositionFromCanvas(r, position); if (!bbox.contains(pos)) return false; if (!r.acceptDrag(pos, e)) return false; start = pos; dragging = r; return true; }
@Override public boolean moveMouse(final Point2D cur) { boolean moved = RenderpassPainter.moveMouse(nlFront, cur); for (final RenderpassPosition<T> p : reverseArray(members())) { final Renderpass r = p.pass; if (!r.isVisible()) { continue; } final Point2D pos = RenderpassPainter.getPositionFromCanvas(r, cur); if (r.moveMouse(pos)) { moved = true; } } return RenderpassPainter.moveMouse(nlBack, cur) || moved; }
/** * Picks a layouted render pass. * * @param position The position. * @return The render pass at the given position or <code>null</code> if there is none. */ protected Renderpass pickLayouted(final Point2D position) { final Rectangle2D bbox = new Rectangle2D.Double(); for (final RenderpassPosition<T> p : reverseArray(members())) { final Renderpass r = p.pass; if (!r.isVisible()) { continue; } r.getBoundingBox(bbox); final Point2D pos = RenderpassPainter.getPositionFromCanvas(r, position); if (!bbox.contains(pos)) { continue; } return r; } return null; }
@Override public boolean click(final Camera cam, final Point2D position, final MouseEvent e) { if (RenderpassPainter.click(nlFront, cam, position, e)) return true; final Rectangle2D bbox = new Rectangle2D.Double(); for (final RenderpassPosition<T> p : reverseArray(members())) { final Renderpass r = p.pass; if (!r.isVisible()) { continue; } r.getBoundingBox(bbox); final Point2D pos = RenderpassPainter.getPositionFromCanvas(r, position); if (!bbox.contains(pos)) { continue; } if (r.click(cam, pos, e)) return true; } return RenderpassPainter.click(nlBack, cam, position, e); }
@Override public String getTooltip(final Point2D position) { final String tt = RenderpassPainter.getTooltip(nlFront, position); if (tt != null) return tt; final Rectangle2D bbox = new Rectangle2D.Double(); for (final RenderpassPosition<T> p : reverseArray(members())) { final Renderpass r = p.pass; if (!r.isVisible()) { continue; } r.getBoundingBox(bbox); final Point2D pos = RenderpassPainter.getPositionFromCanvas(r, position); if (!bbox.contains(pos)) { continue; } final String tooltip = r.getTooltip(pos); if (tooltip != null) return tooltip; } return RenderpassPainter.getTooltip(nlBack, position); }