001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.plugins.algorithmanimator.core; 005 006 import graphlab.library.algorithms.AutomatedAlgorithm; 007 import graphlab.platform.core.AbstractAction; 008 import graphlab.platform.core.BlackBoard; 009 import graphlab.ui.UIUtils; 010 011 /** 012 * @author azin azadi 013 */ 014 public abstract class SimpleAlgorithmAnimator extends AbstractAction { 015 /** 016 * constructor 017 * 018 * @param bb the blackboard of the action 019 */ 020 public SimpleAlgorithmAnimator(BlackBoard bb) { 021 super(bb); 022 listen4Event(UIUtils.getUIEventKey(getID())); 023 } 024 025 public void performAction(String eventName, Object value) { 026 startAnim(); 027 } 028 029 private void startAnim() { 030 new Thread() { 031 public void run() { 032 AlgorithmAnimator a = new AlgorithmAnimator(blackboard); 033 a.animateAlgorithm(getAlgorithm()); 034 } 035 }.start(); 036 037 } 038 039 public abstract String getID(); 040 041 public abstract AutomatedAlgorithm getAlgorithm(); 042 }