Ejemplo n.º 1
0
 /**
  * Creates a render pass position.
  *
  * @param pass The render pass.
  * @param list The animation list.
  */
 public RenderpassPosition(final T pass, final AnimationList list) {
   super(new Point2D.Double(pass.getOffsetX(), pass.getOffsetY()));
   bbox = new Rectangle2D.Double();
   pass.getBoundingBox(bbox);
   this.pass = pass;
   list.addAnimated(this);
   pass.setAnimationList(list);
 }
Ejemplo n.º 2
0
    @Override
    protected AnimationAction beforeAnimation(
        final AnimationTiming timing, final AnimationAction onFinish) {
      if (timing.duration <= 0) return onFinish;
      pass.setForceCache(true);
      // TODO #43 -- Java 8 simplification
      return new AnimationAction() {

        @Override
        public void animationFinished() {
          pass.setForceCache(false);
          if (onFinish != null) {
            onFinish.animationFinished();
          }
        }
      };
    }
Ejemplo n.º 3
0
 @Override
 protected void doSet(final Point2D t) {
   super.doSet(t);
   pass.setOffset(t.getX(), t.getY());
 }
Ejemplo n.º 4
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();
   }
 }
Ejemplo n.º 5
0
 /**
  * Getter.
  *
  * @param rect When the position is in animation the resulting frame is the destination
  *     bounding-box of the render pass. Otherwise the current bounding box is used.
  */
 public void getPredictBBox(final Rectangle2D rect) {
   pass.getBoundingBox(rect);
   final Point2D pred = getPredict();
   rect.setFrame(
       rect.getX() + pred.getX(), rect.getY() + pred.getY(), rect.getWidth(), rect.getHeight());
 }