Java Code Examples for net.sourceforge.plantuml.FileFormat

The following examples show how to use net.sourceforge.plantuml.FileFormat. These examples are extracted from open source projects. 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 Project: netbeans-mmd-plugin   Source File:    License: Apache License 2.0 6 votes vote down vote up
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 Project: Ratel   Source File:    License: 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));
    FileOutputStream fos = new FileOutputStream(fileName);

    reader.generateImage(fos, new FileFormatOption(FileFormat.PNG));
Example 3
Source Project: umlbot   Source File:    License: 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)))))
Example 4
public FileFormatOption getFormatOption() {
    return new FileFormatOption(FileFormat.SVG);
Example 5
public FileFormatOption getFormatOption() {
    return new FileFormatOption(FileFormat.PNG);