diff --git a/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java b/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java index 8ee36b5..bcbd998 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java +++ b/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java @@ -21,6 +21,7 @@ private TreeLayoutAction treeLayoutAction = null; private CircleLayoutAction circleLayoutAction = null; private ShowNavigationAction showNavigationAction; + private ShowFlowLayerWindowAction showFlowLayerWindowAction; //private SimulateAction simulateAction = null; @@ -67,6 +68,7 @@ menu = add(new JMenu("Window")); menu.add(showNavigationAction = new ShowNavigationAction(applicationWindow)); + menu.add(showFlowLayerWindowAction = new ShowFlowLayerWindowAction(applicationWindow)); } public Editor getEditor() { diff --git a/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java b/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java index 794a44d..c692fa3 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java +++ b/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java @@ -1,6 +1,7 @@ package application; import application.editor.Editor; +import application.views.FlowLayerWindow; import application.views.NavigationWindow; import com.mxgraph.model.mxCell; import com.mxgraph.model.mxGeometry; @@ -26,6 +27,7 @@ private ApplicationMenuBar menuBar = null; private NavigationWindow navigationWindow; + private FlowLayerWindow showFlowLayerWindow = null; public ApplicationWindow() { setTitle(title); @@ -58,7 +60,12 @@ navigationWindow = new NavigationWindow(this, editor); navigationWindow.setVisible(true); + + showFlowLayerWindow = new FlowLayerWindow(this); + showFlowLayerWindow.setVisible(false); + editor.addStageChangeListener(navigationWindow); + editor.addStageChangeListener(showFlowLayerWindow); } public mxGraph getGraph() { @@ -80,4 +87,8 @@ public void showNavigationWindow() { navigationWindow.setVisible(true); } -} + + public void showSwitchLayerWindow(){ + showFlowLayerWindow.setVisible(true); + } +} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/src/application/actions/ShowFlowLayerWindowAction.java b/AlgebraicDataflowArchitectureModel/src/application/actions/ShowFlowLayerWindowAction.java new file mode 100644 index 0000000..a73a535 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/application/actions/ShowFlowLayerWindowAction.java @@ -0,0 +1,17 @@ +package application.actions; + +import application.ApplicationWindow; + +import java.awt.event.ActionEvent; + +public class ShowFlowLayerWindowAction extends AbstractSystemAction { + + public ShowFlowLayerWindowAction(ApplicationWindow frame) { + super(/*propName*/"Show FlowLayer", frame); + } + + @Override + public void actionPerformed(ActionEvent e) { + frame.showSwitchLayerWindow(); + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index 30b667a..62c3780 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -15,7 +15,6 @@ import com.mxgraph.view.mxGraph; import com.mxgraph.view.mxGraphView; import models.EdgeAttribute; -import models.algebra.Expression; import models.algebra.Symbol; import models.algebra.Variable; import models.dataConstraintModel.Channel; @@ -280,8 +279,10 @@ 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 dataFlowLayer = (mxCell) ((mxCell) root).getChildAt(Stage.DATA_FLOW_LAYER); + + 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); @@ -290,14 +291,6 @@ 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"); - } - } - for (ResourcePath res : model.getResourcePaths()) { if (res != null && state.getLabel().equals(res.getLeafResourceName())) fileString.append("\tnode r ").append(state.getLabel()).append(":").append(x).append(",").append(y).append(",").append(w).append(",").append(h).append("\n"); @@ -308,6 +301,13 @@ fileString.append("\tnode ioc ").append(state.getLabel()).append(":").append(x).append(",").append(y).append(",").append(w).append(",").append(h).append("\n"); } } + 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"); @@ -316,11 +316,14 @@ public void setDAGLayout() { 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(root); + ctl.execute(dataFlowLayer); +// for(int i = 0; i < dataFlowLayer.getChildCount(); i++){ +// ctl.execute(dataFlowLayer.getChildAt(i)); +// } } finally { graph.getModel().endUpdate(); } @@ -328,7 +331,6 @@ public void setTreeLayout() { mxCell root = (mxCell) graph.getDefaultParent(); - graph.getModel().beginUpdate(); try { mxCompactTreeLayout ctl = new mxCompactTreeLayout(graph); @@ -345,7 +347,6 @@ public void setCircleLayout() { mxCell root = (mxCell) graph.getDefaultParent(); - graph.getModel().beginUpdate(); try { mxCircleLayout ctl = new mxCircleLayout(graph); diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java index 33114bd..8eb198e 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Stage.java @@ -1,5 +1,6 @@ package application.editor; +import com.mxgraph.model.mxCell; import com.mxgraph.swing.mxGraphComponent; import com.mxgraph.swing.view.mxICellEditor; import com.mxgraph.util.mxEventSource.mxIEventListener; @@ -18,6 +19,11 @@ protected mxGraphComponent graphComponent; protected mxGraph graph; + public static final int NODE_LAYER = 0; + public static final int DATA_FLOW_LAYER = 0; + public static final int PUSH_FLOW_LAYER = 1; + public static final int PULL_FLOW_LAYER = 2; + public Stage(mxGraphComponent graphComponent) { this.graphComponent = graphComponent; this.graph = graphComponent.getGraph(); @@ -36,4 +42,54 @@ public DataTransferModel getModel() { return model; } -} + + /** + * Constructs the hierarchical layer structure under the root cell. + */ + public void constructLayer(mxGraph graph){ + mxCell root = (mxCell) graph.getDefaultParent(); + + mxCell nodeAndDataFlowLayer = new mxCell(); // 0 + mxCell pushFlowLayer = new mxCell(); // 1 + mxCell pullFlowLayer = new mxCell(); // 2 + + graph.getModel().beginUpdate(); + try { + graph.addCell(nodeAndDataFlowLayer, root); + graph.addCell(pushFlowLayer, root); + graph.addCell(pullFlowLayer, root); + } finally { + graph.getModel().endUpdate(); + } + } + + /** + * Enable or disable only the specified layer (layerNo) + */ + public void setEnabledForLayer(final int layerNo, final boolean isEnable){ + mxCell rootCell = (mxCell) graph.getDefaultParent(); + if(rootCell == null) return; + if(rootCell.getChildCount() <= 0) return; + + graph.getModel().setVisible(rootCell.getChildAt(layerNo), isEnable); + graph.refresh(); + } + + /** + * After hiding all layers, show only the specified ones (argsOfLayers) + */ + public void showOnlyLayer(final int... argsOfLayers){ + mxCell rootCell = (mxCell) graph.getDefaultParent(); + if(rootCell == null) return; + if(rootCell.getChildCount() <= 0) return; + + + for(int i = 0; i < rootCell.getChildCount(); i++){ + graph.getModel().setVisible(rootCell.getChildAt(i), false); + } + + for(int layerNo : argsOfLayers){ + graph.getModel().setVisible(rootCell.getChildAt(layerNo), true); + } + } +} \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java index 6c97196..d3a550e 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java @@ -98,6 +98,7 @@ model = null; ((mxGraphModel) graph.getModel()).clear(); + constructLayer(this.graph); } public DataTransferModel getModel() { @@ -159,9 +160,10 @@ graph.getModel().beginUpdate(); mxCell root = (mxCell) graph.getDefaultParent(); + mxCell layer = (mxCell) root.getChildAt(DATA_FLOW_LAYER); try { if (parentNode == null) { - mxCell resCell = (mxCell) graph.insertVertex(root, null, resourceNode.getPrimaryResourcePath().getName(), 20, 20, 80, 30, "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top"); // insert a resource as a vertex + mxCell resCell = (mxCell) graph.insertVertex(layer, null, resourceNode.getPrimaryResourcePath().getName(), 20, 20, 80, 30, "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top"); // insert a resource as a vertex resNodeToCell.put(resourceNode, resCell); cellToResNode.put(resCell, resourceNode); } else { @@ -182,6 +184,7 @@ graph.getModel().beginUpdate(); mxCell root = (mxCell) graph.getDefaultParent(); + mxCell layer = (mxCell) root.getChildAt(DATA_FLOW_LAYER); try { mxGeometry geo1 = new mxGeometry(0, 0.5, PORT_DIAMETER, PORT_DIAMETER); geo1.setOffset(new mxPoint(-PORT_RADIUS, -PORT_RADIUS)); @@ -203,7 +206,7 @@ } channelName += ")"; } - Object chCell = graph.insertVertex(root, null, channelName, 150, 20, 30, 30, "verticalAlign=top"); // insert a channel as a vertex + Object chCell = graph.insertVertex(layer, null, channelName, 150, 20, 30, 30, "verticalAlign=top"); // insert a channel as a vertex mxCell port_in = new mxCell(null, geo1, "shape=ellipse;perimter=ellipsePerimeter"); port_in.setVertex(true); graph.addCell(port_in, chCell); // insert the input port of a channel @@ -224,6 +227,7 @@ graph.getModel().beginUpdate(); mxCell root = (mxCell) graph.getDefaultParent(); + mxCell layer = (mxCell) root.getChildAt(NODE_LAYER); try { mxGeometry geo2 = new mxGeometry(1.0, 0.5, PORT_DIAMETER, PORT_DIAMETER); geo2.setOffset(new mxPoint(-PORT_RADIUS, -PORT_RADIUS)); @@ -241,7 +245,7 @@ } channelName += ")"; } - Object chCell = graph.insertVertex(root, null, channelName, 150, 20, 30, 30, "verticalAlign=top"); // insert an I/O channel as a vertex + Object chCell = graph.insertVertex(layer, null, channelName, 150, 20, 30, 30, "verticalAlign=top"); // insert an I/O channel as a vertex mxCell port_out = new mxCell(null, geo2, "shape=ellipse;perimter=ellipsePerimeter"); port_out.setVertex(true); graph.addCell(port_out, chCell); // insert the output port of a channel @@ -258,6 +262,7 @@ graph.getModel().beginUpdate(); mxCell root = (mxCell) graph.getDefaultParent(); + mxCell layer = (mxCell) root.getChildAt(DATA_FLOW_LAYER); try { mxGeometry geo1 = new mxGeometry(0, 0.5, PORT_DIAMETER, PORT_DIAMETER); geo1.setOffset(new mxPoint(-PORT_RADIUS, -PORT_RADIUS)); @@ -279,7 +284,7 @@ } channelName += ")"; } - Object chCell = graph.insertVertex(root, null, channelName, 150, 20, 30, 30, "verticalAlign=top"); // insert a channel as a vertex + Object chCell = graph.insertVertex(layer, null, channelName, 150, 20, 30, 30, "verticalAlign=top"); // insert a channel as a vertex mxCell port_in = new mxCell(null, geo1, "shape=ellipse;perimter=ellipsePerimeter"); port_in.setVertex(true); graph.addCell(port_in, chCell); // insert the input port of a channel diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java index b1e32e7..9ba5b43 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java @@ -37,6 +37,7 @@ if (prevStage instanceof DataFlowModelingStage) { model = prevStage.getModel(); dataFlowGraph = analyzeDataTransferModel(model); + showOnlyLayer(DATA_FLOW_LAYER); } } @@ -83,15 +84,17 @@ DataFlowGraph flowGraph = DataTransferModelAnalyzer.createDataFlowGraphWithStateStoringAttribute(model); dataFlowGraph = DataTransferModelAnalyzer.annotateWithSelectableDataTransferAttiribute(flowGraph); mxCell parent = (mxCell) graph.getDefaultParent(); - if (parent.getChildCount() == 0) { - constructGraph(); // Construct data-flow graph (on file open action) - } + mxCell layer = (mxCell) parent.getChildAt(DATA_FLOW_LAYER); + if (layer.getChildCount() == 0) { + constructGraph(); // Construct data-flow graph (on file open action) + } // Construct data-flow graph (on file open action) updateEdgeAttributes(dataFlowGraph); // Update push/pull selection pull-downs return dataFlowGraph; } private void updateEdgeAttributes(DataFlowGraph dataFlowGraph) { mxCell root = (mxCell) graph.getDefaultParent(); + mxCell layer = (mxCell) root.getChildAt(DATA_FLOW_LAYER); graph.getModel().beginUpdate(); try { @@ -103,7 +106,7 @@ ResourceNode srcRes = (ResourceNode) dataFlow.getSource(); DataTransferChannel channel = ((ChannelNode) dataFlow.getDestination()).getChannel(); // input edge - for (Object edge : graph.getChildEdges(root)) { + for (Object edge : graph.getChildEdges(layer)) { mxCell edgeCell = (mxCell) edge; if (edgeCell.getValue() instanceof Editor.SrcDstAttribute) { Editor.SrcDstAttribute edgeAttr = (Editor.SrcDstAttribute) edgeCell.getValue(); @@ -127,7 +130,10 @@ */ public void constructGraph() { ((mxGraphModel) graph.getModel()).clear(); + constructLayer(this.graph); + mxCell parent = (mxCell) graph.getDefaultParent(); + mxCell layer = (mxCell) parent.getChildAt(DATA_FLOW_LAYER); graph.getModel().beginUpdate(); try { @@ -149,8 +155,9 @@ int w = 80; int h = 30; ResourcePath resourcePath = resourceNode.getPrimaryResourcePath(); - mxCell resourceCell = (mxCell) graph.insertVertex(parent, null, resourcePath.getLeafResourceName(), 20, 20, w, h, "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top"); // insert a resource as a vertex + mxCell resourceCell = (mxCell) graph.insertVertex(layer, null, resourcePath.getLeafResourceName(), 20, 20, w, h, "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top"); // insert a resource as a vertex resNodeToCell.put(resourceNode, resourceCell); + createChildResourceVertices(resourceCell, resourceNode, w, h); } @@ -178,7 +185,7 @@ w *= 2; h *= 2; } - mxCell channelCell = (mxCell) graph.insertVertex(parent, null, channelName, 150, 20, w, h, "verticalAlign=top"); // insert a channel as a vertex + mxCell channelCell = (mxCell) graph.insertVertex(layer, null, channelName, 150, 20, w, h, "verticalAlign=top"); // insert a channel as a vertex channelToCell.put(channel, channelCell); mxCell portIn = new mxCell(null, geoPortIn, "shape=ellipse;perimter=ellipsePerimeter"); @@ -213,7 +220,7 @@ w *= 2; h *= 2; } - mxCell channelCell = (mxCell) graph.insertVertex(parent, null, channelName, 150, 20, w, h, "verticalAlign=top"); // insert a channel as a vertex + mxCell channelCell = (mxCell) graph.insertVertex(layer, null, channelName, 150, 20, w, h, "verticalAlign=top"); // insert a channel as a vertex channelToCell.put(channel, channelCell); mxCell portOut = new mxCell(null, geoPortOut, "shape=ellipse;perimter=ellipsePerimeter"); @@ -232,17 +239,17 @@ // output edge DataTransferChannel channel = ((ChannelNode) dataFlowEdge.getSource()).getChannel(); ResourcePath dstRes = ((ResourceNode) dataFlowEdge.getDestination()).getInSideResource(channel); - graph.insertEdge(parent, null, new Editor.SrcDstAttribute(channel, dstRes), channelOutToCell.get(channel), resNodeToCell.get((ResourceNode) dataFlowEdge.getDestination()), "movable=false"); + graph.insertEdge(layer, null, new Editor.SrcDstAttribute(channel, dstRes), channelOutToCell.get(channel), resNodeToCell.get((ResourceNode) dataFlowEdge.getDestination()), "movable=false"); } else { // input edge DataTransferChannel channel = ((ChannelNode) dataFlowEdge.getDestination()).getChannel(); ResourcePath srcRes = ((ResourceNode) dataFlowEdge.getSource()).getOutSideResource(channel); Set> toRes = getResourceDependencyForChannel(channel, dataFlowGraph); for (Map.Entry RtoR : toRes) { - graph.insertEdge(parent, null, null, resNodeToCell.get(RtoR.getValue()), resNodeToCell.get(RtoR.getKey()), "dashed=true;movable=false"); + graph.insertEdge(layer, null, null, resNodeToCell.get(RtoR.getValue()), resNodeToCell.get(RtoR.getKey()), "dashed=true;movable=false"); } - graph.insertEdge(parent, null, new Editor.SrcDstAttribute(srcRes, channel), resNodeToCell.get((ResourceNode) dataFlowEdge.getSource()), channelInToCell.get(channel), "movable=false"); + graph.insertEdge(layer, null, new Editor.SrcDstAttribute(srcRes, channel), resNodeToCell.get((ResourceNode) dataFlowEdge.getSource()), channelInToCell.get(channel), "movable=false"); } } @@ -250,7 +257,7 @@ // reference edges DataTransferChannel channel = (DataTransferChannel) ch; for (ResourcePath refRes : channel.getReferenceResources()) { - graph.insertEdge(parent, null, null, resNodeToCell.get(dataFlowGraph.getResourceNode(refRes)), channelInToCell.get(channel), "dashed=true;movable=false"); + graph.insertEdge(layer, null, null, resNodeToCell.get(dataFlowGraph.getResourceNode(refRes)), channelInToCell.get(channel), "dashed=true;movable=false"); } } } finally { diff --git a/AlgebraicDataflowArchitectureModel/src/application/views/FlowLayerWindow.java b/AlgebraicDataflowArchitectureModel/src/application/views/FlowLayerWindow.java new file mode 100644 index 0000000..ae2749a --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/application/views/FlowLayerWindow.java @@ -0,0 +1,82 @@ +package application.views; + +import application.ApplicationWindow; +import application.editor.Editor; +import application.editor.IStageChangeListener; +import application.editor.Stage; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class FlowLayerWindow extends JDialog implements IStageChangeListener { + private String title = "Flow Layer"; + private JCheckBox dataFlowCheckBox = null; + private JCheckBox pushFlowCheckBox = null; + private JCheckBox pullFlowCheckBox = null; + + private Stage stage = null; + + public FlowLayerWindow(final ApplicationWindow owner){ + super(owner); + + setTitle(title); + setDefaultCloseOperation(HIDE_ON_CLOSE); + + stage = Editor.STAGE_PUSH_PULL_SELECTION; + + //ボタンの追加 + dataFlowCheckBox = new JCheckBox("Data-Flow", false); + pushFlowCheckBox = new JCheckBox("Push-Flow", true); + pullFlowCheckBox = new JCheckBox("Pull-Flow", true); + + // 各Viewにイベントハンドラを追加 + dataFlowCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + stage.setEnabledForLayer(Stage.DATA_FLOW_LAYER, dataFlowCheckBox.isSelected()); + }}); + + pushFlowCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + stage.setEnabledForLayer(Stage.PUSH_FLOW_LAYER, pushFlowCheckBox.isSelected()); + }}); + + pullFlowCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + stage.setEnabledForLayer(Stage.PULL_FLOW_LAYER, pullFlowCheckBox.isSelected()); + }}); + + dataFlowCheckBox.setEnabled(false); + pushFlowCheckBox.setEnabled(false); + pullFlowCheckBox.setEnabled(false); + + // レイヤーのパネルレイアウトの初期化. + Container panel = getContentPane(); + panel.setLayout(new GridLayout(/*low*/4, /*col*/1)); + panel.add(dataFlowCheckBox); + panel.add(pushFlowCheckBox); + panel.add(pullFlowCheckBox); + Point location = new Point(owner.getX() + (owner.getWidth() / 2) - (this.getWidth() / 2), owner.getY() + (owner.getHeight() / 2) - (this.getHeight() / 2)); + setLocation(location); + + pack(); + setResizable(false); + } + + /** + * When the stage changes, toggle the active state of layer visibility buttons + */ + @Override + public void stageChanged(Stage newStage) { + dataFlowCheckBox.setEnabled(false); + pushFlowCheckBox.setEnabled(false); + pullFlowCheckBox.setEnabled(false); + + newStage.setEnabledForLayer(Stage.PUSH_FLOW_LAYER, false); + newStage.setEnabledForLayer(Stage.PULL_FLOW_LAYER, false); + } +} diff --git a/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java b/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java index eae7ac7..2ea990b 100644 --- a/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java +++ b/AlgebraicDataflowArchitectureModel/src/parser/ParserDTRAM.java @@ -3,6 +3,7 @@ import java.io.BufferedReader; import java.io.IOException; +import application.editor.Stage; import com.mxgraph.model.mxCell; import com.mxgraph.model.mxGeometry; import com.mxgraph.model.mxIGraphModel; @@ -160,10 +161,27 @@ int hC = Integer.parseInt(h); Object root = graph.getDefaultParent(); + mxCell nodeLayer = (mxCell) ((mxCell) root).getChildAt(Stage.NODE_LAYER); + mxCell dataFlowLayer = (mxCell) ((mxCell) root).getChildAt(Stage.DATA_FLOW_LAYER); mxIGraphModel graphModel = graph.getModel(); - for (int i = 0; i < graph.getModel().getChildCount(root); i++) { + for (int i = 0; i < graph.getModel().getChildCount(nodeLayer); i++) { - Object cell = graph.getModel().getChildAt(root, i); + Object cell = graph.getModel().getChildAt(nodeLayer, i); + if (!graph.getModel().isVertex(cell)) continue; + + mxGeometry geom = (mxGeometry) ((mxCell) cell).getGeometry().clone(); + mxGraphView view = graph.getView(); + mxCellState state = view.getState(cell); + + if (!name.equals(state.getLabel())) continue; + + geom.setX(xC); + geom.setY(yC); + graphModel.setGeometry(cell, geom); + } + for (int i = 0; i < graph.getModel().getChildCount(dataFlowLayer); i++) { + + Object cell = graph.getModel().getChildAt(dataFlowLayer, i); if (!graph.getModel().isVertex(cell)) continue; mxGeometry geom = (mxGeometry) ((mxCell) cell).getGeometry().clone();