@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(); } }
@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(); } }
/** * Creates a render pass position directly without adding it to the member list yet. Note that if * this position will not be used it must be removed with {@link #remove(RenderpassPosition)}. * This method is a convenience method for methods that have direct access to the member list like * {@link #doLayout(List)}. * * @param pass The render pass. * @return The converted render pass position. */ protected RenderpassPosition<T> create(final T pass) { final RenderpassPosition<T> rp = convert(pass); rp.checkBBoxChange(); addedRenderpassIntern(rp); return rp; }