diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index edcf69a..5ef20a1 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -124,12 +124,12 @@ // Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, "view", "view", "fillColor=white"); //creates a white vertex. // ((mxICell)vertex).getGeometry().setX(view.getGraphBounds().getWidth()); // ((mxICell)vertex).getGeometry().setY(10); - + System.out.print("Scale " + componentWidth + ", " + viewWidth + ", " + coordinatorPoint.getX()); if (viewWidth < coordinatorPoint.getX()) { viewWidth += coordinatorPoint.getX(); } - scale = (double)componentWidth/viewWidth; +// scale = (double)componentWidth/viewWidth; System.out.println(", " + scale); // scale = 1.5; view.setScale(scale); @@ -1103,6 +1103,48 @@ if(alias.getAliasType().equals(AliasType.METHOD_INVOCATION) || alias.getAliasType().equals(AliasType.CONSTRACTOR_INVOCATION)) { MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + 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 != sourceVertexObject) { + System.out.println("argumentRemove"); + mxICell cell = (mxICell)vo.getCell(); + Point absolutePointCell = getAbsolutePointforCell(cell); + cell.getParent().remove(cell); + cell.setParent(mxDefaultParent); + cell.getGeometry().setX(absolutePointCell.getX()); + cell.getGeometry().setY(absolutePointCell.getY()); + deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); + deltaAnimation.startVertexAnimation(); + methodExecToVertexMap.get(calledMethodExec).getArguments().remove(vo); + } + } + } + if (locals.size() != 0) { + for (ObjectVertex vo: locals) { + if (vo != sourceVertexObject) { + System.out.println("localRemove"); + mxICell cell = (mxICell)vo.getCell(); + Point absolutePointCell = getAbsolutePointforCell(cell); + cell.getParent().remove(cell); + cell.setParent(mxDefaultParent); + cell.getGeometry().setX(absolutePointCell.getX()); + cell.getGeometry().setY(absolutePointCell.getY()); + deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); + deltaAnimation.startVertexAnimation(); + methodExecToVertexMap.get(calledMethodExec).getLocals().remove(vo); + } + } + } + } finally { + mxgraph.getModel().endUpdate(); + } + + removeCalledMethodExecutionVertex(sourceVertexObject, methodExec, calledMethodExec); } else { removeMethodExecutionVertex(sourceVertexObject, methodExec); @@ -1120,7 +1162,7 @@ if (methodExecToVertexMap.containsKey(methodExec)) { mxCell targetVertexCell = (mxCell)methodExecToVertexMap.get(methodExec).getCell(); targetVertexCell.getParent().remove(targetVertexCell); - targetVertexCell.setParent(mxDefaultParent); + targetVertexCell.setParent(mxDefaultParent); mxgraph.removeCells(new Object[] {targetVertexCell}); objectToVertexMap.get(methodExec.getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(methodExec)); methodExecToVertexMap.remove(methodExec); @@ -1147,16 +1189,11 @@ // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); try { - mxgraph.removeCells(mxgraph.getEdgesBetween(sourceVertexCell, targetVertexCell)); - try { - mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); - Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); - - // -// List arguments = new ArrayList<>(methodExecToVertexMap.get(calledMethodExec).getArguments()); -// List locals = new ArrayList<>(methodExecToVertexMap.get(calledMethodExec).getLocals()); -// if (arguments.size() != 0) { -// for (ObjectVertex vo: arguments) { +// 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 != sourceVertexObject) { // mxICell cell = (mxICell)vo.getCell(); // Point absolutePointCell = getAbsolutePointforCell(cell); // cell.getParent().remove(cell); @@ -1167,8 +1204,10 @@ // deltaAnimation.startVertexAnimation(); // methodExecToVertexMap.get(calledMethodExec).getArguments().remove(vo); // } -// }else if (locals.size() != 0) { -// for (ObjectVertex vo: locals) { +// } +// }else if (locals.size() != 0) { +// for (ObjectVertex vo: locals) { +// if (vo != sourceVertexObject) { // mxICell cell = (mxICell)vo.getCell(); // Point absolutePointCell = getAbsolutePointforCell(cell); // cell.getParent().remove(cell); @@ -1180,8 +1219,12 @@ // methodExecToVertexMap.get(calledMethodExec).getLocals().remove(vo); // } // } - // +// } + mxgraph.removeCells(mxgraph.getEdgesBetween(sourceVertexCell, targetVertexCell)); + try { + mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); + Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); cloneTargetVertexCell.getGeometry().setX(absolutPointTargetVertexCell.getX()); cloneTargetVertexCell.getGeometry().setY(absolutPointTargetVertexCell.getY()); cloneTargetVertexCell.setStyle("fillColor=none;strokeColor=none;fontColor=#008000;"); @@ -1190,8 +1233,8 @@ ((mxCell)tempEdge).setStyle("dashed=1;strokeColor=#008000;exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;endArrow=none"); deltaAnimation.setReductionEdgeAnimation(cloneTargetVertexCell, new mxPoint(absolutPointSourceVertexCell.getX(), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight())); deltaAnimation.startReductionEdgeAnimation(); -// deltaAnimation.setReductionEdgeAnimation(new mxPoint(absolutPointSourceVertexCell.getX() + (sourceVertexCell.getGeometry().getWidth() / 2), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(absolutPointTargetVertexCell.getX() + (targetVertexCell.getGeometry().getWidth() / 2), absolutPointTargetVertexCell.getY())); -// deltaAnimation.startReductionEdgeAnimation(); +// deltaAnimation.setReductionEdgeAnimation(new mxPoint(absolutPointSourceVertexCell.getX() + (sourceVertexCell.getGeometry().getWidth() / 2), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(absolutPointTargetVertexCell.getX() + (targetVertexCell.getGeometry().getWidth() / 2), absolutPointTargetVertexCell.getY())); +// deltaAnimation.startReductionEdgeAnimation(); mxgraph.removeCells(new Object[]{cloneTargetVertexCell}); } catch (CloneNotSupportedException e) { e.printStackTrace();