diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index b94ee078d..f23b19331 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -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; diff --git a/src/net/sourceforge/plantuml/PlainDiagram.java b/src/net/sourceforge/plantuml/PlainDiagram.java index 95d6da0a6..70e4ee686 100644 --- a/src/net/sourceforge/plantuml/PlainDiagram.java +++ b/src/net/sourceforge/plantuml/PlainDiagram.java @@ -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; diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index 20a19e3b2..6815d0562 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -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); + } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index e363d5d01..51ed65563 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/board/BoardDiagram.java b/src/net/sourceforge/plantuml/board/BoardDiagram.java index 95f7587c5..364451731 100644 --- a/src/net/sourceforge/plantuml/board/BoardDiagram.java +++ b/src/net/sourceforge/plantuml/board/BoardDiagram.java @@ -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 activities = new ArrayList(); @@ -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); } diff --git a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java index adc22c35a..691dbe0d7 100644 --- a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java +++ b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index 8fb823cdb..3841eaf47 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java index 0265c0bfb..ef71ecf5a 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java @@ -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 { diff --git a/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java b/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java index d0d2d107b..3b18dc0e3 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java @@ -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 diff --git a/src/net/sourceforge/plantuml/error/PSystemError.java b/src/net/sourceforge/plantuml/error/PSystemError.java index 58cee13c1..b80543361 100644 --- a/src/net/sourceforge/plantuml/error/PSystemError.java +++ b/src/net/sourceforge/plantuml/error/PSystemError.java @@ -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); diff --git a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java index 1ecb19c04..3d4edff63 100644 --- a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java +++ b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/gitlog/GitDiagram.java b/src/net/sourceforge/plantuml/gitlog/GitDiagram.java index c72c4f843..29a922bde 100644 --- a/src/net/sourceforge/plantuml/gitlog/GitDiagram.java +++ b/src/net/sourceforge/plantuml/gitlog/GitDiagram.java @@ -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 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); } diff --git a/src/net/sourceforge/plantuml/help/Help.java b/src/net/sourceforge/plantuml/help/Help.java index 580c55897..82d5bc53b 100644 --- a/src/net/sourceforge/plantuml/help/Help.java +++ b/src/net/sourceforge/plantuml/help/Help.java @@ -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 lines = new ArrayList(); @@ -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); } diff --git a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java index b33481560..872a85b47 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java +++ b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java index dcfae9cc9..cec1473bd 100644 --- a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java index 3e1cd7c75..1351cebec 100644 --- a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java +++ b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/project/GanttDiagram.java b/src/net/sourceforge/plantuml/project/GanttDiagram.java index 4d803d601..76713ac6a 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagram.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagram.java @@ -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(); } -} \ No newline at end of file +} diff --git a/src/net/sourceforge/plantuml/salt/PSystemSalt.java b/src/net/sourceforge/plantuml/salt/PSystemSalt.java index 6031b3628..3bdcae425 100644 --- a/src/net/sourceforge/plantuml/salt/PSystemSalt.java +++ b/src/net/sourceforge/plantuml/salt/PSystemSalt.java @@ -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 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(); diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index 11c36d85e..9b9af13f9 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -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 participantsList = new ArrayList(); @@ -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 } diff --git a/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java index 48d8169dc..aa7af0f08 100644 --- a/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java +++ b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java b/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java index 403a2306e..8b386e34a 100644 --- a/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java +++ b/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java index 8a31971b1..008b7b54e 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java @@ -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; diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java index 96b391e14..f5384b5cf 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 33cb3e28c..c352667be 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -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); diff --git a/src/net/sourceforge/plantuml/wbs/WBSDiagram.java b/src/net/sourceforge/plantuml/wbs/WBSDiagram.java index fae88af93..d4cdbfa75 100644 --- a/src/net/sourceforge/plantuml/wbs/WBSDiagram.java +++ b/src/net/sourceforge/plantuml/wbs/WBSDiagram.java @@ -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); } diff --git a/src/net/sourceforge/plantuml/wire/WireDiagram.java b/src/net/sourceforge/plantuml/wire/WireDiagram.java index b2a90c9c2..2d1d0763e 100644 --- a/src/net/sourceforge/plantuml/wire/WireDiagram.java +++ b/src/net/sourceforge/plantuml/wire/WireDiagram.java @@ -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); } diff --git a/test/net/sourceforge/plantuml/ugraphic/ImageBuilderTest.java b/test/net/sourceforge/plantuml/ugraphic/ImageBuilderTest.java index 8b9377dc6..c8a81ee86 100644 --- a/test/net/sourceforge/plantuml/ugraphic/ImageBuilderTest.java +++ b/test/net/sourceforge/plantuml/ugraphic/ImageBuilderTest.java @@ -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);