| |
---|
| | import com.mxgraph.model.mxGraphModel; |
---|
| | import com.mxgraph.util.mxPoint; |
---|
| | import com.mxgraph.view.mxGraph; |
---|
| | |
---|
| | import algorithm.DataStorageNecessity; |
---|
| | import algorithm.EdgeTransitionSelectable; |
---|
| | import algorithm.UpdateConflictCheck; |
---|
| | import models.Edge; |
---|
| | import models.Node; |
---|
| | import models.dataFlowModel.DataFlowModel; |
---|
| | import models.dataFlowModel.DataflowChannelGenerator; |
---|
| |
---|
| | final int PORT_RADIUS = PORT_DIAMETER / 2; |
---|
| | |
---|
| | private mxGraph graph = null; |
---|
| | private DataFlowModel model = null; |
---|
| | private ResourceDependencyGraph resourceGraph = null; |
---|
| | |
---|
| | public Editor(mxGraph graph) { |
---|
| | this.graph = graph; |
---|
| | } |
---|
| |
---|
| | public void setModel(DataFlowModel model) { |
---|
| | this.model = model; |
---|
| | } |
---|
| | |
---|
| | public ResourceDependencyGraph getResourceGraph() { |
---|
| | return resourceGraph; |
---|
| | } |
---|
| | |
---|
| | public void setResourceGraph(ResourceDependencyGraph resourceGraph) { |
---|
| | this.resourceGraph = resourceGraph; |
---|
| | } |
---|
| | |
---|
| | public DataFlowModel open(File file) { |
---|
| | try { |
---|
| | Parser parser = new Parser(new BufferedReader(new FileReader(file))); |
---|
| | try { |
---|
| | model = parser.doParse(); |
---|
| | |
---|
| | if(!UpdateConflictCheck.run(model)) return null; |
---|
| | graph = constructGraph(model); |
---|
| | return model; |
---|
| | } catch (ExpectedChannel | ExpectedChannelName | ExpectedLeftCurlyBracket | ExpectedInOrOutKeyword |
---|
| | | ExpectedStateTransition | ExpectedEquals | ExpectedRHSExpression | WrongLHSExpression |
---|
| |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | public mxGraph constructGraph(DataFlowModel model) { |
---|
| | ResourceDependencyGraph resourceDependencyGraph = model.getResourceDependencyGraph(); |
---|
| | |
---|
| | ResourceDependencyGraph resourceDependencyGraph = DataStorageNecessity.run(model); |
---|
| | EdgeTransitionSelectable.run(resourceDependencyGraph); |
---|
| | |
---|
| | ((mxGraphModel) graph.getModel()).clear(); |
---|
| | Object parent = graph.getDefaultParent(); |
---|
| | graph.getModel().beginUpdate(); |
---|
| | try { |
---|
| |
---|
| | } finally { |
---|
| | graph.getModel().endUpdate(); |
---|
| | } |
---|
| | setTreeLayout(); |
---|
| | setResourceGraph(resourceDependencyGraph); |
---|
| | |
---|
| | return graph; |
---|
| | } |
---|
| | |
---|
| |
---|
| | |