diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 58e6ca2..06b5a1e 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -397,20 +397,51 @@ String sourceObjectId = fieldUpdateStatement.getContainerObjId(); createObjectRefrence(fieldUpdateStatement, fieldName); + + // Change! + String targetObjectId = fieldUpdateStatement.getValueObjId(); + ObjectVertex targetObjectVertex = objectToVertexMap.get(targetObjectId); + MethodExecution calledMethodExec = alias.getMethodExecution(); + + if (methodExecToVertexMap.containsKey(calledMethodExec)) { + if (methodExecToVertexMap.get(calledMethodExec).getLocals().contains(targetObjectVertex)) { + methodExecToVertexMap.get(calledMethodExec).getLocals().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(calledMethodExec).getArguments().contains(targetObjectVertex)) { + methodExecToVertexMap.get(calledMethodExec).getArguments().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); + } + } + removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); updateObjectVertices(); } if(statement instanceof MethodInvocation) { MethodInvocation methodInvocationStatement = (MethodInvocation) statement; - MethodExecution methodExec = methodInvocationStatement.getCalledMethodExecution(); + //Array��List�̂Ƃ��������x����t����i�m���ɕ������Ă�����̂Ƃ�)getSignature->contains("List.get(") || "Map.get(") <�z���C�g���X�g> if (methodExec.getSignature().contains("List.add(") || methodExec.getSignature().contains("Map.put(")) { String sourceObjectId = methodExec.getThisObjId(); createObjectRefrence(methodExec); + + // Change! + String targetObjectId = methodExec.getArguments().get(0).getId(); + ObjectVertex targetObjectVertex = objectToVertexMap.get(targetObjectId); + MethodExecution calledMethodExec = alias.getMethodExecution(); + + if (methodExecToVertexMap.containsKey(calledMethodExec)) { + if (methodExecToVertexMap.get(calledMethodExec).getLocals().contains(targetObjectVertex)) { + methodExecToVertexMap.get(calledMethodExec).getLocals().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(calledMethodExec).getArguments().contains(targetObjectVertex)) { + methodExecToVertexMap.get(calledMethodExec).getArguments().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(calledMethodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); + } + } removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); updateObjectVertices(); } @@ -460,14 +491,14 @@ Point absolutePointCalledCell = getAbsolutePointforCell(calledCell); System.out.println(objectId + ", " + methodExec.getSignature()); // objectToVertexMap.get(calledObjectId).resetCellPosition(); - if (methodExecToVertexMap.get(methodExec).getArguments().contains(objectToVertexMap.get(calledObjectId)) || methodExecToVertexMap.get(methodExec).getLocals().contains(objectToVertexMap.get(calledObjectId))) { - calledCell.getParent().remove(calledCell); - calledCell.setParent(mxDefaultParent); - calledCell.getGeometry().setX(absolutePointCalledCell.getX()); - calledCell.getGeometry().setY(absolutePointCalledCell.getY()); - deltaAnimation.setVertexAnimation(calledCell, new mxPoint(objectToVertexMap.get(calledObjectId).getInitialX(), objectToVertexMap.get(calledObjectId).getInitialY())); - deltaAnimation.startVertexAnimation(); - } +// if (methodExecToVertexMap.get(methodExec).getArguments().contains(objectToVertexMap.get(calledObjectId)) || methodExecToVertexMap.get(methodExec).getLocals().contains(objectToVertexMap.get(calledObjectId))) { +// calledCell.getParent().remove(calledCell); +// calledCell.setParent(mxDefaultParent); +// calledCell.getGeometry().setX(absolutePointCalledCell.getX()); +// calledCell.getGeometry().setY(absolutePointCalledCell.getY()); +// deltaAnimation.setVertexAnimation(calledCell, new mxPoint(objectToVertexMap.get(calledObjectId).getInitialX(), objectToVertexMap.get(calledObjectId).getInitialY())); +// deltaAnimation.startVertexAnimation(); +// } removeCalledMethodExecutionVertex(sourceVertexObject, methodExec.getCallerMethodExecution(), methodExec); updateObjectVertices(); // removeVertexMethodExecution(sourceVertexObject, methodExec); @@ -478,6 +509,8 @@ } } else { outputLog(); + + // Change! List arguments = new ArrayList<>(methodExecToVertexMap.get(methodExec).getArguments()); List locals = new ArrayList<>(methodExecToVertexMap.get(methodExec).getLocals()); if (arguments.size() != 0) { @@ -649,6 +682,7 @@ deltaAnimation.startVertexAnimation(); targetCell.getGeometry().setX(objectToVertexMap.get(targetObjectId).getInitialX()); targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); + } private void createObjectRefrence(MethodExecution methodExec) { @@ -658,19 +692,24 @@ mxICell targetCell = (mxICell)objectToVertexMap.get(targetObjectId).getCell(); Point absolutePointTargetCell = getAbsolutePointforCell(targetCell); - targetCell.getParent().remove(targetCell); - targetCell.setParent(mxDefaultParent); - targetCell.getGeometry().setX(absolutePointTargetCell.getX()); - targetCell.getGeometry().setY(absolutePointTargetCell.getY()); - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, targetObjectId, null, objectToVertexMap.get(sourceObjectId).getCell(), objectToVertexMap.get(targetObjectId).getCell()); - ((mxCell)edge).setStyle("exitX=0;exitY=0.5;exitPerimeter=1;entryX=1;entryY=0.5;entryPerimeter=1;"); - edgeMap.put(targetObjectId, new Edge(null, TypeName.Reference, edge)); - // System.out.println("last" + objectToVertexMap.get(targetObjectId).getInitialX() + ", " + objectToVertexMap.get(targetObjectId).getInitialY()); - deltaAnimation.setVertexAnimation(targetCell, new mxPoint(objectToVertexMap.get(targetObjectId).getInitialX(), objectToVertexMap.get(targetObjectId).getInitialY())); - deltaAnimation.startVertexAnimation(); - targetCell.getGeometry().setX(objectToVertexMap.get(targetObjectId).getInitialX()); - targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); - + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + targetCell.getParent().remove(targetCell); + targetCell.setParent(mxDefaultParent); + targetCell.getGeometry().setX(absolutePointTargetCell.getX()); + targetCell.getGeometry().setY(absolutePointTargetCell.getY()); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, targetObjectId, null, objectToVertexMap.get(sourceObjectId).getCell(), objectToVertexMap.get(targetObjectId).getCell()); + ((mxCell)edge).setStyle("exitX=0;exitY=0.5;exitPerimeter=1;entryX=1;entryY=0.5;entryPerimeter=1;"); + edgeMap.put(targetObjectId, new Edge(null, TypeName.Reference, edge)); +// System.out.println("last" + objectToVertexMap.get(targetObjectId).getInitialX() + ", " + objectToVertexMap.get(targetObjectId).getInitialY()); + deltaAnimation.setVertexAnimation(targetCell, new mxPoint(objectToVertexMap.get(targetObjectId).getInitialX(), objectToVertexMap.get(targetObjectId).getInitialY())); + deltaAnimation.startVertexAnimation(); + targetCell.getGeometry().setX(objectToVertexMap.get(targetObjectId).getInitialX()); + targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); + } finally { + mxgraph.getModel().endUpdate(); + } System.out.println("rTHIS " + srcClassName + ", " + targetObjectId); } @@ -868,6 +907,11 @@ mxICell targetCell = (mxICell) targetVertexMethodExec.getCell(); // mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); + if (sourceCell == targetCell.getParent()) { + System.out.println("nothing."); + return; + } + // Remove sourceVertex from Locals and Arguments Vertex of MethodExecution's Vertex. // MethodExecution callerMethodExecution = methodExec.getCallerMethodExecution(); System.out.println(methodExec.getSignature()); @@ -1188,41 +1232,44 @@ mxICell sourceVertexCell = (mxICell)methodExecToVertexMap.get(methodExec).getCell(); mxCell targetVertexCell = (mxCell)methodExecToVertexMap.get(calledMethodExec).getCell(); Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); + 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(); 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) { -// 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); -// } -// } -// }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); -// 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); -// } -// } -// } + // Dangerous + 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); + 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) { + 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); + } + } + } mxgraph.removeCells(mxgraph.getEdgesBetween(sourceVertexCell, targetVertexCell)); try {