diff --git a/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java new file mode 100644 index 0000000..89345f9 --- /dev/null +++ b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java @@ -0,0 +1,36 @@ +package org.ntlab.deltaViewer; + +import java.util.ArrayList; +import java.util.List; + +import org.ntlab.deltaExtractor.Alias; +import org.ntlab.deltaExtractor.IAliasCollector; + +public class CollaborationAliasCollector implements IAliasCollector { + // Reverse execution order. + private List aliasList = new ArrayList<>(); + + public CollaborationAliasCollector(DeltaAliasCollector dac) { + aliasList.addAll(dac.getAliasList()); + } + + /* + * Do nothing! + */ + @Override + public void addAlias(Alias alias) { + // TODO Auto-generated method stub + + } + + @Override + public List getAliasList() { + return aliasList; + } + + public void merge(DeltaAliasCollector dac) { + for (Alias alias: dac.getAliasList()) { + + } + } +} diff --git a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java new file mode 100644 index 0000000..1a64cb4 --- /dev/null +++ b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java @@ -0,0 +1,56 @@ +package org.ntlab.deltaViewer; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.ntlab.deltaExtractor.ExtractedStructure; +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.Reference; +import org.ntlab.trace.TracePoint; + +public class CollaborationObjectCallGraph implements IObjectCallGraph { + private List references = new ArrayList<>(); + private List startPoints = new ArrayList<>(); + private List relatedPoints = new ArrayList<>(); + + public CollaborationObjectCallGraph(ExtractedStructure e) { + references.addAll(e.getDelta().getSrcSide()); + references.addAll(e.getDelta().getDstSide()); + startPoints.add(e.getCoordinator()); + relatedPoints.add(e.getRelatedTracePoint()); + } + + @Override + public List getReferences() { + // TODO Auto-generated method stub + return references; + } + + @Override + public List getStartPoints() { + // TODO Auto-generated method stub + return startPoints; + } + + @Override + public List getRelatedPoints() { + // TODO Auto-generated method stub + return relatedPoints; + } + + @Override + public Map> getCallTree() { + // TODO Auto-generated method stub + return null; + } + + public void merge(ExtractedStructure e) { + references.addAll(e.getDelta().getSrcSide()); + references.addAll(e.getDelta().getDstSide()); + // lowest common ancestor algorithm +// startPoints.add(e.getCoordinator()); + relatedPoints.add(e.getRelatedTracePoint()); // ���ԏ��ɂ���̂� + } + +} diff --git a/src/org/ntlab/deltaViewer/CollaborationViewer.java b/src/org/ntlab/deltaViewer/CollaborationViewer.java index 6a56873..c018914 100644 --- a/src/org/ntlab/deltaViewer/CollaborationViewer.java +++ b/src/org/ntlab/deltaViewer/CollaborationViewer.java @@ -30,8 +30,6 @@ public class CollaborationViewer extends MagnetRONViewer { private IObjectCallGraph objectCallGraph; - private IAliasCollector aliasCollector; - private static Dimension VERTEX_OBJECT_SIZE = new Dimension(70, 70); private static Dimension VERTEX_METHOD_EXECUTION_SIZE = new Dimension(55, 20); @@ -41,16 +39,26 @@ super(); } - public void init(IObjectCallGraph objectCallGraph, IAliasCollector deltaAliasCollector) { + /** + * Set objectCallGraph and aliasCollector, create vertex object and edge object. + * @param objectCallGraph + * @param aliasCollector + */ + public void init(IObjectCallGraph objectCallGraph, IAliasCollector aliasCollector, IObjectLayout layout) { this.objectCallGraph = objectCallGraph; - this.aliasCollector = deltaAliasCollector; + this.aliasCollector = aliasCollector; // Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. - createObjectVertices(objectCallGraph); - createEdgeToObject(aliasCollector.getAliasList()); + createObjectVertices(this.objectCallGraph); + createEdgeToObject(this.aliasCollector.getAliasList()); + layout.execute(mxgraph, objectCallGraph, aliasCollector); + reflectCoordinates(mxgraph); // objectVertex��mxGraph�̍��W�𔽉f������ } - - /** Initialize JFrame, make vertex object and edge object. */ + + /** + * Initialize animation.�@�Đ��{�^���������Ƃ� + */ public void initAnimation() { +// reflectCoordinates(mxgraph); // objectVertex��mxGraph�̍��W�𔽉f������(���[�U���w�肵�����W�ʒu�𔽉f) // Fit graph size in visible JFrame. mxGraphView view = mxgraphComponent.getGraph().getView(); @@ -102,6 +110,5 @@ */ public void stepToAnimation(int numFrame) { } - } diff --git a/src/org/ntlab/deltaViewer/DeltaObjectCallGraph.java b/src/org/ntlab/deltaViewer/DeltaObjectCallGraph.java index 4a66ec4..b90d9f2 100644 --- a/src/org/ntlab/deltaViewer/DeltaObjectCallGraph.java +++ b/src/org/ntlab/deltaViewer/DeltaObjectCallGraph.java @@ -2,19 +2,23 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.ntlab.deltaExtractor.ExtractedStructure; import org.ntlab.trace.MethodExecution; import org.ntlab.trace.Reference; +import org.ntlab.trace.TracePoint; public class DeltaObjectCallGraph implements IObjectCallGraph { private List references = new ArrayList<>(); private List startPoints = new ArrayList<>(); - + private List relatedPoints = new ArrayList<>(); + public DeltaObjectCallGraph(ExtractedStructure e) { references.addAll(e.getDelta().getSrcSide()); references.addAll(e.getDelta().getDstSide()); startPoints.add(e.getCoordinator()); + relatedPoints.add(e.getRelatedTracePoint()); } @Override @@ -27,4 +31,15 @@ return startPoints; } + @Override + public List getRelatedPoints() { + // TODO Auto-generated method stub + return relatedPoints; + } + + @Override + public Map> getCallTree() { + // TODO Auto-generated method stub + return null; + } } diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index c255a26..c266200 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -64,8 +64,6 @@ //BUG: ObjectVertex position when Resize ObjectVertex. O public class DeltaViewer extends MagnetRONViewer { private ExtractedStructure eStructure; - private IAliasCollector deltaAliasCollector; - 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(0, 100); @@ -76,12 +74,12 @@ super(); } - public void init(ExtractedStructure extractedStructure, IAliasCollector deltaAliasCollector) { + public void init(ExtractedStructure extractedStructure, IAliasCollector aliasCollector) { this.eStructure = extractedStructure; - this.deltaAliasCollector = deltaAliasCollector; + this.aliasCollector = aliasCollector; // Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. createObjectVertices(eStructure); - createEdgeToObject(deltaAliasCollector.getAliasList()); + createEdgeToObject(this.aliasCollector.getAliasList()); } /** Initialize JFrame, make vertex object and edge object. */ @@ -115,7 +113,7 @@ } public void setDeltaAliasCollector(DeltaAliasTracker deltaAliasCollector) { - this.deltaAliasCollector = deltaAliasCollector; + this.aliasCollector = deltaAliasCollector; } public void setCoordinatorPoint(double x, double y) { @@ -123,94 +121,6 @@ coordinatorPoint.setY(y); } - /** Set style of All cells. */ -// private void setCellsStyle() { -// List vertexObject = new ArrayList<>(); -// List staticVertexObject = new ArrayList<>(); -// List alignMiddleVertex = new ArrayList<>(); -// List alignTopVertex = new ArrayList<>(); -// List edgeObject = new ArrayList<>(); -// List edgeObjectCreate = new ArrayList<>(); -// List edgeMethodExec = new ArrayList<>(); -// List roundEdge = new ArrayList<>(); -// -// for (Entry objectToVertexEntry: objectToVertexMap.entrySet()) { -// String key = objectToVertexEntry.getKey(); -// ObjectVertex objectVertex = objectToVertexEntry.getValue(); -// if (key.matches("0")) { -// staticVertexObject.add(objectVertex.getCell()); -// } else { -// vertexObject.add(objectVertex.getCell()); -// } -// if(objectVertex.getVertexMethodExecutions().size() == 0) { -// alignMiddleVertex.add(objectVertex.getCell()); -// } else { -// alignTopVertex.add(objectVertex.getCell()); -// } -// } -// -// List vertexMethodExecList = new ArrayList<>(methodExecToVertexMap.values()); -// Collections.reverse(vertexMethodExecList); -// for (int i = 0; i < vertexMethodExecList.size(); i++) { -// switch(i) { -// case 0: -// ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ff7fbf"); -// break; -// case 1: -// ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ff99cc"); -// break; -// case 2: -// ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffb2d8"); -// break; -// case 3: -// ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffcce5"); -// break; -// case 4: -// ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffe0ef"); -// break; -// default: -// break; -// } -// } -// -// for (Edge edge: edgeMap.values()) { -// roundEdge.add(edge.getCell()); -// switch(edge.getTypeName()) { -// case Reference: -// edgeObject.add(edge.getCell()); -// break; -// case Create: -// edgeObject.add(edge.getCell()); -// edgeObjectCreate.add(edge.getCell()); -// break; -// case Call: -// edgeMethodExec.add(edge.getCell()); -// break; -// default: -// break; -// } -// } -// -// /*Given a cell, we can change it's style attributes, for example the color. NOTE that you have to call the graphComponent.refresh() function, otherwise you won't see the difference! */ -// mxgraph.setCellStyles(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE, vertexObject.toArray(new Object[vertexObject.size()])); -// mxgraph.setCellStyles(mxConstants.STYLE_PERIMETER, mxConstants.PERIMETER_ELLIPSE, vertexObject.toArray(new Object[vertexObject.size()])); -// mxgraph.setCellStyleFlags(mxConstants.STYLE_FONTSTYLE, mxConstants.FONT_UNDERLINE, true, vertexObject.toArray(new Object[vertexObject.size()])); -// mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE, alignMiddleVertex.toArray(new Object[alignMiddleVertex.size()])); -// mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_TOP, alignTopVertex.toArray(new Object[alignTopVertex.size()])); -// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_TOPTOBOTTOM, edgeObject.toArray(new Object[edgeObject.size()])); -// mxgraph.setCellStyleFlags(mxConstants.STYLE_DASHED, 1, true, edgeObjectCreate.toArray(new Object[edgeObjectCreate.size()])); -//// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ENTITY_RELATION, edgeObject.toArray(new Object[edgeObject.size()])); -//// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL, edgeObject.toArray(new Object[edgeObject.size()])); -// mxgraph.setCellStyleFlags(mxConstants.STYLE_ROUNDED, 1, true, roundEdge.toArray(new Object[roundEdge.size()])); -// mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_TOP, roundEdge.toArray(new Object[roundEdge.size()])); -// mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_LABEL_POSITION, mxConstants.ALIGN_BOTTOM, roundEdge.toArray(new Object[roundEdge.size()])); -//// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.SHAPE_CURVE, edgeObject.toArray(new Object[edgeObject.size()])); -// mxgraph.setCellStyles(mxConstants.STYLE_STROKECOLOR, "#008000", edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); -// mxgraph.setCellStyleFlags(mxConstants.STYLE_DASHED, 1, true, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); -//// mxgraph.setCellStyleFlags(mxConstants.STYLE_AUTOSIZE, 1, true, vertexObject.toArray(new Object[vertexObject.size()])); -//// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); -//// mxgraph.setCellStyles(mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); -// } // private double getXForCell(String id) { // double res = -1; @@ -245,7 +155,7 @@ */ public void stepToAnimation(Alias alias) { try { - stepToAnimation(deltaAliasCollector.getAliasList().indexOf(alias)); + stepToAnimation(aliasCollector.getAliasList().indexOf(alias)); } catch (IndexOutOfBoundsException e) { stepToAnimation(-1); } @@ -257,9 +167,9 @@ * @param numFrame Current animation frame. */ public void stepToAnimation(int numFrame) { - if (deltaAliasCollector.getAliasList().size() > numFrame) { + if (aliasCollector.getAliasList().size() > numFrame) { doAnimation(curFrame, numFrame); - } else if (deltaAliasCollector.getAliasList().size() == numFrame){ + } else if (aliasCollector.getAliasList().size() == numFrame){ System.out.println("\r\nLast Animation."); doLastAnimation(numFrame); } else { @@ -275,7 +185,7 @@ */ private void doAnimation(int fromFrame, int toFrame) { for (int i = fromFrame; i <= toFrame; i++) { - List aliasList = new ArrayList<>(deltaAliasCollector.getAliasList()); + List aliasList = new ArrayList<>(aliasCollector.getAliasList()); Alias alias = aliasList.get(i); System.out.println("\r\n" + i + ": " + alias.getAliasType().toString()); System.out.println(alias.getObjectId() + ", " + alias.getMethodSignature() + " l." + alias.getLineNo()); @@ -340,7 +250,7 @@ private void doLastAnimation(int numFrame) { outputLog(); curFrame = numFrame; - Alias alias = deltaAliasCollector.getAliasList().get(numFrame - 1); + Alias alias = aliasCollector.getAliasList().get(numFrame - 1); // Make ObjectEdge and reset position of vertexObject, remove vertexMethodExecution. // for(Statement statement: alias.getMethodExecution().getStatements()) @@ -1498,9 +1408,9 @@ } } - /** Make edge object in JGraphT and draw this in JGraphX. - * @param map - * @param collection + /** Make edge object in JGraphT and draw this in JGraphX. + * + * @param aliasList */ private void createEdgeToObject(List aliasList) { for (int i = 0; i < aliasList.size()-1; i++) { diff --git a/src/org/ntlab/deltaViewer/IObjectCallGraph.java b/src/org/ntlab/deltaViewer/IObjectCallGraph.java index 8093c6e..91d7be5 100644 --- a/src/org/ntlab/deltaViewer/IObjectCallGraph.java +++ b/src/org/ntlab/deltaViewer/IObjectCallGraph.java @@ -1,9 +1,11 @@ package org.ntlab.deltaViewer; import java.util.List; +import java.util.Map; import org.ntlab.trace.MethodExecution; import org.ntlab.trace.Reference; +import org.ntlab.trace.TracePoint; public interface IObjectCallGraph { @@ -13,4 +15,8 @@ * �N�_�ƂȂ郁�\�b�h���s(����2�‚̋N�_�ɂ��g���\��) */ List getStartPoints(); + + List getRelatedPoints(); + + Map> getCallTree(); } diff --git a/src/org/ntlab/deltaViewer/IObjectLayout.java b/src/org/ntlab/deltaViewer/IObjectLayout.java new file mode 100644 index 0000000..d0e81e2 --- /dev/null +++ b/src/org/ntlab/deltaViewer/IObjectLayout.java @@ -0,0 +1,9 @@ +package org.ntlab.deltaViewer; + +import org.ntlab.deltaExtractor.IAliasCollector; + +public interface IObjectLayout { + + public void execute(DeltaGraphAdapter mxgraph, IObjectCallGraph objectCallGraph, IAliasCollector aliasCollector); + +} diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 23a8122..e03978b 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -18,6 +18,7 @@ import org.jgrapht.graph.DefaultEdge; import org.jgrapht.graph.DirectedWeightedPseudograph; import org.ntlab.deltaExtractor.Alias; +import org.ntlab.deltaExtractor.IAliasCollector; import org.ntlab.trace.MethodExecution; import com.mxgraph.canvas.mxGraphics2DCanvas; @@ -37,6 +38,8 @@ protected static Dimension DEFAULT_SIZE = new Dimension(1300, 700); protected static String WINDOW_TITLE = "Delta Viewer"; + protected IAliasCollector aliasCollector; + protected Map objectToVertexMap = new HashMap<>(); protected Map methodExecToVertexMap = new LinkedHashMap<>(); protected Map edgeMap = new HashMap<>(); @@ -182,7 +185,7 @@ } /** - * Whether sourceCell parents contain targetCell + * Whether sourceCell parents contain targetCell. * @param sourceCell * @param targetCell * @return @@ -209,6 +212,10 @@ return new Point((int) (p1.getX() + p2.getX()), (int) (p1.getY() + p2.getY())); } + protected void reflectCoordinates(DeltaGraphAdapter mxgraph) { + // TODO Auto-generated method stub + } + protected class CurvedCanvas extends mxInteractiveCanvas { mxIShape shape = new CurvedConnector();