エディターに一連のアルゴリズムを追加(正常には動作していない)
1 parent 75746f3 commit 8a80a76047ae23db9c0492d49bbbf59c02e5c35f
yoichiro authored on 5 Apr 2020
Showing 3 changed files
View
13
AlgebraicDataflowArchitectureModel/src/algorithm/CodeGenerator.java
if (((StoreAttribute) resource.getAttribute()).isStored()) {
for (Node pn : resource.getSuccessors()) {
str += ((ResourceNode) pn).getIdentifierTemplate().getResourceName().substring(0, 1).toUpperCase() + ((ResourceNode) pn).getIdentifierTemplate().getResourceName().substring(1) + ",";
}
if(str.substring(str.length() - 1, str.length()) == ",") str = str.substring(0, str.length() - 1);
}
str = str + ");";
str += ");";
codes.add(str);
}
codes.add("}");
for (Node n : graph.getNodes()) {
ResourceNode resource = (ResourceNode) n;
codes.add("public class " + resource.getIdentifierTemplate().getResourceName() + " {");
codes.add("public class " + resource.getIdentifierTemplate().getResourceName().substring(0, 1)
.toUpperCase() + resource.getIdentifierTemplate().getResourceName().substring(1) + " {");
if(((StoreAttribute) resource.getAttribute()).isStored()) {
}
codes.add("}");
}
return codes;
}
View
6
AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/PrototypeGenerateAction.java
package graphicalrefactor.actions;
 
import java.awt.event.ActionEvent;
 
import algorithm.CodeGenerator;
import algorithm.DataStorageDecision;
import graphicalrefactor.editor.Editor;
import models.dataFlowModel.ResourceDependencyGraph;
 
public class PrototypeGenerateAction extends AbstractEditorAction {
/**
*
}
 
@Override
public void actionPerformed(ActionEvent e) {
ResourceDependencyGraph graph = editor.getResourceGraph();
DataStorageDecision.run(graph);
CodeGenerator.doGenerate(graph);
}
 
}
View
21
AlgebraicDataflowArchitectureModel/src/graphicalrefactor/editor/Editor.java
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;
}