use of org.ivis.layout.util.MemberPack in project cytoscape-impl by cytoscape.
the class SbgnPDLayout method repopulateComplexes.
/**
* Reassigns the complex content. The outermost complex is placed first.
*/
protected void repopulateComplexes() {
for (SbgnPDNode comp : emptiedDummyComplexMap.keySet()) {
LGraph chGr = emptiedDummyComplexMap.get(comp);
comp.setChild(chGr);
this.getGraphManager().getGraphs().add(chGr);
}
for (int i = complexOrder.size() - 1; i >= 0; i--) {
SbgnPDNode comp = complexOrder.get(i);
LGraph chGr = childGraphMap.get(comp);
// repopulate the complex
comp.setChild(chGr);
// if the child graph is not null, adjust the positions of members
if (chGr != null) {
// adjust the positions of the members
if (compactionMethod == DefaultCompactionAlgorithm.POLYOMINO_PACKING) {
adjustLocation(comp, chGr);
getGraphManager().getGraphs().add(chGr);
} else if (compactionMethod == DefaultCompactionAlgorithm.TILING) {
getGraphManager().getGraphs().add(chGr);
MemberPack pack = memberPackMap.get(comp);
pack.adjustLocations(comp.getLeft(), comp.getTop());
}
}
}
for (SbgnPDNode comp : emptiedDummyComplexMap.keySet()) {
LGraph chGr = emptiedDummyComplexMap.get(comp);
adjustLocation(comp, chGr);
}
removeDummyComplexes();
// reset
getGraphManager().resetAllNodes();
getGraphManager().resetAllNodesToApplyGravitation();
getGraphManager().resetAllEdges();
this.calculateNodesToApplyGravitationTo();
}
use of org.ivis.layout.util.MemberPack in project cytoscape-impl by cytoscape.
the class SbgnPDLayout method clearComplex.
// ********************* SECTION : TILING METHODS *********************
private void clearComplex(SbgnPDNode comp) {
MemberPack pack = null;
LGraph childGr = comp.getChild();
childGraphMap.put(comp, childGr);
if (childGr == null)
return;
if (compactionMethod == DefaultCompactionAlgorithm.POLYOMINO_PACKING) {
applyPolyomino(comp);
} else if (compactionMethod == DefaultCompactionAlgorithm.TILING) {
pack = new MemberPack(childGr);
memberPackMap.put(comp, pack);
}
if (dummyComplexList.contains(comp)) {
for (Object o : comp.getChild().getNodes()) {
clearDummyComplexGraphs((SbgnPDNode) o);
}
}
getGraphManager().getGraphs().remove(childGr);
comp.setChild(null);
if (compactionMethod == DefaultCompactionAlgorithm.TILING) {
comp.setWidth(pack.getWidth());
comp.setHeight(pack.getHeight());
}
// Redirect the edges of complex members to the complex.
if (childGr != null) {
for (Object ch : childGr.getNodes()) {
SbgnPDNode chNd = (SbgnPDNode) ch;
for (Object obj : new ArrayList(chNd.getEdges())) {
LEdge edge = (LEdge) obj;
if (edge.getSource() == chNd) {
chNd.getEdges().remove(edge);
edge.setSource(comp);
comp.getEdges().add(edge);
} else if (edge.getTarget() == chNd) {
chNd.getEdges().remove(edge);
edge.setTarget(comp);
comp.getEdges().add(edge);
}
}
}
}
}
Aggregations