Exemplo n.º 1
0
 @Override
 public void getBoundingBox(final RectangularShape bbox) {
   ensureLayout();
   boolean change = false;
   RenderpassPainter.getBoundingBox(bbox, nlFront);
   final Rectangle2D rect = new Rectangle2D.Double();
   RenderpassPainter.getBoundingBox(rect, nlBack);
   RenderpassPainter.addToRect(bbox, rect);
   if (layout != null) {
     change = layout.addBoundingBox(bbox, members);
   } else {
     for (final RenderpassPosition<T> p : members) {
       if (!p.pass.isVisible()) {
         continue;
       }
       if (p.checkBBoxChange()) {
         change = true;
       }
       RenderpassPainter.addToRect(bbox, p.getPassBBox());
     }
   }
   if (change) {
     invalidate();
   }
 }
Exemplo n.º 2
0
 @Override
 public void processMessage(final String[] ids, final String msg) {
   super.processMessage(ids, msg);
   RenderpassPainter.processMessage(nlBack, ids, msg);
   RenderpassPainter.processMessage(nlFront, ids, msg);
   for (final RenderpassPosition<T> p : members) {
     p.pass.processMessage(ids, msg);
   }
 }
Exemplo n.º 3
0
 @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;
 }
Exemplo n.º 4
0
 @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);
 }
Exemplo n.º 5
0
 @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);
 }
Exemplo n.º 6
0
 /**
  * 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;
 }
Exemplo n.º 7
0
 @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);
 }
Exemplo n.º 8
0
 /**
  * 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;
 }
Exemplo n.º 9
0
 @Override
 public void draw(final Graphics2D gfx, final KanvasContext ctx) {
   ensureLayout();
   if (layout != null) {
     final Graphics2D g = (Graphics2D) gfx.create();
     final Rectangle2D bbox = new Rectangle2D.Double();
     getBoundingBox(bbox);
     layout.drawBackground(g, ctx, bbox, members);
     g.dispose();
   }
   gfx.setColor(java.awt.Color.GREEN);
   RenderpassPainter.draw(nlBack, gfx, ctx);
   final Rectangle2D view = ctx.getVisibleCanvas();
   boolean changed = false;
   T last = null;
   for (final RenderpassPosition<T> p : members) {
     final T r = p.pass;
     if (!r.isVisible()) {
       continue;
     }
     if (p.checkBBoxChange()) {
       changed = true;
     }
     final Rectangle2D bbox = p.getPassBBox();
     if (!view.intersects(bbox)) {
       continue;
     }
     final Graphics2D g = (Graphics2D) gfx.create();
     g.clip(bbox);
     final double dx = r.getOffsetX();
     final double dy = r.getOffsetY();
     g.translate(dx, dy);
     final KanvasContext c = RenderpassPainter.getContextFor(r, ctx);
     r.draw(g, c);
     g.dispose();
     drawBetween(gfx, ctx, last, r);
     last = r;
   }
   drawBetween(gfx, ctx, last, null);
   if (jkanvas.Canvas.DEBUG_BBOX) {
     final Graphics2D g = (Graphics2D) gfx.create();
     PaintUtil.setAlpha(g, 0.3);
     g.setColor(java.awt.Color.BLUE);
     for (final RenderpassPosition<T> rp : members) {
       final Renderpass r = rp.pass;
       if (!r.isVisible()) {
         continue;
       }
       if (rp.checkBBoxChange()) {
         changed = true;
       }
       final Rectangle2D bbox = rp.getPassBBox();
       if (!view.intersects(bbox)) {
         continue;
       }
       g.fill(bbox);
     }
   }
   gfx.setColor(java.awt.Color.GREEN);
   RenderpassPainter.draw(nlFront, gfx, ctx);
   if (changed) {
     invalidate();
   }
 }
Exemplo n.º 10
0
 /**
  * Checks whether the bounding box has changed since the last call and sets the current bounding
  * box.
  *
  * @return Whether the bounding box has changed.
  */
 public boolean checkBBoxChange() {
   final double oldWidth = bbox.getWidth();
   final double oldHeight = bbox.getHeight();
   RenderpassPainter.getPassBoundingBox(bbox, pass);
   return bbox.getWidth() != oldWidth || bbox.getHeight() != oldHeight;
 }