1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-23 11:29:06 +00:00

Add AbstractPSystem.createImageBuilder(). Remove styledImageBuilder()

This commit is contained in:
matthew16550 2021-04-04 23:45:56 +10:00
parent b659ee4d3b
commit 935c52109b
27 changed files with 103 additions and 105 deletions

View File

@ -35,6 +35,8 @@
*/
package net.sourceforge.plantuml;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.imageBuilder;
import java.io.IOException;
import java.io.OutputStream;
@ -51,6 +53,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.version.License;
import net.sourceforge.plantuml.version.Version;
@ -160,6 +163,11 @@ public abstract class AbstractPSystem implements Diagram {
return scale;
}
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return imageBuilder(fileFormatOption);
}
// TODO "index" isnt really being used
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption
) throws IOException;

View File

@ -41,15 +41,12 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import java.io.IOException;
import java.io.OutputStream;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
// This class doesnt feel like a wonderful idea, just a stepping stone towards something
public abstract class PlainDiagram extends AbstractPSystem {
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
final UDrawable drawable = getRootDrawable(fileFormatOption);
return plainImageBuilder(drawable, fileFormatOption)
return super.createImageBuilder(fileFormatOption)
.margin(getDefaultMargins())
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null)
.seed(seed());
@ -59,13 +56,9 @@ public abstract class PlainDiagram extends AbstractPSystem {
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
final ImageBuilder builder = createImageBuilder(fileFormatOption);
return adjustImageBuilder(builder).write(os);
}
// kind of a kludge but good enough for now!
protected ImageBuilder adjustImageBuilder(ImageBuilder builder) {
return builder;
return createImageBuilder(fileFormatOption)
.drawable(getRootDrawable(fileFormatOption))
.write(os);
}
protected abstract UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException;

View File

@ -51,6 +51,7 @@ import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.sprite.Sprite;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated {
@ -230,4 +231,10 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
final public Animation getAnimation() {
return animation;
}
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.styled(this);
}
}

View File

@ -62,8 +62,6 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.comp.CompressionMode;
import net.sourceforge.plantuml.ugraphic.comp.CompressionXorYBuilder;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ActivityDiagram3 extends UmlDiagram {
enum SwimlaneStrategy {
@ -205,7 +203,8 @@ public class ActivityDiagram3 extends UmlDiagram {
result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder);
result = new TextBlockRecentred(result);
return styledImageBuilder(this, result, index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(result)
.write(os);
}

View File

@ -60,8 +60,6 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class BoardDiagram extends UmlDiagram {
private final List<Activity> activities = new ArrayList<Activity>();
@ -78,7 +76,8 @@ public class BoardDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -49,8 +49,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.UDrawable;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class BpmDiagram extends UmlDiagram {
@ -78,12 +77,18 @@ public class BpmDiagram extends UmlDiagram {
super(UmlDiagramType.BPM);
}
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getUDrawable(), index, fileFormatOption)
.annotations(false)
return createImageBuilder(fileFormatOption)
.drawable(getUDrawable())
.write(os);
}

View File

@ -57,8 +57,6 @@ import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.svek.image.EntityImageClass;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ClassDiagram extends AbstractClassOrObjectDiagram {
public ClassDiagram(ISkinSimple skinParam) {
@ -198,8 +196,9 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
final RowLayout rawLayout = getRawLayout(i);
fullLayout.addRowLayout(rawLayout);
}
return styledImageBuilder(this, fullLayout, index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.annotations(false) // Backwards compatibility - this only applies when "layout_new_line" is used
.drawable(fullLayout)
.write(os);
}

View File

@ -65,13 +65,10 @@ import net.sourceforge.plantuml.statediagram.StateDiagram;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.imageBuilder;
public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower {
static private final boolean G1972 = false;
@ -623,11 +620,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
maker.createFiles(suggestedFile);
}
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) {
return imageBuilder(fileFormatOption)
.styled(this);
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {

View File

@ -35,6 +35,7 @@
package net.sourceforge.plantuml.eggs;
import java.awt.image.BufferedImage;
import java.io.IOException;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
@ -56,8 +57,9 @@ public class PSystemCharlie extends PlainDiagram {
}
@Override
protected ImageBuilder adjustImageBuilder(ImageBuilder builder) {
return builder.blackBackcolor();
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.blackBackcolor();
}
@Override

View File

@ -101,8 +101,8 @@ public abstract class PSystemError extends PlainDiagram {
protected ErrorUml singleError;
@Override
protected ImageBuilder adjustImageBuilder(ImageBuilder builder) {
return builder
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.blackBackcolor()
.randomPixel()
.status(FileImageData.ERROR);

View File

@ -60,6 +60,7 @@ import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -68,7 +69,7 @@ import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.imageBuilder;
public class FlowDiagram extends UmlDiagram implements TextBlock {
@ -121,14 +122,20 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return plainImageBuilder(this, fileFormatOption)
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return imageBuilder(fileFormatOption)
.dimension(calculateDimension(fileFormatOption.getDefaultStringBounder(getSkinParam())))
.margin(getDefaultMargins())
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null)
.seed(seed())
.seed(seed());
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return createImageBuilder(fileFormatOption)
.drawable(this)
.write(os);
}

View File

@ -52,8 +52,6 @@ import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class GitDiagram extends UmlDiagram {
private final Collection<GNode> gnodes;
@ -73,7 +71,8 @@ public class GitDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -53,10 +53,9 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class Help extends UmlDiagram {
private final List<CharSequence> lines = new ArrayList<CharSequence>();
@ -69,6 +68,12 @@ public class Help extends UmlDiagram {
super(UmlDiagramType.HELP);
}
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormat)
throws IOException {
@ -78,8 +83,8 @@ public class Help extends UmlDiagram {
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL)
.createSheet(display);
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
return styledImageBuilder(this, sheetBlock, 1, fileFormat)
.annotations(false)
return createImageBuilder(fileFormat)
.drawable(sheetBlock)
.write(os);
}

View File

@ -60,8 +60,6 @@ import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class JsonDiagram extends TitledDiagram {
private final JsonValue root;
@ -89,7 +87,8 @@ public class JsonDiagram extends TitledDiagram {
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -59,8 +59,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class MindMapDiagram extends UmlDiagram {
private Branch left = new Branch();
@ -84,7 +82,8 @@ public class MindMapDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -72,8 +72,6 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class NwDiagram extends UmlDiagram {
private boolean initDone;
@ -215,7 +213,8 @@ public class NwDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -35,8 +35,6 @@
*/
package net.sourceforge.plantuml.project;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
@ -169,7 +167,9 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
return styledImageBuilder(this, getTextBlock(stringBounder), index, fileFormatOption).write(os);
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock(stringBounder))
.write(os);
}
public void setPrintScale(PrintScale printScale) {
@ -733,4 +733,4 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
public ClockwiseTopRightBottomLeft getDefaultMargins() {
return ClockwiseTopRightBottomLeft.none();
}
}
}

View File

@ -90,8 +90,6 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class PSystemSalt extends TitledDiagram implements WithSprite {
private final List<String> data;
@ -118,7 +116,8 @@ public class PSystemSalt extends TitledDiagram implements WithSprite {
final Element salt = createElement(manageSprite());
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
final Dimension2D size = salt.getPreferredDimension(stringBounder, 0, 0);
return styledImageBuilder(this, getTextBlock(salt, size), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock(salt, size))
.write(os);
} catch (Exception e) {
e.printStackTrace();

View File

@ -70,8 +70,6 @@ import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.imageBuilder;
public class SequenceDiagram extends UmlDiagram {
private final List<Participant> participantsList = new ArrayList<Participant>();
@ -247,9 +245,8 @@ public class SequenceDiagram extends UmlDiagram {
return OptionFlags.FORCE_TEOZ || getPragma().useTeozLayout();
}
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) {
return imageBuilder(fileFormatOption)
.styled(this)
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false); // they are managed in the SequenceDiagramFileMaker* classes
}

View File

@ -53,13 +53,12 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ListSpriteDiagram extends UmlDiagram {
public ListSpriteDiagram(ISkinSimple skinParam) {
@ -70,12 +69,18 @@ public class ListSpriteDiagram extends UmlDiagram {
return new DiagramDescription("(Sprites)");
}
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTable(), index, fileFormatOption)
.annotations(false)
return createImageBuilder(fileFormatOption)
.drawable(getTable())
.write(os);
}

View File

@ -59,14 +59,13 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.preproc.Stdlib;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class StdlibDiagram extends UmlDiagram {
private static final int WIDTH = 1800;
@ -80,12 +79,18 @@ public class StdlibDiagram extends UmlDiagram {
return new DiagramDescription("(Sprites)");
}
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTable(), index, fileFormatOption)
.annotations(false)
return createImageBuilder(fileFormatOption)
.drawable(getTable())
.write(os);
}

View File

@ -35,8 +35,6 @@
*/
package net.sourceforge.plantuml.svek;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;

View File

@ -68,8 +68,6 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class TimingDiagram extends UmlDiagram implements Clocks {
public static final double marginX1 = 5;
@ -98,7 +96,8 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -150,14 +150,6 @@ public class ImageBuilder {
.drawable(drawable);
}
// TODO do something with "index"
public static ImageBuilder styledImageBuilder(TitledDiagram diagram, UDrawable drawable, int index,
FileFormatOption fileFormatOption) {
return imageBuilder(fileFormatOption)
.drawable(drawable)
.styled(diagram);
}
private ImageBuilder(FileFormatOption fileFormatOption) {
this.fileFormatOption = fileFormatOption;
this.preserveAspectRatio = calculatePreserveAspectRatio(fileFormatOption, null);

View File

@ -57,13 +57,10 @@ import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.mindmap.IdeaShape;
import net.sourceforge.plantuml.style.NoStyleAvailableException;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class WBSDiagram extends UmlDiagram {
public DiagramDescription getDescription() {
@ -74,17 +71,12 @@ public class WBSDiagram extends UmlDiagram {
super(UmlDiagramType.WBS);
}
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) {
// TODO index should not be -1 here but we currently dont use it anyway,
// the real value we need is "index" in exportDiagramInternal()
return styledImageBuilder(this, getTextBlock(), -1, fileFormatOption);
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -58,8 +58,6 @@ import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class WireDiagram extends UmlDiagram {
private final WBlock root = new WBlock("", new UTranslate(), 0, 0, null);
@ -79,7 +77,8 @@ public class WireDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption)
return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os);
}

View File

@ -43,7 +43,7 @@ class ImageBuilderTest {
},
nullValues = {"NULL"}
)
public void test_preserveAspectRatio_styledDiagram(String inSkinParam, String inFileFormatOption, String expected) {
public void test_preserveAspectRatio_styledDiagram(String inSkinParam, String inFileFormatOption, String expected) throws Exception {
final WBSDiagram diagram = new WBSDiagram();
FileFormatOption fileFormatOption = new FileFormatOption(DEBUG);