// @topic S-0301-01-15-20 Java JTable and MVC Architecture Demo
// @brief class ThreadAnimation (a worker thread)

package Week01;

public class ControllerDemo {
    //------------------------------
    // data
    //------------------------------
    private MainWindow window;
    private ThreadAnimation animationThread;

    //------------------------------
    // constructors
    //------------------------------

    //------------------------------
    // operations
    //------------------------------
    public MainWindow getWindow()
    {
        return window;
    }//getWindow

    public void setWindow(MainWindow window) {
        this.window = window;
    }//setWindow
    
    public void startAnimation()
    {
        // create and start new thread:
        animationThread = new ThreadAnimation( this );
        Thread th = new Thread( animationThread );
        th.start();
    }//startAnimation
    
    public void animate() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                window.update();
            }
        });        
    }//animate
    
    public int getCurrentData() {
        return animationThread.getCount();
    }//getCurrentData
    
}//class ControllerDemo