diff --git a/src/org/ntlab/actions/StartAnimationAction.java b/src/org/ntlab/actions/StartAnimationAction.java index 852f6db..c065303 100644 --- a/src/org/ntlab/actions/StartAnimationAction.java +++ b/src/org/ntlab/actions/StartAnimationAction.java @@ -12,10 +12,6 @@ @Override public void actionPerformed(ActionEvent e) { - new Thread() { - public void run() { - magnetRON.startAnimation(); - } - }.start(); + magnetRON.startAnimation(); } } diff --git a/src/org/ntlab/actions/StopAnimationAction.java b/src/org/ntlab/actions/StopAnimationAction.java new file mode 100644 index 0000000..6372c4f --- /dev/null +++ b/src/org/ntlab/actions/StopAnimationAction.java @@ -0,0 +1,17 @@ +package org.ntlab.actions; + +import java.awt.event.ActionEvent; + +import org.ntlab.deltaViewer.IMagnetRON; + +public class StopAnimationAction extends AbstractMagnetRONAction { + + public StopAnimationAction(IMagnetRON magnetRON) { + super("�I��", magnetRON); + } + + @Override + public void actionPerformed(ActionEvent e) { + magnetRON.stopAnimation(); + } +} diff --git a/src/org/ntlab/deltaViewer/IMagnetRON.java b/src/org/ntlab/deltaViewer/IMagnetRON.java index a00a0ee..04a34dd 100644 --- a/src/org/ntlab/deltaViewer/IMagnetRON.java +++ b/src/org/ntlab/deltaViewer/IMagnetRON.java @@ -1,15 +1,21 @@ package org.ntlab.deltaViewer; import java.io.File; +import java.util.List; import org.ntlab.featureExtractor.Feature; public interface IMagnetRON { - void open(File file); + List open(File file); void doExtract(Feature feature); void startAnimation(); + void pauseAnimation(); + + void resumeAnimation(); + + void stopAnimation(); } \ No newline at end of file diff --git a/src/org/ntlab/deltaViewer/MagnetRONFrame.java b/src/org/ntlab/deltaViewer/MagnetRONFrame.java index c518e35..ea290a2 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONFrame.java +++ b/src/org/ntlab/deltaViewer/MagnetRONFrame.java @@ -41,8 +41,9 @@ private Map argsMap = new HashMap<>(); private IObjectCallGraph objectCallGraph; private IAliasCollector aliasCollector; + private Thread animationThread; -public MagnetRONFrame() throws HeadlessException { + public MagnetRONFrame() throws HeadlessException { super(WINDOW_TITLE); setSize(DEFAULT_SIZE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -100,8 +101,8 @@ } @Override - public void open(File file) { - + public List open(File file) { + return null; } @Override @@ -430,29 +431,47 @@ @Override public void startAnimation() { - // 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(); - TracePoint lastRP = relatedPoints.get(relatedPoints.size() - 1); - Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP); - WINDOW_TITLE = "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; - setTitle(WINDOW_TITLE); - - viewer.init(objectCallGraph, aliasCollector, new CollaborationLayout()); - List aliasList = new ArrayList<>(aliasCollector.getAliasList()); - -// dv.setCoordinatorPoint(1200, 100); - viewer.initAnimation(); -// for(int i = 0; i < aliasList.size(); i++) { -// System.out.println(aliasList.get(i).getObjectId() + ", " + aliasList.get(i).getMethodSignature() + " l." + aliasList.get(i).getLineNo() + " : " + aliasList.get(i).getAliasType().toString()); -// } - for (int i = 0; i <= aliasList.size(); i++) { - viewer.stepToAnimation(i); + animationThread = new Thread() { + 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(); + TracePoint lastRP = relatedPoints.get(relatedPoints.size() - 1); + Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP); + WINDOW_TITLE = "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; + setTitle(WINDOW_TITLE); + + viewer.init(objectCallGraph, aliasCollector, new CollaborationLayout()); + List aliasList = new ArrayList<>(aliasCollector.getAliasList()); + +// dv.setCoordinatorPoint(1200, 100); + viewer.initAnimation(); +// for(int i = 0; i < aliasList.size(); i++) { +// System.out.println(aliasList.get(i).getObjectId() + ", " + aliasList.get(i).getMethodSignature() + " l." + aliasList.get(i).getLineNo() + " : " + aliasList.get(i).getAliasType().toString()); +// } + for (int i = 0; i <= aliasList.size(); i++) { + viewer.stepToAnimation(i); + } + + } } + }; + animationThread.start(); + } - } + @Override + public void pauseAnimation() { } + @Override + public void resumeAnimation() { + } + + @Override + public void stopAnimation() { + animationThread.stop(); + } + public void startDeltaViewer(IObjectCallGraph ocg, IAliasCollector ac) { // Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. if (ocg != null) { diff --git a/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java b/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java index d3cd5c4..60d8845 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java +++ b/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java @@ -5,6 +5,7 @@ import org.ntlab.actions.OpenAction; import org.ntlab.actions.StartAnimationAction; +import org.ntlab.actions.StopAnimationAction; public class MagnetRONMenuBar extends JMenuBar { @@ -21,6 +22,7 @@ JMenu animationMenu = add(new JMenu("�A�j���[�V����")); animationMenu.add(new StartAnimationAction(magnetRON)); + animationMenu.add(new StopAnimationAction(magnetRON)); } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 6fba4dc..be95f46 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -74,6 +74,7 @@ }; deltaAnimation = new DeltaAnimation(mxgraph, mxgraphComponent); mxgraphComponent.setPreferredSize(DEFAULT_SIZE); + setLayout(new BorderLayout()); add(mxgraphComponent, BorderLayout.CENTER); }