本文整理汇总了Java中net.sourceforge.plantuml.SourceStringReader.generateImage方法的典型用法代码示例。如果您正苦于以下问题:Java SourceStringReader.generateImage方法的具体用法?Java SourceStringReader.generateImage怎么用?Java SourceStringReader.generateImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sourceforge.plantuml.SourceStringReader
的用法示例。
在下文中一共展示了SourceStringReader.generateImage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateUMLStateMachine
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
public void generateUMLStateMachine(File outputDir, StateMachineType stateMachine,
STErrorListener errorListener) throws IOException {
StringWriter stringWriter = new StringWriter();
NoIndentWriter writer = new NoIndentWriter(stringWriter);
ST stStates = stGroup.getInstanceOf("stateMachine");
stStates.add("stateMachine", stateMachine);
stStates.write(writer, errorListener);
String umlString = stringWriter.toString();
SourceStringReader reader = new SourceStringReader(umlString);
File outputFile = new File(outputDir, String.format("%s.png", stateMachine.getName()));
FileOutputStream png = new FileOutputStream(outputFile);
String desc = reader.generateImage(png);
}
示例2: generateUMLSequence
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
public void generateUMLSequence(File outputDir, MessageType message, FlowType flow,
List<ResponseType> responseList, STErrorListener errorListener) throws IOException {
StringWriter stringWriter = new StringWriter();
NoIndentWriter writer = new NoIndentWriter(stringWriter);
ST stSequence = stGroup.getInstanceOf("sequence");
stSequence.add("message", message);
stSequence.add("flow", flow);
stSequence.write(writer, errorListener);
generateResponses(responseList, writer, errorListener);
ST stEnd = stGroup.getInstanceOf("sequenceEnd");
stEnd.add("message", message);
stEnd.write(writer, errorListener);
String umlString = stringWriter.toString();
SourceStringReader reader = new SourceStringReader(umlString);
File outputFile =
new File(outputDir, String.format("%s-%s.png", message.getName(), message.getScenario()));
FileOutputStream png = new FileOutputStream(outputFile);
String desc = reader.generateImage(png);
}
示例3: serialize
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
@Override
public void serialize(VerbatimNode node, Printer printer) {
Type type = Type.getByName(node.getType());
String formatted = type.wrap(node.getText());
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
SourceStringReader reader = new SourceStringReader(formatted);
String desc;
try {
desc = reader.generateImage(baos, type.getFormatOption());
} catch (IOException e) {
throw new GeneratorException("Could not generate uml for node " + node, e);
}
final String rendered = type.render(baos.toByteArray(), desc);
printer.print(rendered);
}
示例4: processImage
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
public void processImage(String fileName) throws IOException {
if (fileName.startsWith("/")) {
throw new IllegalArgumentException();
}
final SourceStringReader sourceStringReader = new SourceStringReader(incoming.get(fileName));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final FileFormat format = FileFormat.PNG;
final DiagramDescription desc = sourceStringReader.generateDiagramDescription(baos,
new FileFormatOption(format));
final String pngFileName = format.changeName(fileName, 0);
final String errorFileName = pngFileName.substring(0, pngFileName.length() - 4) + ".err";
synchronized (this) {
outgoing.remove(pngFileName);
outgoing.remove(errorFileName);
if (desc != null && desc.getDescription() != null) {
outgoing.put(pngFileName, baos.toByteArray());
if (desc.getDescription().startsWith("(Error)")) {
final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
sourceStringReader.generateImage(errBaos, new FileFormatOption(FileFormat.ATXT));
errBaos.close();
outgoing.put(errorFileName, errBaos.toByteArray());
}
}
}
}
示例5: applyOnFixtures
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
@Override
public String applyOnFixtures(List<FixtureCallResult> fixtureCallResults, String... parameters) {
String plantUml = plantUmlSequenceDiagramGenerator.getPlantUmlScript(fixtureCallResults);
SourceStringReader reader = new SourceStringReader(plantUml);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
reader.generateImage(os, new FileFormatOption(FileFormat.SVG));
os.close();
return new String(os.toByteArray());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例6: createSvg
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
private String createSvg(String plantUmlMarkup) {
SourceStringReader reader = new SourceStringReader(plantUmlMarkup);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
reader.generateImage(os, new FileFormatOption(SVG));
os.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
return new String(os.toByteArray());
}
示例7: unitConversionSkill
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
@Test
public void unitConversionSkill() throws IOException {
reset(factService);
final Skill skill = skillRepo.get("unitConversion");
final String uml = skill.renderUml();
log.info("UML:\n{}", uml);
final SourceStringReader reader = new SourceStringReader(uml);
final File tempFile = new File(FileUtils.getTempDirectory(), "lumen_skill_unitConversion.png");
final String generated = reader.generateImage(tempFile);
log.info("Generated UML Activity Diagram {} to {}", generated, tempFile);
}
示例8: storeDiagram
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
private void storeDiagram(String source, String fileName) throws IOException, FileNotFoundException {
SourceStringReader reader = new SourceStringReader(source);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
// Write the first image to "os"
reader.generateImage(os, new FileFormatOption(FileFormat.SVG));
os.close();
FileOutputStream fos = new FileOutputStream(fileName);
reader.generateImage(fos, new FileFormatOption(FileFormat.PNG));
fos.close();
}
示例9: processImage
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
public void processImage(String fileName) throws IOException {
if (fileName.startsWith("/")) {
throw new IllegalArgumentException();
}
final String pngFileName = getFutureFileName(fileName);
boolean done = false;
try {
final SourceStringReader sourceStringReader = new SourceStringReader(incoming.get(fileName));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final FileFormat format = getFileFormat();
final DiagramDescription desc = sourceStringReader.generateDiagramDescription(baos, new FileFormatOption(
format));
final String errorFileName = pngFileName.substring(0, pngFileName.length() - 4) + ".err";
synchronized (this) {
outgoing.remove(pngFileName);
futureOutgoing.remove(pngFileName);
outgoing.remove(errorFileName);
if (desc != null && desc.getDescription() != null) {
outgoing.put(pngFileName, baos.toByteArray());
done = true;
if (desc.getDescription().startsWith("(Error)")) {
final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
sourceStringReader.generateImage(errBaos, new FileFormatOption(FileFormat.ATXT));
errBaos.close();
outgoing.put(errorFileName, errBaos.toByteArray());
}
}
}
} finally {
if (done == false) {
outgoing.put(pngFileName, new byte[0]);
}
}
}
示例10: run
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
public void run() {
try {
final String uml = runInternal();
Log.println("UML=" + uml);
final SourceStringReader s = new SourceStringReader(uml);
s.generateImage(os, new FileFormatOption(FileFormat.ATXT));
os.close();
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例11: generatePNG
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
public void generatePNG(String output) throws IOException {
try {
OutputStream png = new FileOutputStream (output);
SourceStringReader reader = new SourceStringReader(this.toString());
String desc = reader.generateImage(png);
png.close();
}
catch ( Exception e) { e.printStackTrace(); }
}
示例12: render
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
public void render(final List<TracingEvent> messages) {
try {
final OutputStream png = new FileOutputStream("out.png");
String source = "@startuml\n";
for (final TracingEvent message : messages) {
// TODO use renderers and remove asXXXMessage methods
switch (message.getTraceType()) {
case ENTRY:
source += message.asCallMessage()+"\n";
break;
case EXIT:
source += message.asExitMessage()+"\n";
break;
case EXCEPTION:
source += message.getTarget().getName() + " -> " + message.getSource().getName() + " : <color:red>throws" + "(" + Arrays.deepToString(message.getArgs()) + ")</color>"+"\n";
break;
}
}
source += "@enduml\n";
final SourceStringReader reader = new SourceStringReader(source);
reader.generateImage(png);
} catch (IOException e) {
e.printStackTrace();
}
}
示例13: generateImage
import net.sourceforge.plantuml.SourceStringReader; //导入方法依赖的package包/类
@Override
protected void generateImage(File pngFile, NamedBlockNode named) throws Exception {
log.debug("About to generated PlantUML diagram as PNG files {}", pngFile.getAbsolutePath());
OutputStream png = new FileOutputStream(pngFile);
String source = named.getBody();
SourceStringReader reader = new SourceStringReader(source);
String desc = reader.generateImage(png);
log.info("PlantUML diagram generated as PNG files {} (description: {})", pngFile.getAbsolutePath(), desc);
}