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 { diff --git a/src/org/ntlab/deltaViewer/DeltaViewerSample.java b/src/org/ntlab/deltaViewer/DeltaViewerSample.java index a4f6f3c..93f67b4 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewerSample.java +++ b/src/org/ntlab/deltaViewer/DeltaViewerSample.java @@ -115,14 +115,14 @@ setArgmentsForDeltaExtract(argsMap); //���o�������f���^�̈������i�[����Map��key // String argsKey = "ArgoUMLPlace1_1"; - String argsKey = "ArgoUMLSelect0_1"; +// String argsKey = "ArgoUMLSelect0_1"; // String argsKey = "ArgoUMLSelect1_2"; // String argsKey = "sampleArray"; // String argsKey = "sampleCollection"; // String argsKey = "sampleCreate"; // String argsKey = "sampleStatic"; // String argsKey = "delta_eg1"; -// String argsKey = "delta_eg5"; + String argsKey = "pre_Exp1"; // String argsKey = "worstCase"; // String argsKey = "sample1"; long time = System.nanoTime(); @@ -172,7 +172,7 @@ // for(int i = 0; i < aliasList.size(); i++) { // System.out.println(aliasList.get(i).getObjectId() + ", " + aliasList.get(i).getMethodSignature() + " l." + aliasList.get(i).getLineNo() + " : " + aliasList.get(i).getAliasType().toString()); // } - for(int i = 0; i <= aliasList.size(); i++) { + for (int i = 0; i <= aliasList.size(); i++) { dv.stepToAnimation(i); } } @@ -194,6 +194,15 @@ String[] testTrace2 = {null, null, "","", "traces/testTrace2.txt"}; map.put("testTrace2", testTrace2); String[] testTrace3 = {null, null, "","", "traces/testTrace3.txt"}; map.put("testTrace3", testTrace3); + // �\�������̂Ƃ��ɗp����Toy program + String[] pre_Exp1 = {null, null, "E","C", "traces/pre_Exp1.txt"}; map.put("pre_Exp1", pre_Exp1); + String[] pre_Exp2 = {null, null, "E","C", "traces/pre_Exp2.txt"}; map.put("pre_Exp2", pre_Exp2); + String[] pre_Exp3 = {null, null, "E","C", "traces/pre_Exp3.txt"}; map.put("pre_Exp3", pre_Exp3); + String[] pre_Exp4 = {null, null, "E","C", "traces/pre_Exp4.txt"}; map.put("pre_Exp4", pre_Exp4); + String[] pre_Exp5 = {null, null, "E","C", "traces/pre_Exp5.txt"}; map.put("pre_Exp5", pre_Exp5); + String[] pre_Exp6 = {null, null, "E","C", "traces/pre_Exp6.txt"}; map.put("pre_Exp6", pre_Exp6); + String[] pre_Exp7 = {null, null, "E","C", "traces/pre_Exp7.txt"}; map.put("pre_Exp7", pre_Exp7); + String[] test = {null, null, "org.argouml.uml.diagram.static_structure.ui.FigClass","org.tigris.gef.base.LayerPerspectiveMutable", "traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("test", test); String[] testVectorAddElement = {null, null, "java.util.Vector", "org.tigris.gef.base.LayerPerspective", "traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("testVectorAddElement", testVectorAddElement);//trace.java��"addElement("�ɑΉ�����悤�ɒlj� String[] ArgoUMLBenchmark = {"", "", "", "", "traces/ArgoUMLBenchmark.trace"}; map.put("ArgoUMLBenchmark", ArgoUMLBenchmark);