diff --git a/src/org/ntlab/animations/MagnetRONAnimation.java b/src/org/ntlab/animations/MagnetRONAnimation.java index 151fea1..42379dd 100644 --- a/src/org/ntlab/animations/MagnetRONAnimation.java +++ b/src/org/ntlab/animations/MagnetRONAnimation.java @@ -179,6 +179,8 @@ STOPPED } +// private static int animationCount = 0; + /** * The constructor of {@code MagnetRONAnimation}. * @@ -362,12 +364,16 @@ updateCurrentCycle(getCurrentCycleCount()); jumpTo(getCurrentCycleCount()); } else if(Math.abs(getCurrentCycleCount()) >= Math.abs(getTotalCycleCount())){ +// animationCount = 0; +// System.out.println(TAG + ": animationCount=" + animationCount); onFinished(); } } }, getInitialDelay(), getDelay(), TimeUnit.MILLISECONDS); setScheduledFuture(scheduledFuture); setCurrentStatus(Status.RUNNING); +// animationCount = 1; +// System.out.println(TAG + ": animationCount=" + animationCount); }; break; case PAUSED: @@ -382,6 +388,22 @@ }; } +// public static void waitAnimationEnd() { +// while (animationCount > 0) { +// try { +// Thread.sleep(1L); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// // Buffer for another waiting animation. +// try { +// Thread.sleep(30L); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } + public void syncPlay() { if (getCurrentStatus() == Status.STOPPED) { try { diff --git a/src/org/ntlab/deltaViewer/CollaborationViewer.java b/src/org/ntlab/deltaViewer/CollaborationViewer.java index 633639d..282704a 100644 --- a/src/org/ntlab/deltaViewer/CollaborationViewer.java +++ b/src/org/ntlab/deltaViewer/CollaborationViewer.java @@ -118,12 +118,12 @@ System.out.println("ERROR : Not exist alias."); } // } else { - // TODO Considering fast-forwarding animations. + // TODO: Considering fast-forwarding animations. // } } private void doLastAnimation(int numFrame, TracePoint relatedPoint) { - // TODO Implement doLastAnimation to support plural Delta. + // TODO: Implement doLastAnimation to support plural Delta. outputLog(); curFrame = numFrame; List aliasList = aliasCollector.getAliasList(); @@ -170,8 +170,8 @@ 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(")) { +// if (methodExec.getSignature().contains("List.add(") || +// methodExec.getSignature().contains("Map.put(")) { if (calledMethodExec.isCollectionType() && (methodSignature.contains("add(") || methodSignature.contains("set(") @@ -260,104 +260,117 @@ // updateObjectVertices(); // } - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - List meList = new ArrayList<>(methodExecToVertexMap.keySet()); - Collections.reverse(meList); - System.out.println(meList.size()); - for(int i = 0; i < meList.size(); i++) { - String objectId = meList.get(i).getThisObjId(); - ObjectVertex sourceVertexObject = objectToVertexMap.get(objectId); // sourceVertex - MethodExecution me = meList.get(i); - if (nextAlias != null && me.getSignature().equals(nextAlias.getMethodSignature())) break; - if (i != meList.size()-1) { - for(Statement st: me.getStatements()) { - if(st instanceof MethodInvocation) { - MethodExecution calledMethodExec = ((MethodInvocation) st).getCalledMethodExecution(); - String calledObjectId = calledMethodExec.getThisObjId(); - System.out.println(calledObjectId); - if(objectToVertexMap.containsKey(calledObjectId)) { - mxICell calledCell = (mxICell)objectToVertexMap.get(calledObjectId).getCell(); - Point2D absolutePointCalledCell = getAbsolutePointforCell(calledCell); - System.out.println(objectId + ", " + me.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(); -// } - removeCalledMethodExecutionVertex(sourceVertexObject, me.getCallerMethodExecution(), me); - updateObjectVertices(); -// removeVertexMethodExecution(sourceVertexObject, methodExec); -// update(); - break; - } + List meList = new ArrayList<>(methodExecToVertexMap.keySet()); + Collections.reverse(meList); + System.out.println(meList.size()); + for(int i = 0; i < meList.size(); i++) { + String objectId = meList.get(i).getThisObjId(); + ObjectVertex sourceVertexObject = objectToVertexMap.get(objectId); // sourceVertex + MethodExecution me = meList.get(i); + if (nextAlias != null && me.getSignature().equals(nextAlias.getMethodSignature())) break; + if (i != meList.size()-1) { + for(Statement st: me.getStatements()) { + if(st instanceof MethodInvocation) { + MethodExecution calledMethodExec = ((MethodInvocation) st).getCalledMethodExecution(); + String calledObjectId = calledMethodExec.getThisObjId(); + System.out.println(calledObjectId); + if(objectToVertexMap.containsKey(calledObjectId)) { + mxICell calledCell = (mxICell)objectToVertexMap.get(calledObjectId).getCell(); + Point2D absolutePointCalledCell = getAbsolutePointforCell(calledCell); + System.out.println(objectId + ", " + me.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(); +// } + removeCalledMethodExecutionVertex(sourceVertexObject, me.getCallerMethodExecution(), me); + updateObjectVertices(); +// removeVertexMethodExecution(sourceVertexObject, methodExec); +// update(); + break; } } - } else { - outputLog(); - - // Change! - List arguments = new ArrayList<>(methodExecToVertexMap.get(me).getArguments()); - List locals = new ArrayList<>(methodExecToVertexMap.get(me).getLocals()); - if (arguments.size() != 0) { - for (ObjectVertex vo: arguments) { - mxICell cell = (mxICell)vo.getCell(); - Point2D absolutePointCell = getAbsolutePointforCell(cell); -// cell.getParent().remove(cell); -// cell.setParent(mxDefaultParent); - if (!cell.getParent().equals(getMxDefaultParent())) { - // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. - cell.getParent().remove(cell); - cell.setParent(getMxDefaultParent()); - } - cell.getGeometry().setX(absolutePointCell.getX()); - cell.getGeometry().setY(absolutePointCell.getY()); -// deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); -// deltaAnimation.startVertexAnimation(); -// deltaAnimation.sleepThread(DEFAULT_THREAD_SLEEP_MILLIS); - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); - vertexAnim.play(); - sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); - methodExecToVertexMap.get(me).getArguments().remove(vo); - } - }else if (locals.size() != 0) { - for (ObjectVertex vo: locals) { - mxICell cell = (mxICell)vo.getCell(); - Point2D absolutePointCell = getAbsolutePointforCell(cell); -// cell.getParent().remove(cell); -// cell.setParent(mxDefaultParent); - if (!cell.getParent().equals(getMxDefaultParent())) { - // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. - cell.getParent().remove(cell); - cell.setParent(getMxDefaultParent()); - } - cell.getGeometry().setX(absolutePointCell.getX()); - cell.getGeometry().setY(absolutePointCell.getY()); -// deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); -// deltaAnimation.startVertexAnimation(); -// deltaAnimation.sleepThread(DEFAULT_THREAD_SLEEP_MILLIS); - MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); - vertexAnim.setTotalCycleCount(10); - vertexAnim.setDelay(100); - vertexAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); - vertexAnim.play(); - sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); - methodExecToVertexMap.get(me).getLocals().remove(vo); - } - } - updateObjectVertices(); } + } else { + outputLog(); + + // Change! + List arguments = new ArrayList<>(methodExecToVertexMap.get(me).getArguments()); + List locals = new ArrayList<>(methodExecToVertexMap.get(me).getLocals()); + if (arguments.size() != 0) { + for (ObjectVertex vo: arguments) { + mxICell cell = (mxICell)vo.getCell(); + Point2D absolutePointCell = getAbsolutePointforCell(cell); + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + synchronized (mxgraph.getModel()) { + try { +// cell.getParent().remove(cell); +// cell.setParent(mxDefaultParent); + if (!cell.getParent().equals(getMxDefaultParent())) { + // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. + cell.getParent().remove(cell); + cell.setParent(getMxDefaultParent()); + } + cell.getGeometry().setX(absolutePointCell.getX()); + cell.getGeometry().setY(absolutePointCell.getY()); + } finally { + mxgraph.getModel().endUpdate(); + } + } + +// deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); +// deltaAnimation.startVertexAnimation(); +// deltaAnimation.sleepThread(DEFAULT_THREAD_SLEEP_MILLIS); + MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + vertexAnim.setTotalCycleCount(10); + vertexAnim.setDelay(100); + vertexAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); +// vertexAnim.play(); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); + vertexAnim.syncPlay(); + methodExecToVertexMap.get(me).getArguments().remove(vo); + } + }else if (locals.size() != 0) { + for (ObjectVertex vo: locals) { + mxICell cell = (mxICell)vo.getCell(); + Point2D absolutePointCell = getAbsolutePointforCell(cell); + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + synchronized (mxgraph.getModel()) { + try { +// cell.getParent().remove(cell); +// cell.setParent(mxDefaultParent); + if (!cell.getParent().equals(getMxDefaultParent())) { + // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. + cell.getParent().remove(cell); + cell.setParent(getMxDefaultParent()); + } + cell.getGeometry().setX(absolutePointCell.getX()); + cell.getGeometry().setY(absolutePointCell.getY()); + } finally { + mxgraph.getModel().endUpdate(); + } + } +// deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); +// deltaAnimation.startVertexAnimation(); +// deltaAnimation.sleepThread(DEFAULT_THREAD_SLEEP_MILLIS); + MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); + vertexAnim.setTotalCycleCount(10); + vertexAnim.setDelay(100); + vertexAnim.init(cell, vo.getInitialX(), vo.getInitialY(), threadPoolExecutor); +// vertexAnim.play(); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); + vertexAnim.syncPlay(); + methodExecToVertexMap.get(me).getLocals().remove(vo); + } + } + updateObjectVertices(); } - } finally { - mxgraph.getModel().endUpdate(); } update(); } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 27d31cd..a30c423 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -66,7 +66,8 @@ protected static Dimension DEFAULT_OBJECT_VERTEX_SIZE = new Dimension(70, 70); protected static Dimension DEFAULT_METHOD_EXECUTION_VERTEX_SIZE = new Dimension(55, 20); - protected static long DEFAULT_THREAD_SLEEP_MILLIS = 1100; + protected static long DEFAULT_THREAD_SLEEP_MILLIS = 1100L; + protected static long POSTPONE_ANIMATION_MILLIS = 400L; protected IAliasCollector aliasCollector; @@ -176,6 +177,7 @@ createObjectVertexOnConstractor(alias); createMethodExecutionVertex(alias.getObjectId(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCallerSideMethodName(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution()); update(); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); removeMethodExecutionVertex(alias); update(); break; @@ -338,8 +340,8 @@ mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - // dstCell.getParent().remove(dstCell); - // dstCell.setParent(mxDefaultParent); +// dstCell.getParent().remove(dstCell); +// dstCell.setParent(mxDefaultParent); if (!dstCell.getParent().equals(getMxDefaultParent())) { // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. dstCell.getParent().remove(dstCell); @@ -393,8 +395,8 @@ mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - // dstCell.getParent().remove(dstCell); - // dstCell.setParent(mxDefaultParent); +// dstCell.getParent().remove(dstCell); +// dstCell.setParent(mxDefaultParent); if (!dstCell.getParent().equals(getMxDefaultParent())) { // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. dstCell.getParent().remove(dstCell); @@ -531,11 +533,11 @@ } mxgraph.orderCells(true, new Object[] {srcCell}); - // srcCell.setParent(dstCell.getParent()); - // dstCell.getParent().insert(srcCell); +// srcCell.setParent(dstCell.getParent()); +// dstCell.getParent().insert(srcCell); if (srcCell.getParent() == null || !srcCell.getParent().equals(dstCell.getParent())) { // TODO: Confirm why not need following comment out. - // if (srcCell.getParent() != null) srcCell.getParent().remove(srcCell); +// if (srcCell.getParent() != null) srcCell.getParent().remove(srcCell); srcCell.setParent(dstCell.getParent()); dstCell.getParent().insert(srcCell); } @@ -563,17 +565,18 @@ vertexAnim.init(srcCell, dstCell.getGeometry().getX() - (srcCellWidth / Math.sqrt(2.5)) + (srcCellWidth * time), dstCell.getGeometry().getY() + dstCellHeight, threadPoolExecutor); - // vertexAnim.play(); - // sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); +// vertexAnim.play(); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); vertexAnim.syncPlay(); // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - // srcCell.setParent(dstCell.getParent()); - // dstCell.getParent().insert(srcCell); +// srcCell.setParent(dstCell.getParent()); +// dstCell.getParent().insert(srcCell); if (!srcCell.getParent().equals(dstCell.getParent())) { + // TODO: Confirm why not need following comment out. srcCell.getParent().remove(srcCell); srcCell.setParent(dstCell.getParent()); dstCell.getParent().insert(srcCell); @@ -639,11 +642,11 @@ synchronized (mxgraph.getModel()) { try { mxgraph.orderCells(true, new Object[] {srcCell}); - // srcCell.setParent(dstCell.getParent()); - // dstCell.getParent().insert(srcCell); +// srcCell.setParent(dstCell.getParent()); +// dstCell.getParent().insert(srcCell); if (srcCell.getParent() == null || !srcCell.getParent().equals(dstCell.getParent())) { // TODO: Confirm why not need following comment out. - // if (srcCell.getParent() != null) srcCell.getParent().remove(srcCell); +// if (srcCell.getParent() != null) srcCell.getParent().remove(srcCell); srcCell.setParent(dstCell.getParent()); dstCell.getParent().insert(srcCell); } @@ -669,8 +672,9 @@ vertexAnim.init(srcCell, dstCell.getGeometry().getX() - overlapWidth, dstCell.getGeometry().getY() - overlapHeight + (srcCellHeight * time), threadPoolExecutor); -// vertexAnim.play(); -// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); +// vertexAnim.play(); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); +// sleepMainThread(POSTPONE_ANIMATION_MILLIS); vertexAnim.syncPlay(); // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. @@ -699,16 +703,21 @@ mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - // srcCell.remove(dstCell.getParent()); - // dstCell.getParent().setParent(mxDefaultParent); - // srcCell.setParent(dstCell.getParent()); - // dstCell.getParent().insert(srcCell); - if (!dstCell.getParent().getParent().equals(getMxDefaultParent()) +// srcCell.remove(dstCell.getParent()); +// dstCell.getParent().setParent(mxDefaultParent); +// srcCell.setParent(dstCell.getParent()); +// dstCell.getParent().insert(srcCell); + if (dstCell.getParent() != null + || dstCell.getParent().getParent() != null + || srcCell.getParent() != null + || !dstCell.getParent().getParent().equals(getMxDefaultParent()) || !srcCell.getParent().equals(dstCell.getParent())) { srcCell.remove(dstCell.getParent()); - dstCell.getParent().remove(dstCell); dstCell.getParent().setParent(getMxDefaultParent()); - srcCell.getParent().remove(srcCell); + // TODO: Confirm why not need following comment out. +// dstCell.getParent().remove(dstCell); + // TODO: Confirm why not need following comment out. +// srcCell.getParent().remove(srcCell); srcCell.setParent(dstCell.getParent()); dstCell.getParent().insert(srcCell); } @@ -737,8 +746,8 @@ vertexAnim.init(srcCell, dstCell.getGeometry().getX() - overlapWidth + (srcCellWidth * time), dstCell.getGeometry().getY() - overlapHeight + (srcCellHeight * time), threadPoolExecutor); -// vertexAnim.play(); -// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); +// vertexAnim.play(); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); vertexAnim.syncPlay(); // Test code (will be deleted) @@ -819,7 +828,8 @@ // srcCell.setParent(dstCell.getParent()); // dstCell.getParent().insert(srcCell); if (srcCell.getParent() == null || !srcCell.getParent().equals(dstCell.getParent())) { - if (srcCell.getParent() != null) srcCell.getParent().remove(srcCell); + // TODO: Confirm why not need following comment out. +// if (srcCell.getParent() != null) srcCell.getParent().remove(srcCell); srcCell.setParent(dstCell.getParent()); dstCell.getParent().insert(srcCell); } @@ -844,8 +854,8 @@ vertexAnim.init(srcCell, dstCell.getGeometry().getX() - (srcCellWidth / Math.sqrt(3)) + (srcCellWidth * time), dstCell.getGeometry().getY() + dstCellHeight, threadPoolExecutor); -// vertexAnim.play(); -// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); +// vertexAnim.play(); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); vertexAnim.syncPlay(); // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. @@ -917,27 +927,27 @@ dstPt.setLocation(dstPt.getX() - (dstDim.getWidth() - curDim.getWidth()) / 2, dstPt.getY() - (dstDim.getHeight() - curDim.getHeight()) / 2); // Test code (will be deleted) System.out.println(TAG + ": Translate " + ovCell.getId() + ". Current point=" + ovCell.getGeometry().getPoint() + ", Destination Point=" + dstPt); -// deltaAnimation.setVertexAnimation(ovCell, dstPt); -// deltaAnimation.startVertexAnimation(); +// deltaAnimation.setVertexAnimation(ovCell, dstPt); +// deltaAnimation.startVertexAnimation(); MagnetRONAnimation vertexAnim = new TranslateAnimation(mxgraph, getGraphComponent()); mxICellToTranslateAnimMap.put(ovCell, vertexAnim); vertexAnim.setTotalCycleCount(10); vertexAnim.setDelay(100); vertexAnim.init(ovCell, dstPt.getX(), dstPt.getY(), threadPoolExecutor); vertexAnim.play(); -// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); -// deltaAnimation.setResizeVertexAnimation(ovCell, dstDim); -// deltaAnimation.startResizeVertexAnimation(); -// deltaAnimation.sleepThread(DEFAULT_THREAD_SLEEP_MILLIS); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); +// deltaAnimation.setResizeVertexAnimation(ovCell, dstDim); +// deltaAnimation.startResizeVertexAnimation(); +// deltaAnimation.sleepThread(DEFAULT_THREAD_SLEEP_MILLIS); MagnetRONAnimation vertexResizeAnim = new VertexResizeAnimation(mxgraph, getGraphComponent()); vertexResizeAnim.setTotalCycleCount(10); vertexResizeAnim.setDelay(100); vertexResizeAnim.init(ovCell, dstDim.getWidth(), dstDim.getHeight(), threadPoolExecutor); vertexResizeAnim.play(); -// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); +// sleepMainThread(DEFAULT_THREAD_SLEEP_MILLIS); for (int i = 0; i < ovCell.getChildCount(); i++) { mxICell childCell = ovCell.getChildAt(i); -// if (mxICellToTranslateAnimMap.get(childCell) != null) continue; +// if (mxICellToTranslateAnimMap.get(childCell) != null) continue; double childCellCurX = childCell.getGeometry().getX(); double childCellCurY = childCell.getGeometry().getY(); Point2D childDstPt = @@ -1000,31 +1010,35 @@ time -= 1; } + mxICell cell = null; + MethodExecutionVertex methodExecVertex = null; // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); synchronized (mxgraph.getModel()) { try { - // Creates a white cell of {@code ObjectVertex}. - mxICell cell = (mxICell) mxgraph.insertDeltaVertex(parentCell, methodSignature, methodSignature, "fillColor=white"); + // Creates a white cell of MethodExecutionVertex. + cell = (mxICell) mxgraph.insertDeltaVertex(parentCell, methodSignature, methodSignature, "fillColor=white"); mxgraph.orderCells(false, new Object[] {cell}); // Test code (will be deleted) System.out.println("makeVertexMethodExecution: " + cell.getId() + " in " + objectId + " (" + stdX + ", " + coordY * (time + 1) + stdY + ")"); - - MethodExecutionVertex methodExecVertex = + methodExecVertex = new MethodExecutionVertex(methodSignature, cell, stdX, coordY * (time + 1) + stdY, DEFAULT_METHOD_EXECUTION_VERTEX_SIZE.getWidth(), DEFAULT_METHOD_EXECUTION_VERTEX_SIZE.getHeight()); methodExecToVertexMap.put(methodExecution, methodExecVertex); if(methodExecToVertexMap.size() > 1) { + // Caution: If synchronized block is split here, {@code cell} display instantly until cell#setVisible(false) is executed. cell.setVisible(false); - createEdgeToMethodExecution(); } - objectToVertexMap.get(objectId).addMethodExecution(methodExecVertex); } finally { mxgraph.getModel().endUpdate(); } -// setCellsStyle(); - update(); } + if(methodExecToVertexMap.size() > 1) { + createEdgeToMethodExecution(); + } + objectToVertexMap.get(objectId).addMethodExecution(methodExecVertex); +// setCellsStyle(); + update(); } /** @@ -1159,7 +1173,7 @@ protected void removeCalledMethodExecutionVertex(ObjectVertex sourceObjectVertex, MethodExecution methodExecution, MethodExecution calledMethodExecution) { // Test code (will be deleted) outputLog(); - +// MagnetRONAnimation.waitAnimationEnd(); // Remove ObjectVertex other than sourceObjectVertex from locals and arguments of called MethodExecutionVertex. if (methodExecToVertexMap.containsKey(calledMethodExecution)) { MethodExecutionVertex calledMethodExecVertex = methodExecToVertexMap.get(calledMethodExecution); @@ -1315,14 +1329,15 @@ mxgraph.removeCells(new Object[]{clonedstMethodExecVertexCell[0]}); // TODO: Confirm execution order. -// dstMethodExecVertexCell.getParent().remove(dstMethodExecVertexCell); -// dstMethodExecVertexCell.setParent(mxDefaultParent); +// dstMethodExecVertexCell.getParent().remove(dstMethodExecVertexCell); +// dstMethodExecVertexCell.setParent(mxDefaultParent); if (!dstMethodExecVertexCell.getParent().equals(getMxDefaultParent())) { // If parent of ObjectVertex cell isn't mxDefaltParent, reset parent. dstMethodExecVertexCell.getParent().remove(dstMethodExecVertexCell); dstMethodExecVertexCell.setParent(getMxDefaultParent()); } mxgraph.removeCells(new Object[] {dstMethodExecVertexCell}); + update(); } finally { mxgraph.getModel().endUpdate(); } @@ -1338,12 +1353,11 @@ } methodExecToVertexMap.get(calledMethodExecution).getLocals().remove(sourceObjectVertex); methodExecToVertexMap.remove(calledMethodExecution); - edgeMap.remove(methodExecution.getSignature()); - - sleepMainThread(400); + edgeMap.remove(methodExecution.getSignature()); } catch (CloneNotSupportedException e) { e.printStackTrace(); - } + } + sleepMainThread(POSTPONE_ANIMATION_MILLIS); } // Test code (will be deleted) @@ -1405,10 +1419,10 @@ // Test code (will be deleted) System.out.println("Stretch edge animation action performed. "); mxICell edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), methodSig, null, srcMethodExecVertexCell, dstMethodExecVertexCell); - // edge.getParent().remove(edge); - // edge.setParent(mxDefaultParent); +// edge.getParent().remove(edge); +// edge.setParent(mxDefaultParent); if (!edge.getParent().equals(getMxDefaultParent())) { - // If parent of {@code Edge} cell isn't mxDefaltParent, reset parent. + // If parent of Edge cell isn't mxDefaltParent, reset parent. edge.getParent().remove(edge); edge.setParent(getMxDefaultParent()); } @@ -1423,6 +1437,7 @@ } } }); +// MagnetRONAnimation.waitAnimationEnd(); edgeAnim.play(); // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); @@ -1433,11 +1448,11 @@ mxgraph.getModel().endUpdate(); } } - sleepMainThread(400); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } + sleepMainThread(POSTPONE_ANIMATION_MILLIS); } } @@ -1552,7 +1567,9 @@ protected Point2D getAbsolutePointforCell(mxICell cell) { Point2D p1 = new Point2D.Double(cell.getGeometry().getX(), cell.getGeometry().getY());; // if(cell.getParent().getValue() == null || cell == cell.getParent()) { - if(cell.getParent().getValue() == null || cell.equals(cell.getParent())) { + if(cell.getParent() == null + || cell.getParent().getValue() == null + || cell.equals(cell.getParent())) { return p1; } // Test code (will be deleted) @@ -1768,7 +1785,7 @@ public void sleepMainThread(long millis) { try { // Test code (will be deleted) - System.out.println(TAG + ": Sleep Main thread " + millis + "millis."); + System.out.println(TAG + ": Sleep Main thread " + millis + "millis. ThreadId=" + Thread.currentThread().getId()); Thread.sleep(millis); System.out.println(TAG + ": Resume Main thread."); } catch (InterruptedException e) {