}
// Replace graph
private void updateViewerContent(ScrollingGraphicalViewer viewer)
{
BioPAXGraph graph = (BioPAXGraph) viewer.getContents().getModel();
// Updating is supported only for mechanistic views
if (!graph.isMechanistic()) return;
// Remember highlighted object's original nodes (members of chisio root graph)
Map<String, Color> highlightMap = new HashMap<String, Color>();
for (Object o : graph.getNodes())
{
IBioPAXNode node = (IBioPAXNode) o;
if (node.isHighlighted())
{
highlightMap.put(node.getIDHash(), node.getHighlightColor());
}
}
for (Object o : graph.getEdges())
{
IBioPAXEdge edge = (IBioPAXEdge) o;
if (edge.isHighlighted())
{
highlightMap.put(edge.getIDHash(), edge.getHighlightColor());
}
}
// Reset highlight
HighlightLayer hLayer = (HighlightLayer)
((ChsScalableRootEditPart) viewer.getRootEditPart()).getLayer(
HighlightLayer.HIGHLIGHT_LAYER);
hLayer.removeAll();
hLayer.highlighted.clear();
viewer.deselectAll();
// Record layout
graph.recordLayout();
// Create updated graph
PathwayHolder p = graph.getPathway();
// Update pathway components if update needed
if (withContent != null)
{
p.updateContentWith(withContent);
}
// Excise pathway
BioPAXGraph newGraph = main.getRootGraph().excise(p);
newGraph.setAsRoot();
// Replace the graph
viewer.setContents(newGraph);
// Use same layout
boolean layedout = newGraph.fetchLayout();
if (!layedout)
{
new CoSELayoutAction(main).run();
}
viewer.deselectAll();
GraphAnimation.run(viewer);
// Recover highlights
for (Object o : newGraph.getNodes())
{
IBioPAXNode node = (IBioPAXNode) o;
if (highlightMap.containsKey(node.getIDHash()))
{
node.setHighlightColor(highlightMap.get(node.getIDHash()));
node.setHighlight(true);
}
}
for (Object o : newGraph.getEdges())
{
IBioPAXEdge edge = (IBioPAXEdge) o;
if (highlightMap.containsKey(edge.getIDHash()))
{
edge.setHighlightColor(highlightMap.get(edge.getIDHash()));