1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 21:15:09 +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; package net.sourceforge.plantuml;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.imageBuilder;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -51,6 +53,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.stats.StatsUtilsIncrement; import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.version.License; import net.sourceforge.plantuml.version.License;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
@ -160,6 +163,11 @@ public abstract class AbstractPSystem implements Diagram {
return scale; 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 protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption
) throws IOException; ) throws IOException;

View File

@ -41,15 +41,12 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; 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 // This class doesnt feel like a wonderful idea, just a stepping stone towards something
public abstract class PlainDiagram extends AbstractPSystem { public abstract class PlainDiagram extends AbstractPSystem {
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException { public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
final UDrawable drawable = getRootDrawable(fileFormatOption); return super.createImageBuilder(fileFormatOption)
return plainImageBuilder(drawable, fileFormatOption)
.margin(getDefaultMargins()) .margin(getDefaultMargins())
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null) .metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null)
.seed(seed()); .seed(seed());
@ -59,13 +56,9 @@ public abstract class PlainDiagram extends AbstractPSystem {
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ImageBuilder builder = createImageBuilder(fileFormatOption); return createImageBuilder(fileFormatOption)
return adjustImageBuilder(builder).write(os); .drawable(getRootDrawable(fileFormatOption))
} .write(os);
// kind of a kludge but good enough for now!
protected ImageBuilder adjustImageBuilder(ImageBuilder builder) {
return builder;
} }
protected abstract UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException; 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.sprite.Sprite;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated { 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() { final public Animation getAnimation() {
return animation; 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.CompressionMode;
import net.sourceforge.plantuml.ugraphic.comp.CompressionXorYBuilder; import net.sourceforge.plantuml.ugraphic.comp.CompressionXorYBuilder;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ActivityDiagram3 extends UmlDiagram { public class ActivityDiagram3 extends UmlDiagram {
enum SwimlaneStrategy { enum SwimlaneStrategy {
@ -205,7 +203,8 @@ public class ActivityDiagram3 extends UmlDiagram {
result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder); result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder);
result = new TextBlockRecentred(result); result = new TextBlockRecentred(result);
return styledImageBuilder(this, result, index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(result)
.write(os); .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.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class BoardDiagram extends UmlDiagram { public class BoardDiagram extends UmlDiagram {
private final List<Activity> activities = new ArrayList<Activity>(); 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) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .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.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class BpmDiagram extends UmlDiagram { public class BpmDiagram extends UmlDiagram {
@ -78,12 +77,18 @@ public class BpmDiagram extends UmlDiagram {
super(UmlDiagramType.BPM); super(UmlDiagramType.BPM);
} }
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getUDrawable(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.annotations(false) .drawable(getUDrawable())
.write(os); .write(os);
} }

View File

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

View File

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

View File

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

View File

@ -101,8 +101,8 @@ public abstract class PSystemError extends PlainDiagram {
protected ErrorUml singleError; protected ErrorUml singleError;
@Override @Override
protected ImageBuilder adjustImageBuilder(ImageBuilder builder) { public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return builder return super.createImageBuilder(fileFormatOption)
.blackBackcolor() .blackBackcolor()
.randomPixel() .randomPixel()
.status(FileImageData.ERROR); .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.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic; 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.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; 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 { public class FlowDiagram extends UmlDiagram implements TextBlock {
@ -121,14 +122,20 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
} }
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
throws IOException { return imageBuilder(fileFormatOption)
return plainImageBuilder(this, fileFormatOption)
.dimension(calculateDimension(fileFormatOption.getDefaultStringBounder(getSkinParam()))) .dimension(calculateDimension(fileFormatOption.getDefaultStringBounder(getSkinParam())))
.margin(getDefaultMargins()) .margin(getDefaultMargins())
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null) .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); .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.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class GitDiagram extends UmlDiagram { public class GitDiagram extends UmlDiagram {
private final Collection<GNode> gnodes; private final Collection<GNode> gnodes;
@ -73,7 +71,8 @@ public class GitDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .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.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class Help extends UmlDiagram { public class Help extends UmlDiagram {
private final List<CharSequence> lines = new ArrayList<CharSequence>(); private final List<CharSequence> lines = new ArrayList<CharSequence>();
@ -69,6 +68,12 @@ public class Help extends UmlDiagram {
super(UmlDiagramType.HELP); super(UmlDiagramType.HELP);
} }
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormat) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormat)
throws IOException { throws IOException {
@ -78,8 +83,8 @@ public class Help extends UmlDiagram {
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL) final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL)
.createSheet(display); .createSheet(display);
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
return styledImageBuilder(this, sheetBlock, 1, fileFormat) return createImageBuilder(fileFormat)
.annotations(false) .drawable(sheetBlock)
.write(os); .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.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class JsonDiagram extends TitledDiagram { public class JsonDiagram extends TitledDiagram {
private final JsonValue root; private final JsonValue root;
@ -89,7 +87,8 @@ public class JsonDiagram extends TitledDiagram {
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .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.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class MindMapDiagram extends UmlDiagram { public class MindMapDiagram extends UmlDiagram {
private Branch left = new Branch(); private Branch left = new Branch();
@ -84,7 +82,8 @@ public class MindMapDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .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.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class NwDiagram extends UmlDiagram { public class NwDiagram extends UmlDiagram {
private boolean initDone; private boolean initDone;
@ -215,7 +213,8 @@ public class NwDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .write(os);
} }

View File

@ -35,8 +35,6 @@
*/ */
package net.sourceforge.plantuml.project; package net.sourceforge.plantuml.project;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.io.IOException; 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) protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); 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) { public void setPrintScale(PrintScale printScale) {
@ -733,4 +733,4 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
public ClockwiseTopRightBottomLeft getDefaultMargins() { public ClockwiseTopRightBottomLeft getDefaultMargins() {
return ClockwiseTopRightBottomLeft.none(); 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.HColorUtils;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class PSystemSalt extends TitledDiagram implements WithSprite { public class PSystemSalt extends TitledDiagram implements WithSprite {
private final List<String> data; private final List<String> data;
@ -118,7 +116,8 @@ public class PSystemSalt extends TitledDiagram implements WithSprite {
final Element salt = createElement(manageSprite()); final Element salt = createElement(manageSprite());
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
final Dimension2D size = salt.getPreferredDimension(stringBounder, 0, 0); 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); .write(os);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.imageBuilder;
public class SequenceDiagram extends UmlDiagram { public class SequenceDiagram extends UmlDiagram {
private final List<Participant> participantsList = new ArrayList<Participant>(); private final List<Participant> participantsList = new ArrayList<Participant>();
@ -247,9 +245,8 @@ public class SequenceDiagram extends UmlDiagram {
return OptionFlags.FORCE_TEOZ || getPragma().useTeozLayout(); return OptionFlags.FORCE_TEOZ || getPragma().useTeozLayout();
} }
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) { public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return imageBuilder(fileFormatOption) return super.createImageBuilder(fileFormatOption)
.styled(this)
.annotations(false); // they are managed in the SequenceDiagramFileMaker* classes .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.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ListSpriteDiagram extends UmlDiagram { public class ListSpriteDiagram extends UmlDiagram {
public ListSpriteDiagram(ISkinSimple skinParam) { public ListSpriteDiagram(ISkinSimple skinParam) {
@ -70,12 +69,18 @@ public class ListSpriteDiagram extends UmlDiagram {
return new DiagramDescription("(Sprites)"); return new DiagramDescription("(Sprites)");
} }
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTable(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.annotations(false) .drawable(getTable())
.write(os); .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.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.preproc.Stdlib;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class StdlibDiagram extends UmlDiagram { public class StdlibDiagram extends UmlDiagram {
private static final int WIDTH = 1800; private static final int WIDTH = 1800;
@ -80,12 +79,18 @@ public class StdlibDiagram extends UmlDiagram {
return new DiagramDescription("(Sprites)"); return new DiagramDescription("(Sprites)");
} }
@Override
public ImageBuilder createImageBuilder(FileFormatOption fileFormatOption) throws IOException {
return super.createImageBuilder(fileFormatOption)
.annotations(false);
}
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTable(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.annotations(false) .drawable(getTable())
.write(os); .write(os);
} }

View File

@ -35,8 +35,6 @@
*/ */
package net.sourceforge.plantuml.svek; package net.sourceforge.plantuml.svek;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; 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.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class TimingDiagram extends UmlDiagram implements Clocks { public class TimingDiagram extends UmlDiagram implements Clocks {
public static final double marginX1 = 5; 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) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .write(os);
} }

View File

@ -150,14 +150,6 @@ public class ImageBuilder {
.drawable(drawable); .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) { private ImageBuilder(FileFormatOption fileFormatOption) {
this.fileFormatOption = fileFormatOption; this.fileFormatOption = fileFormatOption;
this.preserveAspectRatio = calculatePreserveAspectRatio(fileFormatOption, null); 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.mindmap.IdeaShape;
import net.sourceforge.plantuml.style.NoStyleAvailableException; import net.sourceforge.plantuml.style.NoStyleAvailableException;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class WBSDiagram extends UmlDiagram { public class WBSDiagram extends UmlDiagram {
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
@ -74,17 +71,12 @@ public class WBSDiagram extends UmlDiagram {
super(UmlDiagramType.WBS); 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 @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return createImageBuilder(fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .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.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class WireDiagram extends UmlDiagram { public class WireDiagram extends UmlDiagram {
private final WBlock root = new WBlock("", new UTranslate(), 0, 0, null); 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) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
return styledImageBuilder(this, getTextBlock(), index, fileFormatOption) return createImageBuilder(fileFormatOption)
.drawable(getTextBlock())
.write(os); .write(os);
} }

View File

@ -43,7 +43,7 @@ class ImageBuilderTest {
}, },
nullValues = {"NULL"} 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(); final WBSDiagram diagram = new WBSDiagram();
FileFormatOption fileFormatOption = new FileFormatOption(DEBUG); FileFormatOption fileFormatOption = new FileFormatOption(DEBUG);