1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 10:59:01 +00:00

Merge pull request #480 from matthew16550/refactor-image-params

Refactor duplicated logic into ImageParameter class
This commit is contained in:
arnaudroques 2021-03-09 18:26:53 +01:00 committed by GitHub
commit 89c170d3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 75 additions and 123 deletions

View File

@ -226,15 +226,13 @@ public class ActivityDiagram3 extends UmlDiagram {
final double dpiFactor = getDpiFactor(fileFormatOption, final double dpiFactor = getDpiFactor(fileFormatOption,
Dimension2DDouble.delta(dim, margins.getLeft() + margins.getRight(), 0)); Dimension2DDouble.delta(dim, margins.getLeft() + margins.getRight(), 0));
final HColor backcolor = skinParam.getBackgroundColor(false); final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, getAnimation(), dpiFactor,
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null; getWarningOrError());
final ImageParameter imageParameter = new ImageParameter(this, getAnimation(), dpiFactor, metadata,
getWarningOrError(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }

View File

@ -55,10 +55,6 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.InnerStrategy; 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.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import net.sourceforge.plantuml.ugraphic.ImageParameter;
@ -89,18 +85,9 @@ public class BoardDiagram extends UmlDiagram {
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ISkinParam skinParam = getSkinParam();
final Style style = StyleSignature.of(SName.root, SName.document, SName.mindmapDiagram)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
HColor backgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); final ImageParameter imageParameter = new ImageParameter(this,
if (backgroundColor == null) { fileFormatOption, null, dpiFactor, "");
backgroundColor = HColorUtils.transparent();
}
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(this, skinParam.getColorMapper(), skinParam.handwritten(),
null, dpiFactor, metadata, "", backgroundColor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
@ -110,7 +97,7 @@ public class BoardDiagram extends UmlDiagram {
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -42,7 +42,6 @@ import java.util.Deque;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
@ -52,7 +51,6 @@ 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 net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class BpmDiagram extends UmlDiagram { public class BpmDiagram extends UmlDiagram {
@ -84,16 +82,13 @@ public class BpmDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final double dpiFactor = 1; final double dpiFactor = 1;
ISkinParam skinParam = getSkinParam(); final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, getAnimation(), dpiFactor,
final HColor backcolor = skinParam.getBackgroundColor(false); getWarningOrError());
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(this, getAnimation(), dpiFactor, metadata,
getWarningOrError(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(getUDrawable()); imageBuilder.setUDrawable(getUDrawable());
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private UDrawable getUDrawable() { private UDrawable getUDrawable() {

View File

@ -39,7 +39,6 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
@ -59,7 +58,6 @@ import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.svek.image.EntityImageClass; import net.sourceforge.plantuml.svek.image.EntityImageClass;
import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class ClassDiagram extends AbstractClassOrObjectDiagram { public class ClassDiagram extends AbstractClassOrObjectDiagram {
@ -200,12 +198,10 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
final RowLayout rawLayout = getRawLayout(i); final RowLayout rawLayout = getRawLayout(i);
fullLayout.addRowLayout(rawLayout); fullLayout.addRowLayout(rawLayout);
} }
ISkinParam skinParam = getSkinParam(); final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, null, 1.0, null);
final HColor backcolor = skinParam.getBackgroundColor(false);
final ImageParameter imageParameter = new ImageParameter(this, null, 1.0, null, null, backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(fullLayout); imageBuilder.setUDrawable(fullLayout);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private RowLayout getRawLayout(int raw) { private RowLayout getRawLayout(int raw) {

View File

@ -63,7 +63,6 @@ import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
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.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
public class JsonDiagram extends TitledDiagram { public class JsonDiagram extends TitledDiagram {
@ -96,16 +95,15 @@ public class JsonDiagram extends TitledDiagram {
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100); final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ISkinParam skinParam = getSkinParam();
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null; final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, null, dpiFactor,
final ImageParameter imageParameter = new ImageParameter(this, new ColorMapperIdentity(), false, null, dpiFactor, "");
metadata, "", null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(); TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam())) result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, 0, os); return imageBuilder.writeImageTOBEMOVED(0, os);
} }
private void drawInternal(UGraphic ug) { private void drawInternal(UGraphic ug) {

View File

@ -56,7 +56,6 @@ 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.NoStyleAvailableException; import net.sourceforge.plantuml.style.NoStyleAvailableException;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleBuilder;
@ -68,7 +67,6 @@ import net.sourceforge.plantuml.ugraphic.MinMax;
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.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class MindMapDiagram extends UmlDiagram { public class MindMapDiagram extends UmlDiagram {
@ -99,15 +97,8 @@ public class MindMapDiagram extends UmlDiagram {
final Style style = StyleSignature.of(SName.root, SName.document, SName.mindmapDiagram) final Style style = StyleSignature.of(SName.root, SName.document, SName.mindmapDiagram)
.getMergedStyle(skinParam.getCurrentStyleBuilder()); .getMergedStyle(skinParam.getCurrentStyleBuilder());
HColor backgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); final ImageParameter imageParameter = new ImageParameter(this,
if (backgroundColor == null) { fileFormatOption, null, dpiFactor, "");
backgroundColor = HColorUtils.transparent();
}
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(this, skinParam.getColorMapper(), skinParam.handwritten(),
null, dpiFactor, metadata, "", backgroundColor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
@ -117,7 +108,7 @@ public class MindMapDiagram extends UmlDiagram {
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -74,7 +74,6 @@ import net.sourceforge.plantuml.ugraphic.UEmpty;
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.ColorMapperIdentity;
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;
@ -222,15 +221,15 @@ public class NwDiagram extends UmlDiagram {
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100); final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ISkinParam skinParam = getSkinParam();
final ImageParameter imageParameter = new ImageParameter(this, new ColorMapperIdentity(), false, null, dpiFactor, "", final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, null, dpiFactor,
"", null); "");
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(); TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam())) result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, 0, os); return imageBuilder.writeImageTOBEMOVED(0, os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -99,7 +99,6 @@ import net.sourceforge.plantuml.ugraphic.ImageParameter;
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.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
@ -171,8 +170,8 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
throws IOException { throws IOException {
final Scale scale = getScale(); final Scale scale = getScale();
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100); final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final ImageParameter imageParameter = new ImageParameter(this, new ColorMapperIdentity(), false, null, dpiFactor, final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, null, dpiFactor,
getMetadata(), "", null); "");
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
@ -180,7 +179,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
result = new AnnotatedWorker(this, getSkinParam(), stringBounder).addAdd(result); result = new AnnotatedWorker(this, getSkinParam(), stringBounder).addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os); return imageBuilder.writeImageTOBEMOVED(seed, os);
} }
public void setPrintScale(PrintScale printScale) { public void setPrintScale(PrintScale printScale) {

View File

@ -127,11 +127,8 @@ public class PSystemSalt extends TitledDiagram implements WithSprite {
final Scale scale = getScale(); final Scale scale = getScale();
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ISkinParam skinParam = getSkinParam();
HColor backcolor = skinParam.getBackgroundColor(false); final ImageParameter imageParameter = new ImageParameter(this,
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null; fileFormatOption, null, dpiFactor, "");
final ImageParameter imageParameter = new ImageParameter(this, skinParam.getColorMapper(),
skinParam.handwritten(), null, dpiFactor, metadata, "", backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
@ -140,7 +137,7 @@ public class PSystemSalt extends TitledDiagram implements WithSprite {
result = new AnnotatedWorker(this, skinParam, stringBounder).addAdd(result); result = new AnnotatedWorker(this, skinParam, stringBounder).addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed, getMetadata(), "none", UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed, getMetadata(), "none",

View File

@ -443,11 +443,8 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
// } // }
final double scale = 1; final double scale = 1;
ISkinParam skinParam = diagram.getSkinParam(); final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption, diagram.getAnimation(), scale,
final HColor backcolor = skinParam.getBackgroundColor(false); null);
final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(diagram, diagram.getAnimation(), scale, metadata,
null, backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
@ -460,7 +457,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
// imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight()))); // imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
imageBuilder.setUDrawable(annotatedWorker.addAdd(new Drawing(new YMirror(dim.getHeight()), dim))); imageBuilder.setUDrawable(annotatedWorker.addAdd(new Drawing(new YMirror(dim.getHeight()), dim)));
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os); return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
} catch (Throwable e) { } catch (Throwable e) {
SmetanaDebug.printMe(); SmetanaDebug.printMe();
UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(), UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(),

View File

@ -194,13 +194,9 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
// System.err.println("dpiFactor=" + dpiFactor); // System.err.println("dpiFactor=" + dpiFactor);
// System.err.println("scale=" + scale); // System.err.println("scale=" + scale);
final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
ISkinParam skinParam = diagram.getSkinParam();
final HColor backcolor = skinParam.getBackgroundColor(false);
final double factor = oneOf(scale, dpiFactor); final double factor = oneOf(scale, dpiFactor);
final ImageParameter imageParameter = new ImageParameter(diagram, diagram.getAnimation(), factor, metadata, final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption, diagram.getAnimation(), factor,
null, backcolor); null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new UDrawable() { imageBuilder.setUDrawable(new UDrawable() {
@ -237,7 +233,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
} }
}); });
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os); return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
} }
private void drawFooter(SequenceDiagramArea area, UGraphic ug, int page) { private void drawFooter(SequenceDiagramArea area, UGraphic ug, int page) {

View File

@ -149,18 +149,15 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
final double dpiFactor = diagram.getDpiFactor(fileFormatOption, dimTotal); final double dpiFactor = diagram.getDpiFactor(fileFormatOption, dimTotal);
final double scale = 1; final double scale = 1;
final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
ISkinParam skinParam = diagram.getSkinParam();
final HColor backcolor = skinParam.getBackgroundColor(false);
final double factor = oneOf(scale, dpiFactor); final double factor = oneOf(scale, dpiFactor);
final ImageParameter imageParameter = new ImageParameter(diagram, diagram.getAnimation(), factor, metadata, final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption, diagram.getAnimation(), factor,
null, backcolor); null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new Foo(index)); imageBuilder.setUDrawable(new Foo(index));
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os); return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
} }

View File

@ -41,7 +41,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
@ -59,7 +58,6 @@ import net.sourceforge.plantuml.ugraphic.ImageParameter;
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.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class ListSpriteDiagram extends UmlDiagram { public class ListSpriteDiagram extends UmlDiagram {
@ -78,15 +76,12 @@ public class ListSpriteDiagram extends UmlDiagram {
final TextBlock result = getTable(); final TextBlock result = getTable();
final double dpiFactor = 1; final double dpiFactor = 1;
ISkinParam skinParam = getSkinParam(); final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, getAnimation(), dpiFactor,
final HColor backcolor = skinParam.getBackgroundColor(false); getWarningOrError());
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(this, getAnimation(), dpiFactor, metadata,
getWarningOrError(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlock getTable() { private TextBlock getTable() {

View File

@ -42,7 +42,6 @@ import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
@ -65,7 +64,6 @@ import net.sourceforge.plantuml.ugraphic.ImageParameter;
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.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;
@ -89,15 +87,12 @@ public class StdlibDiagram extends UmlDiagram {
final TextBlock result = getTable(); final TextBlock result = getTable();
final double dpiFactor = 1; final double dpiFactor = 1;
ISkinParam skinParam = getSkinParam(); final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, getAnimation(), dpiFactor,
final HColor backcolor = skinParam.getBackgroundColor(false); getWarningOrError());
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(this, getAnimation(), dpiFactor, metadata,
getWarningOrError(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlock getTable() { private TextBlock getTable() {

View File

@ -124,12 +124,12 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
final HColor backcolor = result.getBackcolor(); final HColor backcolor = result.getBackcolor();
final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null; final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(diagram, diagram.getAnimation(), scale, metadata, final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption, diagram.getAnimation(), scale, metadata,
warningOrError, backcolor); warningOrError, backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
final ImageData imageData = imageBuilder.writeImageTOBEMOVED(fileFormatOption, diagram.seed(), os); final ImageData imageData = imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
if (isGraphvizCrash) { if (isGraphvizCrash) {
((ImageDataAbstract) imageData).setStatus(503); ((ImageDataAbstract) imageData).setStatus(503);
} }

View File

@ -100,11 +100,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 {
final double dpiFactor = 1; final double dpiFactor = 1;
ISkinParam skinParam1 = getSkinParam(); final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption, getAnimation(), dpiFactor,
final HColor backcolor = skinParam1.getBackgroundColor(false); getWarningOrError());
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(this, getAnimation(), dpiFactor, metadata,
getWarningOrError(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(); TextBlock result = getTextBlock();
@ -113,7 +110,7 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -118,6 +118,10 @@ public class ImageBuilder {
this.udrawable = udrawable; this.udrawable = udrawable;
} }
public ImageData writeImageTOBEMOVED(long seed, OutputStream os) throws IOException {
return writeImageTOBEMOVED(param.getFileFormatOption(), seed, os);
}
public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, long seed, OutputStream os) public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, long seed, OutputStream os)
throws IOException { throws IOException {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.ugraphic;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.CornerParam; import net.sourceforge.plantuml.CornerParam;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SvgCharSizeHack; import net.sourceforge.plantuml.SvgCharSizeHack;
@ -70,6 +71,7 @@ public class ImageParameter {
private final UStroke borderStroke; private final UStroke borderStroke;
private final HColor borderColor; private final HColor borderColor;
private final double borderCorner; private final double borderCorner;
private final FileFormatOption fileFormatOption;
public ImageParameter(ColorMapper colorMapper, boolean useHandwritten, Animation animation, double dpiFactor, public ImageParameter(ColorMapper colorMapper, boolean useHandwritten, Animation animation, double dpiFactor,
String metadata, String warningOrError, ClockwiseTopRightBottomLeft margins, HColor backcolor) { String metadata, String warningOrError, ClockwiseTopRightBottomLeft margins, HColor backcolor) {
@ -88,16 +90,25 @@ public class ImageParameter {
this.borderStroke = null; this.borderStroke = null;
this.svgCharSizeHack = SvgCharSizeHack.NO_HACK; this.svgCharSizeHack = SvgCharSizeHack.NO_HACK;
this.lengthAdjust = LengthAdjust.defaultValue(); this.lengthAdjust = LengthAdjust.defaultValue();
this.fileFormatOption = null;
} }
public ImageParameter(TitledDiagram diagram, ColorMapper colorMapper, boolean useHandwritten, Animation animation, double dpiFactor, public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption, Animation animation, double dpiFactor, String warningOrError) {
String metadata, String warningOrError, HColor backcolor) { this(
this(colorMapper, useHandwritten, animation, dpiFactor, metadata, warningOrError, calculateDiagramMargin(diagram), backcolor); diagram,
fileFormatOption,
animation,
dpiFactor,
fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null,
warningOrError,
diagram.getSkinParam().getBackgroundColor(false)
);
} }
public ImageParameter(TitledDiagram diagram, Animation animation, double dpiFactor, String metadata, public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption, Animation animation, double dpiFactor, String metadata,
String warningOrError, HColor backcolor) { String warningOrError, HColor backcolor) {
final ISkinParam skinParam = diagram.getSkinParam(); final ISkinParam skinParam = diagram.getSkinParam();
this.fileFormatOption = fileFormatOption;
this.colorMapper = skinParam.getColorMapper(); this.colorMapper = skinParam.getColorMapper();
this.useHandwritten = skinParam.handwritten(); this.useHandwritten = skinParam.handwritten();
this.animation = animation; this.animation = animation;
@ -179,6 +190,10 @@ public class ImageParameter {
return lengthAdjust; return lengthAdjust;
} }
public FileFormatOption getFileFormatOption() {
return fileFormatOption;
}
private static ClockwiseTopRightBottomLeft calculateDiagramMargin(TitledDiagram diagram) { private static ClockwiseTopRightBottomLeft calculateDiagramMargin(TitledDiagram diagram) {
if (UseStyle.useBetaStyle()) { if (UseStyle.useBetaStyle()) {
final Style style = StyleSignature.of(SName.root, SName.document).getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); final Style style = StyleSignature.of(SName.root, SName.document).getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());

View File

@ -83,10 +83,8 @@ public class WBSDiagram extends UmlDiagram {
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ISkinParam skinParam = getSkinParam();
HColor backcolor = skinParam.getBackgroundColor(false); final ImageParameter imageParameter = new ImageParameter(this,
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null; fileFormatOption, null, dpiFactor, "");
final ImageParameter imageParameter = new ImageParameter(this, skinParam.getColorMapper(), skinParam.handwritten(),
null, dpiFactor, metadata, "", backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(); TextBlock result = getTextBlock();
@ -95,7 +93,7 @@ public class WBSDiagram extends UmlDiagram {
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -87,10 +87,8 @@ public class WireDiagram extends UmlDiagram {
final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100);
final ISkinParam skinParam = getSkinParam(); final ISkinParam skinParam = getSkinParam();
HColor backcolor = skinParam.getBackgroundColor(false); final ImageParameter imageParameter = new ImageParameter(this,
final String metadata = fileFormatOption.isWithMetadata() ? getMetadata() : null; fileFormatOption, null, dpiFactor, "");
final ImageParameter imageParameter = new ImageParameter(this, skinParam.getColorMapper(), skinParam.handwritten(),
null, dpiFactor, metadata, "", backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(); TextBlock result = getTextBlock();
@ -99,7 +97,7 @@ public class WireDiagram extends UmlDiagram {
.addAdd(result); .addAdd(result);
imageBuilder.setUDrawable(result); imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {