All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.plantuml.PlainDiagram Maven / Gradle / Ivy

There is a newer version: 1.2024.8
Show newest version
// 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;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy