gumbo.visualize.data
Class PartModel

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.visualize.data.DataModel
              |
              +--gumbo.visualize.data.PartModel
All Implemented Interfaces:
Disposable, java.io.Serializable
Direct Known Subclasses:
EdgeModel, ElementModel, PortModel

public abstract class PartModel
extends DataModel

An abstract data model representing a portion of client data comprising a whole model, and which has a distinct presence in the whole view. This is an important distinction for view layout and display, where an accurate presentation of each part in the display must be available for layout.

A part model is a non-root node in a "part model tree", with the root of the tree being a whole model (i.e. part models form the descendant subtree of a whole model's part model tree). Subclasses of whole and part models can impose restrictions on how the part model tree is structured.

Version:
$Revision: 1.19 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.
See Also:
Serialized Form

Method Summary
protected  void addPartModel(PartModel child)
          Used by subclasses to add a part model as a child in this model's part model tree.
protected  void checkAddPartModel(PartModel child)
          Safely returns if a part model can be added as a child in this model's part model tree.
protected  void checkParentPartModel(DataModel parent)
          Safely returns if a part model can be the parent of this part model.
protected  void checkRootPartModel(WholeModel root)
          Safely returns if a whole model can be the root of this part model.
 WholeModel findPartModelRoot()
          Finds the root whole model in this model's part model tree.
 java.util.List findPartModelSubs(java.util.Collection types, java.util.List retVal)
          Finds descendants in this model's part model tree.
 java.util.List findPartModelSupers(java.util.Collection types, java.util.List retVal)
          Finds ancestors in this model's part model tree, excluding the root, which is a whole model.
 Group getPartModelChildren()
          Gets an immutable view of the children of this model in its part model tree.
 PartModel getPartModelParent()
          Gets the parent part model of this model in its part model tree.
protected  void implDispose()
          Disposes part model children (recursively), and then disposes this model.
protected  void removePartModel(PartModel child)
          Used by subclasses to remove a part model as a child in this model's part model tree, and to dispose it.
 
Methods inherited from class gumbo.visualize.data.DataModel
getClientData, getClientId, initDataModel, setClientData
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPartModelParent

public PartModel getPartModelParent()
Gets the parent part model of this model in its part model tree.

Returns:
The parent model. Null only if the parent is a whole model, which occurs only if the parent is the part model tree root.

getPartModelChildren

public Group getPartModelChildren()
Gets an immutable view of the children of this model in its part model tree.

Returns:
The children (PartModel). Never null.

findPartModelRoot

public WholeModel findPartModelRoot()
Finds the root whole model in this model's part model tree.

Returns:
The root. Never this model. Null if this model is dead (not in a part tree).

findPartModelSupers

public java.util.List findPartModelSupers(java.util.Collection types,
                                          java.util.List retVal)
Finds ancestors in this model's part model tree, excluding the root, which is a whole model. The result will include models that are assignable to (instance of) any one of a group of types.

Parameters:
types - Part model types (Class) to include. If null, all types are included (a normal trace).
retVal - Return value object. The models (PartModel), possibly including this model. Reflects the relative height of the models in the lineage. Use a SetList for speed. Never null.
Returns:
Reference to retVal. Never null.

findPartModelSubs

public java.util.List findPartModelSubs(java.util.Collection types,
                                        java.util.List retVal)
Finds descendants in this model's part model tree. The result will include models that are assignable to (instance of) any one of a group of types.

Parameters:
types - Part model types (Class) to include. If null, all types are included (a normal trace).
retVal - Return value object. The models (PartModel), possibly including this model. Reflects the relative depth of the models in the subtree. Use a SetList for speed. Never null.
Returns:
Reference to retVal. Never null.

checkRootPartModel

protected void checkRootPartModel(WholeModel root)
Safely returns if a whole model can be the root of this part model. To be valid, this model must not be disposed, this model must not be in a part model tree (have a whole model root), and root must not be null. Override to add further qualifications.

Throws:
java.lang.IllegalStateException - This object has been disposed.

checkParentPartModel

protected void checkParentPartModel(DataModel parent)
Safely returns if a part model can be the parent of this part model. To be valid, this model must not be disposed, this model must not be in a part model tree (have a whole model root), and parent must not be null. Override to add further qualifications.

Throws:
java.lang.IllegalStateException - This object has been disposed.

checkAddPartModel

protected void checkAddPartModel(PartModel child)
Safely returns if a part model can be added as a child in this model's part model tree. To be valid, this model must not be disposed, this model must be in a part model tree (have a part model root), and child must not be null. Override to add further qualifications.

Parameters:
child - The potential child model. Never null.
Throws:
java.lang.IllegalStateException - This object has been disposed.

addPartModel

protected final void addPartModel(PartModel child)
Used by subclasses to add a part model as a child in this model's part model tree. Must satisfy checkAddPartModel() for the child, and the child's checkParentPartModel() and checkRootPartModel() for this model.

Parameters:
child - The model to be added. Never null.

removePartModel

protected final void removePartModel(PartModel child)
Used by subclasses to remove a part model as a child in this model's part model tree, and to dispose it.

Parameters:
child - The model to be removed. Ignored if null or not a child.

implDispose

protected void implDispose()
Disposes part model children (recursively), and then disposes this model.

Overrides:
implDispose in class DataModel