diff --git a/src/org/ntlab/deltaViewer/CollaborationLayout.java b/src/org/ntlab/deltaViewer/CollaborationLayout.java index 45ea389..0f5ce73 100644 --- a/src/org/ntlab/deltaViewer/CollaborationLayout.java +++ b/src/org/ntlab/deltaViewer/CollaborationLayout.java @@ -27,7 +27,7 @@ import com.mxgraph.util.mxPoint; public class CollaborationLayout implements IObjectLayout { - private static final int angleStep = 15; + private static final int angleStep = 30; private mxPoint coordinatorPoint = new mxPoint(0, 100); private double step; private double padding; @@ -114,7 +114,12 @@ String dstObjId = methodExec.getReturnValue().getId(); String srcClassName = methodExec.getThisClassName(); String dstClassName = methodExec.getReturnValue().getActualType(); - idx = references.indexOf(new Reference(srcObjId, dstObjId, srcClassName, dstClassName)); + Reference r = new Reference(srcObjId, dstObjId, srcClassName, dstClassName); + idx = references.indexOf(r); + if (idx < 0) { + references.add(r); + idx = references.indexOf(r); + } } } else if (a.getAliasType() == AliasType.CONSTRACTOR_INVOCATION) { MethodInvocation c = (MethodInvocation) a.getOccurrencePoint().getStatement(); diff --git a/src/org/ntlab/deltaViewer/CollaborationViewer.java b/src/org/ntlab/deltaViewer/CollaborationViewer.java index 1a7ce0f..2cfe039 100644 --- a/src/org/ntlab/deltaViewer/CollaborationViewer.java +++ b/src/org/ntlab/deltaViewer/CollaborationViewer.java @@ -414,8 +414,8 @@ } for (Alias alias: aliasCollector.getAliasList()) { if (alias.getAliasType() == Alias.AliasType.THIS) { - if (!objectToVertexMap.containsKey(alias.getObjectId())) { - // When both of the calling and called method are static. + if (!objectToVertexMap.containsKey(alias.getObjectId()) && alias.getMethodExecution().isStatic()) { + // When both of the calling and called methods are static. String thisObjId = alias.getObjectId(); String thisClassName = alias.getMethodExecution().getThisClassName(); mxICell vertex = (mxICell) mxgraph.insertDeltaVertex(getMxDefaultParent(), thisObjId, thisClassName, 0, 0, objecVertexWidth, ObjectVertexHeight, "fillColor=white"); //creates a white vertex. @@ -428,7 +428,7 @@ thisObjId += ":" + thisClassName; } if (!objectToVertexMap.containsKey(thisObjId)) { - // When the called method are static. + // When the called method is static. mxICell vertex = (mxICell) mxgraph.insertDeltaVertex(getMxDefaultParent(), thisObjId, thisClassName, 0, 0, objecVertexWidth, ObjectVertexHeight, "fillColor=white"); //creates a white vertex. objectToVertexMap.put(thisObjId, new ObjectVertex(thisClassName, vertex, 0, 0)); } @@ -507,9 +507,9 @@ fieldName = nextAliasObjId; } } - if(statement != null && statement instanceof FieldAccess - && curAliasObjId.equals(((FieldAccess)statement).getContainerObjId())) { // Contains alias type of nextAlias is FIELD. + if (statement != null && statement instanceof FieldAccess) { FieldAccess fieldAccess = (FieldAccess)statement; + String containerId = fieldAccess.getContainerObjId(); if (fieldAccess.getFieldName() != null) { String fieldNames[] = formatFieldName(fieldAccess.getFieldName()); srcClassName = fieldNames[0]; @@ -518,6 +518,13 @@ srcClassName = fieldAccess.getContainerClassName(); fieldName = nextAliasObjId; } + if (containerId.matches("0")) { + containerId = "0:" + srcClassName; + } + if (!curAliasObjId.equals(containerId)) { // Contains alias type of nextAlias is FIELD. + srcClassName = null; + fieldName = null; + } } } System.out.println(TAG + ": srcClassName=" + srcClassName + "(curObjectId=" + curAliasObjId + ") -- fieldName=" + fieldName + " --> " + "(nextObjectId" + nextAliasObjId + ")");