diff --git a/src/org/ntlab/deltaExtractor/Alias.java b/src/org/ntlab/deltaExtractor/Alias.java index f62d75a..bc33fc4 100644 --- a/src/org/ntlab/deltaExtractor/Alias.java +++ b/src/org/ntlab/deltaExtractor/Alias.java @@ -115,7 +115,7 @@ return true; if (obj == null) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof Alias)) return false; Alias other = (Alias) obj; if (aliasType != other.aliasType) diff --git a/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java index c1be68f..1851f3c 100644 --- a/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java +++ b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java @@ -9,7 +9,6 @@ import org.ntlab.deltaExtractor.IAliasCollector; import org.ntlab.featureExtractor.Extract; import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.TracePoint; /** * CollaborationAliasCollector is IAliasCollector implementation class to merge aliasList in time stamp order. diff --git a/src/org/ntlab/deltaViewer/MagnetRONFrame.java b/src/org/ntlab/deltaViewer/MagnetRONFrame.java index 7bcaad9..b90ccdb 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONFrame.java +++ b/src/org/ntlab/deltaViewer/MagnetRONFrame.java @@ -62,7 +62,7 @@ // Test code (will be deleted) private static final String TAG = MagnetRONFrame.class.getSimpleName(); - private static Dimension DEFAULT_FRAME_SIZE = new Dimension(1300, 700); + private static Dimension DEFAULT_FRAME_SIZE = new Dimension(1300, 600); private static String FRAME_TITLE = "MagnetRON Viewer "; private Trace trace = null; @@ -88,6 +88,7 @@ setSize(DEFAULT_FRAME_SIZE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BorderLayout()); + setExtendedState(JFrame.MAXIMIZED_BOTH); this.viewer = new CollaborationViewer(); getContentPane().add(viewer, BorderLayout.CENTER); @@ -231,6 +232,7 @@ aliasCollector = extracted.getValue(); fFeatureChanged = true; + animationThread = null; if (objectCallGraph != null && aliasCollector != null) { viewer.init(objectCallGraph, aliasCollector, new CollaborationLayout()); viewer.initAnimation(); @@ -654,6 +656,7 @@ } } animationThread = null; + viewer.setAnimationSpeed(1.0); } }; animationThread.start(); @@ -712,6 +715,7 @@ if (animationThread != null) { animationThread.stop(); animationThread = null; + viewer.setAnimationSpeed(1.0); } } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 44fd99b..49e6479 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -62,7 +62,7 @@ // Test code (will be deleted) private static final String TAG = MagnetRONViewer.class.getSimpleName(); - protected static final Dimension DEFAULT_COMPONENT_SIZE = new Dimension(1300, 700); + protected static final Dimension DEFAULT_COMPONENT_SIZE = new Dimension(1300, 600); protected static final Dimension DEFAULT_OBJECT_VERTEX_SIZE = new Dimension(70, 70); protected static final Dimension DEFAULT_METHOD_EXECUTION_VERTEX_SIZE = new Dimension(55, 20); @@ -78,7 +78,6 @@ protected mxICell defaultParent; protected int curFrame = 0; - protected int prevFrame = 0; protected int skipBackFrame = 0; // Use assigned value, when skip back animation. protected double animationSpeed = DEFAULT_ANIMATION_SPEED; @@ -103,7 +102,7 @@ return new CurvedCanvas(this); } }; - mxgraphComponent.setPreferredSize(DEFAULT_COMPONENT_SIZE); + mxgraphComponent.setPreferredSize(DEFAULT_COMPONENT_SIZE); this.setLayout(new BorderLayout()); this.add(mxgraphComponent, BorderLayout.CENTER); @@ -160,41 +159,37 @@ System.out.println("\r\n" + TAG + ": Frame=" + i + ", aliasType=" + alias.getAliasType().toString() + ", objectId=" + alias.getObjectId() + ", methodSignature=" + alias.getMethodSignature() + ", l." + alias.getLineNo()); switch(alias.getAliasType()) { case RETURN_VALUE: - prevFrame = curFrame; moveObjectVertex(alias); update(); break; case METHOD_INVOCATION: - prevFrame = curFrame; removeMethodExecutionVertex(alias); moveObjectVertex(alias); update(); break; case CONSTRACTOR_INVOCATION: - prevFrame = curFrame; // TODO: Confirm the program behavior when called after RECEIVER. - if (!objectToVertexMap.containsKey(alias.getObjectId()) || objectToVertexMap.get(alias.getObjectId()).getCell() == null) { + MethodInvocation methodInv = (MethodInvocation) alias.getOccurrencePoint().getStatement(); + String objId = alias.getObjectId(); + if (!objectToVertexMap.containsKey(objId) || objectToVertexMap.get(objId).getCell() == null) { createObjectVertexOnConstractor(alias); } - if (!methodExecToVertexMap.containsKey(((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution())) { - createMethodExecutionVertex(alias.getObjectId(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCallerSideMethodName(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution()); + if (!methodExecToVertexMap.containsKey(methodInv.getCalledMethodExecution())) { + createMethodExecutionVertex(objId, methodInv.getCallerSideMethodName(), methodInv.getCalledMethodExecution()); update(); } removeMethodExecutionVertex(alias); update(); break; case FORMAL_PARAMETER: - prevFrame = curFrame; moveObjectVertex(alias); update(); break; case ACTUAL_ARGUMENT: - prevFrame = curFrame; moveObjectVertex(alias); update(); break; case THIS: - prevFrame = curFrame; if (curFrame == 0 || alias.getObjectId().startsWith("0:")) { createMethodExecutionVertex(alias); update(); @@ -205,7 +200,6 @@ MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); if (calledMethodExec.isConstructor() && (!objectToVertexMap.containsKey(alias.getObjectId()) || objectToVertexMap.get(alias.getObjectId()).getCell() == null)) { - prevFrame = curFrame; createObjectVertexOnConstractor(alias); } if (!methodExecToVertexMap.containsKey(calledMethodExec)) { @@ -215,7 +209,6 @@ && objectToVertexMap.containsKey(methodExec.getThisObjId())) { createMethodExecutionVertex(methodExec.getThisObjId(), methodExec.getSignature(), methodExec); } - prevFrame = curFrame; createMethodExecutionVertex(alias.getObjectId(), calledMethodExec.getSignature(), calledMethodExec); update(); } @@ -1015,9 +1008,21 @@ private void removeMethodExecutionVertex(Alias alias) { // source ObjectVertex ObjectVertex srcObjVx = objectToVertexMap.get(alias.getObjectId()); + AliasType aliasType = alias.getAliasType(); + // Quick fix + if (aliasType == AliasType.CONSTRACTOR_INVOCATION) { + MethodInvocation methodInv = (MethodInvocation) alias.getOccurrencePoint().getStatement(); + List statements = methodInv.getCalledMethodExecution().getStatements(); + if (!statements.isEmpty() && statements.get(0) instanceof MethodInvocation) { + MethodInvocation calledMethodInv = (MethodInvocation) statements.get(0); + if (!calledMethodInv.getCalledMethodExecution().getArguments().isEmpty() + && objectToVertexMap.containsKey(calledMethodInv.getCalledMethodExecution().getArguments().get(0).getId())) { + srcObjVx = objectToVertexMap.get(calledMethodInv.getCalledMethodExecution().getArguments().get(0).getId()); + } + } + } MethodExecution methodExec = alias.getMethodExecution(); - AliasType aliasType = alias.getAliasType(); if(aliasType.equals(AliasType.METHOD_INVOCATION) || aliasType.equals(AliasType.CONSTRACTOR_INVOCATION)) { MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); List arguments = new ArrayList<>(methodExecToVertexMap.get(calledMethodExec).getArguments()); @@ -1129,103 +1134,104 @@ */ protected void removeCalledMethodExecutionVertex(ObjectVertex sourceObjectVertex, MethodExecution methodExecution, MethodExecution calledMethodExecution) { MagnetRONAnimation.waitAnimationEnd(); - + // Remove ObjectVertex other than source ObjectVertex from locals and arguments of called MethodExecutionVertex. if (methodExecToVertexMap.containsKey(calledMethodExecution)) { MethodExecutionVertex calledMethodExecVx = methodExecToVertexMap.get(calledMethodExecution); - // TODO: Confirm bug. - List arguments = new ArrayList<>(calledMethodExecVx.getArguments()); - if (arguments.size() != 0) { - for (ObjectVertex objVx: arguments) { - if (objVx != sourceObjectVertex) { - mxICell objVxCell = (mxICell)objVx.getCell(); - Point2D objVxCellAbsPt = getAbsolutePointforCell(objVxCell); + // TODO: Confirm bug. + List arguments = new ArrayList<>(calledMethodExecVx.getArguments()); + if (arguments.size() != 0) { + for (ObjectVertex objVx: arguments) { + if (objVx != sourceObjectVertex) { + mxICell objVxCell = (mxICell)objVx.getCell(); + Point2D objVxCellAbsPt = getAbsolutePointforCell(objVxCell); + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + synchronized (mxgraph.getModel()) { + try { + if (!objVxCell.getParent().equals(getMxDefaultParent())) { + // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. + objVxCell.getParent().remove(objVxCell); + objVxCell.setParent(getMxDefaultParent()); + } + } finally { + mxgraph.getModel().endUpdate(); + } + } + if (!objVxCellAbsPt.equals(objVx.getInitialPoint())) { // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - if (!objVxCell.getParent().equals(getMxDefaultParent())) { - // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. - objVxCell.getParent().remove(objVxCell); - objVxCell.setParent(getMxDefaultParent()); - } + objVxCell.getGeometry().setX(objVxCellAbsPt.getX()); + objVxCell.getGeometry().setY(objVxCellAbsPt.getY()); } finally { mxgraph.getModel().endUpdate(); } } - if (!objVxCellAbsPt.equals(objVx.getInitialPoint())) { - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - synchronized (mxgraph.getModel()) { - try { - objVxCell.getGeometry().setX(objVxCellAbsPt.getX()); - objVxCell.getGeometry().setY(objVxCellAbsPt.getY()); - } finally { - mxgraph.getModel().endUpdate(); - } - } - MagnetRONAnimation objVxCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - objVxCellAnim.setTotalCycleCount(getMagnetRONAnimationTotalCycleCount()); - objVxCellAnim.setDelay(getMagnetRONAnimationDelayMillis()); - objVxCellAnim.init(objVxCell, objVx.getInitialX(), objVx.getInitialY(), threadPoolExecutor); - objVxCellAnim.syncPlay(); - } - methodExecToVertexMap.get(calledMethodExecution).getArguments().remove(objVx); + MagnetRONAnimation objVxCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + objVxCellAnim.setTotalCycleCount(getMagnetRONAnimationTotalCycleCount()); + objVxCellAnim.setDelay(getMagnetRONAnimationDelayMillis()); + objVxCellAnim.init(objVxCell, objVx.getInitialX(), objVx.getInitialY(), threadPoolExecutor); + objVxCellAnim.syncPlay(); } + methodExecToVertexMap.get(calledMethodExecution).getArguments().remove(objVx); } } - - List locals = new ArrayList<>(calledMethodExecVx.getLocals()); - if (locals.size() != 0) { - for (ObjectVertex objVx: locals) { - if (objVx != sourceObjectVertex) { - mxICell objVxCell = (mxICell)objVx.getCell(); - Point2D objVxCellAbsPt = getAbsolutePointforCell(objVxCell); + } + + List locals = new ArrayList<>(calledMethodExecVx.getLocals()); + if (locals.size() != 0) { + for (ObjectVertex objVx: locals) { + if (objVx != sourceObjectVertex) { + mxICell objVxCell = (mxICell)objVx.getCell(); + Point2D objVxCellAbsPt = getAbsolutePointforCell(objVxCell); + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + synchronized (mxgraph.getModel()) { + try { + if (!objVxCell.getParent().equals(getMxDefaultParent())) { + // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. + objVxCell.getParent().remove(objVxCell); + objVxCell.setParent(getMxDefaultParent()); + } + } finally { + mxgraph.getModel().endUpdate(); + } + } + if (!objVxCellAbsPt.equals(objVx.getInitialPoint())) { // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - if (!objVxCell.getParent().equals(getMxDefaultParent())) { - // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. - objVxCell.getParent().remove(objVxCell); - objVxCell.setParent(getMxDefaultParent()); - } + objVxCell.getGeometry().setX(objVxCellAbsPt.getX()); + objVxCell.getGeometry().setY(objVxCellAbsPt.getY()); } finally { mxgraph.getModel().endUpdate(); } } - if (!objVxCellAbsPt.equals(objVx.getInitialPoint())) { - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - synchronized (mxgraph.getModel()) { - try { - objVxCell.getGeometry().setX(objVxCellAbsPt.getX()); - objVxCell.getGeometry().setY(objVxCellAbsPt.getY()); - } finally { - mxgraph.getModel().endUpdate(); - } - } - MagnetRONAnimation objVxCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - objVxCellAnim.setTotalCycleCount(getMagnetRONAnimationTotalCycleCount()); - objVxCellAnim.setDelay(getMagnetRONAnimationDelayMillis()); - objVxCellAnim.init(objVxCell, objVx.getInitialX(), objVx.getInitialY(), threadPoolExecutor); - objVxCellAnim.syncPlay(); - } - methodExecToVertexMap.get(calledMethodExecution).getLocals().remove(objVx); + MagnetRONAnimation objVxCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + objVxCellAnim.setTotalCycleCount(getMagnetRONAnimationTotalCycleCount()); + objVxCellAnim.setDelay(getMagnetRONAnimationDelayMillis()); + objVxCellAnim.init(objVxCell, objVx.getInitialX(), objVx.getInitialY(), threadPoolExecutor); + objVxCellAnim.syncPlay(); } + methodExecToVertexMap.get(calledMethodExecution).getLocals().remove(objVx); } } - - if (methodExecution == null) { + } + + // Quick fix + if (methodExecution == null || !methodExecToVertexMap.get(calledMethodExecution).getArguments().isEmpty()) { return; } - + mxICell srcMethodExecVxCell = (mxICell)methodExecToVertexMap.get(methodExecution).getCell(); mxICell dstMethodExecVxCell = (mxICell)calledMethodExecVx.getCell(); - + scrollCellsToVisible(srcMethodExecVxCell.getParent(), dstMethodExecVxCell.getParent()); - + try { Point2D srcMethodExecVxCellAbsPt = null; Point2D dstMethodExecVxCellAbsPt = null; @@ -1248,7 +1254,7 @@ mxgraph.getModel().endUpdate(); } } - + // Animate an edge to shrink. MagnetRONAnimation edgeCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); edgeCellAnim.setTotalCycleCount(getMagnetRONAnimationTotalCycleCount()); @@ -1280,7 +1286,7 @@ } }); edgeCellAnim.play(); - + if (!calledMethodExecution.isStatic()) { objectToVertexMap.get(calledMethodExecution.getThisObjId()).getMethodExecutionVertices().remove(methodExecToVertexMap.get(calledMethodExecution)); } else { @@ -1314,13 +1320,14 @@ String methodSig = srcMethodExec.getSignature(); if (!edgeMap.containsKey(methodSig)) { + MagnetRONAnimation.waitAnimationEnd(); + // Draw an edge from sourceVertexCell to destinationVertexCell. mxICell srcMethodExecVxCell = (mxICell)methodExecToVertexMap.get(srcMethodExec).getCell(); mxICell dstMethodExecVxCell = (mxICell)methodExecToVertexMap.get(dstMethodExec).getCell(); Point2D srcMethodExecVxCellAbsPt = getAbsolutePointforCell(srcMethodExecVxCell); Point2D dstMethodExecVxCellAbsPt = getAbsolutePointforCell(dstMethodExecVxCell); - MagnetRONAnimation.waitAnimationEnd(); scrollCellsToVisible(srcMethodExecVxCell.getParent(), dstMethodExecVxCell.getParent(), 2); try { @@ -1682,6 +1689,7 @@ } public void setAnimationSpeed(double animationSpeed) { + System.out.println(TAG + ": animationSpeed=" + animationSpeed); this.animationSpeed = animationSpeed; } @@ -1689,10 +1697,6 @@ return this.curFrame; } - protected int getPreviousFrame() { - return this.prevFrame; - } - public int getSkipBackFrame() { return this.skipBackFrame; } diff --git a/traces/ArgoUML.magnet b/traces/ArgoUML.magnet index d3ac3a1..787989b 100644 --- a/traces/ArgoUML.magnet +++ b/traces/ArgoUML.magnet @@ -33,18 +33,6 @@ { "feature": "ArgoUML�}�`�I���@�\", "extracts": [ - { - "src": { - "class": "org.argouml.uml.diagram.static_structure.ui.SelectionClass", - "id": "1672744985" - }, - "dst": { - "class": "org.argouml.uml.diagram.static_structure.ui.FigClass", - "id": "1675174935" - }, - "type": "Container-Component", - "order": "0" - }, { "src": { "class": "java.util.ArrayList", @@ -56,6 +44,18 @@ }, "type": "Container-Component(Collection)", "order": "0" + }, + { + "src": { + "class": "org.argouml.uml.diagram.static_structure.ui.SelectionClass", + "id": "1672744985" + }, + "dst": { + "class": "org.argouml.uml.diagram.static_structure.ui.FigClass", + "id": "1675174935" + }, + "type": "Container-Component", + "order": "0" } ] }