1 package JSci.instruments; 2 3 import java.util.*; 4 import java.awt.*; 5 import javax.swing.*; 6 import java.awt.event.*; 7 import javax.swing.event.*; 8 9 10 13 public abstract class PositionControlAdapter implements PositionControl { 14 15 18 abstract public void setPosition(double p); 19 20 25 abstract public double getPosition(); 26 27 32 abstract public double getActualPosition(); 33 34 37 abstract public double getMinimum(); 38 39 42 abstract public double getMaximum(); 43 44 46 abstract public void sleep(); 47 48 51 abstract public Component getControlComponent(); 52 53 57 abstract public String getUnit(); 58 59 60 61 64 69 private transient ChangeEvent changeEvent = null; 70 71 75 protected EventListenerList listenerList = new EventListenerList(); 76 77 78 85 public void addChangeListener(ChangeListener l) { 86 listenerList.add(ChangeListener.class, l); 87 } 88 89 90 96 public void removeChangeListener(ChangeListener l) { 97 listenerList.remove(ChangeListener.class, l); 98 } 99 100 101 108 public ChangeListener[] getChangeListeners() { 109 return (ChangeListener[])listenerList.getListeners( 110 ChangeListener.class); 111 } 112 113 114 119 protected void fireStateChanged() 120 { 121 Object [] listeners = listenerList.getListenerList(); 122 for (int i = listeners.length - 2; i >= 0; i -=2 ) { 123 if (listeners[i] == ChangeListener.class) { 124 if (changeEvent == null) { 125 changeEvent = new ChangeEvent(this); 126 } 127 ((ChangeListener)listeners[i+1]).stateChanged(changeEvent); 128 } 129 } 130 } 131 132 133 141 public EventListener[] getListeners(Class listenerType) { 142 return listenerList.getListeners(listenerType); 143 } 144 145 146 147 } 148 149 | Popular Tags |