net.sourceforge.plantuml.PlainDiagram Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml;
import java.io.IOException;
import java.io.OutputStream;
import net.atmp.ImageBuilder;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.shape.UDrawable;
// This class doesnt feel like a wonderful idea, just a stepping stone towards something
public abstract class PlainDiagram extends AbstractPSystem {
// ::remove file when __HAXE__
public PlainDiagram(UmlSource source) {
super(source);
}
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption).margin(getDefaultMargins())
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null).seed(seed());
}
@Override
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
final UDrawable rootDrawable = getRootDrawable(fileFormatOption);
return createImageBuilder(fileFormatOption).drawable(rootDrawable).write(os);
}
@Override
public void exportDiagramGraphic(UGraphic ug) {
final FileFormatOption option = new FileFormatOption(FileFormat.PNG);
try {
final UDrawable rootDrawable = getRootDrawable(option);
rootDrawable.drawU(ug);
} catch (IOException e) {
e.printStackTrace();
super.exportDiagramGraphic(ug);
}
}
protected abstract UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException;
}