use of org.antlr.works.visualization.SDGenerator in project antlrworks by antlr.
the class ExportMenu method exportAllRules.
public void exportAllRules(boolean asImage) {
List<String> extensions = null;
if (asImage) {
extensions = lookupAvailableImageFormat();
}
if (!XJFileChooser.shared().displayChooseDirectory(window.getJavaContainer(), extensions, extensions, !asImage)) {
return;
}
String directory = XJFileChooser.shared().getSelectedFilePath();
String extension = XJFileChooser.shared().getSelectedFileExtension();
SDGenerator sd = new SDGenerator(window.getGrammarEngine());
for (ElementRule rule : window.getRules()) {
try {
if (asImage) {
sd.renderRuleToBitmapFile(rule.name, extension, XJUtils.concatPath(directory, rule.name + "." + extension));
} else {
sd.renderRuleToEPSFile(rule.name, XJUtils.concatPath(directory, rule.name + ".eps"));
}
} catch (Exception e) {
XJAlert.display(window.getJavaContainer(), "Error", "Images cannot be saved because:\n" + e);
}
}
}
use of org.antlr.works.visualization.SDGenerator in project antlrworks by antlr.
the class Console method processSyntaxDiagram.
private void processSyntaxDiagram(ProcessSyntaxDiagramDelegate delegate) throws Exception {
GrammarEngine engine = new GrammarEngineImpl(new EngineDelegate());
GrammarSyntaxEngine syntaxEngine = engine.getSyntaxEngine();
syntaxEngine.setDelegate(new SyntaxDelegate());
syntaxEngine.processSyntax();
engine.parserCompleted();
SDGenerator gen = new SDGenerator(engine);
delegate.beginProcess();
for (String name : engine.getRuleNames()) {
delegate.processRule(name, gen);
}
delegate.endProcess();
}
Aggregations