diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index 3f29dc0..6513a65 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -109,8 +109,6 @@ } curStage = nextStage; notifyStageChangeListeners(); - - setDAGLayout(); // FIXME Not correct workaround return true; } @@ -164,7 +162,6 @@ curFilePath = null; curFileName = null; codes = null; - // resetDataFlowGraph } /** @@ -309,9 +306,13 @@ fileString.append("geometry {\n"); - Object root = graph.getDefaultParent(); - for (int i = 0; i < graph.getModel().getChildCount(root); i++) { - Object cell = graph.getModel().getChildAt(root, i); + mxCell root = (mxCell) graph.getDefaultParent(); + mxCell nodeLayer = (mxCell) root.getChildAt(Stage.NODE_LAYER); + mxCell dataFlowLayer = (mxCell) root.getChildAt(Stage.DATA_FLOW_LAYER); + + // Node layer + for (int i = 0; i < graph.getModel().getChildCount(nodeLayer); i++) { + Object cell = graph.getModel().getChildAt(nodeLayer, i); if (graph.getModel().isVertex(cell)) { mxGraphView view = graph.getView(); mxCellState state = view.getState(cell); @@ -340,8 +341,30 @@ } } } - fileString.append("}\n"); + // Data-Flow layer + // From controlFlowModeling branch + for (int i = 0; i < graph.getModel().getChildCount(dataFlowLayer); i++) { + Object cell = graph.getModel().getChildAt(dataFlowLayer, i); + if (graph.getModel().isVertex(cell)) { + mxGraphView view = graph.getView(); + mxCellState state = view.getState(cell); + int x = (int) state.getX(); + int y = (int) state.getY(); + int w = (int) state.getWidth(); + int h = (int) state.getHeight(); + + for (Channel ch : model.getChannels()) { + if (ch instanceof FormulaChannel && state.getLabel().equals(ch.getChannelName())) { + fileString.append("\tnode fc ").append(state.getLabel()).append(":").append(x).append(",").append(y).append(",").append(w).append(",").append(h).append("\n"); + } else if (ch != null && state.getLabel().equals(ch.getChannelName())) { + fileString.append("\tnode c ").append(state.getLabel()).append(":").append(x).append(",").append(y).append(",").append(w).append(",").append(h).append("\n"); + } + } + } + } + + fileString.append("}\n"); return fileString.toString(); } @@ -354,36 +377,44 @@ } public void setDAGLayout() { - Object parent = graph.getDefaultParent(); + mxCell root = (mxCell) graph.getDefaultParent(); + mxCell dataFlowLayer = (mxCell) root.getChildAt(Stage.DATA_FLOW_LAYER); + graph.getModel().beginUpdate(); try { DAGLayout ctl = new DAGLayout(graph); - ctl.execute(parent); + ctl.execute(dataFlowLayer); } finally { graph.getModel().endUpdate(); } } public void setTreeLayout() { - Object parent = graph.getDefaultParent(); + mxCell root = (mxCell) graph.getDefaultParent(); + graph.getModel().beginUpdate(); try { mxCompactTreeLayout ctl = new mxCompactTreeLayout(graph); ctl.setLevelDistance(100); // ctl.setHorizontal(false); ctl.setEdgeRouting(false); - ctl.execute(parent); + for (int i = 0; i < root.getChildCount(); i++) { + ctl.execute(root.getChildAt(i)); + } } finally { graph.getModel().endUpdate(); } } public void setCircleLayout() { - Object parent = graph.getDefaultParent(); + mxCell root = (mxCell) graph.getDefaultParent(); + graph.getModel().beginUpdate(); try { mxCircleLayout ctl = new mxCircleLayout(graph); - ctl.execute(parent); + for (int i = 0; i < root.getChildCount(); i++) { + ctl.execute(root.getChildAt(i)); + } } finally { graph.getModel().endUpdate(); }