Esempio n. 1
0
 public void drawPrevious() {
   if (!_dsi.atStart()) _dsi.retreat();
   DataSetElement dse = null;
   while (!_dsi.atStart()) {
     dse = _dsi.getElement();
     if (_filter.isAcceptable(dse)) break;
     _dsi.retreat();
   }
   _timeText.setText(dse.getXString());
   for (int i = 0; i < _dse.getDimension(); i++) _dse.setX(i, dse.getX(i + 1));
   _pdm.setReferenceObject(_dse);
   _canvas.redoNextPaint();
   _canvas.repaint();
   if (_dsi.atStart()) {
     timer.stopAnimation();
     return;
   }
 }
Esempio n. 2
0
 public void drawNext() {
   if (_dsi.atEnd()) {
     timer.stopAnimation();
   }
   DataSetElement dse = null;
   while (!_dsi.atEnd()) {
     dse = _dsi.getElement();
     if (_filter.isAcceptable(dse)) break;
     _dsi.advance();
   }
   if (dse == null) return; // no more good elements, probably at end
   _timeText.setText(dse.getXString());
   for (int i = 0; i < _dse.getDimension(); i++) _dse.setX(i, dse.getX(i + 1));
   // System.out.println(_dse);
   _pdm.setReferenceObject(_dse);
   _canvas.redoNextPaint();
   _canvas.repaint();
   if (!_dsi.atEnd()) _dsi.advance();
 }
Esempio n. 3
0
 public void increaseAnimationSpeed(int increment) {
   int delay = (int) timer.getInterval();
   if (delay - increment > 0) {
     timer.setInterval(delay - increment);
   }
 }
Esempio n. 4
0
 public PieChartAnimator(RegularTimeSeries[] rts) {
   int delay = 500;
   timer = new Animator();
   timer.setInterval(delay);
   timer.addAnimateDisplay(this);
   _canvas = setUpPieChart(rts);
   _filter = new NaNFilter();
   // set up buttons
   JButton fasterBtn = new JButton("faster");
   JButton slowerBtn = new JButton("slower");
   JButton stopBtn = new JButton("#");
   JButton forwardBtn = new JButton(">");
   JButton reverseBtn = new JButton("<");
   fasterBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           increaseAnimationSpeed(50);
         }
       });
   slowerBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           increaseAnimationSpeed(-50);
         }
       });
   forwardBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           goForward = true;
           timer.startAnimation();
         }
       });
   stopBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           timer.stopAnimation();
         }
       });
   reverseBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           goForward = false;
           timer.startAnimation();
         }
       });
   // setup button panel
   JPanel buttonPanel = new JPanel();
   buttonPanel.setLayout(new FlowLayout());
   buttonPanel.add(forwardBtn);
   buttonPanel.add(stopBtn);
   buttonPanel.add(reverseBtn);
   buttonPanel.add(fasterBtn);
   buttonPanel.add(slowerBtn);
   //
   JFrame fr = new JFrame();
   fr.getContentPane().setLayout(new BorderLayout());
   fr.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
   fr.getContentPane().add(_canvas, BorderLayout.CENTER);
   fr.pack();
   fr.setVisible(true);
   timer.startAnimation();
 }