edu.iastate.metnet.graphmodel
Class NetworkEditHelper

java.lang.Object
  extended by edu.iastate.metnet.graphmodel.NetworkEditHelper

public class NetworkEditHelper
extends java.lang.Object

helper function for NetworkEditForm

Author:
Jie Li

Field Summary
(package private) static org.apache.log4j.Logger logger
          log4j facility
 
Constructor Summary
NetworkEditHelper(org.jgraph.JGraph jGraph)
          default constructor
 
Method Summary
 java.lang.Object[] captureGraphModel(org.jgraph.JGraph graph)
          capture the graph model represented in the current graph, do not consider the bridge interaction right now
 java.util.Map createBounds(org.jgraph.graph.CellView view, java.awt.Color color, int x, int y)
          create the box for the label
 java.util.Map createLines(org.jgraph.graph.CellView view, java.awt.Color color)
          create an line
 MetnetInteraction getCurrentInteraction()
           
 MetnetLiveEntity getCurrentLiveEntity()
           
 MetnetPathway getCurrentPathway()
           
 GraphValidity getCurrentValidity()
           
 org.jgraph.graph.Edge getEdge(org.jgraph.JGraph graph, org.jgraph.graph.GraphCell sourceCell, org.jgraph.graph.GraphCell targetCell)
          get the JGraph edge based on JGraph node
 org.jgraph.JGraph getJGraph()
           
static java.util.Collection getMitochondrionFamily()
          get the location belongs to mitochondrion.
static java.util.Collection getNucleusFamily()
          get the location belongs to nucleus.
 java.util.Collection getPathwayList()
           
static java.util.Collection getPlastidFamily()
          get the location belongs to plastid.
 int getPortObject()
           
 java.util.List getPredEdgeList(org.jgraph.graph.GraphModel model, org.jgraph.graph.GraphCell cell)
          get the predecessor edges
 java.util.List getPredEdgeList(org.jgraph.JGraph jGraph, org.jgraph.graph.GraphCell cell)
          get the predecessor edges
 java.util.List getPredNodeList(org.jgraph.JGraph jGraph, org.jgraph.graph.GraphCell cell)
          get the predecessor node list of the current node
 org.jgraph.graph.DefaultGraphCell getSourceNode(org.jgraph.graph.GraphModel model, org.jgraph.graph.GraphCell cell)
          get the source node list of the edge
 org.jgraph.graph.DefaultGraphCell getSourceNode(org.jgraph.JGraph jGraph, org.jgraph.graph.GraphCell cell)
          get the source node of the edge
 java.util.List getSuccEdgeList(org.jgraph.graph.GraphModel model, org.jgraph.graph.GraphCell cell)
          get the successor edge list
 java.util.List getSuccEdgeList(org.jgraph.JGraph jGraph, org.jgraph.graph.GraphCell cell)
          get the successor edges
 org.jgraph.graph.DefaultGraphCell getTargetNode(org.jgraph.graph.GraphModel model, org.jgraph.graph.GraphCell cell)
          get the target node list of the edge
 org.jgraph.graph.DefaultGraphCell getTargetNode(org.jgraph.JGraph jGraph, org.jgraph.graph.GraphCell cell)
          get the target node of the edge
 boolean isEdge(org.jgraph.graph.GraphModel model, java.lang.Object cell)
          detect if it is a vertex
 boolean isEdge(org.jgraph.JGraph jGraph, java.lang.Object cell)
          detect if it is a vertex
 boolean isVertex(org.jgraph.graph.GraphModel model, java.lang.Object cell)
          detect if it is a vertex
 boolean isVertex(org.jgraph.JGraph jGraph, java.lang.Object cell)
          detect if it is a vertex
 java.lang.Integer nextPortObject()
          create unique port number
 void reset()
          reset the UI and internal model
 void setCurrentInteraction(MetnetInteraction currentInteraction)
           
 void setCurrentLiveEntity(MetnetLiveEntity currentLiveEntity)
           
 void setCurrentPathway(MetnetPathway currentPathway)
           
 void setCurrentValidity(GraphValidity currentValidity)
           
 void setJGraph(org.jgraph.JGraph graph)
           
 void setPortObject(int portObject)
           
 GraphValidity validateGraph(org.jgraph.JGraph jGraph)
          we shoudl check the graph at the model level rather than from the user interface level which is hard to infer the graph structure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
log4j facility

Constructor Detail

NetworkEditHelper

public NetworkEditHelper(org.jgraph.JGraph jGraph)
default constructor

Parameters:
jGraph - the jgraph need to capture
Method Detail

reset

public void reset()
reset the UI and internal model


captureGraphModel

public java.lang.Object[] captureGraphModel(org.jgraph.JGraph graph)
capture the graph model represented in the current graph, do not consider the bridge interaction right now

Returns:
the graph model and the data mapping, and also the mapping from the model data to view data, also the coefficient map.

getEdge

public org.jgraph.graph.Edge getEdge(org.jgraph.JGraph graph,
                                     org.jgraph.graph.GraphCell sourceCell,
                                     org.jgraph.graph.GraphCell targetCell)
get the JGraph edge based on JGraph node

Parameters:
graph - the jgraph
sourceCell - the jgraph node
targetCell - the jgraph node
Returns:
the edge

getJGraph

public org.jgraph.JGraph getJGraph()
Returns:
the jGraph

isVertex

public boolean isVertex(org.jgraph.graph.GraphModel model,
                        java.lang.Object cell)
detect if it is a vertex

Parameters:
cell - the cell
Returns:
if it is a vertex

isVertex

public boolean isVertex(org.jgraph.JGraph jGraph,
                        java.lang.Object cell)
detect if it is a vertex

Parameters:
cell - the cell
Returns:
if it is a vertex

nextPortObject

public java.lang.Integer nextPortObject()
create unique port number

Returns:
unique port number

createBounds

public java.util.Map createBounds(org.jgraph.graph.CellView view,
                                  java.awt.Color color,
                                  int x,
                                  int y)
create the box for the label

Parameters:
view - the box view
color - the color
Returns:
the box attribute map

createLines

public java.util.Map createLines(org.jgraph.graph.CellView view,
                                 java.awt.Color color)
create an line

Parameters:
view - the cell view
color - the color
Returns:
the line attribute map

getTargetNode

public org.jgraph.graph.DefaultGraphCell getTargetNode(org.jgraph.graph.GraphModel model,
                                                       org.jgraph.graph.GraphCell cell)
get the target node list of the edge

Parameters:
model - the graph model
cell - the edge cell
Returns:
the target node

getTargetNode

public org.jgraph.graph.DefaultGraphCell getTargetNode(org.jgraph.JGraph jGraph,
                                                       org.jgraph.graph.GraphCell cell)
get the target node of the edge

Parameters:
jGraph - the jgraph
cell - the edge
Returns:
the target node

getSuccEdgeList

public java.util.List getSuccEdgeList(org.jgraph.graph.GraphModel model,
                                      org.jgraph.graph.GraphCell cell)
get the successor edge list

Parameters:
model - the graph model
cell - the graph element
Returns:
the successor edge list

getSuccEdgeList

public java.util.List getSuccEdgeList(org.jgraph.JGraph jGraph,
                                      org.jgraph.graph.GraphCell cell)
get the successor edges

Parameters:
jGraph - the jgraph
cell - the graph element
Returns:
the successor edge

getPredEdgeList

public java.util.List getPredEdgeList(org.jgraph.graph.GraphModel model,
                                      org.jgraph.graph.GraphCell cell)
get the predecessor edges

Parameters:
model - the graph model
cell - the graph element
Returns:
the edge list

getPredNodeList

public java.util.List getPredNodeList(org.jgraph.JGraph jGraph,
                                      org.jgraph.graph.GraphCell cell)
get the predecessor node list of the current node

Parameters:
jGraph - the graph
cell - the current node
Returns:
the predecessor node list

getPredEdgeList

public java.util.List getPredEdgeList(org.jgraph.JGraph jGraph,
                                      org.jgraph.graph.GraphCell cell)
get the predecessor edges

Parameters:
jGraph - the jgraph
cell - the graph element
Returns:
the edge list

getSourceNode

public org.jgraph.graph.DefaultGraphCell getSourceNode(org.jgraph.graph.GraphModel model,
                                                       org.jgraph.graph.GraphCell cell)
get the source node list of the edge

Parameters:
model - the graph model
cell - the edge
Returns:
the source node

getSourceNode

public org.jgraph.graph.DefaultGraphCell getSourceNode(org.jgraph.JGraph jGraph,
                                                       org.jgraph.graph.GraphCell cell)
get the source node of the edge

Parameters:
jGraph - the jgraph
cell - the edge
Returns:
the source node

isEdge

public boolean isEdge(org.jgraph.graph.GraphModel model,
                      java.lang.Object cell)
detect if it is a vertex

Parameters:
cell - the cell
Returns:
if it is a vertex

isEdge

public boolean isEdge(org.jgraph.JGraph jGraph,
                      java.lang.Object cell)
detect if it is a vertex

Parameters:
cell - the cell
Returns:
if it is a vertex

setJGraph

public void setJGraph(org.jgraph.JGraph graph)
Parameters:
graph - the jGraph to set

getPathwayList

public java.util.Collection getPathwayList()
Returns:
the pbidList

getCurrentInteraction

public MetnetInteraction getCurrentInteraction()
Returns:
the currentInteraction

setCurrentInteraction

public void setCurrentInteraction(MetnetInteraction currentInteraction)
Parameters:
currentInteraction - the currentInteraction to set

getCurrentLiveEntity

public MetnetLiveEntity getCurrentLiveEntity()
Returns:
the currentLiveEntity

setCurrentLiveEntity

public void setCurrentLiveEntity(MetnetLiveEntity currentLiveEntity)
Parameters:
currentLiveEntity - the currentLiveEntity to set

getCurrentPathway

public MetnetPathway getCurrentPathway()
Returns:
the currentPathway

setCurrentPathway

public void setCurrentPathway(MetnetPathway currentPathway)
Parameters:
currentPathway - the currentPathway to set

getPortObject

public int getPortObject()
Returns:
the portObject

setPortObject

public void setPortObject(int portObject)
Parameters:
portObject - the portObject to set

getNucleusFamily

public static java.util.Collection getNucleusFamily()
get the location belongs to nucleus. WARNING: this is hard coded and should be synchronized with database later. Right now there are 8 locations belonging to nucleus family.

Returns:
the location belongs to nucleus

getMitochondrionFamily

public static java.util.Collection getMitochondrionFamily()
get the location belongs to mitochondrion. WARNING: this is hard coded and should be synchronized with database later. Right now there are 6 locations belonging to mitochondrion family.

Returns:
the location belongs to mitochondrion

getPlastidFamily

public static java.util.Collection getPlastidFamily()
get the location belongs to plastid. WARNING: this is hard coded and should be synchronized with database later. Right now there are 25 locations belonging to plastid family.

Returns:
the location belongs to plastid

validateGraph

public GraphValidity validateGraph(org.jgraph.JGraph jGraph)
we shoudl check the graph at the model level rather than from the user interface level which is hard to infer the graph structure

Parameters:
jGraph - the user interface level graph
Returns:
the graph validity result

getCurrentValidity

public GraphValidity getCurrentValidity()
Returns:
the currentValidity

setCurrentValidity

public void setCurrentValidity(GraphValidity currentValidity)
Parameters:
currentValidity - the currentValidity to set