gishur.gui2
Class ModelController

java.lang.Object
  |
  +--gishur.gui2.ModelController

public class ModelController
extends java.lang.Object

The ModelController manages a list of views of one model object. If the model changes, a simple call of makeDirty() notifies all registered views of that change and forces them to update.

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
ModelController(java.lang.Object source)
          Constructs a new ModelController connected with the specified source object.
 
Method Summary
 void addView(DrawAtom drw)
          Adds a view to the ModelController.
 boolean containsView(DrawAtom drw)
          Checks if the given DrawAtom is registered as view on this ModelController.
 void makeDirty()
          Notifies all registered views of a change at the model.
 void removeView(DrawAtom drw)
          Removes a view from the ModelController.
 void setSource(java.lang.Object source)
          Sets the source object (the model) of the controller.
 java.lang.Object source()
          Returns the source object (the model) of the controller.
 boolean sourceChanged()
          Returns true, if the source object has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelController

public ModelController(java.lang.Object source)
Constructs a new ModelController connected with the specified source object.
Parameters:
source - source (model) object of the controller.
Method Detail

source

public java.lang.Object source()
Returns the source object (the model) of the controller.
Returns:
The source object.

setSource

public void setSource(java.lang.Object source)
Sets the source object (the model) of the controller. All view will be notified via makeDirty().
Parameters:
source - the new source object

sourceChanged

public boolean sourceChanged()
Returns true, if the source object has changed. The method will only return true, while the views are set dirty as result of a source change.
Returns:
true, if the source object has changed.

addView

public void addView(DrawAtom drw)
Adds a view to the ModelController.
Parameters:
drw - DrawAtom to add as view.

removeView

public void removeView(DrawAtom drw)
Removes a view from the ModelController.
Parameters:
drw - DrawAtom to remove.

containsView

public boolean containsView(DrawAtom drw)
Checks if the given DrawAtom is registered as view on this ModelController.
Parameters:
drw - DrawAtom to check
Returns:
true, if drw is registered as view, false otherwise.

makeDirty

public void makeDirty()
Notifies all registered views of a change at the model.