harmonic.mz.manager
Class ValidationManager

java.lang.Object
  |
  +--harmonic.mz.manager.ValidationManager

public class ValidationManager
extends java.lang.Object

This handles the validation the data state so that all DataNode's are valid with respect to their dependancies. The validation system is supported through some functions in ModelNode and ValidationManager. A node that becomes invalid (so that its external state no longer matches its internal state) is passed to the addInvalid() function, causesing an envent to be posted. When the event is processed, all invalid objects are validated at the same time by the ValidationManager. A nodes that are dependants of other nodes are validated first. Cyclical dependancies are checked.


Constructor Summary
ValidationManager()
           
 
Method Summary
 void addInvalid(DataNode node)
          Add object to invalid list.
 void addValidationListener(ValidationListener l)
          Register listener of validations.
 void clearInvalidObjects()
          Clear invalid list
 void clearValidated(DataNode node)
          Unmark this node as validated.
 java.util.Vector getInvalidObjects()
          Return invalid node list.
 boolean isValidated(DataNode node)
          Use this in combination with markValidated() to prevent infinite recursion of node validation.
 void markValidated(DataNode node)
          Mark this node as validated.
 void notifyListeners()
          Notify listener's of validations.
 void removeValidationListener(ValidationListener l)
          Un-Register listener of validations.
 void validateNode(ModelNode node)
          Validate the node and any dependancies
 void validateNode(ModelNode node, boolean bAnyParentVisible)
           
 void validateScene()
          validateScene(true)
 void validateScene(boolean bAlowSpawnThread)
          Validate the invalid list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationManager

public ValidationManager()
Method Detail

isValidated

public boolean isValidated(DataNode node)
Use this in combination with markValidated() to prevent infinite recursion of node validation.


markValidated

public void markValidated(DataNode node)
Mark this node as validated. This mark will last untill the next validation job.


clearValidated

public void clearValidated(DataNode node)
Unmark this node as validated.


addValidationListener

public void addValidationListener(ValidationListener l)
Register listener of validations.


removeValidationListener

public void removeValidationListener(ValidationListener l)
Un-Register listener of validations.


notifyListeners

public void notifyListeners()
Notify listener's of validations.


addInvalid

public void addInvalid(DataNode node)
Add object to invalid list. It will be validated in next validate job. This is called by ModelNode.invalidate(). The node will not be added if the calling thread is executing a redraw. And the node will not be added if ViewportManager.invalidateEnabled() is false. Also, if the node is currently being validated, it will not be added.


clearInvalidObjects

public void clearInvalidObjects()
Clear invalid list


getInvalidObjects

public java.util.Vector getInvalidObjects()
Return invalid node list.


validateNode

public void validateNode(ModelNode node)
Validate the node and any dependancies


validateNode

public void validateNode(ModelNode node,
                         boolean bAnyParentVisible)

validateScene

public void validateScene()
validateScene(true)


validateScene

public void validateScene(boolean bAlowSpawnThread)
Validate the invalid list. Nodes are validated in in order that tries to ensure a the dependants of a node are validate befor that node. A secondary thread may be spawned if any nodes request it with ModelNode.shouldSpawnThread().

For every invalid object, if any are known to require a lenghtly calculation, do it in another thread. Else just do it in this thread (to make the interactively created objects smoother) Note that this function is always run in the message loop thread.

If this is called from Viewport before it paints and a new thread is spawned, things will still be not be validated during the paint job. Assuming this is called every redraw, it should not be necessary to do validating form inside PaintStruct. Beware that this may be called again for the next redraw before the previous thread ends. This is why the invalid list is copied to a local and cleared before starting.