|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFinchModel
public class FinchModel
Field Summary | |
---|---|
private java.util.ArrayList<java.awt.event.ActionListener> |
actionListenerList
List of ActionListeners |
private java.util.Random |
generator
|
private int[] |
light
Local copy of the current light levels |
private finch.Finch |
myFinch
Reference to the Finch object |
private double |
temperature
Local copy of the current temperature |
Constructor Summary | |
---|---|
FinchModel(finch.Finch myFinch)
Constructor |
Method Summary | |
---|---|
void |
addActionListener(java.awt.event.ActionListener listener)
Add an ActionListener to the listener list Note: this method is declared as "synchronized" so that only one thread is operating on the actionListenerList at once (each of our Window objects have their own threads) Implementation from Listing 32.2 of Introduction to Java (Liang) |
int[] |
getLight()
Accessor |
double |
getTemperature()
Accessor |
private void |
processEvent(java.awt.event.ActionEvent e)
Alert the listeners that a new event has occurred Implementation from Listing 32.2 of Introduction to Java (Liang) |
void |
removeActionListener(java.awt.event.ActionListener listener)
Remove an ActionListener to the listener list Implementation from Listing 32.2 of Introduction to Java (Liang) |
void |
updateLight()
Called by controller to force the model to update its currently stored light levels. |
void |
updateTemperature()
Called by controller to force the model to update its currently stored temperature level TODO: Complete implementation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private finch.Finch myFinch
private double temperature
private int[] light
private java.util.ArrayList<java.awt.event.ActionListener> actionListenerList
private java.util.Random generator
Constructor Detail |
---|
public FinchModel(finch.Finch myFinch)
myFinch
- Reference to the Finch object. If null, then assumes
that no Finch is connected (and will fill in random data)Method Detail |
---|
public void updateLight()
TODO: complete implementation
public void updateTemperature()
TODO: Complete implementation
public double getTemperature()
public int[] getLight()
public void addActionListener(java.awt.event.ActionListener listener)
Note: this method is declared as "synchronized" so that only one thread is operating on the actionListenerList at once (each of our Window objects have their own threads)
Implementation from Listing 32.2 of Introduction to Java (Liang)
listener
- Reference to the listener to be addedpublic void removeActionListener(java.awt.event.ActionListener listener)
listener
- Listener to be removedprivate void processEvent(java.awt.event.ActionEvent e)
e
- ActionEvent to be sent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |