diff --git a/icons/magnetron/resume_co.png b/icons/magnetron/resume_co.png new file mode 100644 index 0000000..67c1611 --- /dev/null +++ b/icons/magnetron/resume_co.png Binary files differ diff --git a/icons/magnetron/suspend_co.png b/icons/magnetron/suspend_co.png new file mode 100644 index 0000000..f7c9eae --- /dev/null +++ b/icons/magnetron/suspend_co.png Binary files differ diff --git a/icons/magnetron/terminate_co.png b/icons/magnetron/terminate_co.png new file mode 100644 index 0000000..3544673 --- /dev/null +++ b/icons/magnetron/terminate_co.png Binary files differ diff --git a/src/org/ntlab/actions/PauseAnimationAction.java b/src/org/ntlab/actions/PauseAnimationAction.java new file mode 100644 index 0000000..1d10340 --- /dev/null +++ b/src/org/ntlab/actions/PauseAnimationAction.java @@ -0,0 +1,17 @@ +package org.ntlab.actions; + +import java.awt.event.ActionEvent; + +import org.ntlab.deltaViewer.IMagnetRON; + +public class PauseAnimationAction extends AbstractMagnetRONAction { + + public PauseAnimationAction(IMagnetRON magnetRON) { + super("�ꎞ��~", magnetRON); + } + + @Override + public void actionPerformed(ActionEvent e) { + magnetRON.pauseAnimation(); + } +} \ No newline at end of file diff --git a/src/org/ntlab/deltaViewer/DeltaAnimation.java b/src/org/ntlab/deltaViewer/DeltaAnimation.java index a3ac999..76d9c25 100644 --- a/src/org/ntlab/deltaViewer/DeltaAnimation.java +++ b/src/org/ntlab/deltaViewer/DeltaAnimation.java @@ -236,6 +236,7 @@ stepCount++; if(stepCount >= FINAL_STEP_COUNT){ timer.cancel(); + scheduledThreadPoolExecutor.shutdown(); } } } @@ -286,6 +287,7 @@ stepCount++; if(stepCount >= FINAL_STEP_COUNT){ timer.cancel(); + scheduledThreadPoolExecutor.shutdown(); } } } diff --git a/src/org/ntlab/deltaViewer/MagnetRONFrame.java b/src/org/ntlab/deltaViewer/MagnetRONFrame.java index 42a3f13..c7d6f75 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONFrame.java +++ b/src/org/ntlab/deltaViewer/MagnetRONFrame.java @@ -18,8 +18,14 @@ import java.util.Set; import java.util.Map.Entry; +import javax.swing.ImageIcon; +import javax.swing.JButton; import javax.swing.JFrame; +import javax.swing.JToolBar; +import org.ntlab.actions.PauseAnimationAction; +import org.ntlab.actions.StartAnimationAction; +import org.ntlab.actions.StopAnimationAction; import org.ntlab.deltaExtractor.Alias; import org.ntlab.deltaExtractor.DeltaExtractorJSON; import org.ntlab.deltaExtractor.ExtractedStructure; @@ -66,6 +72,17 @@ menuBar = new MagnetRONMenuBar(this); setJMenuBar(menuBar); + JToolBar toolBar = new JToolBar(); + JButton startButton = new JButton(new ImageIcon("icons/magnetron/resume_co.png")); + startButton.addActionListener(new StartAnimationAction(this)); + toolBar.add(startButton); + JButton suspendButton = new JButton(new ImageIcon("icons/magnetron/suspend_co.png")); + suspendButton.addActionListener(new PauseAnimationAction(this)); + toolBar.add(suspendButton); + JButton terminateButton = new JButton(new ImageIcon("icons/magnetron/terminate_co.png")); + terminateButton.addActionListener(new StopAnimationAction(this)); + toolBar.add(terminateButton); + add(toolBar, BorderLayout.NORTH); pack(); } @@ -476,7 +493,7 @@ public void startAnimation() { if (animationThread == null) { animationThread = new Thread() { - public void run() { + public void run() { // Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. if (objectCallGraph != null && aliasCollector != null) { List relatedPoints = objectCallGraph.getRelatedPoints(); @@ -485,6 +502,7 @@ WINDOW_TITLE = "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; setTitle(WINDOW_TITLE); + viewer.clear(); viewer.init(objectCallGraph, aliasCollector, new CollaborationLayout()); List aliasList = new ArrayList<>(aliasCollector.getAliasList()); @@ -502,21 +520,37 @@ } }; animationThread.start(); + } else { + resumeAnimation(); } } @Override - public void pauseAnimation() { + synchronized public void pauseAnimation() { + if (animationThread != null) { + animationThread.suspend(); +// while(true) { +// try { +// animationThread.wait(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } + } } @Override - public void resumeAnimation() { + synchronized public void resumeAnimation() { + if (animationThread != null) { + animationThread.resume(); + } } @Override public void stopAnimation() { if (animationThread != null) { animationThread.stop(); + animationThread = null; } } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 5107805..964f8b7 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -86,7 +86,14 @@ objectToVertexMap.clear(); methodExecToVertexMap.clear(); edgeMap.clear(); - mxgraph.removeCells(mxgraph.getSelectionModel().getCells(), false); + curFrame = 0; + // TODO Fix bug all cells are not remove in ArgoUML Delete. + mxgraph.getModel().beginUpdate(); + try { + mxgraph.removeCells(mxgraph.getChildVertices(mxgraph.getDefaultParent())); + } finally { + mxgraph.getModel().endUpdate(); + } } abstract public void initAnimation();