00001 package edu.stanford.hci.r3.pen; 00002 00003 import java.util.ArrayList; 00004 import java.util.List; 00005 00006 import edu.stanford.hci.r3.pen.streaming.listeners.PenListener; 00007 import edu.stanford.hci.r3.util.DebugUtils; 00008 00021 public abstract class PenInput { 00022 00027 protected boolean liveMode = false; 00028 00032 private String name; 00033 00039 protected List<PenListener> penListenersToAdd = new ArrayList<PenListener>(); 00040 00044 public PenInput(String penName) { 00045 setName(penName); 00046 } 00047 00058 public void addLivePenListener(PenListener penListener) { 00059 if (!isLive()) { 00060 DebugUtils.println("We are not registering this listener [" + penListener.toString() 00061 + "] with the event dispatcher at the moment. The Pen is not in Live Mode."); 00062 DebugUtils.println("We will keep this listener around until you startLiveMode()."); 00063 penListenersToAdd.add(penListener); 00064 } 00065 } 00066 00070 public String getName() { 00071 return name; 00072 } 00073 00077 public boolean isLive() { 00078 return liveMode; 00079 } 00080 00087 public void removeLivePenListener(PenListener penListener) { 00088 if (penListenersToAdd.contains(penListener)) { 00089 penListenersToAdd.remove(penListener); 00090 DebugUtils.println("Removed " + penListener + " from the cache of listeners."); 00091 } 00092 } 00093 00098 public void setName(String nomDePlume) { 00099 name = nomDePlume; 00100 } 00101 00102 public abstract void startLiveMode(); 00103 00104 public abstract void stopLiveMode(); 00105 00106 }