diff --git a/src/org/ntlab/deltaExtractor/DeltaExtractor.java b/src/org/ntlab/deltaExtractor/DeltaExtractor.java index 47cb66d..ac631ce 100644 --- a/src/org/ntlab/deltaExtractor/DeltaExtractor.java +++ b/src/org/ntlab/deltaExtractor/DeltaExtractor.java @@ -858,6 +858,7 @@ private ExtractedStructure extractSub(TracePoint creationTracePoint, Reference targetRef, IAliasCollector aliasCollector) { eStructure = new ExtractedStructure(); + eStructure.setRelatedTracePoint(creationTracePoint.duplicate()); ArrayList objList = new ArrayList(); srcObject = targetRef.getSrcObject(); dstObject = targetRef.getDstObject(); @@ -915,11 +916,12 @@ * @return ���o���� */ public ExtractedStructure extract(TracePoint thisTracePoint, ObjectReference anotherObj, IAliasCollector aliasCollector) { + eStructure = new ExtractedStructure(); + eStructure.setRelatedTracePoint(thisTracePoint.duplicate()); MethodExecution methodExecution = thisTracePoint.getMethodExecution(); if (!thisTracePoint.isMethodEntry()) { thisTracePoint.stepNext(); } - eStructure = new ExtractedStructure(); ArrayList objList = new ArrayList(); String thisObjectId = methodExecution.getThisObjId(); objList.add(thisObjectId); diff --git a/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java b/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java index ff9da6a..940e0e5 100644 --- a/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java +++ b/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java @@ -605,6 +605,7 @@ if (objectId.equals(srcObject.getId())) { r = new Reference(arguments.get(0), srcObject); r.setCollection(true); + r.setCreation(true); // �߂�l�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addSrcSide(r); srcObject = arguments.get(0); aliasCollector.changeTrackingObject(objectId, arguments.get(0).getId(), true); @@ -612,6 +613,7 @@ } else if(objectId.equals(dstObject.getId())) { r = new Reference(arguments.get(0), dstObject); r.setCollection(true); + r.setCreation(true); // �߂�l�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addDstSide(r); dstObject =arguments.get(0); aliasCollector.changeTrackingObject(objectId, arguments.get(0).getId(), false); @@ -624,6 +626,8 @@ if (objectId.equals(srcObject.getId())) { r = new Reference(thisObj, srcObject); r.setCollection(true); + if (methodExecution.getSignature().contains(".iterator()") || + methodExecution.getSignature().contains(".listIterator()")) r.setCreation(true); // �C�e���[�^�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addSrcSide(r); srcObject = thisObj; aliasCollector.changeTrackingObject(objectId, thisObjectId, true); @@ -631,6 +635,8 @@ } else if(objectId.equals(dstObject.getId())) { r = new Reference(thisObj, dstObject); r.setCollection(true); + if (methodExecution.getSignature().contains(".iterator()") || + methodExecution.getSignature().contains(".listIterator()")) r.setCreation(true); // �C�e���[�^�I�u�W�F�N�g�𐶐������Ƃ݂Ȃ� eStructure.addDstSide(r); dstObject =thisObj; aliasCollector.changeTrackingObject(objectId, thisObjectId, false); diff --git a/src/org/ntlab/deltaExtractor/ExtractedStructure.java b/src/org/ntlab/deltaExtractor/ExtractedStructure.java index 6e47f75..54d74e1 100644 --- a/src/org/ntlab/deltaExtractor/ExtractedStructure.java +++ b/src/org/ntlab/deltaExtractor/ExtractedStructure.java @@ -2,6 +2,7 @@ import org.ntlab.trace.MethodExecution; import org.ntlab.trace.Reference; +import org.ntlab.trace.TracePoint; public class ExtractedStructure { @@ -10,6 +11,7 @@ private MethodExecution coordinator = null; private MethodExecution parent = null; private MethodExecution creationCallTree; + private TracePoint relatedTracePoint = null; public Delta getDelta() { return delta; @@ -64,5 +66,13 @@ public MethodExecution getCreationCallTree() { return creationCallTree; } + + public void setRelatedTracePoint(TracePoint relatedTracePoint) { + this.relatedTracePoint = relatedTracePoint; + } + + public TracePoint getRelatedTracePoint() { + return relatedTracePoint; + } } diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index f7afadb..4f52ab5 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -64,7 +64,7 @@ //BUG: methodExecution drawing order. -> parent //BUG: ObjectVertex position when Resize ObjectVertex. O public class DeltaViewer { - private static Dimension DEFAULT_SIZE = new Dimension(700, 700); + private static Dimension DEFAULT_SIZE = new Dimension(1300, 700); private static String WINDOW_TITLE = "Delta Viewer"; private ExtractedStructure eStructure; @@ -84,7 +84,7 @@ private int curFrame = 0; private static Dimension VERTEX_OBJECT_SIZE = new Dimension(70, 70); private static Dimension VERTEX_METHOD_EXECUTION_SIZE = new Dimension(55, 20); - private mxPoint coordinatorPoint = new mxPoint(DEFAULT_SIZE.getWidth() / 2 + 75, 100); + private mxPoint coordinatorPoint = new mxPoint(0, 100); private DeltaAnimation deltaAnimation; @@ -378,7 +378,7 @@ break; case CONSTRACTOR_INVOCATION: createObjectVertexOnConstractor(alias); - createMethodExecutionVertex(alias, ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCallerSideMethodName(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution()); + createMethodExecutionVertex(alias.getObjectId(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCallerSideMethodName(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution()); update(); removeMethodExecutionVertex(alias); update(); @@ -401,7 +401,13 @@ // Make VertexMethodExecution of called method execution. MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); if (!methodExecToVertexMap.containsKey(calledMethodExec)) { - createMethodExecutionVertex(alias, calledMethodExec.getSignature(), calledMethodExec); + if (curFrame == 0) { + MethodExecution methodExec = alias.getMethodExecution(); + if (methodExec.getSignature() != calledMethodExec.getSignature() && objectToVertexMap.containsKey(methodExec.getThisObjId())) { + createMethodExecutionVertex(methodExec.getThisObjId(), methodExec.getSignature(), methodExec); + } + } + createMethodExecutionVertex(alias.getObjectId(), calledMethodExec.getSignature(), calledMethodExec); update(); } break; @@ -422,8 +428,12 @@ outputLog(); curFrame = numFrame; Alias alias = deltaAliasCollector.getAliasList().get(numFrame - 1); + // Make ObjectEdge and reset position of vertexObject, remove vertexMethodExecution. - for(Statement statement: alias.getMethodExecution().getStatements()) { +// for(Statement statement: alias.getMethodExecution().getStatements()) + { + Statement statement = eStructure.getRelatedTracePoint().getStatement(); + MethodExecution methodExec = alias.getMethodExecution(); if(statement instanceof FieldUpdate) { // Format fieldName. FieldUpdate fieldUpdateStatement = (FieldUpdate) statement; @@ -436,53 +446,83 @@ // 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()); + if (methodExecToVertexMap.containsKey(methodExec)) { + if (methodExecToVertexMap.get(methodExec).getLocals().contains(targetObjectVertex)) { + methodExecToVertexMap.get(methodExec).getLocals().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeLocal: " + targetObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(methodExec).getArguments().contains(targetObjectVertex)) { + methodExecToVertexMap.get(methodExec).getArguments().remove(targetObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeArgument: " + targetObjectVertex.getLabel()); } } - removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); + removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), methodExec.getCallerMethodExecution(), methodExec); updateObjectVertices(); - ObjectVertex targetParentObjVertex = objectToVertexMap.get(calledMethodExec.getThisObjId()); - deltaAnimation.setVertexAnimation((mxCell)targetParentObjVertex.getCell(), new mxPoint(targetParentObjVertex.getInitialX(), targetParentObjVertex.getInitialY())); - deltaAnimation.startVertexAnimation(); } if(statement instanceof MethodInvocation) { - MethodInvocation methodInvocationStatement = (MethodInvocation) statement; - MethodExecution methodExec = methodInvocationStatement.getCalledMethodExecution(); + MethodInvocation methodInvStatement = (MethodInvocation) statement; + MethodExecution calledMethodExec = methodInvStatement.getCalledMethodExecution(); + String methodSignature = calledMethodExec.getSignature(); + String srcClassName = null; + String srcObjId = null; + String tgtObjId = null; //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(); +// if (methodExec.getSignature().contains("List.add(") || +// methodExec.getSignature().contains("Map.put(")) { + if (calledMethodExec.isCollectionType() + && (methodSignature.contains("add(") + || methodSignature.contains("set(") + || methodSignature.contains("put(") + || methodSignature.contains("push(") + || methodSignature.contains("addElement("))) { - createObjectRefrence(methodExec); + srcClassName = calledMethodExec.getThisClassName(); + srcObjId = calledMethodExec.getThisObjId(); + tgtObjId = calledMethodExec.getArguments().get(0).getId(); + ObjectVertex tgtObjectVertex = objectToVertexMap.get(tgtObjId); - // 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()); + createObjectRefrence(srcClassName, srcObjId, tgtObjId); + if (methodExecToVertexMap.containsKey(methodExec)) { + if (methodExecToVertexMap.get(methodExec).getLocals().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(methodExec).getLocals().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeLocal: " + tgtObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(methodExec).getArguments().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(methodExec).getArguments().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeArgument: " + tgtObjectVertex.getLabel()); } } - removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); + 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 + srcClassName = methodInvStatement.getThisClassName(); + srcObjId = methodInvStatement.getThisObjId(); + tgtObjId = calledMethodExec.getReturnValue().getId(); + ObjectVertex tgtObjectVertex = objectToVertexMap.get(tgtObjId); + + createObjectRefrence(srcClassName, srcObjId, tgtObjId); + if (methodExecToVertexMap.containsKey(methodExec)) { + if (methodExecToVertexMap.get(methodExec).getLocals().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(methodExec).getLocals().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeLocal: " + tgtObjectVertex.getLabel()); + } else if (methodExecToVertexMap.get(methodExec).getArguments().contains(tgtObjectVertex)) { + methodExecToVertexMap.get(methodExec).getArguments().remove(tgtObjectVertex); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeArgument: " + tgtObjectVertex.getLabel()); + } + } + removeCalledMethodExecutionVertex(objectToVertexMap.get(srcObjId), methodExec, calledMethodExec); updateObjectVertices(); } + } } @@ -586,26 +626,36 @@ } /** Create ObjectVertices. */ - private void createObjectVertices(ExtractedStructure eStructure) { - while(coordinatorPoint.getX() - (150 * (eStructure.getDelta().getDstSide().size())) < 0) { - coordinatorPoint.setX(coordinatorPoint.getX() + 150); - } + private void createObjectVertices(ExtractedStructure eStructure) { + Delta delta = eStructure.getDelta(); + double time = 150; + double padding = 200; + coordinatorPoint.setX(coordinatorPoint.getX() + (time * delta.getDstSide().size()) + padding); // ����(0, 0) double xCor = coordinatorPoint.getX(); double yCor = coordinatorPoint.getY(); - double time = 150; //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); try { // Draw vertex object. // srcSide - Delta delta = eStructure.getDelta(); int srcSideSize = delta.getSrcSide().size(); + MethodExecution coordinator = eStructure.getCoordinator(); + String coordinatorObjId = coordinator.getThisObjId(); + String coordinatorClassName = coordinator.getThisClassName(); for (int i = srcSideSize - 1; i >= 0; i--) { Reference ref = delta.getSrcSide().get(i); - System.out.println("srcSide: " + ref.getSrcClassName() + ", " + ref.isCreation()); + if (i == srcSideSize - 1 && !coordinatorObjId.equals(ref.getSrcObjectId()) && !coordinatorClassName.equals(ref.getSrcClassName())) { + System.out.println("coordinator: " + coordinatorClassName + ", " + coordinatorObjId); + coordinatorPoint.setX(coordinatorPoint.getX() + time * 2); + xCor += time * 2; + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, coordinatorObjId, coordinatorClassName, 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(coordinatorObjId, new ObjectVertex(coordinatorClassName, vertex, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)))); + srcSideSize++; + } + System.out.println("srcSide: " + ref.getSrcClassName() + ", " + ref.isCreation() + ", " + ref.getSrcObjectId()); if (!ref.isCreation() && !ref.getSrcObjectId().equals(ref.getDstObjectId())) { if (!objectToVertexMap.containsKey(ref.getSrcObjectId())) { String srcClassName = ref.getSrcClassName(); @@ -625,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)))); } } @@ -634,6 +690,15 @@ int cnt = 0; for (int i = dstSideSize - 1; i >= 0; i--) { Reference ref = delta.getDstSide().get(i); + if (i == dstSideSize - 1 && srcSideSize == 0 && !coordinatorObjId.equals(ref.getSrcObjectId()) && !coordinatorClassName.equals(ref.getSrcClassName())) { + System.out.println("coordinator: " + coordinatorClassName + ", " + coordinatorObjId); + coordinatorPoint.setX(coordinatorPoint.getX() + time * 2); + xCor += time * 2; + System.out.println(coordinatorPoint.getX() + ", " + xCor); + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, coordinatorObjId, coordinatorClassName, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. + objectToVertexMap.put(coordinatorObjId, new ObjectVertex(coordinatorClassName, vertex, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)))); + dstSideSize++; + } System.out.println("dstSide: " + ref.getSrcClassName() + ", " + ref.getDstClassName() + ", " + ref.isCreation()); if (!ref.isCreation() && !ref.getSrcObjectId().equals(ref.getDstObjectId())) { if (!objectToVertexMap.containsKey(ref.getSrcObjectId())) { @@ -668,14 +733,18 @@ */ private void createObjectVertexOnConstractor(Alias alias) { ObjectVertex vertexObj = objectToVertexMap.get(alias.getObjectId()); - String souceObjId = alias.getMethodExecution().getThisObjId(); - mxICell sourceCell = (mxICell)objectToVertexMap.get(souceObjId).getCell(); + String sourceObjId = alias.getMethodExecution().getThisObjId(); + mxICell sourceCell = (mxICell)objectToVertexMap.get(sourceObjId).getCell(); double sourceWidth = sourceCell.getGeometry().getWidth(); double sourceHeight = sourceCell.getGeometry().getHeight(); double overlapWidth = sourceWidth * Math.sqrt(2) * 0.1; double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); - MethodInvocation methodInvocation = (MethodInvocation)alias.getOccurrencePoint().getStatement(); - String fieldName = methodInvocation.getCallerSideMethodName(); + MethodInvocation methodInvocation; + String fieldName = null; + if (!alias.getMethodExecution().isCollectionType() && alias.getOccurrencePoint().getStatement() != null) { + methodInvocation = (MethodInvocation)alias.getOccurrencePoint().getStatement(); + fieldName = methodInvocation.getCallerSideMethodName(); + } List aliasPairListByAlias = deltaAliasCollector.getAliasPairListByAlias(alias); AliasPair aliasPair = null; if (aliasPairListByAlias.size() >= 1) { @@ -702,6 +771,51 @@ } } + /** + * Create ObjectVertex when CONSTRACTOR_INVOCATION is preceded by FORMAL_PARAMETER. + * @param alias + */ + private void createObjectVertexOnConstractorByFormalParameter(Alias alias) { + ObjectVertex objectVertex = objectToVertexMap.get(alias.getObjectId()); // Create cell of this object vertex. + MethodExecution methodExec = alias.getMethodExecution(); + String srcObjId = methodExec.getArguments().get(0).getId(); + 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); + Point absPtSrcCell = getAbsolutePointforCell(srcCell); + MethodInvocation methodInv; + String fieldName = null; + List aliasPairListByAlias = deltaAliasCollector.getAliasPairListByAlias(alias); + AliasPair aliasPair = null; + if (!methodExec.isCollectionType() && alias.getOccurrencePoint().getStatement() != null) { + methodInv = (MethodInvocation)alias.getOccurrencePoint().getStatement(); + fieldName = methodInv.getCallerSideMethodName(); + } + if (aliasPairListByAlias.size() >= 1) { + aliasPair = aliasPairListByAlias.get(0); + } + boolean isSrcSideChanged = aliasPair.getIsSrcSideChanged(); + mxgraph.getModel().beginUpdate(); + try { + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, objectVertex.getLabel(), objectVertex.getLabel(), absPtSrcCell.getX() + overlapWidth, absPtSrcCell.getY() + overlapHeight, VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. + objectVertex.setCell(vertex); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldName, null, srcCell, vertex); + if(isSrcSideChanged) { + ((mxCell)edge).setStyle("exitX=1;exitY=1;exitPerimeter=1;entryX=0;entryY=0;entryPerimeter=1;"); + } else { + ((mxCell)edge).setStyle("exitX=0;exitY=1;exitPerimeter=1;entryX=1;entryY=0;entryPerimeter=1;"); + } + edgeMap.put(methodExec.getThisClassName() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); + setCellsStyle(); + deltaAnimation.setVertexAnimation((mxICell)vertex, new mxPoint(objectVertex.getInitialX(), objectVertex.getInitialY())); + deltaAnimation.startVertexAnimation(); + } finally { + mxgraph.getModel().endUpdate(); + } + } + private void createObjectRefrence(FieldUpdate fieldUpdateStatement, String fieldName) { String sourceObjectId = fieldUpdateStatement.getContainerObjId(); String targetObjectId = fieldUpdateStatement.getValueObjId(); @@ -723,11 +837,14 @@ targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); } - private void createObjectRefrence(MethodExecution methodExec) { - String sourceObjectId = methodExec.getThisObjId(); - String srcClassName = methodExec.getThisClassName(); - String targetObjectId = methodExec.getArguments().get(0).getId(); - mxICell targetCell = (mxICell)objectToVertexMap.get(targetObjectId).getCell(); + private void createObjectRefrence(String srcClassName, String srcObjId, String tgtObjId) { + mxICell targetCell; +// if (objectToVertexMap.containsKey(targetObjId)) { + targetCell = (mxICell)objectToVertexMap.get(tgtObjId).getCell(); +// } else { +// targetObjId = methodExec.getCallerMethodExecution().getArguments().get(0).getId(); +// targetCell = (mxICell)objectToVertexMap.get(targetObjId).getCell(); +// } Point absolutePointTargetCell = getAbsolutePointforCell(targetCell); // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. @@ -737,19 +854,19 @@ 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()); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, tgtObjId, null, objectToVertexMap.get(srcObjId).getCell(), objectToVertexMap.get(tgtObjId).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)); + edgeMap.put(tgtObjId, 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.setVertexAnimation(targetCell, new mxPoint(objectToVertexMap.get(tgtObjId).getInitialX(), objectToVertexMap.get(tgtObjId).getInitialY())); deltaAnimation.startVertexAnimation(); - targetCell.getGeometry().setX(objectToVertexMap.get(targetObjectId).getInitialX()); - targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); + targetCell.getGeometry().setX(objectToVertexMap.get(tgtObjId).getInitialX()); + targetCell.getGeometry().setY(objectToVertexMap.get(tgtObjId).getInitialY()); } finally { mxgraph.getModel().endUpdate(); } - System.out.println("rTHIS " + srcClassName + ", " + targetObjectId); + System.out.println("rTHIS " + srcClassName + ", " + tgtObjId); } /** @@ -761,7 +878,7 @@ // sourceVertex ObjectVertex sourceObjectVertex = objectToVertexMap.get(alias.getObjectId()); if (alias.getMethodExecution().isStatic() && !methodExecToVertexMap.containsKey(alias.getMethodExecution())) { - createMethodExecutionVertex(alias, alias.getMethodExecution().getSignature(), alias.getMethodExecution()); + createMethodExecutionVertex(alias.getObjectId(), alias.getMethodExecution().getSignature(), alias.getMethodExecution()); } // targetVertex MethodExecutionVertex targetMethodExecVertex = methodExecToVertexMap.get(alias.getMethodExecution()); @@ -781,6 +898,13 @@ private void moveObjectVertex(Alias alias, ObjectVertex sourceVertexObject, MethodExecutionVertex targetVertexMethodExec) { MethodExecution methodExec = alias.getMethodExecution(); if (alias.getAliasType().equals(AliasType.RETURN_VALUE) || alias.getAliasType().equals(AliasType.METHOD_INVOCATION)) { + if (sourceVertexObject.getCell() == null && methodExec.isCollectionType()) { + if (methodExec.getArguments().isEmpty()) { + createObjectVertexOnConstractor(alias); + } else { + createObjectVertexOnConstractorByFormalParameter(alias); + } + } moveLocalObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); } else if (alias.getAliasType().equals(AliasType.FORMAL_PARAMETER)) { moveArgumentObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); @@ -932,7 +1056,7 @@ } else { // �d�l��̃o�O, ���[�v������ outputLog(); // try { - // ObjectVertex(sourceCell)�̃N���[������ + // ObjectVertex(sourceCell)�̃N���[������ // mxICell cloneSourceCell = (mxICell) mxgraph.addCell(sourceCell.clone()); // // cloneSourceCell.setStyle("fillColor=#ffffff;opacity=50;shape=ellipse"); @@ -944,36 +1068,36 @@ // cloneSourceCell.getGeometry().setX(0); // cloneSourceCell.getGeometry().setY(0); - // ����ObjectVertex - Point absPtSourceCell = getAbsolutePointforCell(sourceCell); - Point absPtTargetParentCell = getAbsolutePointforCell(targetCell.getParent()); + // ����ObjectVertex + Point absPtSourceCell = getAbsolutePointforCell(sourceCell); + Point absPtTargetParentCell = getAbsolutePointforCell(targetCell.getParent()); - sourceCell.remove(targetCell.getParent()); - targetCell.getParent().setParent(mxDefaultParent); - sourceCell.setParent(targetCell.getParent()); - targetCell.getParent().insert(sourceCell); + sourceCell.remove(targetCell.getParent()); + targetCell.getParent().setParent(mxDefaultParent); + sourceCell.setParent(targetCell.getParent()); + targetCell.getParent().insert(sourceCell); - targetCell.getParent().getGeometry().setX(absPtTargetParentCell.getX()); - targetCell.getParent().getGeometry().setY(absPtTargetParentCell.getY()); - sourceCell.getGeometry().setX(absPtSourceCell.getX() - absPtTargetParentCell.getX()); - sourceCell.getGeometry().setY(absPtSourceCell.getY() - absPtTargetParentCell.getY()); - sourceCell.setStyle("opacity=50;shape=ellipse"); + targetCell.getParent().getGeometry().setX(absPtTargetParentCell.getX()); + targetCell.getParent().getGeometry().setY(absPtTargetParentCell.getY()); + sourceCell.getGeometry().setX(absPtSourceCell.getX() - absPtTargetParentCell.getX()); + sourceCell.getGeometry().setY(absPtSourceCell.getY() - absPtTargetParentCell.getY()); + sourceCell.setStyle("opacity=50;shape=ellipse"); - double sourceWidth = sourceCell.getGeometry().getWidth(); - double sourceHeight = sourceCell.getGeometry().getHeight(); + double sourceWidth = sourceCell.getGeometry().getWidth(); + double sourceHeight = sourceCell.getGeometry().getHeight(); // double overlapWidth = targetCell.getGeometry().getWidth() / 2; - double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); - double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); + double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); + double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); // deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() + overlapWidth, targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); - deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth + (sourceWidth * time), targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); - deltaAnimation.startVertexAnimation(); - outputLog(); + deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth + (sourceWidth * time), targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); + deltaAnimation.startVertexAnimation(); + outputLog(); // sourceCell.getGeometry().setX(targetCell.getGeometry().getX() + overlapWidth); - sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth + (sourceWidth * time)); - sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); + sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth + (sourceWidth * time)); + sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); - targetVertexMethodExec.getArguments().add(sourceVertexObject); + targetVertexMethodExec.getArguments().add(sourceVertexObject); // } catch (CloneNotSupportedException e) { // e.printStackTrace(); @@ -1171,21 +1295,29 @@ * @param alias */ private void createMethodExecutionVertex(Alias alias) { + String objId = alias.getObjectId(); + MethodExecution methodExec = alias.getMethodExecution(); + String methodExecSignature = methodExec.getSignature(); + if (curFrame == 0) { - createMethodExecutionVertex(alias, alias.getMethodExecution().getSignature(), alias.getMethodExecution()); + MethodExecution callerMethodExec = methodExec.getCallerMethodExecution(); + if (methodExecSignature != callerMethodExec.getSignature() && objectToVertexMap.containsKey(callerMethodExec.getThisObjId())) { + createMethodExecutionVertex(callerMethodExec.getThisObjId(), callerMethodExec.getSignature(), callerMethodExec); + } + createMethodExecutionVertex(objId, methodExecSignature, methodExec); } else if (alias.getObjectId().matches("0")) { - createMethodExecutionVertex(alias, alias.getMethodExecution().getSignature(), alias.getMethodExecution()); + createMethodExecutionVertex(objId, methodExecSignature, methodExec); } } /** * Parent : Create MethodExecutionVertex. * - * @param alias + * @param objId * @param methodSignature Called or this MethodSignature. * @param methodExec Called or this MethodExecution. */ - private void createMethodExecutionVertex(Alias alias, String methodSignature, MethodExecution methodExec) { + private void createMethodExecutionVertex(String objId, String methodSignature, MethodExecution methodExec) { if (methodSignature.contains(" ")) { System.out.println(methodSignature); @@ -1195,26 +1327,28 @@ // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); try { - String objectId = alias.getObjectId(); - if (methodExec.isStatic() && !objectId.equals("0")) { - objectId = alias.getMethodExecution().getCallerMethodExecution().getThisObjId(); + if (methodExec.isStatic() && !objId.equals("0")) { + objId = methodExec.getCallerMethodExecution().getThisObjId(); } - Object object = objectToVertexMap.get(objectId).getCell(); + + Object object = objectToVertexMap.get(objId).getCell(); + +// if (object != null) { double xCor = VERTEX_OBJECT_SIZE.getWidth() * 0.1; double yCor = VERTEX_OBJECT_SIZE.getHeight() * 0.5; double standardX = xCor; double standardY = 0; - int time = objectToVertexMap.get(objectId).getVertexMethodExecutions().size(); + int time = objectToVertexMap.get(objId).getVertexMethodExecutions().size(); System.out.println(time); if (time >= 1) { - mxICell standardCell = (mxICell) objectToVertexMap.get(objectId).getVertexMethodExecutions().get(0).getCell(); + mxICell standardCell = (mxICell) objectToVertexMap.get(objId).getVertexMethodExecutions().get(0).getCell(); standardX = standardCell.getGeometry().getX(); standardY = standardCell.getGeometry().getY(); time-=1; } Object vertex = mxgraph.insertDeltaVertex(object, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. - System.out.println("makeVertexMethodExecution: " + ((mxICell)vertex).getId() + " in " + objectId + " (" + standardX + ", " + yCor * (time + 1) + standardY + ")"); + System.out.println("makeVertexMethodExecution: " + ((mxICell)vertex).getId() + " in " + objId + " (" + standardX + ", " + yCor * (time + 1) + standardY + ")"); MethodExecutionVertex vertexMethodExecution = new MethodExecutionVertex(methodSignature, vertex, standardX , yCor * (time + 1) + standardY, VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); // Object vertex = mxgraph.insertVertex(object, methodSignature, methodSignature, 0, 0, 0, 0, "fillColor=white", true); //creates a white vertex. @@ -1225,7 +1359,8 @@ ((mxICell)vertex).setVisible(false); createEdgeToMethodExecution(); } - objectToVertexMap.get(objectId).addMethodExecution(vertexMethodExecution); + objectToVertexMap.get(objId).addMethodExecution(vertexMethodExecution); +// } } finally { mxgraph.getModel().endUpdate(); } @@ -1324,102 +1459,111 @@ // 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(); - - 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(); + 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(); + try { + // 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); + System.out.println(cell); + System.out.println(vo.getInitialX() + ", " + vo.getInitialY()); + System.out.println(cell.getGeometry().getX() + ", " + cell.getGeometry().getY()); + System.out.println(absolutePointCell); + if (cell.getParent() != mxDefaultParent) { + cell.getParent().remove(cell); + cell.setParent(mxDefaultParent); + } + if (!absolutePointCell.equals(vo.getInitialPoint())) { + 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); + System.out.println(cell); + System.out.println(vo.getInitialX() + ", " + vo.getInitialY()); + System.out.println(cell.getGeometry().getX() + ", " + cell.getGeometry().getY()); + System.out.println(absolutePointCell); + if (cell.getParent() != mxDefaultParent) { + cell.getParent().remove(cell); + cell.setParent(mxDefaultParent); + } + if (!absolutePointCell.equals(vo.getInitialPoint())) { + 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); + } + } + } + + if (sourceVertexCell == null || targetVertexCell == null) return; + + mxgraph.removeCells(mxgraph.getEdgesBetween(sourceVertexCell, targetVertexCell)); try { - // 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); - System.out.println(cell); - System.out.println(vo.getInitialX() + ", " + vo.getInitialY()); - System.out.println(cell.getGeometry().getX() + ", " + cell.getGeometry().getY()); - System.out.println(absolutePointCell); - if (cell.getParent() != mxDefaultParent) { - cell.getParent().remove(cell); - cell.setParent(mxDefaultParent); - } - if (!absolutePointCell.equals(vo.getInitialPoint())) { - 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); - System.out.println(cell); - System.out.println(vo.getInitialX() + ", " + vo.getInitialY()); - System.out.println(cell.getGeometry().getX() + ", " + cell.getGeometry().getY()); - System.out.println(absolutePointCell); - if (cell.getParent() != mxDefaultParent) { - cell.getParent().remove(cell); - cell.setParent(mxDefaultParent); - } - if (!absolutePointCell.equals(vo.getInitialPoint())) { - 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 { - mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); - Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); - Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); - cloneTargetVertexCell.getGeometry().setX(absolutPointTargetVertexCell.getX()); - cloneTargetVertexCell.getGeometry().setY(absolutPointTargetVertexCell.getY()); - cloneTargetVertexCell.setStyle("fillColor=none;strokeColor=none;fontColor=#008000;"); - cloneTargetVertexCell.setValue(null); - Object tempEdge = mxgraph.insertEdge(mxDefaultParent, null, null, sourceVertexCell, cloneTargetVertexCell); - ((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(); + mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); + Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); + Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); + cloneTargetVertexCell.getGeometry().setX(absolutPointTargetVertexCell.getX()); + cloneTargetVertexCell.getGeometry().setY(absolutPointTargetVertexCell.getY()); + cloneTargetVertexCell.setStyle("fillColor=none;strokeColor=none;fontColor=#008000;"); + cloneTargetVertexCell.setValue(null); + Object tempEdge = mxgraph.insertEdge(mxDefaultParent, null, null, sourceVertexCell, cloneTargetVertexCell); + ((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(); - mxgraph.removeCells(new Object[]{cloneTargetVertexCell}); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } finally { - mxgraph.getModel().endUpdate(); + mxgraph.removeCells(new Object[]{cloneTargetVertexCell}); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); } - ((mxCell)targetVertexCell.getParent()).remove(targetVertexCell); - targetVertexCell.setParent(mxDefaultParent); - mxgraph.removeCells(new Object[] {targetVertexCell}); + } finally { + mxgraph.getModel().endUpdate(); + } + ((mxCell)targetVertexCell.getParent()).remove(targetVertexCell); + targetVertexCell.setParent(mxDefaultParent); + mxgraph.removeCells(new Object[] {targetVertexCell}); + if (!calledMethodExec.isStatic()) { objectToVertexMap.get(calledMethodExec.getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExec)); - methodExecToVertexMap.get(calledMethodExec).getLocals().remove(sourceVertexObject); - methodExecToVertexMap.remove(calledMethodExec); - edgeMap.remove(methodExec.getSignature()); + } else { + objectToVertexMap.get(calledMethodExec.getCallerMethodExecution().getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExec)); + } + methodExecToVertexMap.get(calledMethodExec).getLocals().remove(sourceVertexObject); + methodExecToVertexMap.remove(calledMethodExec); + edgeMap.remove(methodExec.getSignature()); // moveInitialVertexObject(methodExec); // updateObjectVerticesSize(); - } else { - ((mxCell)targetVertexCell.getParent()).remove(targetVertexCell); - targetVertexCell.setParent(mxDefaultParent); - mxgraph.removeCells(new Object[] {targetVertexCell}); - objectToVertexMap.get(calledMethodExec.getCallerMethodExecution().getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExec)); - methodExecToVertexMap.get(calledMethodExec).getLocals().remove(sourceVertexObject); - methodExecToVertexMap.remove(calledMethodExec); - } +// } else { +// ((mxCell)targetVertexCell.getParent()).remove(targetVertexCell); +// targetVertexCell.setParent(mxDefaultParent); +// mxgraph.removeCells(new Object[] {targetVertexCell}); +// methodExecToVertexMap.get(calledMethodExec).getLocals().remove(sourceVertexObject); +// methodExecToVertexMap.remove(calledMethodExec); +// } } outputLog(); } @@ -1502,15 +1646,20 @@ String dstObjId = aliasPair.getAliasPair().getValue().getObjectId(); boolean isSrcSideChanged = aliasPair.getIsSrcSideChanged(); // String dstClassName = curAlias.getMethodExecution().getThisClassName(); - System.out.println("makeEdgeObject: " + fieldName + ", " + srcClassName + " (" + objectToVertexMap.get(srcObjId).getCell().hashCode() + "), " + " (" + objectToVertexMap.get(dstObjId).getCell().hashCode() + ")"/* + ", " + dstClassName*/); - // BUG:NullPointerException - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldName, fieldName, objectToVertexMap.get(srcObjId).getCell(), objectToVertexMap.get(dstObjId).getCell()); - if(isSrcSideChanged) { - ((mxCell)edge).setStyle("exitX=1;exitY=1;exitPerimeter=1;entryX=0;entryY=0;entryPerimeter=1;"); - } else { - ((mxCell)edge).setStyle("exitX=0;exitY=1;exitPerimeter=1;entryX=1;entryY=0;entryPerimeter=1;"); + System.out.println(aliasPair.getAliasPair().getKey().getMethodExecution().isConstructor()); + Object srcCell = objectToVertexMap.get(srcObjId).getCell(); + Object dstCell = objectToVertexMap.get(dstObjId).getCell(); + if (srcCell != null && dstCell != null) { // isCreation() + System.out.println("makeEdgeObject: " + fieldName + ", " + srcClassName + " (" + srcCell.hashCode() + "), " + " (" + dstCell.hashCode() + ")"/* + ", " + dstClassName*/); + // BUG:NullPointerException + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldName, fieldName, srcCell, dstCell); + if(isSrcSideChanged) { + ((mxCell)edge).setStyle("exitX=1;exitY=1;exitPerimeter=1;entryX=0;entryY=0;entryPerimeter=1;"); + } else { + ((mxCell)edge).setStyle("exitX=0;exitY=1;exitPerimeter=1;entryX=1;entryY=0;entryPerimeter=1;"); + } + edgeMap.put(srcClassName + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); } - edgeMap.put(srcClassName + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); } finally { mxgraph.getModel().endUpdate(); } @@ -1530,40 +1679,39 @@ if (!edgeMap.containsKey(methodSignature)) { mxICell sourceVertexCell = (mxICell)methodExecToVertexMap.get(sourceMethodExec).getCell(); mxICell targetVertexCell = (mxICell)methodExecToVertexMap.get(targetMethodExec).getCell(); - if (!targetMethodExec.isStatic()) { - Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); - Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology - mxgraph.getModel().beginUpdate(); +// if (!targetMethodExec.isStatic()) { + Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); + Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology + mxgraph.getModel().beginUpdate(); + try { try { - - try { - mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); - cloneTargetVertexCell.getGeometry().setX(absolutPointSourceVertexCell.getX()); - cloneTargetVertexCell.getGeometry().setY(absolutPointSourceVertexCell.getY() + targetVertexCell.getGeometry().getHeight()); - cloneTargetVertexCell.setStyle("fillColor=none;strokeColor=none;fontColor=#008000;"); - cloneTargetVertexCell.setValue(null); - cloneTargetVertexCell.setVisible(true); - Object tempEdge = mxgraph.insertEdge(mxDefaultParent, null, null, sourceVertexCell, cloneTargetVertexCell); - ((mxCell)tempEdge).setStyle("dashed=1;strokeColor=#008000;exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;endArrow=none"); - deltaAnimation.setExpandEdgeAnimation(cloneTargetVertexCell, new mxPoint(absolutPointTargetVertexCell.getX(), absolutPointTargetVertexCell.getY())); - deltaAnimation.startExpandEdgeAnimation(); - targetVertexCell.setVisible(true); + mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); + cloneTargetVertexCell.getGeometry().setX(absolutPointSourceVertexCell.getX()); + cloneTargetVertexCell.getGeometry().setY(absolutPointSourceVertexCell.getY() + targetVertexCell.getGeometry().getHeight()); + cloneTargetVertexCell.setStyle("fillColor=none;strokeColor=none;fontColor=#008000;"); + cloneTargetVertexCell.setValue(null); + cloneTargetVertexCell.setVisible(true); + Object tempEdge = mxgraph.insertEdge(mxDefaultParent, null, null, sourceVertexCell, cloneTargetVertexCell); + ((mxCell)tempEdge).setStyle("dashed=1;strokeColor=#008000;exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;endArrow=none"); + deltaAnimation.setExpandEdgeAnimation(cloneTargetVertexCell, new mxPoint(absolutPointTargetVertexCell.getX(), absolutPointTargetVertexCell.getY())); + deltaAnimation.startExpandEdgeAnimation(); + targetVertexCell.setVisible(true); // deltaAnimation.setExpandEdgeAnimation(new mxPoint(absolutPointSourceVertexCell.getX() + (sourceVertexCell.getGeometry().getWidth() / 2), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(absolutPointTargetVertexCell.getX() + (targetVertexCell.getGeometry().getWidth() / 2), absolutPointTargetVertexCell.getY())); // deltaAnimation.startExpandEdgeAnimation(); - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, methodSignature, null, sourceVertexCell, targetVertexCell); - ((mxCell)edge).setStyle("exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;"); - mxgraph.removeCells(new Object[]{cloneTargetVertexCell}); - edgeMap.put(methodSignature, new Edge(methodSignature, TypeName.Call, edge)); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } finally { - mxgraph.getModel().endUpdate(); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, methodSignature, null, sourceVertexCell, targetVertexCell); + ((mxCell)edge).setStyle("exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;"); + mxgraph.removeCells(new Object[]{cloneTargetVertexCell}); + edgeMap.put(methodSignature, new Edge(methodSignature, TypeName.Call, edge)); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); } - } else { - targetVertexCell.setVisible(true); + } finally { + mxgraph.getModel().endUpdate(); } +// } else { +// targetVertexCell.setVisible(true); +// } } } @@ -1652,7 +1800,9 @@ System.out.println("\nEdge"); for (Edge e: edgeMap.values()) { System.out.println(e.getLabel()); - System.out.println(" " + ((mxICell)e.getCell()).getParent().getId()); + if (((mxICell)e.getCell()).getParent() != null) { + System.out.println(" " + ((mxICell)e.getCell()).getParent().getId()); + } } } diff --git a/src/org/ntlab/deltaViewer/DeltaViewerSample.java b/src/org/ntlab/deltaViewer/DeltaViewerSample.java index d4a203d..6ed41c2 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewerSample.java +++ b/src/org/ntlab/deltaViewer/DeltaViewerSample.java @@ -121,23 +121,20 @@ setArgmentsForDeltaExtract(argsMap); //���o�������f���^�̈������i�[����Map��key // String argsKey = "ArgoUMLSelect"; -// String argsKey = "ArgoUMLDelete2"; -// String argsKey = "JHotDrawTransform"; -// String argsKey = "JHotDrawSelect3"; + String argsKey = "ArgoUMLDelete1"; +// String argsKey = "JHotDrawTransform"; +// String argsKey = "JHotDrawSelect3"; // String argsKey = "sampleArray"; // String argsKey = "sampleCollection"; // String argsKey = "sampleCreate"; // String argsKey = "sampleStatic"; // String argsKey = "delta_eg1"; - String argsKey = "pre_Exp3"; +// String argsKey = "pre_Exp1"; // String argsKey = "worstCase"; // String argsKey = "sample1"; long time = System.nanoTime(); TraceJSON trace = new TraceJSON(argsMap.get(argsKey)[4]); DeltaExtractorJSON s = new DeltaExtractorJSON(trace); - System.out.println(CONTAINER_COMPONENT); - System.out.println(argsMap.get(argsKey)[5]); - System.out.println(CONTAINER_COMPONENT == argsMap.get(argsKey)[5]); if (argsMap.get(argsKey)[5] == CONTAINER_COMPONENT || argsMap.get(argsKey)[5] == CONTAINER_COMPONENT_COLLECTION) { HashMap threads = trace.getAllThreads(); @@ -203,19 +200,19 @@ private static void setArgmentsForDeltaExtract(Map map){ // one delta extract - String[] traceSample1 = {null, null, "","", "traces/traceSample1.txt"}; map.put("traceSample1", traceSample1); - String[] traceSample2 = {null, null, "","", "traces/traceSample2.txt"}; map.put("traceSample2", traceSample2); - String[] presenSample = {null, null, "","", "traces/presenSample.txt"}; map.put("presenSample", presenSample); - String[] worstCase = {null, null, "worstCase.P", "worstCase.M", "traces/_worstCase.txt"}; map.put("worstCase", worstCase); - String[] sample1 = {null, null, "sample1.D", "sample1.C", "traces\\sample1.trace"}; map.put("sample1", sample1); - String[] sampleArray = {null, null, "sampleArray.D", "sampleArray.C", "traces\\sampleArray.trace"}; map.put("sampleArray", sampleArray); - String[] sampleCollection = {null, null, "sampleCollection.D", "sampleCollection.C", "traces\\sampleCollection.trace"}; map.put("sampleCollection", sampleCollection); - String[] sampleCreate = {null, null, "sampleCreate.D", "sampleCreate.C", "traces\\sampleCreate.trace"}; map.put("sampleCreate", sampleCreate); - String[] sampleStatic = {null, null, "sampleStatic.D", "sampleStatic.C", "traces\\sampleStatic.trace"}; map.put("sampleStatic", sampleStatic); - String[] delta_eg1 = {null, null, "E","C", "traces/testTrace.txt"}; map.put("delta_eg1", delta_eg1); - String[] delta_eg5 = {null, null, "E","C", "traces/testTrace5.txt"}; map.put("delta_eg5", delta_eg5); - String[] testTrace2 = {null, null, "","", "traces/testTrace2.txt"}; map.put("testTrace2", testTrace2); - String[] testTrace3 = {null, null, "","", "traces/testTrace3.txt"}; map.put("testTrace3", testTrace3); + String[] traceSample1 = {null, null, "","", "traces/traceSample1.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("traceSample1", traceSample1); + String[] traceSample2 = {null, null, "","", "traces/traceSample2.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("traceSample2", traceSample2); + String[] presenSample = {null, null, "","", "traces/presenSample.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("presenSample", presenSample); + String[] worstCase = {null, null, "worstCase.P", "worstCase.M", "traces/_worstCase.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("worstCase", worstCase); + String[] sample1 = {null, null, "sample1.D", "sample1.C", "traces\\sample1.trace", CONTAINER_COMPONENT_COLLECTION}; map.put("sample1", sample1); + String[] sampleArray = {null, null, "sampleArray.D", "sampleArray.C", "traces\\sampleArray.trace", CONTAINER_COMPONENT_COLLECTION}; map.put("sampleArray", sampleArray); + String[] sampleCollection = {null, null, "sampleCollection.D", "sampleCollection.C", "traces\\sampleCollection.trace", CONTAINER_COMPONENT_COLLECTION}; map.put("sampleCollection", sampleCollection); + String[] sampleCreate = {null, null, "sampleCreate.D", "sampleCreate.C", "traces\\sampleCreate.trace", CONTAINER_COMPONENT_COLLECTION}; map.put("sampleCreate", sampleCreate); + String[] sampleStatic = {null, null, "sampleStatic.D", "sampleStatic.C", "traces\\sampleStatic.trace", CONTAINER_COMPONENT_COLLECTION}; map.put("sampleStatic", sampleStatic); + String[] delta_eg1 = {null, null, "E","C", "traces/testTrace.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("delta_eg1", delta_eg1); + String[] delta_eg5 = {null, null, "E","C", "traces/testTrace5.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("delta_eg5", delta_eg5); + String[] testTrace2 = {null, null, "","", "traces/testTrace2.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("testTrace2", testTrace2); + String[] testTrace3 = {null, null, "","", "traces/testTrace3.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("testTrace3", testTrace3); // �\�������̂Ƃ��ɗp����Toy program String[] pre_Exp1 = {null, null, "E","C", "traces/pre_Exp1.txt", CONTAINER_COMPONENT_COLLECTION}; map.put("pre_Exp1", pre_Exp1);