Examples of SWTTimingSource


Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

  public static void main(String args[]) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final TimingSource ts = new SWTTimingSource(display);
    Animator.setDefaultTimingSource(ts);
    ts.init();

    new RaceBasic(shell, "SWT Race (Basic)");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    ts.dispose();
    display.dispose();
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

  public static void main(String args[]) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final TimingSource ts = new SWTTimingSource(display);
    Animator.setDefaultTimingSource(ts);
    ts.init();

    final RaceCompleteMultiStep race = new RaceCompleteMultiStep(shell, "SWT Race (Multi-Step)");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    race.stopSoundEffects();
    ts.dispose();
    display.dispose();
    System.exit(0);
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

  private static Text f_benchmarkOutput;

  public static void main(String args[]) {
    f_display = Display.getDefault();

    TimingSource ts = new SWTTimingSource(DURATION / 10, TimeUnit.MILLISECONDS, f_display);
    Animator.setDefaultTimingSource(ts);
    ts.init();

    final Shell f_shell = new Shell(f_display);
    f_shell.setText("SWT SplineInterpolator Test");
    f_shell.setLayout(new FillLayout());
    f_benchmarkOutput = new Text(f_shell, SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    f_benchmarkOutput.setEditable(false);
    Font fixed = new Font(f_display, "Courier", 11, SWT.NONE);
    f_benchmarkOutput.setFont(fixed);
    f_benchmarkOutput.setBackground(f_display.getSystemColor(SWT.COLOR_BLACK));
    f_benchmarkOutput.setForeground(f_display.getSystemColor(SWT.COLOR_GREEN));

    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();
    }
    ts.dispose();
    f_display.dispose();
    System.exit(0);
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

public class DiscreteInterpolationTest extends TimingTargetAdapter {

  public static void main(String args[]) {
    f_display = Display.getDefault();

    TimingSource ts = new SWTTimingSource(100, TimeUnit.MILLISECONDS, f_display);
    Animator.setDefaultTimingSource(ts);
    ts.init();

    final Shell f_shell = new Shell(f_display);
    f_shell.setText("SWT DiscreteInterpolation Test");
    f_shell.setLayout(new FillLayout());
    f_benchmarkOutput = new Text(f_shell, SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
    f_benchmarkOutput.setEditable(false);
    Font fixed = new Font(f_display, "Courier", 11, SWT.NONE);
    f_benchmarkOutput.setFont(fixed);
    f_benchmarkOutput.setBackground(f_display.getSystemColor(SWT.COLOR_BLACK));
    f_benchmarkOutput.setForeground(f_display.getSystemColor(SWT.COLOR_GREEN));

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

    DiscreteInterpolationTest object = new DiscreteInterpolationTest();

    final KeyFrames<Integer> keyFrames = new KeyFrames.Builder<Integer>().addFrames(2, 6, 3, 5, 4)
        .setInterpolator(DiscreteInterpolator.getInstance()).build();
    out("Constructed Key Frames");
    out("----------------------");
    int i = 0;
    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();
    }
    ts.dispose();
    f_display.dispose();
    System.exit(0);
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

  public static void main(String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setText("SWT Triggers");

    final TimingSource ts = new SWTTimingSource(display);
    Animator.setDefaultTimingSource(ts);
    ts.init();

    createAndShowGUI(shell);

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    ts.dispose();
    display.dispose();
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setText("SWT Click and Go!");
    shell.setLayout(new FillLayout());

    final TimingSource ts = new SWTTimingSource(display);
    Animator.setDefaultTimingSource(ts);
    ts.init();

    setupGUI(shell, ts);

    shell.setSize(800, 600);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    ts.dispose();
    display.dispose();
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

  public static void main(String args[]) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final TimingSource ts = new SWTTimingSource(display);
    Animator.setDefaultTimingSource(ts);
    ts.init();

    new RaceBasicNonLinear(shell, "SWT Race (Non-Linear)");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    ts.dispose();
    display.dispose();
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setText("SWT Fading Button TF");
    shell.setLayout(new FillLayout());

    final TimingSource animationTimer = new SWTTimingSource(display);
    Animator.setDefaultTimingSource(animationTimer);

    f_squareColor = display.getSystemColor(SWT.COLOR_RED);

    final Canvas checkerboard = new Canvas(shell, SWT.DOUBLE_BUFFERED);
    checkerboard.setLayout(new GridLayout());
    checkerboard.addPaintListener(new PaintListener() {

      private static final int CHECKER_SIZE = 60;

      @Override
      public void paintControl(PaintEvent e) {
        final GC gc = e.gc;
        final int width = checkerboard.getSize().x;
        final int height = checkerboard.getSize().y;
        gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
        gc.fillRectangle(0, 0, width, height);
        gc.setBackground(f_squareColor);
        for (int stripeX = 0; stripeX < width; stripeX += CHECKER_SIZE) {
          for (int y = 0, row = 0; y < height; y += CHECKER_SIZE / 2, ++row) {
            int x = (row % 2 == 0) ? stripeX : (stripeX + CHECKER_SIZE / 2);
            gc.fillRectangle(x, y, CHECKER_SIZE / 2, CHECKER_SIZE / 2);
          }
        }
      }
    });

    final TimingTarget target = new TimingTargetAdapter() {

      Color c;

      @Override
      public void timingEvent(Animator source, double fraction) {
        if (c != null)
          c.dispose();
        // fade the red color
        int red = (int) (fraction * 255);
        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();
        }
      }
    });
    push.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false));

    animationTimer.init();

    shell.setSize(500, 300);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    animationTimer.dispose();
    display.dispose();
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

    shell.setText("SWT Too Many Balls!");

    /**
     * Used for ball animations.
     */
    final TimingSource animationTimer = new SWTTimingSource(display);
    Animator.setDefaultTimingSource(animationTimer);

    /**
     * Used to update the FPS display once a second.
     */
    final TimingSource infoTimer = new SWTTimingSource(1, TimeUnit.SECONDS, display);

    final GridLayout panelLayout = new GridLayout(2, false);
    shell.setLayout(panelLayout);
    GridData gridData;

    final Composite topPanel = new Composite(shell, SWT.NONE);
    gridData = new GridData(SWT.LEFT, SWT.FILL, false, false);
    topPanel.setLayoutData(gridData);
    final RowLayout topPanelLayout = new RowLayout();
    topPanel.setLayout(topPanelLayout);

    final Button addBall = new Button(topPanel, SWT.PUSH);
    addBall.setText("Add Ball");
    addBall.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event event) {
        addBall();
        updateBallCount();
      }
    });
    final Button add10Balls = new Button(topPanel, SWT.PUSH);
    add10Balls.setText("Add 10 Balls");
    add10Balls.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event event) {
        addBall();
        addBall();
        addBall();
        addBall();
        addBall();
        addBall();
        addBall();
        addBall();
        addBall();
        addBall();
        updateBallCount();
      }
    });

    final Button removeBall = new Button(topPanel, SWT.PUSH);
    removeBall.setText("Remove Ball");
    removeBall.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event event) {
        removeBall();
        updateBallCount();
      }
    });
    final Button remove10Balls = new Button(topPanel, SWT.PUSH);
    remove10Balls.setText("Remove 10 Balls");
    remove10Balls.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event event) {
        removeBall();
        removeBall();
        removeBall();
        removeBall();
        removeBall();
        removeBall();
        removeBall();
        removeBall();
        removeBall();
        removeBall();
        updateBallCount();
      }
    });

    f_infoLabel = new Label(shell, SWT.RIGHT);
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    f_infoLabel.setLayoutData(gridData);
    updateBallCount();

    f_panel = new Canvas(shell, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    f_panel.setLayoutData(gridData);
    f_panel.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

    JRenderer renderer = JRendererFactory.getDefaultRenderer(f_panel, this);

    infoTimer.addTickListener(new TickListener() {
      @Override
      public void timingSourceTick(TimingSource source, long nanoTime) {
        updateBallCount();
      }
    });

    animationTimer.init();
    infoTimer.init();

    shell.setSize(800, 600);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    renderer.getTimingSource().dispose();
    renderer.shutdown();
    animationTimer.dispose();
    infoTimer.dispose();
    display.dispose();
  }
View Full Code Here

Examples of org.jdesktop.swt.animation.timing.sources.SWTTimingSource

      f_display = display;
    }

    @Override
    public TimingSource getTimingSource(int periodMillis) {
      return new SWTTimingSource(periodMillis, TimeUnit.MILLISECONDS, f_display);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.