1 19 20 21 package ca.mcgill.sable.graph.editparts; 22 23 import org.eclipse.draw2d.AbstractLayout; 24 import org.eclipse.draw2d.IFigure; 25 import org.eclipse.draw2d.geometry.*; 26 import org.eclipse.draw2d.graph.*; 27 import java.util.*; 28 29 public class GraphLayoutManager extends AbstractLayout { 30 31 private GraphEditPart graphPart; 32 33 34 public GraphLayoutManager(GraphEditPart graphPart) { 35 setGraphPart(graphPart); 36 } 37 38 41 protected Dimension calculatePreferredSize( 42 IFigure arg0, 43 int arg1, 44 int arg2) { 45 return null; 46 } 47 48 51 public void layout(IFigure arg0) { 52 DirectedGraph graph = new DirectedGraph(); 53 HashMap map = new HashMap(); 54 getGraphPart().contributeNodesToGraph(graph, map); 57 getGraphPart().contributeEdgesToGraph(graph, map); 58 if (graph.nodes.size() != 0){ 59 DirectedGraphLayout layout = new DirectedGraphLayout(); 60 layout.visit(graph); 61 getGraphPart().applyGraphResults(graph, map); 62 } 63 64 } 65 66 69 public GraphEditPart getGraphPart() { 70 return graphPart; 71 } 72 73 76 public void setGraphPart(GraphEditPart part) { 77 graphPart = part; 78 } 79 80 } 81 | Popular Tags |