diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 0d8b82a..4f52ab5 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -494,7 +494,13 @@ System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeArgument: " + tgtObjectVertex.getLabel()); } } - removeCalledMethodExecutionVertex(objectToVertexMap.get(srcObjId), methodExec.getCallerMethodExecution(), methodExec); + List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); + System.out.println(methodExecList.size()); + if (methodExecList.size() > 1) { + removeCalledMethodExecutionVertex(null, methodExec.getCallerMethodExecution(), methodExec); + } else { + removeCalledMethodExecutionVertex(null, null, methodExec); + } updateObjectVertices(); } else { // this to another @@ -669,7 +675,13 @@ objectToVertexMap.put(ref.getDstObjectId(), new ObjectVertex(ref.getDstClassName(), vertex, xCor + (time * (srcSideSize - i)), yCor + (time * (srcSideSize - i)))); } } else { - objectToVertexMap.put(ref.getSrcObjectId(), new ObjectVertex(ref.getSrcClassName(), null, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)))); + String srcClassName = ref.getSrcClassName(); + if (srcClassName.contains("[L")) { + srcClassName = formatArrayName(srcClassName); + } + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getSrcObjectId(), srcClassName, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. + objectToVertexMap.put(ref.getSrcObjectId(), new ObjectVertex(ref.getSrcClassName(), vertex, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)))); + objectToVertexMap.put(ref.getDstObjectId(), new ObjectVertex(ref.getDstClassName(), null, xCor + (time * (srcSideSize - i)), yCor + (time * (srcSideSize - i)))); } } @@ -1447,9 +1459,13 @@ // Remove sourceVertex from Locals and Arguments Vertex of CalledMethodExecution's Vertex. if (methodExecToVertexMap.containsKey(calledMethodExec)) { - mxICell sourceVertexCell = (mxICell)methodExecToVertexMap.get(methodExec).getCell(); - mxCell targetVertexCell = (mxCell)methodExecToVertexMap.get(calledMethodExec).getCell(); - + mxICell sourceVertexCell = null; + mxCell targetVertexCell = null; + + if (methodExec != null) { + sourceVertexCell = (mxICell)methodExecToVertexMap.get(methodExec).getCell(); + targetVertexCell = (mxCell)methodExecToVertexMap.get(calledMethodExec).getCell(); + } // if(!calledMethodExec.isStatic()) { // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); @@ -1503,7 +1519,9 @@ } } } - + + if (sourceVertexCell == null || targetVertexCell == null) return; + mxgraph.removeCells(mxgraph.getEdgesBetween(sourceVertexCell, targetVertexCell)); try { mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone());