uk.ac.ic.doc.automed.p2p.gui.graph
Class DefaultGraphModel

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.gui.graph.DefaultGraphModel
All Implemented Interfaces:
java.io.Serializable, GraphModel
Direct Known Subclasses:
QPlannerDataModel

public class DefaultGraphModel
extends java.lang.Object
implements GraphModel, java.io.Serializable

See Also:
Serialized Form

Field Summary
private  GShape activeShape
           
protected static java.lang.Class EDGE_CLS
           
protected  GTree graph
           
protected static java.lang.Class NODE_CLS
           
protected  java.util.Map objectMap
           
protected  java.util.Collection propObjs
           
private static long serialVersionUID
           
protected  java.util.Map userData
           
 
Constructor Summary
DefaultGraphModel()
           
DefaultGraphModel(boolean fork)
           
DefaultGraphModel(GTree graph)
           
 
Method Summary
protected  java.lang.Object addEdge(java.lang.Object shape, java.lang.Object s1ID, java.lang.Object s2ID, java.lang.Object metadata)
          Add a directed edge to the graph.
protected  java.lang.Object addNode(java.lang.Object nodeData)
           
 void clear()
           
 void clearUserData()
           
 boolean containsObject(java.lang.Object shape)
           
 Graph getGraphData()
           
 java.lang.Object getObjectByShape(java.lang.Object shape)
          Return the id of the object that is mapped to a given shape ID.
 java.util.Collection getPropertyObjects()
          Return property objects for display on a property editor
 GShape getSelectedShape()
          Return the active shape
 java.lang.Object getShapeByObject(java.lang.Object obj)
          Returns the id of the shape that represents an object
 java.util.Collection getShapesByObjectType(java.lang.Class objClass)
          Return the ids of shapes that are mapped to objects of a given type (class)
 java.util.Map getUserData()
           
 DefaultGraphModel load(java.io.File f)
           
protected  DefaultGraphModel load(java.io.File f, boolean serialised)
           
 java.lang.Object removeByObject(java.lang.Object obj)
          Remove shape-object mapping by object
 java.lang.Object removeByShape(java.lang.Object shape)
          Remove shape-object mapping by shape ID
 void save(java.io.File f)
           
private  void save(java.io.File f, boolean serialised)
           
 void setGraphData(Graph ngraph)
           
 void setObjectByShape(java.lang.Object shape, java.lang.Object obj)
          Add an entry that maps the ID of a shape that represents that object to the id of the object
 void setSelectedShape(GShape shape)
          Set the shape on which the user is working
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

NODE_CLS

protected static transient java.lang.Class NODE_CLS

EDGE_CLS

protected static transient java.lang.Class EDGE_CLS

graph

protected GTree graph

userData

protected java.util.Map userData

objectMap

protected java.util.Map objectMap

activeShape

private GShape activeShape

propObjs

protected transient java.util.Collection propObjs
Constructor Detail

DefaultGraphModel

public DefaultGraphModel()

DefaultGraphModel

public DefaultGraphModel(GTree graph)

DefaultGraphModel

public DefaultGraphModel(boolean fork)
Method Detail

addNode

protected java.lang.Object addNode(java.lang.Object nodeData)

containsObject

public boolean containsObject(java.lang.Object shape)

addEdge

protected java.lang.Object addEdge(java.lang.Object shape,
                                   java.lang.Object s1ID,
                                   java.lang.Object s2ID,
                                   java.lang.Object metadata)
Add a directed edge to the graph. If the graph is a tree then the first data object is the parent and the second data object becomes the child of that parent.

Parameters:
shape -
ndata1 -
ndata2 -
metadata -

setObjectByShape

public void setObjectByShape(java.lang.Object shape,
                             java.lang.Object obj)
Add an entry that maps the ID of a shape that represents that object to the id of the object

Parameters:
obj -
shape -

getShapeByObject

public java.lang.Object getShapeByObject(java.lang.Object obj)
Returns the id of the shape that represents an object

Parameters:
obj -
Returns:

getShapesByObjectType

public java.util.Collection getShapesByObjectType(java.lang.Class objClass)
Return the ids of shapes that are mapped to objects of a given type (class)

Parameters:
objClass -
Returns:

getObjectByShape

public java.lang.Object getObjectByShape(java.lang.Object shape)
Return the id of the object that is mapped to a given shape ID.

Parameters:
shapeClass -
shape -
Returns:

removeByShape

public java.lang.Object removeByShape(java.lang.Object shape)
Remove shape-object mapping by shape ID

Parameters:
shapeClass -
shape -
Returns:

removeByObject

public java.lang.Object removeByObject(java.lang.Object obj)
Remove shape-object mapping by object

Parameters:
shapeClass -
shapeID -
Returns:

getPropertyObjects

public java.util.Collection getPropertyObjects()
Return property objects for display on a property editor

Returns:

save

public void save(java.io.File f)
          throws AutoMedException
Throws:
AutoMedException

load

public DefaultGraphModel load(java.io.File f)
                       throws AutoMedException
Throws:
AutoMedException

save

private void save(java.io.File f,
                  boolean serialised)
           throws AutoMedException
Throws:
AutoMedException

load

protected DefaultGraphModel load(java.io.File f,
                                 boolean serialised)
                          throws AutoMedException
Throws:
AutoMedException

setSelectedShape

public void setSelectedShape(GShape shape)
Set the shape on which the user is working

Parameters:
shape -

getSelectedShape

public GShape getSelectedShape()
Return the active shape

Returns:

getGraphData

public Graph getGraphData()
Specified by:
getGraphData in interface GraphModel

setGraphData

public void setGraphData(Graph ngraph)
Specified by:
setGraphData in interface GraphModel

getUserData

public java.util.Map getUserData()
Specified by:
getUserData in interface GraphModel

clear

public void clear()

clearUserData

public void clearUserData()