diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index c255db9..115c5fb 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -7,45 +7,27 @@ import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.Set; import com.mxgraph.layout.mxCircleLayout; import com.mxgraph.layout.mxCompactTreeLayout; import com.mxgraph.model.mxCell; -import com.mxgraph.model.mxGraphModel; -import com.mxgraph.model.mxIGraphModel; import com.mxgraph.swing.mxGraphComponent; -import com.mxgraph.swing.view.mxICellEditor; -import com.mxgraph.util.mxConstants; import com.mxgraph.view.mxCellState; -import com.mxgraph.util.mxRectangle; import com.mxgraph.view.mxGraph; import com.mxgraph.view.mxGraphView; -import algorithms.DataTransferModelAnalyzer; -import algorithms.Validation; import application.editor.stages.ControlFlowDelegationStage; -import application.editor.stages.DataFlowCellEditor; import application.editor.stages.DataFlowModelingStage; import application.editor.stages.PushPullSelectionStage; import application.layouts.*; import code.ast.CompilationUnit; -import models.Edge; import models.EdgeAttribute; -import models.Node; import models.dataConstraintModel.ChannelGenerator; import models.dataConstraintModel.IdentifierTemplate; import models.dataFlowModel.DataTransferModel; import models.dataFlowModel.DataTransferChannelGenerator; -import models.dataFlowModel.PushPullAttribute; -import models.dataFlowModel.DataFlowEdge; import models.dataFlowModel.DataFlowGraph; -import models.dataFlowModel.ResourceNode; import models.visualModel.FormulaChannelGenerator; import parser.Parser; import parser.exceptions.ExpectedAssignment; @@ -87,7 +69,7 @@ public Editor(mxGraphComponent graphComponent) { this.graphComponent = graphComponent; this.graph = graphComponent.getGraph(); - + STAGE_DATA_FLOW_MODELING = new DataFlowModelingStage(graph); STAGE_PUSH_PULL_SELECTION = new PushPullSelectionStage(graph); STAGE_CONTROL_FLOW_DELEGATION = new ControlFlowDelegationStage(graph); @@ -334,9 +316,33 @@ fileString += "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); + 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); + int x = (int) state.getX(); + int y = (int) state.getY(); + int w = (int) state.getWidth(); + int h = (int) state.getHeight(); + + for (IdentifierTemplate res: model.getIdentifierTemplates()){ + if(res instanceof IdentifierTemplate && state.getLabel().equals(res.getResourceName())) + fileString += "\tnode r " + state.getLabel() + ":" + x + "," + y + "," + w + "," + h + "\n"; + } + + for (ChannelGenerator ioC: model.getIOChannelGenerators()) { + if(ioC instanceof ChannelGenerator && state.getLabel().equals(ioC.getChannelName())) { + fileString += "\tnode ioc " + state.getLabel() + ":" + x + "," + y + "," + w + "," + h + "\n"; + } + } + } + } + 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); @@ -352,55 +358,47 @@ fileString +="\tnode c " + state.getLabel() + ":" + x + "," + y + "," + w + "," + h+"\n"; } } - - for (IdentifierTemplate res: model.getIdentifierTemplates()){ - if(res instanceof IdentifierTemplate && state.getLabel().equals(res.getResourceName())) - fileString += "\tnode r " + state.getLabel() + ":" + x + "," + y + "," + w + "," + h + "\n"; - } - - for (ChannelGenerator ioC: model.getIOChannelGenerators()) { - if(ioC instanceof ChannelGenerator && state.getLabel().equals(ioC.getChannelName())) { - fileString += "\tnode ioc " + state.getLabel() + ":" + x + "," + y + "," + w + "," + h + "\n"; - } - } } - } + } fileString += "}\n"; return fileString; } 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(); + mxCell dataFlowLayer = (mxCell) root.getChildAt(Stage.DATA_FLOW_LAYER); graph.getModel().beginUpdate(); try { mxCompactTreeLayout ctl = new mxCompactTreeLayout(graph); ctl.setLevelDistance(100); // ctl.setHorizontal(false); ctl.setEdgeRouting(false); - ctl.execute(parent); + ctl.execute(dataFlowLayer); } finally { graph.getModel().endUpdate(); } } public void setCircleLayout() { - Object parent = graph.getDefaultParent(); + mxCell root = (mxCell) graph.getDefaultParent(); + mxCell dataFlowLayer = (mxCell) root.getChildAt(Stage.DATA_FLOW_LAYER); graph.getModel().beginUpdate(); try { mxCircleLayout ctl = new mxCircleLayout(graph); - ctl.execute(parent); + ctl.execute(dataFlowLayer); } finally { graph.getModel().endUpdate(); }