|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.cmu.sun.model.Model
public class Model
A basic Observer pattern that holds off update notification. All models can have observers (or listeners) who listen for changes to the model. Most models notify listeners when the change happens. This model works slightly differently. The models mark when they need an update. Then, when the static method notifyAllListeners() is called, every Model object then notifys it's listeners if a change has occoured. There is probably a better way to handle this change, but we use this to hold off updates from applying to the scene graph untill all of the models have been updated first.
| Field Summary | |
|---|---|
private static java.util.List<Model> |
allModels
Pointers to every Model object created in the system. |
private java.util.Set<ModelListener> |
listeners
A set of listeners for this Model. |
private boolean |
modelNeedsUpdate
True if the model has changed that the listeners need an update. |
| Constructor Summary | |
|---|---|
Model()
Create a new model. |
|
| Method Summary | |
|---|---|
void |
addModelListener(ModelListener l)
Add a listener to this model. |
protected void |
needsUpdate()
Called by subclasses to signial that a model has changed and needs updating. |
static void |
notifyAllListeners()
Calls notifyListeners() on every Model object in the system. |
void |
notifyListeners()
Sends a modelChanged(...) call to all listeners of this model. |
void |
removeModelListener(ModelListener l)
Remove a listener from this model. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static java.util.List<Model> allModels
private java.util.Set<ModelListener> listeners
private boolean modelNeedsUpdate
| Constructor Detail |
|---|
public Model()
| Method Detail |
|---|
public void addModelListener(ModelListener l)
public void removeModelListener(ModelListener l)
public static void notifyAllListeners()
public void notifyListeners()
protected void needsUpdate()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||