Search in sources :

Example 6 with FileFormatOption

use of net.sourceforge.plantuml.FileFormatOption in project netbeans-mmd-plugin by raydac.

the class PlantUmlTextEditor method renderCurrentTextInPlantUml.

private void renderCurrentTextInPlantUml() {
    final String text = this.editor.getText();
    final SourceStringReader reader = new SourceStringReader(text, "UTF-8");
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(131072);
    try {
        reader.outputImage(buffer, new FileFormatOption(FileFormat.PNG, false));
        this.imageComponent.setImage(ImageIO.read(new ByteArrayInputStream(buffer.toByteArray())));
        this.renderedScrollPane.revalidate();
    } catch (IOException e) {
        LOGGER.error("Can't render plant uml", e);
        this.renderedScrollPane.setViewportView(new JLabel("Error during rendering"));
    }
}
Also used : FileFormatOption(net.sourceforge.plantuml.FileFormatOption) ByteArrayInputStream(java.io.ByteArrayInputStream) SourceStringReader(net.sourceforge.plantuml.SourceStringReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

FileFormatOption (net.sourceforge.plantuml.FileFormatOption)6 SourceStringReader (net.sourceforge.plantuml.SourceStringReader)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 BlockUml (net.sourceforge.plantuml.BlockUml)2 NullOutputStream (net.sourceforge.plantuml.NullOutputStream)2 Diagram (net.sourceforge.plantuml.core.Diagram)2 DiagramDescription (net.sourceforge.plantuml.core.DiagramDescription)2 ImageData (net.sourceforge.plantuml.core.ImageData)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 Nonnull (javax.annotation.Nonnull)1 FileFilter (javax.swing.filechooser.FileFilter)1 CannotRedoException (javax.swing.undo.CannotRedoException)1 CannotUndoException (javax.swing.undo.CannotUndoException)1