diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 997b2df..0d8b82a 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -482,30 +482,41 @@ srcClassName = calledMethodExec.getThisClassName(); srcObjId = calledMethodExec.getThisObjId(); tgtObjId = calledMethodExec.getArguments().get(0).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.getCallerMethodExecution(), 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); - - // Change! - ObjectVertex tgtObjectVertex = objectToVertexMap.get(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()); + 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(); } - removeCalledMethodExecutionVertex(objectToVertexMap.get(srcObjId), methodExec.getCallerMethodExecution(), methodExec); - updateObjectVertices(); + } } @@ -710,14 +721,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) { @@ -744,6 +759,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(); @@ -826,6 +886,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); @@ -1383,99 +1450,102 @@ 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(); - 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(!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 (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(); + 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(); // 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(); } @@ -1591,40 +1661,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); +// } } } @@ -1713,7 +1782,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()); + } } }