gumbo.visualize.data
Class PortModel

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

public class PortModel
extends PartModel

A part model representing a connection point for edge models, such as on a vertex model.

In the part model tree, a port model can have none or more port models. A port model may connect to none or more edge model ends.

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

Field Summary
static Group TYPES
          A singleton immutable group containing the type (Class) of this class.
 
Constructor Summary
PortModel(java.lang.Object clientId, java.lang.Object clientData)
          Creates a new instance.
 
Method Summary
 void addPortModel(PortModel child)
          Adds a port model as a child in this model's part model tree.
protected  void checkConnectable(WholeModel edgeRoot)
          Safely returns if this port model can be connected to and edge model.
 java.util.Collection getAllEdgeModels(java.util.Collection retVal)
          A convenience method for getting all the edge models connected to this port model, including those from nested port models.
 java.util.List getEdgeModels()
          Gets an immutable view of the edge models connected to this port model.
 VertexModel getVertexModel()
          Gets the vertex model containing this port model.
protected  void implDispose()
          Disposes connected edge models, and then disposes this model.
 void removePortModel(PortModel child)
          Removes a child port model from this model's part model tree, and disposes it.
 
Methods inherited from class gumbo.visualize.data.PartModel
addPartModel, checkAddPartModel, checkParentPartModel, checkRootPartModel, findPartModelRoot, findPartModelSubs, findPartModelSupers, getPartModelChildren, getPartModelParent, removePartModel
 
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
 

Field Detail

TYPES

public static final Group TYPES
A singleton immutable group containing the type (Class) of this class. Supports both Set and List views.

Constructor Detail

PortModel

public PortModel(java.lang.Object clientId,
                 java.lang.Object clientData)
Creates a new instance.

Parameters:
clientId - See DataModel. Null if none, in which case the client ID defaults to this object.
clientData - See DataModel. Null if none.
Method Detail

addPortModel

public void addPortModel(PortModel child)
Adds a port model as a child in this model's part model tree. The model must be "addable" as defined by its checkAddPartModel().

Parameters:
child - The child model. Ignored if null.

removePortModel

public void removePortModel(PortModel child)
Removes a child port model from this model's part model tree, and disposes it.

Parameters:
child - The child model. If null or not a child, does nothing.

getEdgeModels

public java.util.List getEdgeModels()
Gets an immutable view of the edge models connected to this port model. Does not include edges from any nested ports. Duplicates will occur if multiple ends of the same edge are connected to this port.

Returns:
The view (EdgeModel). Never null.
Throws:
java.lang.IllegalStateException - This model is not in a tree.

getAllEdgeModels

public java.util.Collection getAllEdgeModels(java.util.Collection retVal)
A convenience method for getting all the edge models connected to this port model, including those from nested port models.

Parameters:
retVal - Return value object. Collection of models (EdgeModel). Never null.
Returns:
Reference to retVal. Never null.

getVertexModel

public VertexModel getVertexModel()
Gets the vertex model containing this port model.

Returns:
Reference to the model. Never null.
Throws:
java.lang.IllegalStateException - This model is not in a tree.

checkConnectable

protected void checkConnectable(WholeModel edgeRoot)
Safely returns if this port model can be connected to and edge model. To be connectable, this model must not be disposed, it must be in a part model tree (have a part model root), and it must have a common ancestor with the edge's root. Override to add further qualifications.

Parameters:
edgeRoot - The part model root of the potential edge. Never null.
Throws:
java.lang.IllegalStateException - This object has been disposed.

implDispose

protected void implDispose()
Disposes connected edge models, and then disposes this model.

Overrides:
implDispose in class PartModel