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 Lesser General Public License (LGPL): http://www.gnu.org/licenses/ 004 005 package graphlab.library.algorithms; 006 007 import graphlab.library.event.Event; 008 import graphlab.library.event.EventDispatcher; 009 010 /** 011 * @author Omid Aladini 012 * Animated algorithms should extend this class. 013 */ 014 public abstract class Algorithm implements AlgorithmInterface { 015 /** 016 * Reference to the event dispatcher object. 017 */ 018 EventDispatcher dispatcher = null; 019 020 /** 021 * Gets a reference to the dispatcher object responsible for dispatching events. 022 * 023 * @param D Reference to the dispatcher object. 024 */ 025 public void acceptEventDispatcher(EventDispatcher D) { 026 dispatcher = D; 027 } 028 029 /** 030 * Sends the event <code>ae</code> to the dispatcher. 031 * 032 * @param ae The event object to be dispatched. 033 */ 034 public void dispatchEvent(Event ae) { 035 if (dispatcher != null && ae != null) 036 dispatcher.dispatchEvent(ae); 037 } 038 039 protected EventDispatcher getDispatcher() { 040 return dispatcher; 041 042 } 043 }