diff --git a/src/org/ntlab/actions/AutoTrackingAction.java b/src/org/ntlab/actions/AutoTrackingAction.java new file mode 100644 index 0000000..86c3f27 --- /dev/null +++ b/src/org/ntlab/actions/AutoTrackingAction.java @@ -0,0 +1,31 @@ +package org.ntlab.actions; + +import java.awt.event.ActionEvent; + +import javax.swing.JCheckBox; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import org.ntlab.deltaViewer.MagnetRONViewer; + +public class AutoTrackingAction extends AbstractViewerAction implements ChangeListener { + + private static final long serialVersionUID = -4780429455781975464L; + + public AutoTrackingAction(MagnetRONViewer viewer) { + super("Auto Tracking", viewer); + } + + @Override + public void stateChanged(ChangeEvent e) { + if (e.getSource() instanceof JCheckBox) { + JCheckBox checkBox = (JCheckBox) e.getSource(); + super.viewer.setAutoTracking(checkBox.isSelected()); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + } +} \ No newline at end of file diff --git a/src/org/ntlab/deltaViewer/MagnetRONFrame.java b/src/org/ntlab/deltaViewer/MagnetRONFrame.java index 3601a8f..c6ccdf9 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONFrame.java +++ b/src/org/ntlab/deltaViewer/MagnetRONFrame.java @@ -56,8 +56,11 @@ private static final long serialVersionUID = -7635196578197342313L; - private static Dimension DEFAULT_SIZE = new Dimension(1300, 700); - private static String WINDOW_TITLE = "MagnetRON Viewer "; + // 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 String FRAME_TITLE = "MagnetRON Viewer "; private Trace trace = null; private DeltaExtractor s = null; @@ -72,13 +75,13 @@ private Thread animationThread; public MagnetRONFrame() throws HeadlessException { - super(WINDOW_TITLE); - setSize(DEFAULT_SIZE); + super(FRAME_TITLE); + setSize(DEFAULT_FRAME_SIZE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BorderLayout()); this.viewer = new CollaborationViewer(); getContentPane().add(viewer, BorderLayout.CENTER); - + menuBar = new MagnetRONMenuBar(this); setJMenuBar(menuBar); @@ -188,8 +191,8 @@ public void doExtract(Feature feature) { Map.Entry extracted = extractMulti(feature); if (feature.getName() != null) { - WINDOW_TITLE = feature.getName() + " "; - setTitle(WINDOW_TITLE); + FRAME_TITLE = feature.getName() + " "; + setTitle(FRAME_TITLE); } objectCallGraph = extracted.getKey(); aliasCollector = extracted.getValue(); @@ -566,13 +569,13 @@ List relatedPoints = objectCallGraph.getRelatedPoints(); TracePoint lastRP = relatedPoints.get(relatedPoints.size() - 1); Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP, aliasCollector); - if (WINDOW_TITLE.contains("extract delta of")) { - String[] splits = WINDOW_TITLE.split("extract delta of"); + if (FRAME_TITLE.contains("extract delta of")) { + String[] splits = FRAME_TITLE.split("extract delta of"); String featureName = splits[0]; - WINDOW_TITLE = featureName; + FRAME_TITLE = featureName; } - WINDOW_TITLE += "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; - setTitle(WINDOW_TITLE); + FRAME_TITLE += "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; + setTitle(FRAME_TITLE); viewer.clear(); viewer.init(objectCallGraph, aliasCollector, new CollaborationLayout()); @@ -632,8 +635,8 @@ List relatedPoints = ocg.getRelatedPoints(); TracePoint lastRP = relatedPoints.get(relatedPoints.size() - 1); Map.Entry rpInf = MagnetRONViewer.getRelatedInformation(lastRP, ac); - WINDOW_TITLE = "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; - setTitle(WINDOW_TITLE); + FRAME_TITLE = "extract delta of:" + rpInf.getKey().getSrcClassName() + "(" + rpInf.getKey().getSrcObjectId() + ")" + " -> " + rpInf.getKey().getDstClassName()+ "(" + rpInf.getKey().getDstObjectId()+ ")"; + setTitle(FRAME_TITLE); } viewer.init(ocg, ac, new CollaborationLayout()); diff --git a/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java b/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java index 3002141..a1a4dc3 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java +++ b/src/org/ntlab/deltaViewer/MagnetRONMenuBar.java @@ -9,6 +9,7 @@ import javax.swing.JMenu; import javax.swing.JMenuBar; +import org.ntlab.actions.AutoTrackingAction; import org.ntlab.actions.ExtractAction; import org.ntlab.actions.OpenAction; import org.ntlab.actions.ZoomInAction; @@ -65,6 +66,9 @@ defaultCheck.addActionListener(new ZoomActualAction(magnetRON.getViewer())); defaultCheck.setEnabled(false); animationSettingMenu.add(defaultCheck); + JCheckBox autoTrackingCheck = new JCheckBox(properties.getProperty("auto_tracking"), false); + autoTrackingCheck.addChangeListener(new AutoTrackingAction(magnetRON.getViewer())); + animationSettingMenu.add(autoTrackingCheck); JMenu viewMenu = add(new JMenu(properties.getProperty("view"))); viewMenu.add(new ZoomInAction(properties.getProperty("zoom_in"), magnetRON.getViewer())); diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 62be2ee..6b3d93f 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -3,11 +3,11 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Graphics2D; +import java.awt.Rectangle; import java.awt.event.ActionListener; import java.awt.geom.Dimension2D; import java.awt.geom.Path2D; import java.awt.geom.Point2D; -import java.awt.geom.Point2D.Double; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collections; @@ -62,8 +62,7 @@ // Test code (will be deleted) private static final String TAG = MagnetRONViewer.class.getSimpleName(); - protected static Dimension DEFAULT_WINDOW_SIZE = new Dimension(1300, 700); - protected static String WINDOW_TITLE = "Delta Viewer"; + protected static Dimension DEFAULT_COMPONENT_SIZE = new Dimension(1300, 700); protected static Dimension DEFAULT_OBJECT_VERTEX_SIZE = new Dimension(70, 70); protected static Dimension DEFAULT_METHOD_EXECUTION_VERTEX_SIZE = new Dimension(55, 20); @@ -78,13 +77,14 @@ protected Map edgeMap = new HashMap<>(); + protected mxGraphComponent mxgraphComponent; protected DeltaGraphAdapter mxgraph; protected mxICell mxDefaultParent; - protected mxGraphComponent mxgraphComponent; protected ThreadPoolExecutor threadPoolExecutor; - protected DeltaAnimation deltaAnimation; protected int curFrame = 0; + + private boolean autoTracking = false; public MagnetRONViewer() { mxgraph = new DeltaGraphAdapter(new DirectedWeightedPseudograph(DefaultEdge.class)); @@ -94,21 +94,20 @@ return new CurvedCanvas(this); } }; + mxgraphComponent.setPreferredSize(DEFAULT_COMPONENT_SIZE); + this.setLayout(new BorderLayout()); + this.add(mxgraphComponent, BorderLayout.CENTER); - deltaAnimation = new DeltaAnimation(mxgraph, getGraphComponent()); threadPoolExecutor = new MagnetRONScheduledThreadPoolExecutor(2); - getGraphComponent().setPreferredSize(DEFAULT_WINDOW_SIZE); - setLayout(new BorderLayout()); - add(getGraphComponent(), BorderLayout.CENTER); } - public mxICell getMxDefaultParent() { - return mxDefaultParent; - } - public mxGraphComponent getGraphComponent() { return mxgraphComponent; } + + protected mxICell getMxDefaultParent() { + return mxDefaultParent; + } public void clear() { mxgraph.getModel().beginUpdate(); @@ -161,6 +160,7 @@ for (int i = fromFrame; i <= toFrame; i++) { List aliasList = new ArrayList<>(aliasCollector.getAliasList()); Alias alias = aliasList.get(i); + // Test code (will be deleted) System.out.println("\r\n" + TAG + ": Frame=" + i + ", aliasType=" + alias.getAliasType().toString() + ", objectId=" + alias.getObjectId() + ", methodSignature=" + alias.getMethodSignature() + ", l." + alias.getLineNo()); switch(alias.getAliasType()) { @@ -225,20 +225,24 @@ } /** - * Create {@code ObjectVertex} when CONSTRACTOR_INVOCATION. + * Create a {@code mxIcell} of {@code ObjectVertex} while animating {@code TranslateAnimation} when {@link Alias#getAliasType()} is CONSTRACTOR_INVOCATION. * * @param alias */ protected void createObjectVertexOnConstractor(Alias alias) { ObjectVertex objectVertex = objectToVertexMap.get(alias.getObjectId()); + mxICell ovCell = null; + + // Position of srcCell is start point for ovCell to TranslateAnimation. MethodExecution methodExec = alias.getMethodExecution(); - String srcObjId = alias.getMethodExecution().getThisObjId(); + String srcObjId = methodExec.getThisObjId(); mxICell srcCell = (mxICell)objectToVertexMap.get(srcObjId).getCell(); double srcWidth = srcCell.getGeometry().getWidth(); double srcHeight = srcCell.getGeometry().getHeight(); double overlapWidth = srcWidth * Math.sqrt(2) * 0.1; double overlapHeight = srcHeight - (srcHeight * Math.sqrt(2) * 0.1); Point2D srcCellAbsPt = getAbsolutePointforCell(srcCell); + MethodInvocation methodInv; String fieldName = null; if (!methodExec.isCollectionType() @@ -246,12 +250,14 @@ methodInv = (MethodInvocation)alias.getOccurrencePoint().getStatement(); fieldName = methodInv.getCallerSideMethodName(); } - mxICell ovCell; + MagnetRONAnimation.waitAnimationEnd(); + scrollPointsToVisible(srcCellAbsPt, objectVertex.getInitialPoint(), true); + mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - // Creates a white cell of {@code ObjectVertex}. + // Creates a white mxICell of ObjectVertex. ovCell = (mxICell) mxgraph.insertDeltaVertex(getMxDefaultParent(), alias.getObjectId(), objectVertex.getLabel(), srcCellAbsPt.getX() + overlapWidth, srcCellAbsPt.getY() + overlapHeight, @@ -259,29 +265,30 @@ "fillColor=white"); objectVertex.setCell(ovCell); mxICell edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldName, null, srcCell, ovCell); - // setEdgePoint((mxCell)edge, srcCellAbsPt, objectVertex.getInitialPoint()); edgeMap.put(methodExec.getThisClassName() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); - // setCellsStyle(); update(); } finally { mxgraph.getModel().endUpdate(); } } - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(ovCell, objectVertex.getX(), objectVertex.getY(), threadPoolExecutor); - vertexAnim.syncPlay(); + MagnetRONAnimation ovCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + ovCellAnim.setTotalCycleCount(10); + ovCellAnim.setDelay(100); + ovCellAnim.init(ovCell, objectVertex.getInitialX(), objectVertex.getInitialY(), threadPoolExecutor); + ovCellAnim.syncPlay(); } /** - * Create {@code ObjectVertex} when CONSTRACTOR_INVOCATION is preceded by FORMAL_PARAMETER. + * Create a {@code mxIcell} of {@code ObjectVertex} while animating {@code TranslateAnimation} when {@link Alias#getAliasType()} is CONSTRACTOR_INVOCATION preceded by FORMAL_PARAMETER. * * @param alias */ protected void createObjectVertexOnConstractorByFormalParameter(Alias alias) { - ObjectVertex objectVertex = objectToVertexMap.get(alias.getObjectId()); // Create cell of this object vertex. + ObjectVertex objectVertex = objectToVertexMap.get(alias.getObjectId()); // Create mxICell of this ObjectVertex. MethodExecution methodExec = alias.getMethodExecution(); + mxICell ovCell = null; + + // Position of srcCell is start point for ovCell to TranslateAnimation. String srcObjId = methodExec.getArguments().get(0).getId(); mxICell srcCell = (mxICell)objectToVertexMap.get(srcObjId).getCell(); double srcWidth = srcCell.getGeometry().getWidth(); @@ -289,17 +296,20 @@ double overlapWidth = srcWidth * Math.sqrt(2) * 0.1; double overlapHeight = srcHeight - (srcHeight * Math.sqrt(2) * 0.1); Point2D srcCellAbsPt = getAbsolutePointforCell(srcCell); + + scrollPointsToVisible(srcCellAbsPt, objectVertex.getInitialPoint(), true); + MethodInvocation methodInv; String fieldName = null; if (!methodExec.isCollectionType() && alias.getOccurrencePoint().getStatement() != null) { methodInv = (MethodInvocation)alias.getOccurrencePoint().getStatement(); fieldName = methodInv.getCallerSideMethodName(); } - mxICell ovCell; + mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - // Creates a white cell of {@code ObjectVertex}. + // Creates a white mxIcell of ObjectVertex. ovCell = (mxICell) mxgraph.insertDeltaVertex(getMxDefaultParent(), objectVertex.getLabel(), objectVertex.getLabel(), srcCellAbsPt.getX() + overlapWidth, srcCellAbsPt.getY() + overlapHeight, @@ -307,33 +317,38 @@ "fillColor=white"); objectVertex.setCell(ovCell); mxICell edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldName, null, srcCell, ovCell); - setEdgePoint(edge, srcCellAbsPt, objectVertex.getInitialPoint()); edgeMap.put(methodExec.getThisClassName() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); - // setCellsStyle(); update(); } finally { mxgraph.getModel().endUpdate(); } } - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(ovCell, objectVertex.getInitialX(), objectVertex.getInitialY(), threadPoolExecutor); - vertexAnim.syncPlay(); + MagnetRONAnimation ovCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + ovCellAnim.setTotalCycleCount(10); + ovCellAnim.setDelay(100); + ovCellAnim.init(ovCell, objectVertex.getInitialX(), objectVertex.getInitialY(), threadPoolExecutor); + ovCellAnim.syncPlay(); } /** + * Create edge of {@code ObjectReference}. * * @param fieldUpdateStatement * @param fieldName */ protected void createObjectRefrence(FieldUpdate fieldUpdateStatement, String fieldName) { + // Create edge between srcCell and dstCell. String srcObjId = fieldUpdateStatement.getContainerObjId(); + mxICell srcCell = (mxICell)objectToVertexMap.get(srcObjId).getCell(); + Point2D srcCellAbsPt = getAbsolutePointforCell(srcCell); + String dstObjId = fieldUpdateStatement.getValueObjId(); - ObjectVertex dstObjVertex = objectToVertexMap.get(dstObjId); - mxICell dstCell = (mxICell)dstObjVertex.getCell(); + ObjectVertex dstObjectVertex = objectToVertexMap.get(dstObjId); + mxICell dstCell = (mxICell)dstObjectVertex.getCell(); Point2D dstCellAbsPt = getAbsolutePointforCell(dstCell); + scrollPointsToVisible(srcCellAbsPt, dstObjectVertex.getInitialPoint(), true); + mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { @@ -346,7 +361,7 @@ dstCell.getGeometry().setY(dstCellAbsPt.getY()); mxICell edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldUpdateStatement.getFieldName(), fieldName, - objectToVertexMap.get(srcObjId).getCell(), objectToVertexMap.get(dstObjId).getCell()); + srcCell, dstCell); edge.setStyle("strokeColor=red;"); // mxgraph.orderCells(true, new Object[] {edge}); edgeMap.put(fieldUpdateStatement.getFieldName(), new Edge(fieldName, TypeName.Reference, edge)); @@ -354,16 +369,18 @@ mxgraph.getModel().endUpdate(); } } - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(dstCell, dstObjVertex.getInitialX(), dstObjVertex.getInitialY(), threadPoolExecutor); - vertexAnim.syncPlay(); + MagnetRONAnimation dstCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + dstCellAnim.setTotalCycleCount(10); + dstCellAnim.setDelay(100); + dstCellAnim.init(dstCell, dstObjectVertex.getInitialX(), dstObjectVertex.getInitialY(), threadPoolExecutor); + dstCellAnim.syncPlay(); + + // If the animation didn't work to the end. mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - dstCell.getGeometry().setX(dstObjVertex.getInitialX()); - dstCell.getGeometry().setY(dstObjVertex.getInitialY()); + dstCell.getGeometry().setX(dstObjectVertex.getInitialX()); + dstCell.getGeometry().setY(dstObjectVertex.getInitialY()); } finally { mxgraph.getModel().endUpdate(); } @@ -371,16 +388,23 @@ } /** - * + * Create edge of {@code ObjectReference}. + * * @param sourceClassName * @param sourceObjectId * @param destinationObjectId */ protected void createObjectRefrence(String sourceClassName, String sourceObjectId, String destinationObjectId) { - ObjectVertex dstObjVertex = objectToVertexMap.get(destinationObjectId); - mxICell dstCell = (mxICell)dstObjVertex.getCell(); + // Create edge between srcCell and dstCell. + mxICell srcCell = (mxICell)objectToVertexMap.get(sourceObjectId).getCell(); + Point2D srcCellAbsPt = getAbsolutePointforCell(srcCell); + + ObjectVertex dstObjectVertex = objectToVertexMap.get(destinationObjectId); + mxICell dstCell = (mxICell) dstObjectVertex.getCell(); Point2D dstCellAbsPt = getAbsolutePointforCell(dstCell); + scrollPointsToVisible(srcCellAbsPt, dstObjectVertex.getInitialPoint(), true); + // 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()) { @@ -394,24 +418,26 @@ dstCell.getGeometry().setY(dstCellAbsPt.getY()); mxICell edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), destinationObjectId, null, - objectToVertexMap.get(sourceObjectId).getCell(), objectToVertexMap.get(destinationObjectId).getCell()); + srcCell, dstCell); edge.setStyle("strokeColor=red;"); edgeMap.put(destinationObjectId, new Edge(null, TypeName.Reference, edge)); } finally { mxgraph.getModel().endUpdate(); } } - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(dstCell, dstObjVertex.getInitialX(), dstObjVertex.getInitialY(), threadPoolExecutor); - vertexAnim.syncPlay(); + MagnetRONAnimation dstCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + dstCellAnim.setTotalCycleCount(10); + dstCellAnim.setDelay(100); + dstCellAnim.init(dstCell, dstObjectVertex.getInitialX(), dstObjectVertex.getInitialY(), threadPoolExecutor); + dstCellAnim.syncPlay(); + + // If the animation didn't work to the end. // 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 { - dstCell.getGeometry().setX(dstObjVertex.getInitialX()); - dstCell.getGeometry().setY(dstObjVertex.getInitialY()); + dstCell.getGeometry().setX(dstObjectVertex.getInitialX()); + dstCell.getGeometry().setY(dstObjectVertex.getInitialY()); } finally { mxgraph.getModel().endUpdate(); } @@ -425,14 +451,16 @@ */ protected void moveObjectVertex(Alias alias) { // source {@code ObjectVertex} - ObjectVertex srcObjVertex = objectToVertexMap.get(alias.getObjectId()); - if (alias.getMethodExecution().isStatic() && !methodExecToVertexMap.containsKey(alias.getMethodExecution())) { - createMethodExecutionVertex(alias.getObjectId(), alias.getMethodExecution().getSignature(), alias.getMethodExecution()); + String objId = alias.getObjectId(); + ObjectVertex srcObjectVertex = objectToVertexMap.get(objId); + MethodExecution methodExec = alias.getMethodExecution(); + if (!methodExecToVertexMap.containsKey(methodExec) && methodExec.isStatic()) { + createMethodExecutionVertex(objId, methodExec.getSignature(), methodExec); sleepMainThread(POSTPONE_ANIMATION_MILLIS); } // destination {@code ObjectVertex} - MethodExecutionVertex dstMethodExecVertex = methodExecToVertexMap.get(alias.getMethodExecution()); - moveObjectVertex(alias, srcObjVertex, dstMethodExecVertex); + MethodExecutionVertex dstMethodExecVertex = methodExecToVertexMap.get(methodExec); + moveObjectVertex(alias, srcObjectVertex, dstMethodExecVertex); updateObjectVertices(); } @@ -445,7 +473,8 @@ */ private void moveObjectVertex(Alias alias, ObjectVertex sourceObjectVertex, MethodExecutionVertex destinationMethodExecutionVertex) { MethodExecution methodExec = alias.getMethodExecution(); - if (alias.getAliasType().equals(AliasType.RETURN_VALUE) || alias.getAliasType().equals(AliasType.METHOD_INVOCATION)) { + AliasType aliasType = alias.getAliasType(); + if (aliasType.equals(AliasType.RETURN_VALUE) || aliasType.equals(AliasType.METHOD_INVOCATION)) { if (sourceObjectVertex.getCell() == null && methodExec.isCollectionType()) { if (methodExec.getArguments().isEmpty()) { createObjectVertexOnConstractor(alias); @@ -453,13 +482,13 @@ createObjectVertexOnConstractorByFormalParameter(alias); } } - if (alias.getAliasType().equals(AliasType.RETURN_VALUE)) { + if (aliasType.equals(AliasType.RETURN_VALUE)) { MagnetRONAnimation.waitAnimationEnd(); } moveLocalObjectVertex(methodExec, sourceObjectVertex, destinationMethodExecutionVertex); - } else if (alias.getAliasType().equals(AliasType.FORMAL_PARAMETER)) { + } else if (aliasType.equals(AliasType.FORMAL_PARAMETER)) { moveArgumentObjectVertex(methodExec, sourceObjectVertex, destinationMethodExecutionVertex); - } else if (alias.getAliasType().equals(AliasType.ACTUAL_ARGUMENT)) { + } else if (aliasType.equals(AliasType.ACTUAL_ARGUMENT)) { moveActualArgumentObjectVertex(methodExec, sourceObjectVertex, destinationMethodExecutionVertex); } } @@ -472,76 +501,80 @@ * @param destinationMethodExecutionVertex */ private void moveLocalObjectVertex(MethodExecution callerMethodExecution, ObjectVertex sourceObjectVertex, MethodExecutionVertex destinationMethodExecutionVertex) { - mxICell srcCell = (mxICell)sourceObjectVertex.getCell(); - mxICell dstCell = (mxICell) destinationMethodExecutionVertex.getCell(); + mxICell srcObjectVertexCell = (mxICell)sourceObjectVertex.getCell(); + mxICell dstMethodExecVertexCell = (mxICell) destinationMethodExecutionVertex.getCell(); - if (srcCell.equals(dstCell.getParent())) { + if (srcObjectVertexCell.equals(dstMethodExecVertexCell.getParent())) { return; } - // Remove sourceObjectVertex from Locals and Arguments of MethodExecution's Vertex. - if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getLocals().contains(sourceObjectVertex)) { - methodExecToVertexMap.get(callerMethodExecution).getLocals().remove(sourceObjectVertex); - } + scrollCellsToVisible(srcObjectVertexCell, dstMethodExecVertexCell); - if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getArguments().contains(sourceObjectVertex)) { - methodExecToVertexMap.get(callerMethodExecution).getArguments().remove(sourceObjectVertex); + // Remove source ObjectVertex from Locals and Arguments of caller MethodExecutionVertex. + if (methodExecToVertexMap.containsKey(callerMethodExecution)) { + MethodExecutionVertex callerMethodExecVertex = methodExecToVertexMap.get(callerMethodExecution); + if (callerMethodExecVertex.getLocals().contains(sourceObjectVertex)) { + callerMethodExecVertex.getLocals().remove(sourceObjectVertex); + } + if (callerMethodExecVertex.getArguments().contains(sourceObjectVertex)) { + callerMethodExecVertex.getArguments().remove(sourceObjectVertex); + } } - int time = destinationMethodExecutionVertex.getLocals().size(); - // 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 { - double srcCellCoordX = srcCell.getGeometry().getX(); - double srcCellCoordY = srcCell.getGeometry().getY(); + double srcCellCoordX = srcObjectVertexCell.getGeometry().getX(); + double srcCellCoordY = srcObjectVertexCell.getGeometry().getY(); - if(srcCell.getParent().getValue() != null) { - Point2D absolutePointSourceCell = getAbsolutePointforCell(srcCell); + // TODO: Confirm why not .equals(getMxDefaultParent()). + if(srcObjectVertexCell.getParent().getValue() != null) { + Point2D absolutePointSourceCell = getAbsolutePointforCell(srcObjectVertexCell); srcCellCoordX = absolutePointSourceCell.getX(); srcCellCoordY = absolutePointSourceCell.getY(); - srcCell.getParent().remove(srcCell); + srcObjectVertexCell.getParent().remove(srcObjectVertexCell); } - - mxgraph.orderCells(true, new Object[] {srcCell}); - if (srcCell.getParent() == null || !srcCell.getParent().equals(dstCell.getParent())) { + mxgraph.orderCells(true, new Object[] {srcObjectVertexCell}); + if (srcObjectVertexCell.getParent() == null || !srcObjectVertexCell.getParent().equals(dstMethodExecVertexCell.getParent())) { // TODO: Confirm why not need following comment out. // if (srcCell.getParent() != null) srcCell.getParent().remove(srcCell); - srcCell.setParent(dstCell.getParent()); - dstCell.getParent().insert(srcCell); + srcObjectVertexCell.setParent(dstMethodExecVertexCell.getParent()); + dstMethodExecVertexCell.getParent().insert(srcObjectVertexCell); } - Point2D dstCellAbsPt = getAbsolutePointforCell(srcCell.getParent()); - srcCell.getGeometry().setX(srcCellCoordX - dstCellAbsPt.getX()); - srcCell.getGeometry().setY(srcCellCoordY - dstCellAbsPt.getY()); + Point2D dstCellAbsPt = getAbsolutePointforCell(srcObjectVertexCell.getParent()); + srcObjectVertexCell.getGeometry().setX(srcCellCoordX - dstCellAbsPt.getX()); + srcObjectVertexCell.getGeometry().setY(srcCellCoordY - dstCellAbsPt.getY()); } finally { mxgraph.getModel().endUpdate(); } } - double srcCellWidth = srcCell.getGeometry().getWidth(); - double dstCellHeight = dstCell.getGeometry().getHeight(); + int sizeScale = destinationMethodExecutionVertex.getLocals().size(); + double srcCellWidth = srcObjectVertexCell.getGeometry().getWidth(); + double dstCellHeight = dstMethodExecVertexCell.getGeometry().getHeight(); + double srcCellDstX = dstMethodExecVertexCell.getGeometry().getX() - (srcCellWidth / Math.sqrt(2.5)) + (srcCellWidth * sizeScale); + double srcCellDstY = dstMethodExecVertexCell.getGeometry().getY() + dstCellHeight; - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(srcCell, - dstCell.getGeometry().getX() - (srcCellWidth / Math.sqrt(2.5)) + (srcCellWidth * time), dstCell.getGeometry().getY() + dstCellHeight, - threadPoolExecutor); - vertexAnim.syncPlay(); + MagnetRONAnimation srcCellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + srcCellAnim.setTotalCycleCount(10); + srcCellAnim.setDelay(100); + srcCellAnim.init(srcObjectVertexCell, srcCellDstX, srcCellDstY, threadPoolExecutor); + srcCellAnim.syncPlay(); + // If the animation didn't work to the end. // 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 (!srcCell.getParent().equals(dstCell.getParent())) { - srcCell.getParent().remove(srcCell); - srcCell.setParent(dstCell.getParent()); - dstCell.getParent().insert(srcCell); - } - srcCell.getGeometry().setX(dstCell.getGeometry().getX() - (srcCellWidth / Math.sqrt(2.5)) + (srcCellWidth * time)); - srcCell.getGeometry().setY(dstCell.getGeometry().getY() + dstCellHeight); +// if (!srcObjectVertexCell.getParent().equals(dstMethodExecVertexCell.getParent())) { +// srcObjectVertexCell.getParent().remove(srcObjectVertexCell); +// srcObjectVertexCell.setParent(dstMethodExecVertexCell.getParent()); +// dstMethodExecVertexCell.getParent().insert(srcObjectVertexCell); +// } + srcObjectVertexCell.getGeometry().setX(dstMethodExecVertexCell.getGeometry().getX() - (srcCellWidth / Math.sqrt(2.5)) + (srcCellWidth * sizeScale)); + srcObjectVertexCell.getGeometry().setY(dstMethodExecVertexCell.getGeometry().getY() + dstCellHeight); destinationMethodExecutionVertex.getLocals().add(sourceObjectVertex); } finally { mxgraph.getModel().endUpdate(); @@ -863,7 +896,7 @@ abstract protected void createMethodExecutionVertex(Alias alias); /** - * Parent: Create {@code MethodExecutionVertex}. + * Create {@code MethodExecutionVertex} and Call {@link MagnetRONViewer#createEdgesToMethodExecutions()}. * * @param objectId * @param methodSignature: called or this method signature @@ -878,18 +911,19 @@ methodSignature = formatMethodSignature(methodSignature, methodExecution.getThisClassName()); } - if (methodExecution.isStatic() && !objectId.equals("0")) { + if (methodExecution.isStatic() && !objectId.startsWith("0:")) { objectId = methodExecution.getCallerMethodExecution().getThisObjId(); } - mxICell parentCell = (mxICell) objectToVertexMap.get(objectId).getCell(); + ObjectVertex parentObjectVertex = objectToVertexMap.get(objectId); + mxICell parentCell = (mxICell) parentObjectVertex.getCell(); double coordX = DEFAULT_OBJECT_VERTEX_SIZE.getWidth() * 0.1; double coordY = DEFAULT_OBJECT_VERTEX_SIZE.getHeight() * 0.5; double stdX = coordX; double stdY = 0; - int time = objectToVertexMap.get(objectId).getVertexMethodExecutions().size(); + int time = parentObjectVertex.getMethodExecutionVertices().size(); if (time >= 1) { - mxICell stdCell = (mxICell) objectToVertexMap.get(objectId).getVertexMethodExecutions().get(0).getCell(); + mxICell stdCell = (mxICell) parentObjectVertex.getMethodExecutionVertices().get(0).getCell(); stdX = stdCell.getGeometry().getX(); stdY = stdCell.getGeometry().getY(); time -= 1; @@ -916,31 +950,33 @@ mxgraph.getModel().endUpdate(); } } + if(methodExecToVertexMap.size() > 1) { createEdgesToMethodExecutions(); } - objectToVertexMap.get(objectId).addMethodExecution(methodExecVertex); -// setCellsStyle(); + parentObjectVertex.addMethodExecutionVertex(methodExecVertex); update(); } /** - * Remove {@code MethodExecutionVertex} on AliasType is {@code AliasType.METHOD_INVOCATION}. + * Remove {@code MethodExecutionVertex} on {@code {@link Alias#getAliasType()} is {@code AliasType.METHOD_INVOCATION}. * * @param alias */ private void removeMethodExecutionVertex(Alias alias) { - // source {@code ObjectVertex} - ObjectVertex srcObjVertex = objectToVertexMap.get(alias.getObjectId()); + // source ObjectVertex + ObjectVertex srcObjectVertex = objectToVertexMap.get(alias.getObjectId()); MethodExecution methodExec = alias.getMethodExecution(); - if(alias.getAliasType().equals(AliasType.METHOD_INVOCATION) || alias.getAliasType().equals(AliasType.CONSTRACTOR_INVOCATION)) { + 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()); List locals = new ArrayList<>(methodExecToVertexMap.get(calledMethodExec).getLocals()); if (arguments.size() != 0) { for (ObjectVertex vo: arguments) { - if (vo != srcObjVertex) { + // TODO: Implement equals(). + if (vo != srcObjectVertex) { mxICell cell = (mxICell)vo.getCell(); if (!cell.getParent().equals(getMxDefaultParent())) { // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. @@ -957,20 +993,19 @@ mxgraph.getModel().endUpdate(); } } - - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); - vertexAnim.play(); + MagnetRONAnimation cellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + cellAnim.setTotalCycleCount(10); + cellAnim.setDelay(100); + cellAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); + cellAnim.play(); methodExecToVertexMap.get(calledMethodExec).getArguments().remove(vo); } } } if (locals.size() != 0) { for (ObjectVertex vo: locals) { - if (vo != srcObjVertex) { - mxICell cell = (mxICell)vo.getCell(); + if (vo != srcObjectVertex) { + mxICell cell = (mxICell) vo.getCell(); // 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()) { @@ -987,22 +1022,23 @@ mxgraph.getModel().endUpdate(); } } - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); - vertexAnim.play(); + MagnetRONAnimation cellAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + cellAnim.setTotalCycleCount(10); + cellAnim.setDelay(100); + cellAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); + cellAnim.play(); } } } } + MagnetRONAnimation.waitAnimationEnd(); - if (alias.getAliasType().equals(AliasType.CONSTRACTOR_INVOCATION)) { + if (aliasType.equals(AliasType.CONSTRACTOR_INVOCATION)) { sleepMainThread(500L); } - removeCalledMethodExecutionVertex(srcObjVertex, methodExec, calledMethodExec); + removeCalledMethodExecutionVertex(srcObjectVertex, methodExec, calledMethodExec); } else { - removeMethodExecutionVertex(srcObjVertex, methodExec); + removeMethodExecutionVertex(srcObjectVertex, methodExec); } } @@ -1025,7 +1061,7 @@ dstMethodExecVertexCell.setParent(getMxDefaultParent()); } mxgraph.removeCells(new Object[] {dstMethodExecVertexCell}); - objectToVertexMap.get(methodExecution.getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(methodExecution)); + objectToVertexMap.get(methodExecution.getThisObjId()).getMethodExecutionVertices().remove(methodExecToVertexMap.get(methodExecution)); methodExecToVertexMap.remove(methodExecution); edgeMap.remove(methodExecution.getSignature()); updateObjectVertices(); @@ -1045,7 +1081,8 @@ */ protected void removeCalledMethodExecutionVertex(ObjectVertex sourceObjectVertex, MethodExecution methodExecution, MethodExecution calledMethodExecution) { MagnetRONAnimation.waitAnimationEnd(); - // Remove ObjectVertex other than sourceObjectVertex from locals and arguments of called MethodExecutionVertex. + + // Remove ObjectVertex other than source ObjectVertex from locals and arguments of called MethodExecutionVertex. if (methodExecToVertexMap.containsKey(calledMethodExecution)) { MethodExecutionVertex calledMethodExecVertex = methodExecToVertexMap.get(calledMethodExecution); @@ -1138,7 +1175,8 @@ mxICell srcMethodExecVertexCell = (mxICell)methodExecToVertexMap.get(methodExecution).getCell(); mxICell dstMethodExecVertexCell = (mxICell)calledMethodExecVertex.getCell(); - + scrollCellsToVisible(srcMethodExecVertexCell.getParent(), dstMethodExecVertexCell.getParent()); + try { Point2D srcMethodExecVertexCellAbsPt = null; Point2D dstMethodExecVertexCellAbsPt = null; @@ -1161,6 +1199,7 @@ mxgraph.getModel().endUpdate(); } } + // Animate an edge to shrink. MagnetRONAnimation edgeAnim = new TranslateAnimation(mxgraph, getGraphComponent()); edgeAnim.setTotalCycleCount(10); @@ -1194,9 +1233,9 @@ edgeAnim.play(); if (!calledMethodExecution.isStatic()) { - objectToVertexMap.get(calledMethodExecution.getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExecution)); + objectToVertexMap.get(calledMethodExecution.getThisObjId()).getMethodExecutionVertices().remove(methodExecToVertexMap.get(calledMethodExecution)); } else { - objectToVertexMap.get(calledMethodExecution.getCallerMethodExecution().getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExecution)); + objectToVertexMap.get(calledMethodExecution.getCallerMethodExecution().getThisObjId()).getMethodExecutionVertices().remove(methodExecToVertexMap.get(calledMethodExecution)); } methodExecToVertexMap.get(calledMethodExecution).getLocals().remove(sourceObjectVertex); methodExecToVertexMap.remove(calledMethodExecution); @@ -1209,7 +1248,7 @@ } /** - * Create an edge between method execution While animating the edge to stretch. + * Create an edge between {@code MethodExecutions} while animating the edge to stretch. */ private void createEdgesToMethodExecutions() { List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); @@ -1219,6 +1258,7 @@ MethodExecution srcMethodExec = methodExecList.get(i); MethodExecution dstMethodExec = methodExecList.get(i + 1); String methodSig = srcMethodExec.getSignature(); + if (!edgeMap.containsKey(methodSig)) { // Draw an edge from sourceVertexCell to destinationVertexCell. mxICell srcMethodExecVertexCell = (mxICell)methodExecToVertexMap.get(srcMethodExec).getCell(); @@ -1227,9 +1267,10 @@ Point2D dstMethodExecVertexCellAbsPt = getAbsolutePointforCell(dstMethodExecVertexCell); MagnetRONAnimation.waitAnimationEnd(); + scrollCellsToVisible(srcMethodExecVertexCell.getParent(), dstMethodExecVertexCell.getParent()); + try { final mxICell[] clonedstMethodExecVertexCell = new mxICell[1]; - // 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()) { @@ -1243,10 +1284,12 @@ mxICell tmpEdge = (mxICell) mxgraph.insertEdge(getMxDefaultParent(), null, null, srcMethodExecVertexCell, clonedstMethodExecVertexCell[0]); tmpEdge.setStyle("dashed=1;strokeColor=#008000;exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;endArrow=none"); dstMethodExecVertexCell.setVisible(true); + update(); } finally { mxgraph.getModel().endUpdate(); } } + // Animate an edge to stretch. MagnetRONAnimation edgeAnim = new TranslateAnimation(mxgraph, getGraphComponent()); edgeAnim.setTotalCycleCount(10); @@ -1279,15 +1322,16 @@ } }); edgeAnim.play(); - // 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 { - update(); - } finally { - mxgraph.getModel().endUpdate(); - } - } + +// // 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 { +// update(); +// } finally { +// mxgraph.getModel().endUpdate(); +// } +// } } catch (CloneNotSupportedException e) { e.printStackTrace(); } @@ -1333,7 +1377,7 @@ } else { objectVertex.add(ov.getCell()); } - if(ov.getVertexMethodExecutions().size() == 0) { + if(ov.getMethodExecutionVertices().size() == 0) { alignMidObjectVertex.add(ov.getCell()); } else { alignTopObjectVertex.add(ov.getCell()); @@ -1418,15 +1462,85 @@ * NOTE that you have to call the graphComponent.refresh() function, * otherwise you won't see the difference! */ setCellsStyle(); - mxgraphComponent.refresh(); + getGraphComponent().refresh(); + } + + private void scrollCellsToVisible(mxICell cell1, mxICell cell2) { + if (isAutoTracking()) { + Rectangle rec = new Rectangle(); + Point2D cell1AbsPt = getAbsolutePointforCell(cell1); + Point2D cell2AbsPt = getAbsolutePointforCell(cell2); + int cell1X = (int) cell1AbsPt.getX(), cell1Y = (int) cell1AbsPt.getY(); + int cell2X = (int) cell2AbsPt.getX(), cell2Y = (int) cell2AbsPt.getY(); + if (cell1X <= cell2X) { + if (cell1Y <= cell2Y) { + cell2X += cell2.getGeometry().getWidth(); + cell2Y += cell2.getGeometry().getHeight(); + rec.setBounds(cell1X, cell1Y, cell2X - cell1X, cell2Y - cell1Y); + } else { + cell2X += cell2.getGeometry().getWidth(); + cell1Y += cell1.getGeometry().getHeight(); + rec.setBounds(cell1X, cell2Y, cell2X - cell1X, cell1Y - cell2Y); + } + } else { + if (cell1Y <= cell2Y) { + cell1X += cell1.getGeometry().getWidth(); + cell2Y += cell2.getGeometry().getHeight(); + rec.setBounds(cell2X, cell1Y, cell1X - cell2X, cell2Y - cell1Y); + } else { + cell1X += cell1.getGeometry().getWidth(); + cell1Y += cell1.getGeometry().getHeight(); + rec.setBounds(cell2X, cell2Y, cell1X - cell2X, cell1Y - cell2Y); + } + } + scrollRectToVisible(rec); + } + } + + private void scrollPointsToVisible(Point2D p1, Point2D p2, boolean center) { + if (isAutoTracking()) { + Rectangle rec = new Rectangle(); + int p1X = (int) p1.getX(), p1Y = (int) p1.getY(); + int p2X = (int) p2.getX(), p2Y = (int) p2.getY(); + if (p1X <= p2X) { + if (p1Y <= p2Y) { + rec.setBounds(p1X, p1Y, p2X - p1X, p2Y - p1Y); + } else { + rec.setBounds(p1X, p2Y, p2X - p1X, p1Y - p2Y); + } + } else { + if (p1Y <= p2Y) { + rec.setBounds(p2X, p1Y, p1X - p2X, p2Y - p1Y); + } else { + rec.setBounds(p2X, p2Y, p1X - p2X, p1Y - p2Y); + } + } + + if (center) { + int x = (int) (rec.getCenterX() - getWidth() / 2); + int y = (int) (rec.getCenterY() - getHeight() / 2); + rec.setBounds(x, y, getWidth(), getHeight()); + } + scrollRectToVisible(rec); + } + } + + @Override + public void scrollRectToVisible(Rectangle rec) { + Rectangle visibleRec = getGraphComponent().getGraphControl().getVisibleRect(); + if (isAutoTracking() && !visibleRec.contains(rec)) { + System.out.println(TAG + ": Before scroll visibleRect=" + getGraphComponent().getGraphControl().getVisibleRect()); + getGraphComponent().getGraphControl().scrollRectToVisible(rec); + System.out.println(TAG + ": After scroll visibleRect=" + getGraphComponent().getGraphControl().getVisibleRect()); + } } private int countChildVertex(ObjectVertex objectVertex) { - int time = objectVertex.getVertexMethodExecutions().size(); + int time = objectVertex.getMethodExecutionVertices().size(); if(time == 0) { return 1; } - for(MethodExecutionVertex mev: objectVertex.getVertexMethodExecutions()) { + for(MethodExecutionVertex mev: objectVertex.getMethodExecutionVertices()) { for(ObjectVertex ov: mev.getLocals()) { time += countChildVertex(ov); } @@ -1494,10 +1608,6 @@ return sb.toString(); } - private void setWindowSize(int width, int height) { - DEFAULT_WINDOW_SIZE.setSize(width, height); - } - /** * Test code (will be deleted) */ @@ -1517,7 +1627,7 @@ } else { System.out.println(vo.getLabel() + " (" + objId + ")"); } - for (MethodExecutionVertex vme: vo.getVertexMethodExecutions()) { + for (MethodExecutionVertex vme: vo.getMethodExecutionVertices()) { System.out.println(" " + vme.getLabel()); for (ObjectVertex vmevo: vme.getArguments()) { System.out.println(" Argument: " + vmevo.getLabel()); @@ -1637,6 +1747,16 @@ return new AbstractMap.SimpleEntry<>(new Reference(rpSrcObjId, rpDstObjId, rpSrcClassName, rpDstClassName), rpFieldName); } + private boolean isAutoTracking() { + return this.autoTracking; + } + + public void setAutoTracking(boolean autoTracking) { + if (autoTracking != isAutoTracking()) { + this.autoTracking = autoTracking; + } + } + public void sleepMainThread(long millis) { try { // Test code (will be deleted) diff --git a/src/org/ntlab/deltaViewer/ObjectVertex.java b/src/org/ntlab/deltaViewer/ObjectVertex.java index d161d3b..537ace3 100644 --- a/src/org/ntlab/deltaViewer/ObjectVertex.java +++ b/src/org/ntlab/deltaViewer/ObjectVertex.java @@ -11,7 +11,7 @@ * @author Nitta Lab. */ public class ObjectVertex extends Vertex { - protected List vertexMethodExecutions = new ArrayList<>(); + protected List methodExecutionVertices = new ArrayList<>(); public ObjectVertex(String label, Object cell) { super(label, cell); @@ -25,15 +25,15 @@ super(label, cell, x, y, width, height); } - public List getVertexMethodExecutions() { - return vertexMethodExecutions; + public List getMethodExecutionVertices() { + return methodExecutionVertices; } - public void setVertexMethodExecutions(List vertexMethodExecutions) { - this.vertexMethodExecutions = vertexMethodExecutions; + public void setMethodExecutionVertices(List methodExecutionVertices) { + this.methodExecutionVertices = methodExecutionVertices; } - public void addMethodExecution(MethodExecutionVertex vertexMethodExecution) { - this.vertexMethodExecutions.add(vertexMethodExecution); + public void addMethodExecutionVertex(MethodExecutionVertex methodExecutionVertex) { + this.methodExecutionVertices.add(methodExecutionVertex); } }