if(srcj == null)
{
//if not present in our hashmap, then the cell doesnt exist in the jgraph
//so add it and store the reference of the cell
logger.info("Adding agent " + srcIdString + " to the view.");
mxCell o = (mxCell) m_graph.insertVertex(parent, srcIdString, srcIdString, 20, 20, 20, 20, "ROUNDED");
jGraphCells.put(srcIdString, o);
}
if(sinkj == null)
{
//if not present in our hashmap, then the cell doesnt exist in the jgraph
//so add it and store the reference of the cell
logger.info("Adding agent " + sinkIdString + " to the view.");
mxCell o = (mxCell) m_graph.insertVertex(parent, sinkIdString, sinkIdString, 20, 20, 20, 20, "ROUNDED");
jGraphCells.put(sinkIdString, o);
}
String edgeKey = srcIdString + "-"+ sinkIdString;
if(!jGraphCells.containsKey(edgeKey))
{
//guaranteed jgraphVertices.get(srcIdString) and jgraphVertices.get(sinkIdString) will not be null
//and that the cells are already present in jraph
mxCell o = (mxCell) m_graph.insertEdge(parent, null, "", jGraphCells.get(srcIdString), jGraphCells.get(sinkIdString));
jGraphCells.put(edgeKey, o);
}
else
{
//edge exists in graph. remove it and add it again with the updated edge info
mxCell cell1 = jGraphCells.get(edgeKey);
m_graph.removeCells(new Object[]{cell1});
mxCell cell2 = (mxCell) m_graph.insertEdge(parent, null, "", jGraphCells.get(srcIdString), jGraphCells.get(sinkIdString));
jGraphCells.remove(edgeKey);
jGraphCells.put(edgeKey, cell2);
}
//TODO display the changed label on the edge