diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 3b101f5..a7e527e 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -18,6 +18,7 @@ import java.util.Map.Entry; import javax.swing.JFrame; +import javax.swing.JPanel; import org.jgrapht.graph.DefaultEdge; import org.jgrapht.graph.DirectedWeightedPseudograph; @@ -63,7 +64,7 @@ //BUG: edge drawing order. -> parent //BUG: methodExecution drawing order. -> parent //BUG: ObjectVertex position when Resize ObjectVertex. O -public class DeltaViewer { +public class DeltaViewer extends JPanel { private static Dimension DEFAULT_SIZE = new Dimension(1300, 700); private static String WINDOW_TITLE = "Delta Viewer"; @@ -74,7 +75,6 @@ private Map methodExecToVertexMap = new LinkedHashMap<>(); private Map edgeMap = new HashMap<>(); - private JFrame frame; private DeltaGraphAdapter mxgraph; // No clue what this does but it is needed. private mxICell mxDefaultParent; @@ -97,35 +97,21 @@ public mxInteractiveCanvas createCanvas() { return new CurvedCanvas(this); } - }; + }; deltaAnimation = new DeltaAnimation(mxgraph, mxgraphComponent); + mxgraphComponent.setPreferredSize(DEFAULT_SIZE); + add(mxgraphComponent, BorderLayout.CENTER); } - public DeltaViewer(ExtractedStructure extractedStructure, DeltaAliasCollector deltaAliasCollector) { - this(); + public void init(ExtractedStructure extractedStructure, DeltaAliasCollector deltaAliasCollector) { this.eStructure = extractedStructure; this.deltaAliasCollector = deltaAliasCollector; // init(); } /** Initialize JFrame, make vertex object and edge object. */ - public void init() { + public void initAnimation() { // Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. - if(eStructure != null) { - List srcSide = eStructure.getDelta().getSrcSide(); - List dstSide = eStructure.getDelta().getDstSide(); - if (srcSide.size() >= 1 && dstSide.size() >= 1) { - WINDOW_TITLE = "extract delta of:" + eStructure.getDelta().getSrcSide().get(0).getDstClassName() + "(" + eStructure.getDelta().getSrcSide().get(0).getDstObjectId() + ")" + " -> " + eStructure.getDelta().getDstSide().get(0).getDstClassName() + "(" + eStructure.getDelta().getDstSide().get(0).getDstObjectId() + ")"; - } - } - - frame = new JFrame(WINDOW_TITLE); - frame.setSize(DEFAULT_SIZE); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - frame.add(mxgraphComponent, BorderLayout.CENTER); - frame.setVisible(true); - createObjectVertices(eStructure); createEdgeToObject(deltaAliasCollector.getAliasList(), deltaAliasCollector.getAliasPairList()); @@ -150,7 +136,6 @@ // scale = 1.5; view.setScale(scale); deltaAnimation.setScale(scale); - update(); }