net.sourceforge.plantuml.FileFormat Java Examples

The following examples show how to use net.sourceforge.plantuml.FileFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPlUmlEditor.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Nullable
@UiThread
private String renderPageAsAscII() {
  final String theText = this.preprocessEditorText(this.editor.getText());

  final SourceStringReader reader = new SourceStringReader(theText, "UTF-8");
  final int totalPages = Math.max(countNewPages(theText), reader.getBlocks().size());

  final int imageIndex = Math.max(1, Math.min(this.pageNumberToRender, totalPages));

  final ByteArrayOutputStream utfBuffer = new ByteArrayOutputStream();

  try {
    final DiagramDescription description = reader
        .outputImage(utfBuffer, imageIndex - 1, new FileFormatOption(FileFormat.ATXT, false));
    final String result = new String(utfBuffer.toByteArray(), StandardCharsets.UTF_8);
    if (result.contains("java.lang.UnsupportedOperationException: ATXT")) {
      throw new UnsupportedOperationException("ATXT is not supported for the diagram");
    }
    return result;
  } catch (Exception ex) {
    logger.error("Can't export ASCII image", ex);
    return null;
  }
}
 
Example #2
Source File: DiagramGenerator.java    From Ratel with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #3
Source File: Uml.java    From umlbot with GNU General Public License v3.0 5 votes vote down vote up
Object imgs(Request request, Response response) throws Exception {
	return request.params("encoded").map(Trial.of(transcoder()::decode))
			.map(t -> t.either(SourceStringReader::new, ex -> {
				LOG.fatal(ex.getMessage(), ex);
				return null;
			}))
			.map(v -> response.type("image/png").render(v,
					Renderer.ofStream((m, os) -> m.generateImage(os, new FileFormatOption(FileFormat.PNG, false)))))
			.orElse(404);
}
 
Example #4
Source File: PlantUmlVerbatimSerializer.java    From protostuff-compiler with Apache License 2.0 4 votes vote down vote up
@Override
public FileFormatOption getFormatOption() {
    return new FileFormatOption(FileFormat.SVG);
}
 
Example #5
Source File: PlantUmlVerbatimSerializer.java    From protostuff-compiler with Apache License 2.0 4 votes vote down vote up
@Override
public FileFormatOption getFormatOption() {
    return new FileFormatOption(FileFormat.PNG);
}