summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/UmlDiagram.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/UmlDiagram.java')
-rw-r--r--src/net/sourceforge/plantuml/UmlDiagram.java127
1 files changed, 65 insertions, 62 deletions
diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java
index 2254ba8..2254c09 100644
--- a/src/net/sourceforge/plantuml/UmlDiagram.java
+++ b/src/net/sourceforge/plantuml/UmlDiagram.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -56,12 +56,13 @@ import javax.script.ScriptException;
import net.sourceforge.plantuml.anim.Animation;
import net.sourceforge.plantuml.anim.AnimationDecoder;
import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.command.BlocLines;
+import net.sourceforge.plantuml.command.CommandControl;
import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandSkinParamMultilines;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
@@ -69,13 +70,12 @@ import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.fun.IconLoader;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
-import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
-import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
import net.sourceforge.plantuml.pdf.PdfConverter;
+import net.sourceforge.plantuml.sprite.Sprite;
import net.sourceforge.plantuml.svek.EmptySvgException;
import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
@@ -84,50 +84,29 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate;
-import net.sourceforge.plantuml.ugraphic.sprite.Sprite;
import net.sourceforge.plantuml.version.Version;
-public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Annotated, WithSprite {
+public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annotated, WithSprite {
private boolean rotation;
private boolean hideUnlinkedData;
private int minwidth = Integer.MAX_VALUE;
- private DisplayPositionned title = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.TOP);
- private DisplayPositionned caption = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
- private DisplayPositionned legend = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
- private final DisplaySection header = DisplaySection.none();
- private final DisplaySection footer = DisplaySection.none();
- private Display mainFrame;
-
private final Pragma pragma = new Pragma();
private Animation animation;
- private final SkinParam skinParam = SkinParam.create(getUmlDiagramType());
-
- final public void setTitle(DisplayPositionned title) {
- if (title.isNull() || title.getDisplay().isWhite()) {
- return;
- }
- this.title = title;
- }
-
- final public void setMainFrame(Display mainFrame) {
- this.mainFrame = mainFrame;
- }
-
- final public void setCaption(DisplayPositionned caption) {
- this.caption = caption;
- }
+ private final SkinParam skinParam;
- final public DisplayPositionned getCaption() {
- return caption;
+ public UmlDiagram() {
+ this.skinParam = SkinParam.create(getUmlDiagramType());
}
- @Override
- final public DisplayPositionned getTitle() {
- return title;
+ public UmlDiagram(ISkinSimple orig) {
+ this();
+ if (orig != null) {
+ this.skinParam.copyAllFrom(orig);
+ }
}
final public int getMinwidth() {
@@ -154,14 +133,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
skinParam.setParam(StringUtils.goLowerCase(key), value);
}
- public final DisplaySection getHeader() {
- return header;
- }
-
- public final DisplaySection getFooter() {
- return footer;
- }
-
public final DisplaySection getFooterOrHeaderTeoz(FontParam param) {
if (param == FontParam.FOOTER) {
return getFooter();
@@ -192,15 +163,11 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
return animation;
}
- public final double getDpiFactor(FileFormatOption fileFormatOption) {
+ public final double getScaleCoef(FileFormatOption fileFormatOption) {
if (getSkinParam().getDpi() == 96) {
- return 1.0;
+ return fileFormatOption.getScaleCoef();
}
- return getSkinParam().getDpi() / 96.0;
- }
-
- public final int getDpi(FileFormatOption fileFormatOption) {
- return getSkinParam().getDpi();
+ return getSkinParam().getDpi() * fileFormatOption.getScaleCoef() / 96.0;
}
public final boolean isHideUnlinkedData() {
@@ -219,6 +186,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
if (fileFormatOption.getSvgLinkTarget() == null || fileFormatOption.getSvgLinkTarget().equals("_top")) {
fileFormatOption = fileFormatOption.withSvgLinkTarget(getSkinParam().getSvgLinkTarget());
}
+ fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
if (hover != null) {
fileFormatOption = fileFormatOption.withHoverColor(StringUtils.getAsHtml(getSkinParam().getColorMapper()
@@ -423,14 +391,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
skinParam.addSprite(name, sprite);
}
- public final DisplayPositionned getLegend() {
- return legend;
- }
-
- public final void setLegend(DisplayPositionned legend) {
- this.legend = legend;
- }
-
private boolean useJDot;
public void setUseJDot(boolean useJDot) {
@@ -445,11 +405,54 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
return useJDot;
}
- private void setDotExecutable(String dotExecutable) {
- skinParam.setDotExecutable(dotExecutable);
+ public CommandExecutionResult loadSkin(String newSkin) throws IOException {
+ getSkinParam().setDefaultSkin(newSkin + ".skin");
+ return CommandExecutionResult.ok();
+ // final String res = "/skin/" + filename + ".skin";
+ // final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res);
+ // if (internalIs != null) {
+ // final BlocLines lines2 = BlocLines.load(internalIs, new LineLocationImpl(filename, null));
+ // return loadSkinInternal(lines2);
+ // }
+ // if (OptionFlags.ALLOW_INCLUDE == false) {
+ // return CommandExecutionResult.ok();
+ // }
+ // final File f = FileSystem.getInstance().getFile(filename + ".skin");
+ // if (f == null || f.exists() == false || f.canRead() == false) {
+ // return CommandExecutionResult.error("Cannot load skin from " + filename);
+ // }
+ // final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(), null));
+ // return loadSkinInternal(lines);
+ }
+
+ // private CommandExecutionResult loadSkinInternal(final BlocLines lines) {
+ // final CommandSkinParam cmd1 = new CommandSkinParam();
+ // final CommandSkinParamMultilines cmd2 = new CommandSkinParamMultilines();
+ // for (int i = 0; i < lines.size(); i++) {
+ // final BlocLines ext1 = lines.subList(i, i + 1);
+ // if (cmd1.isValid(ext1) == CommandControl.OK) {
+ // cmd1.execute(this, ext1);
+ // } else if (cmd2.isValid(ext1) == CommandControl.OK_PARTIAL) {
+ // i = tryMultilines(cmd2, i, lines);
+ // }
+ // }
+ // return CommandExecutionResult.ok();
+ // }
+
+ private int tryMultilines(CommandSkinParamMultilines cmd2, int i, BlocLines lines) {
+ for (int j = i + 1; j <= lines.size(); j++) {
+ final BlocLines ext1 = lines.subList(i, j);
+ if (cmd2.isValid(ext1) == CommandControl.OK) {
+ cmd2.execute(this, ext1);
+ return j;
+ } else if (cmd2.isValid(ext1) == CommandControl.NOT_OK) {
+ return j;
+ }
+ }
+ return i;
}
- public final Display getMainFrame() {
- return mainFrame;
+ public void setHideEmptyDescription(boolean hideEmptyDescription) {
}
+
}