Package org.jdesktop.core.animation.timing

Examples of org.jdesktop.core.animation.timing.Animator


        controller.setBackground(to);
        repaint(controller);
      }
    };
   
    Animator animator = new Animator.Builder().addTarget(tt).setDuration(100, TimeUnit.MILLISECONDS).build();
    controller.setAnimator(animator);
    animator.start();
  }
View Full Code Here


        controller.setOffsetAnimator(null);
      }
    };
   
    Interpolator interpol = new AccelerationInterpolator(0.0, 0.1);
    Animator animator = new Animator.Builder().addTarget(timingTarget).setInterpolator(interpol).setDuration(250, TimeUnit.MILLISECONDS).build();
    controller.setOffsetAnimator(animator);
    animator.start();
    System.out.println("Started: " + System.currentTimeMillis());
  }
View Full Code Here

        controller.setBackgroundAnimator(null);
      }
    };
   
    Interpolator interpol = new AccelerationInterpolator(0.0, 0.1);
    Animator animator = new Animator.Builder().addTarget(timingTarget).setInterpolator(interpol).setDuration(100, TimeUnit.MILLISECONDS).build();
    controller.setBackgroundAnimator(animator);
    animator.start();
  }
View Full Code Here

    if (controller == null) {
      throw new NullPointerException();
    }
   
    if (controller.hasOffsetAnimator()) {
      Animator animator = controller.getOffsetAnimator();
      animator.cancel();
      controller.setOffsetAnimator(null);
    }

    Rectangle bounds = controller.getItemBounds();
    bounds.x += controller.getOffset();
    final int from = bounds.x;
   
    TimingTarget tt = new TimingTargetAdapter() {
      @Override
      public void timingEvent(Animator source, double fraction) {
        int distance = (int )Math.round(((double )to - (double )from) * fraction);
       
        Rectangle bounds = controller.getItemBounds();
        int oldOffset = controller.getOffset();
        int newOffset = from + distance - bounds.x;
        controller.setOffset(newOffset);
       
        if (!hasDraggedItem()) {
          Point mouseLocation = getDisplay().getCursorLocation();
          mouseLocation = toControl(mouseLocation);
          Rectangle testBounds = controller.getItemBounds();
          testBounds.x += controller.getOffset();
         
          if (testBounds.contains(mouseLocation)) {
            processFocus(controller);
          } else {
            processFocus(null);
          }
        }
       
        redraw(bounds.x + oldOffset, bounds.y, bounds.width, bounds.height, true);
        redraw(bounds.x + newOffset, bounds.y, bounds.width, bounds.height, true);
      }
      @Override
      public void end(Animator source) {
        Rectangle oldBounds = controller.getItemBounds();
        oldBounds.x += controller.getOffset();
       
        Rectangle newBounds = controller.getItemBounds();
        int newOffset = to - newBounds.x;
        controller.setOffset(newOffset);
        newBounds.x += newOffset;
       
        redraw(oldBounds.x, oldBounds.y, oldBounds.width, oldBounds.height, true);
        redraw(newBounds.x, newBounds.y, newBounds.width, newBounds.height, true);
      }
    };
   
    Interpolator interpol = new AccelerationInterpolator(0, 0.9);
    Animator animator = new Animator.Builder().addTarget(tt).setDuration(160, TimeUnit.MILLISECONDS).setInterpolator(interpol).build();
    controller.setOffsetAnimator(animator);
    animator.start();
  }
View Full Code Here

    if (controller == null) {
      throw new NullPointerException();
    }
   
    if (controller.hasBackgroundAnimator()) {
      Animator animator = controller.getBackgroundAnimator();
      animator.cancel();
      controller.setBackgroundAnimator(null);
    }
   
    final RGB from = controller.getBackground();
   
    TimingTarget tt = new TimingTargetAdapter() {
      @Override
      public void timingEvent(Animator source, double fraction) {
        double r = to.red - from.red;
        double g = to.green - from.green;
        double b = to.blue - from.blue;
       
        r *= fraction;
        g *= fraction;
        b *= fraction;
       
        r += from.red;
        g += from.green;
        b += from.blue;
       
        int red = (int )Math.round(r);
        int green = (int )Math.round(g);
        int blue = (int )Math.round(b);

        RGB rgb = new RGB(red, green, blue);
        controller.setBackground(rgb);
       
        Rectangle bounds = controller.getItemBounds();
        redraw(bounds.x, bounds.y, bounds.width, bounds.height, true);
      }
      @Override
      public void end(Animator source) {
        controller.setBackground(to);
       
        Rectangle bounds = controller.getItemBounds();
        redraw(bounds.x, bounds.y, bounds.width, bounds.height, true);
      }
    };
   
    Interpolator interpol = new AccelerationInterpolator(0, 0.9);
    Animator animator = new Animator.Builder().addTarget(tt).setDuration(160, TimeUnit.MILLISECONDS).setInterpolator(interpol).build();
    controller.setBackgroundAnimator(animator);
    animator.start();
  }
View Full Code Here

    f_shell.setSize(350, 500);
    f_shell.open();

    SplineInterpolator si = new SplineInterpolator(1, 0, 0, 1);
    Animator animator = new Animator.Builder().setDuration(DURATION, TimeUnit.MILLISECONDS).setInterpolator(si)
        .addTarget(new SplineInterpolatorTest()).build();
    animator.start();

    while (!f_shell.isDisposed()) {
      if (!f_display.readAndDispatch())
        f_display.sleep();
    }
View Full Code Here

    for (KeyFrames.Frame<Integer> keyFrame : keyFrames) {
      final String s = keyFrame.getInterpolator() == null ? "null" : keyFrame.getInterpolator().getClass().getSimpleName();
      out(String.format("Frame %d: value=%d timeFraction=%f interpolator=%s", i++, keyFrame.getValue(), keyFrame.getTimeFraction(),
          s));
    }
    final Animator animator = new Animator.Builder().setDuration(3, TimeUnit.SECONDS)
        .addTarget(PropertySetter.getTarget(object, "intValue", keyFrames)).addTarget(object).build();
    out("");
    out("Animation of intValue");
    out("---------------------");
    animator.start();

    while (!f_shell.isDisposed()) {
      if (!f_display.readAndDispatch())
        f_display.sleep();
    }
View Full Code Here

        Color c = new Color(display, new RGB(red, 0, 0));
        f_squareColor = c;
        checkerboard.redraw();
      }
    };
    final Animator animator = new Animator.Builder().setRepeatCount(Animator.INFINITE).setStartDirection(Direction.BACKWARD)
        .addTarget(target).build();
    final Button push = new Button(checkerboard, SWT.PUSH);
    push.setText("Start Animation");
    push.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event event) {
        if (!animator.isRunning()) {
          push.setText("Stop Animation");
          animator.start();
        } else {
          animator.stop();
          push.setText("Start Animation");
          // reset square color to red
          f_squareColor = display.getSystemColor(SWT.COLOR_RED);
          checkerboard.redraw();
        }
View Full Code Here

TOP

Related Classes of org.jdesktop.core.animation.timing.Animator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.