diff --git a/pom.xml b/pom.xml index 1f08503ae..ce11cdd64 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 1.2021.1-SNAPSHOT + 1.2021.2-SNAPSHOT jar PlantUML diff --git a/src/jcckit/util/ConfigParameters.java b/src/jcckit/util/ConfigParameters.java index bfa4ae177..537f200ac 100644 --- a/src/jcckit/util/ConfigParameters.java +++ b/src/jcckit/util/ConfigParameters.java @@ -23,6 +23,7 @@ import java.util.StringTokenizer; import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; /** @@ -302,8 +303,12 @@ public class ConfigParameters { static private HColorSet colors = HColorSet.instance(); private Color decodeInternal(String value) { - if (colors.getColorIfValid(value)!=null) { - return new ColorMapperIdentity().toColor(colors.getColorIfValid(value)); + if (value!=null) { + try { + return new ColorMapperIdentity().toColor(colors.getColor(value, null)); + } catch (NoSuchColorException e) { + return Color.WHITE; + } } return Color.decode(value); } diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index 5ef76eef3..bcf59fe38 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.stats.StatsUtilsIncrement; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.version.License; import net.sourceforge.plantuml.version.Version; @@ -126,7 +127,11 @@ public abstract class AbstractPSystem implements Diagram { public CommandExecutionResult executeCommand(Command cmd, BlocLines lines) { cmd = new ProtectedCommand(cmd); - return cmd.execute(this, lines); + try { + return cmd.execute(this, lines); + } catch (NoSuchColorException e) { + return CommandExecutionResult.badColor(); + } } public boolean hasUrl() { diff --git a/src/net/sourceforge/plantuml/ColorParam.java b/src/net/sourceforge/plantuml/ColorParam.java index 5b6041431..983b60613 100644 --- a/src/net/sourceforge/plantuml/ColorParam.java +++ b/src/net/sourceforge/plantuml/ColorParam.java @@ -142,6 +142,8 @@ public enum ColorParam { nodeBorder(HColorUtils.BLACK, ColorType.LINE), rectangleBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK), rectangleBorder(HColorUtils.BLACK, ColorType.LINE), + hexagonBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK), + hexagonBorder(HColorUtils.BLACK, ColorType.LINE), archimateBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK), archimateBorder(HColorUtils.BLACK, ColorType.LINE), cardBackground(HColorUtils.MY_YELLOW, true, ColorType.BACK), diff --git a/src/net/sourceforge/plantuml/CornerParam.java b/src/net/sourceforge/plantuml/CornerParam.java index 971c6b8b6..f4161a4ad 100644 --- a/src/net/sourceforge/plantuml/CornerParam.java +++ b/src/net/sourceforge/plantuml/CornerParam.java @@ -36,7 +36,7 @@ package net.sourceforge.plantuml; public enum CornerParam { - DEFAULT, diagramBorder, titleBorder, rectangle, archimate, component, card, agent; + DEFAULT, diagramBorder, titleBorder, rectangle, hexagon, archimate, component, card, agent; public String getRoundKey() { if (this == DEFAULT) { diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java index 69dce46a1..7c4f0a947 100644 --- a/src/net/sourceforge/plantuml/EmbeddedDiagram.java +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -83,6 +83,12 @@ public class EmbeddedDiagram implements CharSequence { if (s.equals("{{json")) { return "json"; } + if (s.equals("{{yaml")) { + return "yaml"; + } + if (s.equals("{{wire")) { + return "wire"; + } return null; } diff --git a/src/net/sourceforge/plantuml/ErrorUml.java b/src/net/sourceforge/plantuml/ErrorUml.java index 82267a388..903a36bea 100644 --- a/src/net/sourceforge/plantuml/ErrorUml.java +++ b/src/net/sourceforge/plantuml/ErrorUml.java @@ -35,22 +35,27 @@ */ package net.sourceforge.plantuml; - public class ErrorUml { private final String error; private final ErrorUmlType type; private final LineLocation lineLocation; + private final int score; - public ErrorUml(ErrorUmlType type, String error, LineLocation lineLocation) { + public ErrorUml(ErrorUmlType type, String error, int score, LineLocation lineLocation) { if (error == null || type == null) { throw new IllegalArgumentException(); } + this.score = score; this.error = error; this.type = type; this.lineLocation = lineLocation; } + public int score() { + return score; + } + @Override public boolean equals(Object obj) { final ErrorUml this2 = (ErrorUml) obj; diff --git a/src/net/sourceforge/plantuml/FileFormat.java b/src/net/sourceforge/plantuml/FileFormat.java index 624d1394f..bd6c3e28e 100644 --- a/src/net/sourceforge/plantuml/FileFormat.java +++ b/src/net/sourceforge/plantuml/FileFormat.java @@ -46,9 +46,8 @@ import java.io.IOException; import net.sourceforge.plantuml.braille.BrailleCharFactory; import net.sourceforge.plantuml.braille.UGraphicBraille; -import net.sourceforge.plantuml.graphic.FontStyle; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.StyledString; +import net.sourceforge.plantuml.graphic.StringBounderRaw; import net.sourceforge.plantuml.png.MetadataTag; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.svg.SvgGraphics; @@ -116,12 +115,12 @@ public enum FileFormat { } private StringBounder getSvgStringBounder(final SvgCharSizeHack charSizeHack) { - return new StringBounder() { + return new StringBounderRaw() { public String toString() { return "FileFormat::getSvgStringBounder"; } - public Dimension2D calculateDimension(UFont font, String text) { + protected Dimension2D calculateDimensionInternal(UFont font, String text) { text = charSizeHack.transformStringForSizeHack(text); return getJavaDimension(font, text); } @@ -130,13 +129,13 @@ public enum FileFormat { } private StringBounder getNormalStringBounder() { - return new StringBounder() { + return new StringBounderRaw() { @Override public String toString() { return "FileFormat::getNormalStringBounder"; } - public Dimension2D calculateDimension(UFont font, String text) { + protected Dimension2D calculateDimensionInternal(UFont font, String text) { return getJavaDimension(font, text); } @@ -144,30 +143,20 @@ public enum FileFormat { } static private Dimension2DDouble getJavaDimension(UFont font, String text) { - double width = 0; - double height = 0; - for (StyledString styledString : StyledString.build(text)) { - final Font javaFont; - if (styledString.getStyle() == FontStyle.BOLD) - javaFont = font.bold().getFont(); - else - javaFont = font.getFont(); - final FontMetrics fm = gg.getFontMetrics(javaFont); - final Rectangle2D rect = fm.getStringBounds(styledString.getText(), gg); - width += rect.getWidth(); - height = Math.max(height, rect.getHeight()); - } - return new Dimension2DDouble(width, height); + final Font javaFont = font.getFont(); + final FontMetrics fm = gg.getFontMetrics(javaFont); + final Rectangle2D rect = fm.getStringBounds(text, gg); + return new Dimension2DDouble(rect.getWidth(), rect.getHeight()); } private StringBounder getBrailleStringBounder() { - return new StringBounder() { + return new StringBounderRaw() { @Override public String toString() { return "FileFormat::getBrailleStringBounder"; } - public Dimension2D calculateDimension(UFont font, String text) { + protected Dimension2D calculateDimensionInternal(UFont font, String text) { final int nb = BrailleCharFactory.build(text).size(); final double quanta = UGraphicBraille.QUANTA; final double height = 5 * quanta; @@ -178,13 +167,13 @@ public enum FileFormat { } private StringBounder getTikzStringBounder(final TikzFontDistortion tikzFontDistortion) { - return new StringBounder() { + return new StringBounderRaw() { @Override public String toString() { return "FileFormat::getTikzStringBounder"; } - public Dimension2D calculateDimension(UFont font, String text) { + protected Dimension2D calculateDimensionInternal(UFont font, String text) { final Dimension2DDouble w1 = getJavaDimension(font.goTikz(-1), text); final Dimension2DDouble w2 = getJavaDimension(font.goTikz(0), text); final Dimension2DDouble w3 = getJavaDimension(font.goTikz(1), text); diff --git a/src/net/sourceforge/plantuml/FileSystem.java b/src/net/sourceforge/plantuml/FileSystem.java index 8a3d91ca1..69ad20c63 100644 --- a/src/net/sourceforge/plantuml/FileSystem.java +++ b/src/net/sourceforge/plantuml/FileSystem.java @@ -44,7 +44,7 @@ public class FileSystem { private final static FileSystem singleton = new FileSystem(); - private final ThreadLocal currentDir = new ThreadLocal(); + private ThreadLocal currentDir = new ThreadLocal(); private FileSystem() { reset(); @@ -55,24 +55,27 @@ public class FileSystem { } public void setCurrentDir(SFile dir) { - // if (dir == null) { - // throw new IllegalArgumentException(); - // } - if (dir != null) { + if (dir == null) { + this.currentDir.set(null); + } else { Log.info("Setting current dir: " + dir.getAbsolutePath()); + this.currentDir.set(dir.getAbsolutePath()); } - this.currentDir.set(dir); } public SFile getCurrentDir() { - return this.currentDir.get(); + final String path = this.currentDir.get(); + if (path != null) { + return new SFile(path); + } + return null; } public SFile getFile(String nameOrPath) throws IOException { if (isAbsolute(nameOrPath)) { return new SFile(nameOrPath).getCanonicalFile(); } - final SFile dir = currentDir.get(); + final SFile dir = getCurrentDir(); SFile filecurrent = null; if (dir != null) { filecurrent = dir.getAbsoluteFile().file(nameOrPath); diff --git a/src/net/sourceforge/plantuml/FontParam.java b/src/net/sourceforge/plantuml/FontParam.java index 683c88c27..7ea7bdf9a 100644 --- a/src/net/sourceforge/plantuml/FontParam.java +++ b/src/net/sourceforge/plantuml/FontParam.java @@ -79,6 +79,8 @@ public enum FontParam { ENTITY(14, Font.PLAIN), // AGENT(14, Font.PLAIN), // RECTANGLE(14, Font.PLAIN), // + LABEL(14, Font.PLAIN), // + HEXAGON(14, Font.PLAIN), // ARCHIMATE(14, Font.PLAIN), // CARD(14, Font.PLAIN), // NODE(14, Font.PLAIN), // @@ -113,6 +115,8 @@ public enum FontParam { ENTITY_STEREOTYPE(14, Font.ITALIC), // AGENT_STEREOTYPE(14, Font.ITALIC), // RECTANGLE_STEREOTYPE(14, Font.ITALIC), // + LABEL_STEREOTYPE(14, Font.ITALIC), // + HEXAGON_STEREOTYPE(14, Font.ITALIC), // ARCHIMATE_STEREOTYPE(14, Font.ITALIC), // CARD_STEREOTYPE(14, Font.ITALIC), // NODE_STEREOTYPE(14, Font.ITALIC), // diff --git a/src/net/sourceforge/plantuml/GeneratedImageImpl.java b/src/net/sourceforge/plantuml/GeneratedImageImpl.java index ddc103c10..f8a0614fc 100644 --- a/src/net/sourceforge/plantuml/GeneratedImageImpl.java +++ b/src/net/sourceforge/plantuml/GeneratedImageImpl.java @@ -61,7 +61,7 @@ public class GeneratedImageImpl implements GeneratedImage { } public File getPngFile() { - return pngFile.internal; + return pngFile.conv(); } public String getDescription() { diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index c1d69a15d..11454ede3 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public interface ISkinParam extends ISkinSimple { @@ -68,7 +69,7 @@ public interface ISkinParam extends ISkinSimple { public HColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable); - public Colors getColors(ColorParam param, Stereotype stereotype); + public Colors getColors(ColorParam param, Stereotype stereotype) throws NoSuchColorException; public HColor getFontHtmlColor(Stereotype stereotype, FontParam... param); diff --git a/src/net/sourceforge/plantuml/LineParam.java b/src/net/sourceforge/plantuml/LineParam.java index 3b3704394..89fdc66e2 100644 --- a/src/net/sourceforge/plantuml/LineParam.java +++ b/src/net/sourceforge/plantuml/LineParam.java @@ -55,6 +55,7 @@ public enum LineParam { titleBorder, diagramBorder, rectangleBorder, + hexagonBorder, archimateBorder, componentBorder, cardBorder, diff --git a/src/net/sourceforge/plantuml/NewpagedDiagram.java b/src/net/sourceforge/plantuml/NewpagedDiagram.java index 5d15f5c2a..0dff3902d 100644 --- a/src/net/sourceforge/plantuml/NewpagedDiagram.java +++ b/src/net/sourceforge/plantuml/NewpagedDiagram.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class NewpagedDiagram extends AbstractPSystem { @@ -74,22 +75,26 @@ public class NewpagedDiagram extends AbstractPSystem { public CommandExecutionResult executeCommand(Command cmd, BlocLines lines) { final int nb = diagrams.size(); - final CommandExecutionResult tmp = cmd.execute(diagrams.get(nb - 1), lines); - if (tmp.getNewDiagram() instanceof NewpagedDiagram) { - final NewpagedDiagram new1 = (NewpagedDiagram) tmp.getNewDiagram(); - // System.err.println("this=" + this); - // System.err.println("new1=" + new1); - if (new1.size() != 2) { - throw new IllegalStateException(); - } - if (new1.diagrams.get(0) != this.diagrams.get(nb - 1)) { - throw new IllegalStateException(); - } - this.diagrams.add(new1.diagrams.get(1)); - return tmp.withDiagram(this); + try { + final CommandExecutionResult tmp = cmd.execute(diagrams.get(nb - 1), lines); + if (tmp.getNewDiagram() instanceof NewpagedDiagram) { + final NewpagedDiagram new1 = (NewpagedDiagram) tmp.getNewDiagram(); + // System.err.println("this=" + this); + // System.err.println("new1=" + new1); + if (new1.size() != 2) { + throw new IllegalStateException(); + } + if (new1.diagrams.get(0) != this.diagrams.get(nb - 1)) { + throw new IllegalStateException(); + } + this.diagrams.add(new1.diagrams.get(1)); + return tmp.withDiagram(this); + } + return tmp; + } catch (NoSuchColorException e) { + return CommandExecutionResult.badColor(); } - return tmp; } private int size() { diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 1689482c4..782c14eaa 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -118,7 +118,7 @@ public class PSystemBuilder { // Dead code : should not append assert false; Log.error("Preprocessor Error: " + s.getPreprocessorError()); - final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), /* cpt */ + final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), 0, s.getLocation()); return PSystemErrorUtils.buildV2(umlSource, err, Collections.emptyList(), source); } diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 2dbeff312..99ed934b5 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -85,6 +85,7 @@ import net.sourceforge.plantuml.ugraphic.color.ColorOrder; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class SkinParam implements ISkinParam { @@ -316,8 +317,8 @@ public class SkinParam implements ISkinParam { checkStereotype(stereotype); for (String s : stereotype.getMultipleLabels()) { final String value2 = getValue(param.name() + "color" + "<<" + s + ">>"); - if (value2 != null && getIHtmlColorSet().getColorIfValid(value2) != null) { - return getIHtmlColorSet().getColorIfValid(value2); + if (value2 != null && getIHtmlColorSet().getColorOrWhite(value2) != null) { + return getIHtmlColorSet().getColorOrWhite(value2); } } } @@ -330,12 +331,12 @@ public class SkinParam implements ISkinParam { return HColorUtils.transparent(); } if (param == ColorParam.background) { - return getIHtmlColorSet().getColorIfValid(value); + return getIHtmlColorSet().getColorOrWhite(value); } assert param != ColorParam.background; // final boolean acceptTransparent = param == ColorParam.background // || param == ColorParam.sequenceGroupBodyBackground || param == ColorParam.sequenceBoxBackground; - return getIHtmlColorSet().getColorIfValid(value, getBackgroundColor(false)); + return getIHtmlColorSet().getColorOrWhite(value, getBackgroundColor(false)); } public char getCircledCharacter(Stereotype stereotype) { @@ -349,11 +350,11 @@ public class SkinParam implements ISkinParam { return 0; } - public Colors getColors(ColorParam param, Stereotype stereotype) { + public Colors getColors(ColorParam param, Stereotype stereotype) throws NoSuchColorException { if (stereotype != null) { checkStereotype(stereotype); final String value2 = getValue(param.name() + "color" + stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR)); - if (value2 != null && getIHtmlColorSet().getColorIfValid(value2) != null) { + if (value2 != null) { return new Colors(value2, getIHtmlColorSet(), param.getColorType()); } } @@ -430,16 +431,19 @@ public class SkinParam implements ISkinParam { value = getFirstValueNonNullWithSuffix("fontcolor" + stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR), param); } - if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) { + if (value == null) { value = getFirstValueNonNullWithSuffix("fontcolor", param); } - if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) { + if (value == null) { value = getValue("defaultfontcolor"); } - if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) { + if (value == null) { value = param[0].getDefaultColor(); } - return getIHtmlColorSet().getColorIfValid(value); + if (value == null) { + return null; + } + return getIHtmlColorSet().getColorOrWhite(value); } private String getFirstValueNonNullWithSuffix(String suffix, FontParam... param) { @@ -1130,8 +1134,9 @@ public class SkinParam implements ISkinParam { margin = Integer.parseInt(marginString); } - return new SplitParam(getIHtmlColorSet().getColorIfValid(border), getIHtmlColorSet().getColorIfValid(external), - margin); + final HColor borderColor = border == null ? null : getIHtmlColorSet().getColorOrWhite(border); + final HColor externalColor = external == null ? null : getIHtmlColorSet().getColorOrWhite(external); + return new SplitParam(borderColor, externalColor, margin); } public int swimlaneWidth() { @@ -1154,7 +1159,7 @@ public class SkinParam implements ISkinParam { if (value == null) { return null; } - return getIHtmlColorSet().getColorIfValid(value, null); + return getIHtmlColorSet().getColorOrWhite(value, null); } public double getPadding() { @@ -1232,8 +1237,8 @@ public class SkinParam implements ISkinParam { if (padding == 0 && margin == 0 && borderColor == null && backgroundColor == null) { return Padder.NONE; } - final HColor border = getIHtmlColorSet().getColorIfValid(borderColor); - final HColor background = getIHtmlColorSet().getColorIfValid(backgroundColor); + final HColor border = borderColor == null ? null : getIHtmlColorSet().getColorOrWhite(borderColor); + final HColor background = backgroundColor == null ? null : getIHtmlColorSet().getColorOrWhite(backgroundColor); final double roundCorner = getRoundCorner(CornerParam.DEFAULT, null); return Padder.NONE.withMargin(margin).withPadding(padding).withBackgroundColor(background) .withBorderColor(border).withRoundCorner(roundCorner); diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index b9292535c..ea832c533 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class SkinParamDelegator implements ISkinParam { @@ -245,7 +246,7 @@ public class SkinParamDelegator implements ISkinParam { return skinParam.getMonospacedFamily(); } - public Colors getColors(ColorParam param, Stereotype stereotype) { + public Colors getColors(ColorParam param, Stereotype stereotype) throws NoSuchColorException { return skinParam.getColors(param, stereotype); } diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index 6e39b76fc..670b10d96 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -182,11 +182,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot } catch (UnparsableGraphvizException e) { e.printStackTrace(); exportDiagramError(os, e.getCause(), fileFormatOption, seed, e.getGraphvizVersion()); - } catch (Exception e) { - e.printStackTrace(); - exportDiagramError(os, e, fileFormatOption, seed, null); - } catch (Error e) { - e.printStackTrace(); + } catch (Throwable e) { + //e.printStackTrace(); exportDiagramError(os, e, fileFormatOption, seed, null); } return ImageDataSimple.error(); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java index 3fdc79122..2590e1f5d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java @@ -67,6 +67,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandLinkActivity extends SingleLineCommand2 { @@ -121,7 +122,7 @@ public class CommandLinkActivity extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final IEntity entity1 = getEntity(diagram, arg, true); if (entity1 == null) { return CommandExecutionResult.error("No such activity"); @@ -130,8 +131,9 @@ public class CommandLinkActivity extends SingleLineCommand2 { entity1.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0))); } if (arg.get("BACKCOLOR", 0) != null) { - entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(arg.get("BACKCOLOR", 0))); + String s = arg.get("BACKCOLOR", 0); + entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, + diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } final IEntity entity2 = getEntity(diagram, arg, false); @@ -139,8 +141,9 @@ public class CommandLinkActivity extends SingleLineCommand2 { return CommandExecutionResult.error("No such activity"); } if (arg.get("BACKCOLOR2", 0) != null) { - entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(arg.get("BACKCOLOR2", 0))); + String s = arg.get("BACKCOLOR2", 0); + entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, + diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } if (arg.get("STEREOTYPE2", 0) != null) { entity2.setStereotype(new Stereotype(arg.get("STEREOTYPE2", 0))); @@ -163,7 +166,8 @@ public class CommandLinkActivity extends SingleLineCommand2 { type = type.goDotted(); } - Link link = new Link(entity1, entity2, type, linkLabel, lenght, diagram.getSkinParam().getCurrentStyleBuilder()); + Link link = new Link(entity1, entity2, type, linkLabel, lenght, + diagram.getSkinParam().getCurrentStyleBuilder()); if (arrowDirection.contains("*")) { link.setConstraint(false); } @@ -215,8 +219,8 @@ public class CommandLinkActivity extends SingleLineCommand2 { } final Ident ident = diagram.buildLeafIdent(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); - final LeafType type = diagram.V1972() ? getTypeIfExistingSmart(diagram, ident) : getTypeIfExisting(diagram, - code); + final LeafType type = diagram.V1972() ? getTypeIfExistingSmart(diagram, ident) + : getTypeIfExisting(diagram, code); IEntity result; if (diagram.V1972()) { result = diagram.getLeafVerySmart(ident); @@ -252,8 +256,8 @@ public class CommandLinkActivity extends SingleLineCommand2 { } final Ident quotedIdent = diagram.buildLeafIdent(quotedString); final Code quotedCode = diagram.V1972() ? quotedIdent : diagram.buildCode(quotedString); - final LeafType type = diagram.V1972() ? getTypeIfExistingSmart(diagram, quotedIdent) : getTypeIfExisting( - diagram, quotedCode); + final LeafType type = diagram.V1972() ? getTypeIfExistingSmart(diagram, quotedIdent) + : getTypeIfExisting(diagram, quotedCode); final IEntity result = diagram.getOrCreate(quotedIdent, quotedCode, Display.getWithNewlines(quoted.get(0)), type); if (partition != null) { diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java index 84fb2273c..522fd8e78 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java @@ -70,6 +70,7 @@ import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandLinkLongActivity extends CommandMultilines2 { @@ -114,7 +115,7 @@ public class CommandLinkLongActivity extends CommandMultilines2 } @Override - protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) throws NoSuchColorException { lines = lines.trim(); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); @@ -128,8 +129,8 @@ public class CommandLinkLongActivity extends CommandMultilines2 } final String stringColor = line0.get("BACKCOLOR", 0); if (stringColor != null) { - entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(stringColor)); + entity1.setSpecificColorTOBEREMOVED(ColorType.BACK, + diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor)); } final StringBuilder sb = new StringBuilder(); @@ -157,8 +158,8 @@ public class CommandLinkLongActivity extends CommandMultilines2 } } - final List lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast() - .getString()); + final List lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), + lines.getLast().getString()); if (StringUtils.isNotEmpty(lineLast.get(0))) { if (sb.length() > 0 && sb.toString().endsWith(BackSlash.BS_BS_N) == false) { sb.append(BackSlash.BS_BS_N); @@ -197,8 +198,9 @@ public class CommandLinkLongActivity extends CommandMultilines2 entity2.setStereotype(new Stereotype(lineLast.get(2))); } if (lineLast.get(4) != null) { - entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(lineLast.get(4))); + String s = lineLast.get(4); + entity2.setSpecificColorTOBEREMOVED(ColorType.BACK, + diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } final String arrowBody1 = CommandLinkClass.notNull(line0.get("ARROW_BODY1", 0)); @@ -215,7 +217,8 @@ public class CommandLinkLongActivity extends CommandMultilines2 if (arrow.contains(".")) { type = type.goDotted(); } - Link link = new Link(entity1, entity2, type, linkLabel, lenght, diagram.getSkinParam().getCurrentStyleBuilder()); + Link link = new Link(entity1, entity2, type, linkLabel, lenght, + diagram.getSkinParam().getCurrentStyleBuilder()); final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">"); if (direction == Direction.LEFT || direction == Direction.UP) { link = link.getInv(); diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index a3b48486a..ceb82daaf 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandPartition extends SingleLineCommand2 { @@ -84,7 +85,7 @@ public class CommandPartition extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); final Ident ident = diagram.buildLeafIdent(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index 6c7fcc452..e979e83e1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandActivity3 extends SingleLineCommand2 { @@ -101,7 +102,8 @@ public class CommandActivity3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { final Url url; if (arg.get("URL", 0) == null) { @@ -119,7 +121,8 @@ public class CommandActivity3 extends SingleLineCommand2 { colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.activityBackground); } final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0)); - diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), style, url, colors, stereotype); + final Display display = Display.getWithNewlines2(arg.get("LABEL", 0)); + diagram.addActivity(display, style, url, colors, stereotype); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java index 2cd7906b3..3481664d4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandActivityLong3 extends CommandMultilines2 { @@ -73,7 +74,7 @@ public class CommandActivityLong3 extends CommandMultilines2 { } @Override - protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) throws NoSuchColorException { lines = lines.removeEmptyColumns(); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java index 886b29acf..64e0a9b92 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandArrow3 extends SingleLineCommand2 { @@ -67,7 +68,7 @@ public class CommandArrow3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String colorString = arg.get("COLOR", 0); if (colorString != null) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java index 44b0db219..561a5e3e5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandArrowLong3 extends CommandMultilines2 { @@ -72,7 +73,7 @@ public class CommandArrowLong3 extends CommandMultilines2 { } @Override - protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) throws NoSuchColorException { lines = lines.removeEmptyColumns(); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); // final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java index 6cd3b9944..96661de80 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandBackward3.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandBackward3 extends SingleLineCommand2 { @@ -85,7 +86,7 @@ public class CommandBackward3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final BoxStyle boxStyle; final String styleString = arg.get("STYLE", 0); @@ -103,7 +104,7 @@ public class CommandBackward3 extends SingleLineCommand2 { return diagram.backward(label, boxStyle, in, out); } - static public LinkRendering getBackRendering(ActivityDiagram3 diagram, RegexResult arg, String name) { + static public LinkRendering getBackRendering(ActivityDiagram3 diagram, RegexResult arg, String name) throws NoSuchColorException { final LinkRendering in; final Rainbow incomingColor = getRainbow(name + "_COLOR", diagram, arg); if (incomingColor == null) @@ -114,7 +115,7 @@ public class CommandBackward3 extends SingleLineCommand2 { return in.withDisplay(Display.getWithNewlines(label)); } - static private Rainbow getRainbow(String key, ActivityDiagram3 diagram, RegexResult arg) { + static private Rainbow getRainbow(String key, ActivityDiagram3 diagram, RegexResult arg) throws NoSuchColorException { final String colorString = arg.get(key, 0); if (colorString == null) { return null; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java index f71501cf5..bd86e03f9 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandCircleSpot3.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandCircleSpot3 extends SingleLineCommand2 { @@ -61,8 +62,9 @@ public class CommandCircleSpot3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); diagram.addSpot(arg.get("SPOT", 0), color); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java index 72612b0c2..49fd5c0b5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandElse3 extends SingleLineCommand2 { @@ -71,7 +72,7 @@ public class CommandElse3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { // if (getSystem().getLastEntityConsulted() == null) { // return CommandExecutionResult.error("No if for this endif"); // } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java index 4350e5aec..ff19839c2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandElseIf2 extends SingleLineCommand2 { @@ -95,8 +96,9 @@ public class CommandElseIf2 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); String test = arg.get("TEST", 0); if (test.length() == 0) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java index e264ff25f..83a1ecaac 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandIf2 extends SingleLineCommand2 { @@ -78,8 +79,9 @@ public class CommandIf2 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); String test = arg.get("TEST", 0); if (test.length() == 0) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java index c6719a4a5..0d09a5f61 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandIf4 extends SingleLineCommand2 { @@ -75,8 +76,9 @@ public class CommandIf4 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); String test = arg.get("TEST", 0); if (test.length() == 0) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java index a3c40d47a..b1f68e6ea 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandLink3 extends SingleLineCommand2 { @@ -62,8 +63,9 @@ public class CommandLink3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); if (color != null) { diagram.setColorNextArrow(Rainbow.fromColor(color, null)); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java index 6a32573e4..016bdbb93 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandNote3 extends SingleLineCommand2 { @@ -75,7 +76,7 @@ public class CommandNote3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); final Display note = Display.getWithNewlines(arg.get("NOTE", 0)); final NotePosition position = NotePosition.defaultLeft(arg.get("POSITION", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java index 91ee7ca92..c0234ae15 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandNoteLong3 extends CommandMultilines2 { @@ -67,7 +68,7 @@ public class CommandNoteLong3 extends CommandMultilines2 { } @Override - protected CommandExecutionResult executeNow(final ActivityDiagram3 diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(final ActivityDiagram3 diagram, BlocLines lines) throws NoSuchColorException { // final List in = StringUtils.removeEmptyColumns2(lines.subList(1, lines.size() - 1)); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java index e177bd6ed..7189e80f7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandPartition3 extends SingleLineCommand2 { @@ -118,7 +119,7 @@ public class CommandPartition3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); final String b1 = arg.get("BACK1", 0); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java index 51afc90de..3c3050a27 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandRepeat3 extends SingleLineCommand2 { @@ -76,8 +77,9 @@ public class CommandRepeat3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); final BoxStyle boxStyle; final String styleString = arg.get("STYLE", 0); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java index eb16ae64d..6e09ea07b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandRepeatWhile3 extends SingleLineCommand2 { @@ -100,7 +101,7 @@ public class CommandRepeatWhile3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final Display test = Display.getWithNewlines(arg.getLazzy("TEST", 0)); final Display yes = Display.getWithNewlines(arg.getLazzy("WHEN", 0)); final Display out = Display.getWithNewlines(arg.getLazzy("OUT", 0)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java index a8044eac1..3182e6ab2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandSwimlane extends SingleLineCommand2 { @@ -64,8 +65,9 @@ public class CommandSwimlane extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); final String name = arg.get("SWIMLANE", 0); final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); return diagram.swimlane(name, color, label); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java index 30b783d66..9c965bd7e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandSwimlane2 extends SingleLineCommand2 { @@ -72,8 +73,9 @@ public class CommandSwimlane2 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); final String name = arg.get("SWIMLANE", 0); final Display label = Display.getWithNewlines(arg.get("LABEL", 0)); return diagram.swimlane(name, color, label); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java index 84f199f9d..5a383899e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwitch.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandSwitch extends SingleLineCommand2 { @@ -66,8 +67,9 @@ public class CommandSwitch extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); String test = arg.get("TEST", 0); if (test.length() == 0) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java index 324e3cc98..4206f95b2 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandWhile3 extends SingleLineCommand2 { @@ -72,8 +73,9 @@ public class CommandWhile3 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { - final HColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); + protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); + final HColor color = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); diagram.doWhile(Display.getWithNewlines(arg.get("TEST", 0)), Display.getWithNewlines(arg.get("YES", 0)), color); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index c1cabb84e..06edb211e 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -74,6 +74,7 @@ import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class VCompactFactory implements FtileFactory { @@ -111,16 +112,19 @@ public class VCompactFactory implements FtileFactory { } public Ftile stop(Swimlane swimlane) { - final HColor backColor = skinParam.getBackgroundColor(false); final HColor borderColor; Style style = null; + final HColor backgroundColor; if (UseStyle.useBetaStyle()) { style = getDefaultStyleDefinitionCircle().getMergedStyle(skinParam.getCurrentStyleBuilder()); borderColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + // backgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); + backgroundColor = skinParam.getBackgroundColor(false); } else { borderColor = rose.getHtmlColor(skinParam, ColorParam.activityEnd); + backgroundColor = skinParam.getBackgroundColor(false); } - return new FtileCircleStop(skinParam(), backColor, borderColor, swimlane, style); + return new FtileCircleStop(skinParam(), backgroundColor, borderColor, swimlane, style); } public Ftile spot(Swimlane swimlane, String spot, HColor color) { @@ -131,16 +135,19 @@ public class VCompactFactory implements FtileFactory { } public Ftile end(Swimlane swimlane) { - final HColor backColor = skinParam.getBackgroundColor(false); final HColor borderColor; Style style = null; + final HColor backgroundColor; if (UseStyle.useBetaStyle()) { style = getDefaultStyleDefinitionCircle().getMergedStyle(skinParam.getCurrentStyleBuilder()); borderColor = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + // backgroundColor = style.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); + backgroundColor = skinParam.getBackgroundColor(false); } else { borderColor = rose.getHtmlColor(skinParam, ColorParam.activityEnd); + backgroundColor = skinParam.getBackgroundColor(false); } - return new FtileCircleEnd(skinParam(), backColor, borderColor, swimlane, style); + return new FtileCircleEnd(skinParam(), backgroundColor, borderColor, swimlane, style); } public Ftile activity(Display label, Swimlane swimlane, BoxStyle boxStyle, Colors colors, Stereotype stereotype) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java index a1a27324e..bfcda35a3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java @@ -59,8 +59,8 @@ public class FtileCircleEnd extends AbstractFtile { private static final int SIZE = 20; - private final HColor backColor; private final HColor borderColor; + private final HColor backColor; private final Swimlane swimlane; private double shadowing; @@ -71,8 +71,8 @@ public class FtileCircleEnd extends AbstractFtile { public FtileCircleEnd(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane, Style style) { super(skinParam); - this.backColor = backColor; this.borderColor = borderColor; + this.backColor = backColor; this.swimlane = swimlane; if (UseStyle.useBetaStyle()) { this.shadowing = style.value(PName.Shadowing).asDouble(); @@ -108,8 +108,8 @@ public class FtileCircleEnd extends AbstractFtile { circle.setDeltaShadow(shadowing); ug = ug.apply(borderColor); final double thickness = 2.5; - ug.apply(backColor.bg()).apply(new UStroke(1.5)) - .apply(new UTranslate(xTheoricalPosition, yTheoricalPosition)).draw(circle); + ug.apply(backColor.bg()).apply(new UStroke(1.5)).apply(new UTranslate(xTheoricalPosition, yTheoricalPosition)) + .draw(circle); final double size2 = (SIZE - thickness) / Math.sqrt(2); final double delta = (SIZE - size2) / 2; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java index 57fea8063..e76423ca5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java @@ -52,13 +52,14 @@ import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorMiddle; public class FtileCircleStop extends AbstractFtile { private static final int SIZE = 22; - private final HColor backColor; private final HColor borderColor; + private final HColor backColor; private final Swimlane swimlane; private double shadowing; @@ -69,8 +70,8 @@ public class FtileCircleStop extends AbstractFtile { public FtileCircleStop(ISkinParam skinParam, HColor backColor, HColor borderColor, Swimlane swimlane, Style style) { super(skinParam); - this.backColor = backColor; this.borderColor = borderColor; + this.backColor = backColor; this.swimlane = swimlane; if (UseStyle.useBetaStyle()) { this.shadowing = style.value(PName.Shadowing).asDouble(); @@ -99,15 +100,16 @@ public class FtileCircleStop extends AbstractFtile { public void drawU(UGraphic ug) { final UEllipse circle = new UEllipse(SIZE, SIZE); circle.setDeltaShadow(shadowing); - ug = ug.apply(borderColor); - ug.apply(backColor.bg()).draw(circle); + + ug.apply(borderColor).apply(backColor.bg()).draw(circle); final double delta = 5; final UEllipse circleSmall = new UEllipse(SIZE - delta * 2, SIZE - delta * 2); // if (skinParam().shadowing(null)) { // circleSmall.setDeltaShadow(3); // } - ug.apply(borderColor.bg()).apply(new UTranslate(delta, delta)).draw(circleSmall); + ug.apply(new HColorMiddle(borderColor, backColor)).apply(borderColor.bg()).apply(new UTranslate(delta, delta)) + .draw(circleSmall); } @Override diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java index ee9a12975..fdaa3c459 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java @@ -68,10 +68,10 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo this.maxAsciiMessageLength = maxAsciiMessageLength; this.type = type; this.config = config; - this.stringsToDisplay = clean(stringsToDisplay); + this.stringsToDisplay = cleanAndManageBoldNumber(stringsToDisplay, fileFormat); } - private Display clean(Display orig) { + public static Display cleanAndManageBoldNumber(Display orig, FileFormat fileFormat) { if (orig.size() == 0 || orig.get(0) instanceof MessageNumber == false) { return orig; } @@ -79,7 +79,7 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo for (int i = 0; i < orig.size(); i++) { CharSequence element = orig.get(i); if (i == 1) { - element = removeTag(orig.get(0).toString()) + " " + element; + element = removeTagAndManageBoldNumber(orig.get(0).toString(), fileFormat) + " " + element; } if (i != 0) { result = result.add(element); @@ -88,7 +88,7 @@ public class ComponentTextArrow extends AbstractComponentText implements ArrowCo return result; } - private String removeTag(String s) { + private static String removeTagAndManageBoldNumber(String s, FileFormat fileFormat) { if (fileFormat == FileFormat.UTXT) { final Pattern pattern = Pattern.compile("\\([0-9]+)\\"); final Matcher matcher = pattern.matcher(s); diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java index 78a77ef1c..ec03d56ce 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java @@ -60,7 +60,7 @@ public class ComponentTextSelfArrow extends AbstractComponentText implements Arr public ComponentTextSelfArrow(ComponentType type, ArrowConfiguration config, Display stringsToDisplay, FileFormat fileFormat) { this.type = type; - this.stringsToDisplay = stringsToDisplay; + this.stringsToDisplay = ComponentTextArrow.cleanAndManageBoldNumber(stringsToDisplay, fileFormat); this.fileFormat = fileFormat; this.config = config; } diff --git a/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java b/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java index 9bd92799f..465917a1e 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java +++ b/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java @@ -38,12 +38,12 @@ package net.sourceforge.plantuml.asciiart; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.StringBounderRaw; import net.sourceforge.plantuml.ugraphic.UFont; -public class TextStringBounder implements StringBounder { +public class TextStringBounder extends StringBounderRaw { - public Dimension2D calculateDimension(UFont font, String text) { + protected Dimension2D calculateDimensionInternal(UFont font, String text) { final int length1 = text.codePointCount(0, text.length()); final int length2 = text.length(); final int length3 = Wcwidth.length(text); diff --git a/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java index 3ec562326..35256ec5e 100644 --- a/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java +++ b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java @@ -92,9 +92,9 @@ public class UmlCharAreaImpl extends BasicCharAreaImpl implements UmlCharArea { x = 0; } for (CharSequence s : strings) { - if (s instanceof MessageNumber) { - s = StringUtils.toInternalBoldNumber((((MessageNumber) s).getNumberRaw())); - } +// if (s instanceof MessageNumber) { +// s = StringUtils.toInternalBoldNumber((((MessageNumber) s).getNumberRaw())); +// } this.drawStringLR(s.toString(), x, y + i); i++; } diff --git a/src/net/sourceforge/plantuml/braille/BrailleDrawer.java b/src/net/sourceforge/plantuml/braille/BrailleDrawer.java index 5bbe70fb8..a03466906 100644 --- a/src/net/sourceforge/plantuml/braille/BrailleDrawer.java +++ b/src/net/sourceforge/plantuml/braille/BrailleDrawer.java @@ -54,7 +54,7 @@ public class BrailleDrawer implements UDrawable { } public void drawU(UGraphic ug) { - ug = ug.apply(HColorSet.instance().getColorIfValid("#F0F0F0")); + ug = ug.apply(HColorSet.instance().getColorOrWhite("#F0F0F0")); for (int x = grid.getMinX(); x <= grid.getMaxX(); x++) { ug.apply(UTranslate.dx(x * step + spotSize + 1)).draw( ULine.vline((grid.getMaxY() - grid.getMinY()) * step)); diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java index 10f152b9d..839c3cfdd 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandCreateClass extends SingleLineCommand2 { @@ -123,7 +124,7 @@ public class CommandCreateClass extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0))); final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.getLazzy("CODE", 0), "\"([:"); @@ -172,8 +173,9 @@ public class CommandCreateClass extends SingleLineCommand2 { entity.setCodeLine(location); Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + final String s = arg.get("LINECOLOR", 1); - final HColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)); + final HColor lineColor = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); if (lineColor != null) { colors = colors.add(ColorType.LINE, lineColor); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index 0b6c9ea51..e73d14777 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -68,6 +68,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandCreateClassMultilines extends CommandMultilines2 { @@ -142,7 +143,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2 { @@ -151,7 +152,7 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { if (mode == Mode.NORMAL_KEYWORD && diagram.isAllowMixing() == false) { return CommandExecutionResult.error("Use 'allowmixing' if you want to mix classes and other UML elements."); } @@ -209,9 +210,9 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 entity.setDisplay(Display.getWithNewlines(display)); entity.setUSymbol(usymbol); if (stereotype != null) { - entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram - .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam() - .getIHtmlColorSet())); + entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), + diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), + diagram.getSkinParam().getIHtmlColorSet())); } CommandCreateClassMultilines.addTags(entity, arg.get("TAGS", 0)); @@ -221,9 +222,10 @@ public class CommandCreateElementFull2 extends SingleLineCommand2 final Url url = urlBuilder.getUrl(urlString); entity.addUrl(url); } + final String s = arg.get("COLOR", 0); entity.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); + s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java index 9df79c1cc..bc62cac96 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java @@ -62,6 +62,7 @@ import net.sourceforge.plantuml.descdiagram.command.Labels; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; final public class CommandLinkClass extends SingleLineCommand2 { @@ -132,7 +133,7 @@ final public class CommandLinkClass extends SingleLineCommand2 { @@ -64,7 +65,7 @@ public class CommandStereotype extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String name = arg.get("NAME", 0); final Ident ident = diagram.buildLeafIdent(name); final Code code = diagram.V1972() ? ident : diagram.buildCode(name); diff --git a/src/net/sourceforge/plantuml/command/BlocLines.java b/src/net/sourceforge/plantuml/command/BlocLines.java index 6510d74fc..eee7e20fd 100644 --- a/src/net/sourceforge/plantuml/command/BlocLines.java +++ b/src/net/sourceforge/plantuml/command/BlocLines.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.security.SFile; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class BlocLines implements Iterable { @@ -92,7 +93,7 @@ public class BlocLines implements Iterable { this.lines = Collections.unmodifiableList(lines); } - public Display toDisplay() { + public Display toDisplay() throws NoSuchColorException { return Display.createFoo(lines); } diff --git a/src/net/sourceforge/plantuml/command/Command.java b/src/net/sourceforge/plantuml/command/Command.java index 67dec4b39..02ecfe224 100644 --- a/src/net/sourceforge/plantuml/command/Command.java +++ b/src/net/sourceforge/plantuml/command/Command.java @@ -36,10 +36,11 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.core.Diagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public interface Command { - CommandExecutionResult execute(D diagram, BlocLines lines); + CommandExecutionResult execute(D diagram, BlocLines lines) throws NoSuchColorException; CommandControl isValid(BlocLines lines); diff --git a/src/net/sourceforge/plantuml/command/CommandExecutionResult.java b/src/net/sourceforge/plantuml/command/CommandExecutionResult.java index a8c3820c1..e4f6aaae9 100644 --- a/src/net/sourceforge/plantuml/command/CommandExecutionResult.java +++ b/src/net/sourceforge/plantuml/command/CommandExecutionResult.java @@ -45,15 +45,18 @@ public class CommandExecutionResult { private final String error; private final AbstractPSystem newDiagram; private final List debugLines; + private final int score; - private CommandExecutionResult(String error, AbstractPSystem newDiagram, List debugLines) { + private CommandExecutionResult(AbstractPSystem newDiagram, String error, int score, List debugLines) { this.error = error; this.newDiagram = newDiagram; this.debugLines = debugLines; + this.score = score; + } public CommandExecutionResult withDiagram(AbstractPSystem newDiagram) { - return new CommandExecutionResult(error, newDiagram, null); + return new CommandExecutionResult(newDiagram, error, 0, null); } @Override @@ -62,19 +65,23 @@ public class CommandExecutionResult { } public static CommandExecutionResult newDiagram(AbstractPSystem result) { - return new CommandExecutionResult(null, result, null); + return new CommandExecutionResult(result, null, 0, null); } public static CommandExecutionResult ok() { - return new CommandExecutionResult(null, null, null); + return new CommandExecutionResult(null, null, 0, null); + } + + public static CommandExecutionResult badColor() { + return new CommandExecutionResult(null, "No such color", 1, null); } public static CommandExecutionResult error(String error) { - return new CommandExecutionResult(error, null, null); + return new CommandExecutionResult(null, error, 0, null); } public static CommandExecutionResult error(String error, Throwable t) { - return new CommandExecutionResult(error, null, getStackTrace(t)); + return new CommandExecutionResult(null, error, 0, getStackTrace(t)); } public static List getStackTrace(Throwable exception) { @@ -106,6 +113,10 @@ public class CommandExecutionResult { return error; } + public int getScore() { + return score; + } + public AbstractPSystem getNewDiagram() { return newDiagram; } diff --git a/src/net/sourceforge/plantuml/command/CommandMultilines2.java b/src/net/sourceforge/plantuml/command/CommandMultilines2.java index 1d1af037d..19b314a96 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilines2.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilines2.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.core.Diagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public abstract class CommandMultilines2 implements Command { @@ -106,10 +107,14 @@ public abstract class CommandMultilines2 implements Command { @@ -52,7 +53,7 @@ public class CommandMultilinesCaption extends CommandMultilines { return "(?i)^end[%s]?caption$"; } - public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) { + public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) throws NoSuchColorException { lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); final Display strings = lines.toDisplay(); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java index 64fd19973..ff89ef673 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandMultilinesFooter extends CommandMultilines { @@ -54,7 +55,7 @@ public class CommandMultilinesFooter extends CommandMultilines { return "(?i)^end[%s]?footer$"; } - public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) { + public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) throws NoSuchColorException { lines = lines.trim(); final Matcher2 m = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); if (m.find() == false) { diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java index 7d9170d33..bbb13985b 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.UseStyle; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandMultilinesHeader extends CommandMultilines { @@ -54,7 +55,7 @@ public class CommandMultilinesHeader extends CommandMultilines { return "(?i)^end[%s]?header$"; } - public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) { + public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) throws NoSuchColorException { lines = lines.trim(); final Matcher2 m = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); if (m.find() == false) { diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java index ea73cc711..e620912e1 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandMultilinesLegend extends CommandMultilines2 { @@ -73,7 +74,7 @@ public class CommandMultilinesLegend extends CommandMultilines2 { } @Override - protected CommandExecutionResult executeNow(TitledDiagram diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(TitledDiagram diagram, BlocLines lines) throws NoSuchColorException { lines = lines.trimSmart(1); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final String align = line0.get("ALIGN", 0); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java index 6b64ef872..1bb1cce51 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandMultilinesTitle extends CommandMultilines { @@ -52,7 +53,7 @@ public class CommandMultilinesTitle extends CommandMultilines { return "(?i)^end[%s]?title$"; } - public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) { + public CommandExecutionResult execute(final TitledDiagram diagram, BlocLines lines) throws NoSuchColorException { lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); final Display strings = lines.toDisplay(); diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java index 11bf37837..6788737be 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandNamespace extends SingleLineCommand2 { @@ -77,7 +78,7 @@ public class CommandNamespace extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.get("NAME", 0); final Code code; final IGroup currentPackage; @@ -109,7 +110,7 @@ public class CommandNamespace extends SingleLineCommand2 { final String color = arg.get("COLOR", 0); if (color != null) { p.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color)); + diagram.getSkinParam().getIHtmlColorSet().getColor(color)); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace2.java b/src/net/sourceforge/plantuml/command/CommandNamespace2.java index 8bcb09266..dec0cea04 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespace2.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespace2.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandNamespace2 extends SingleLineCommand2 { @@ -85,7 +86,7 @@ public class CommandNamespace2 extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.get("NAME", 0); final Ident ident = diagram.buildLeafIdent(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); @@ -109,7 +110,7 @@ public class CommandNamespace2 extends SingleLineCommand2 { final String color = arg.get("COLOR", 0); if (color != null) { p.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color)); + diagram.getSkinParam().getIHtmlColorSet().getColor(color)); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java index 66854e429..97f671e10 100644 --- a/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandNamespaceEmpty.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandNamespaceEmpty extends SingleLineCommand2 { @@ -80,7 +81,7 @@ public class CommandNamespaceEmpty extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.get("NAME", 0); final Ident idNewLong = diagram.buildLeafIdent(idShort); final Code code = diagram.V1972() ? idNewLong : diagram.buildCode(idShort); @@ -103,7 +104,7 @@ public class CommandNamespaceEmpty extends SingleLineCommand2 { final String color = arg.get("COLOR", 0); if (color != null) { p.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color)); + diagram.getSkinParam().getIHtmlColorSet().getColor(color)); } diagram.endGroup(); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java index eb44c20b4..691c263d9 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandPackage.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.UniqueSequence; public class CommandPackage extends SingleLineCommand2 { @@ -101,7 +102,7 @@ public class CommandPackage extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort; /* final */String display; final String name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)); diff --git a/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java index fb900f613..c50c0ff74 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java +++ b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Ident; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.UniqueSequence; public class CommandPackageEmpty extends SingleLineCommand2 { @@ -81,7 +82,7 @@ public class CommandPackageEmpty extends SingleLineCommand2 trace) { - final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, EMPTY_DESCRIPTION, lineLocation); + final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, EMPTY_DESCRIPTION, 0, lineLocation); final PSystemError result = PSystemErrorUtils.buildV2(source, err, null, trace); result.setSource(source); return result; @@ -66,7 +66,7 @@ public abstract class PSystemAbstractFactory implements PSystemFactory { final protected PSystemError buildExecutionError(UmlSource source, String stringError, LineLocation lineLocation, List trace) { - final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, stringError, lineLocation); + final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, stringError, 0, lineLocation); final PSystemError result = PSystemErrorUtils.buildV2(source, err, null, trace); result.setSource(source); return result; diff --git a/src/net/sourceforge/plantuml/command/PSystemBasicFactory.java b/src/net/sourceforge/plantuml/command/PSystemBasicFactory.java index f8eae3b8d..c5cfbe161 100644 --- a/src/net/sourceforge/plantuml/command/PSystemBasicFactory.java +++ b/src/net/sourceforge/plantuml/command/PSystemBasicFactory.java @@ -89,7 +89,7 @@ public abstract class PSystemBasicFactory

extends PSy } system = executeLine(system, s.getString()); if (system == null) { - final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", s.getLocation()); + final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", 0, s.getLocation()); // return PSystemErrorUtils.buildV1(source, err, null); return PSystemErrorUtils.buildV2(source, err, null, it.getTrace()); } diff --git a/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java index 31826e56d..a17f75167 100644 --- a/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java +++ b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java @@ -120,15 +120,16 @@ public abstract class PSystemCommandFactory extends PSystemAbstractFactory { private AbstractPSystem executeFewLines(AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) { final Step step = getCandidate(it); if (step == null) { - final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.peek().getLocation()); + final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", 0, it.peek().getLocation()); it.next(); return PSystemErrorUtils.buildV2(source, err, null, it.getTrace()); } final CommandExecutionResult result = sys.executeCommand(step.command, step.blocLines); if (result.isOk() == false) { - final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(), - ((StringLocated) step.blocLines.getFirst()).getLocation()); + final LineLocation location = ((StringLocated) step.blocLines.getFirst()).getLocation(); + final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(), result.getScore(), + location); sys = PSystemErrorUtils.buildV2(source, err, result.getDebugLines(), it.getTrace()); } if (result.getNewDiagram() != null) { diff --git a/src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java b/src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java index 596e2db81..829efe809 100644 --- a/src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java +++ b/src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java @@ -80,7 +80,7 @@ public abstract class PSystemSingleLineFactory extends PSystemAbstractFactory { } final AbstractPSystem sys = executeLine(s.getString()); if (sys == null) { - final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", s.getLocation()); + final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", 0, s.getLocation()); // return PSystemErrorUtils.buildV1(source, err, null); return PSystemErrorUtils.buildV2(source, err, null, it.getTrace()); } diff --git a/src/net/sourceforge/plantuml/command/SingleLineCommand2.java b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java index 0865d4ecb..2bc6c2eee 100644 --- a/src/net/sourceforge/plantuml/command/SingleLineCommand2.java +++ b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java @@ -41,12 +41,13 @@ import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.error.PSystemError; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public abstract class SingleLineCommand2 implements Command { private final IRegex pattern; private final boolean doTrim; - + public SingleLineCommand2(IRegex pattern) { this(true, pattern); } @@ -146,13 +147,18 @@ public abstract class SingleLineCommand2 implements Command { @@ -70,7 +71,7 @@ public final class CommandFactoryNote implements SingleMultiFactoryCommand { @@ -98,7 +99,7 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma return "(?i)^[%s]*end[%s]?note$"; } - public final CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) { + public final CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) throws NoSuchColorException { // StringUtils.trim(lines, true); final RegexResult arg = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); @@ -135,7 +136,7 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma @Override protected CommandExecutionResult executeArg(final ActivityDiagram diagram, LineLocation location, - RegexResult arg) { + RegexResult arg) throws NoSuchColorException { final String tmp = UniqueSequence.getString("GN"); final Ident ident = diagram.buildLeafIdent(tmp); final Code code = diagram.V1972() ? ident : diagram.buildCode(tmp); @@ -145,10 +146,11 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma }; } - private CommandExecutionResult executeInternal(ActivityDiagram diagram, RegexResult arg, IEntity note) { + private CommandExecutionResult executeInternal(ActivityDiagram diagram, RegexResult arg, IEntity note) throws NoSuchColorException { + final String s = arg.get("COLOR", 0); note.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); + s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); IEntity activity = diagram.getLastEntityConsulted(); if (activity == null) { @@ -157,8 +159,8 @@ public final class CommandFactoryNoteActivity implements SingleMultiFactoryComma final Link link; - final Position position = Position.valueOf(StringUtils.goUpperCase(arg.get("POSITION", 0))).withRankdir( - diagram.getSkinParam().getRankdir()); + final Position position = Position.valueOf(StringUtils.goUpperCase(arg.get("POSITION", 0))) + .withRankdir(diagram.getSkinParam().getRankdir()); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).goDashed(); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java index c2c98be65..81df04f70 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnEntity.java @@ -69,6 +69,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.UniqueSequence; public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryCommand { @@ -165,7 +166,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma @Override protected CommandExecutionResult executeArg(final AbstractEntityDiagram system, LineLocation location, - RegexResult arg) { + RegexResult arg) throws NoSuchColorException { final String s = arg.get("NOTE", 0); return executeInternal(arg, system, null, BlocLines.getWithNewlines(s)); } @@ -184,7 +185,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma return "(?i)^[%s]*(end[%s]?note)$"; } - protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) { + protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) throws NoSuchColorException { // StringUtils.trim(lines, false); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); @@ -203,7 +204,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma } private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url, - BlocLines strings) { + BlocLines strings) throws NoSuchColorException { final String pos = line0.get("POSITION", 0); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java index c7b4398a6..09984c290 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryNoteOnLink.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public final class CommandFactoryNoteOnLink implements SingleMultiFactoryCommand { @@ -101,7 +102,7 @@ public final class CommandFactoryNoteOnLink implements SingleMultiFactoryCommand return "(?i)^end[%s]?note$"; } - protected CommandExecutionResult executeNow(final CucaDiagram system, BlocLines lines) { + protected CommandExecutionResult executeNow(final CucaDiagram system, BlocLines lines) throws NoSuchColorException { final String line0 = lines.getFirst().getTrimmed().getString(); lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); @@ -119,14 +120,14 @@ public final class CommandFactoryNoteOnLink implements SingleMultiFactoryCommand return new SingleLineCommand2(getRegexConcatSingleLine()) { @Override - protected CommandExecutionResult executeArg(final CucaDiagram system, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(final CucaDiagram system, LineLocation location, RegexResult arg) throws NoSuchColorException { final BlocLines note = BlocLines.getWithNewlines(arg.get("NOTE", 0)); return executeInternal(system, note, arg); } }; } - private CommandExecutionResult executeInternal(CucaDiagram diagram, BlocLines note, final RegexResult arg) { + private CommandExecutionResult executeInternal(CucaDiagram diagram, BlocLines note, final RegexResult arg) throws NoSuchColorException { final Link link = diagram.getLastLink(); if (link == null) { return CommandExecutionResult.error("No link defined"); diff --git a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java index 3f0ba0b31..e90468c28 100644 --- a/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java +++ b/src/net/sourceforge/plantuml/command/note/CommandFactoryTipOnEntity.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.graphic.color.ColorParser; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public final class CommandFactoryTipOnEntity implements SingleMultiFactoryCommand { @@ -121,7 +122,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman return "(?i)^[%s]*(end[%s]?note)$"; } - protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) { + protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) throws NoSuchColorException { // StringUtils.trim(lines, false); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); @@ -140,7 +141,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman } private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url, - BlocLines lines) { + BlocLines lines) throws NoSuchColorException { final String pos = line0.get("POSITION", 0); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java index 692c400f9..181ec3c0e 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteAcrossCommand.java @@ -61,6 +61,7 @@ import net.sourceforge.plantuml.sequencediagram.Note; import net.sourceforge.plantuml.sequencediagram.NoteStyle; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactoryCommand { @@ -108,7 +109,7 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor @Override protected CommandExecutionResult executeArg(final SequenceDiagram system, LineLocation location, - RegexResult arg) { + RegexResult arg) throws NoSuchColorException { final BlocLines strings = BlocLines.getWithNewlines(arg.get("NOTE", 0)); return executeInternal(system, arg, strings); @@ -126,7 +127,7 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor return "(?i)^end[%s]?(note|hnote|rnote)$"; } - protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) { + protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); @@ -136,7 +137,7 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor }; } - private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0, BlocLines lines) { + private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0, BlocLines lines) throws NoSuchColorException { // final Participant p1 = diagram.getOrCreateParticipant(StringUtils // .eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("P1", 0))); // final Participant p2 = diagram.getOrCreateParticipant(StringUtils diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java index e3f83aac5..4ca09b85a 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java @@ -63,6 +63,7 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteStyle; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public final class FactorySequenceNoteCommand implements SingleMultiFactoryCommand { @@ -119,7 +120,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma return "(?i)^end[%s]?(note|hnote|rnote)$"; } - protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) { + protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); @@ -133,14 +134,14 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma @Override protected CommandExecutionResult executeArg(final SequenceDiagram diagram, LineLocation location, - RegexResult arg) { + RegexResult arg) throws NoSuchColorException { return executeInternal(diagram, arg, BlocLines.getWithNewlines(arg.get("NOTE", 0))); } }; } - private CommandExecutionResult executeInternal(SequenceDiagram diagram, RegexResult arg, BlocLines strings) { + private CommandExecutionResult executeInternal(SequenceDiagram diagram, RegexResult arg, BlocLines strings) throws NoSuchColorException { final Participant p = diagram.getOrCreateParticipant(StringUtils .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("PARTICIPANT", 0))); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java index 019a72eb1..7ec03e60c 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java @@ -66,6 +66,7 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteStyle; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFactoryCommand { @@ -106,7 +107,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto @Override protected CommandExecutionResult executeArg(final SequenceDiagram system, LineLocation location, - RegexResult arg) { + RegexResult arg) throws NoSuchColorException { return executeInternal(system, arg, BlocLines.getWithNewlines(arg.get("NOTE", 0))); } @@ -122,7 +123,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto return "(?i)^[%s]*end[%s]?note$"; } - protected CommandExecutionResult executeNow(final SequenceDiagram diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(final SequenceDiagram diagram, BlocLines lines) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); @@ -132,7 +133,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto }; } - private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0, BlocLines lines) { + private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0, BlocLines lines) throws NoSuchColorException { final EventWithDeactivate m = diagram.getLastEventWithDeactivate(); if (m instanceof AbstractMessage || m instanceof GroupingLeaf) { final NotePosition position = NotePosition.valueOf(StringUtils.goUpperCase(line0.get("POSITION", 0))); @@ -145,7 +146,8 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto final NoteStyle style = NoteStyle.getNoteStyle(line0.get("STYLE", 0)); final Display display = diagram.manageVariable(lines.toDisplay()); final String backcolor0 = line0.get("COLOR", 0); - Colors colors = Colors.empty().add(ColorType.BACK, HColorSet.instance().getColorIfValid(backcolor0)); + Colors colors = Colors.empty().add(ColorType.BACK, + backcolor0 == null ? null : HColorSet.instance().getColor(backcolor0)); final Note note = new Note(display, position, style, diagram.getSkinParam().getCurrentStyleBuilder()); final String stereotypeString = line0.get("STEREO", 0); if (stereotypeString != null) { diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java index d7b0f3e46..6770d5732 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java @@ -62,6 +62,7 @@ import net.sourceforge.plantuml.sequencediagram.Note; import net.sourceforge.plantuml.sequencediagram.NoteStyle; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiFactoryCommand { @@ -123,7 +124,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF @Override protected CommandExecutionResult executeArg(final SequenceDiagram system, LineLocation location, - RegexResult arg) { + RegexResult arg) throws NoSuchColorException { final BlocLines strings = BlocLines.getWithNewlines(arg.get("NOTE", 0)); return executeInternal(system, arg, strings); @@ -141,7 +142,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF return "(?i)^end[%s]?(note|hnote|rnote)$"; } - protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) { + protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); @@ -151,7 +152,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF }; } - private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0, BlocLines lines) { + private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0, BlocLines lines) throws NoSuchColorException { final Participant p1 = diagram.getOrCreateParticipant(StringUtils .eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("P1", 0))); final Participant p2 = diagram.getOrCreateParticipant(StringUtils diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java index 9d0d3bc7d..deccc7eb9 100644 --- a/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java +++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java @@ -102,7 +102,7 @@ public class CommandLinkBlock extends SingleLineCommand2 { private LinkDecor getLinkDecor(String s) { if ("[]".equals(s)) { - return LinkDecor.SQUARRE_toberemoved; + return LinkDecor.SQUARE_toberemoved; } return LinkDecor.NONE; } diff --git a/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorAndSizeChange.java b/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorAndSizeChange.java index 58ca24be8..b8a9ed7a0 100644 --- a/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorAndSizeChange.java +++ b/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorAndSizeChange.java @@ -42,6 +42,8 @@ import net.sourceforge.plantuml.creole.legacy.StripeSimple; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorRuntimeException; public class CommandCreoleColorAndSizeChange implements Command { @@ -70,7 +72,7 @@ public class CommandCreoleColorAndSizeChange implements Command { return m.group(1).length(); } - public String executeAndGetRemaining(String line, StripeSimple stripe) { + public String executeAndGetRemaining(String line, StripeSimple stripe) throws NoSuchColorRuntimeException { final Matcher2 m = pattern.matcher(line); if (m.find() == false) { throw new IllegalStateException(); @@ -84,14 +86,19 @@ public class CommandCreoleColorAndSizeChange implements Command { if (m.group(2) != null) { fc2 = fc2.changeSize(Integer.parseInt(m.group(2))); } - if (m.group(3) != null) { - final HColor color = HColorSet.instance().getColorIfValid(m.group(3)); - fc2 = fc2.changeColor(color); - } + try { + if (m.group(3) != null) { + final String s = m.group(3); + final HColor color = HColorSet.instance().getColor(s); + fc2 = fc2.changeColor(color); + } - stripe.setActualFontConfiguration(fc2); - stripe.analyzeAndAdd(m.group(4)); - stripe.setActualFontConfiguration(fc1); - return line.substring(m.group(1).length()); + stripe.setActualFontConfiguration(fc2); + stripe.analyzeAndAdd(m.group(4)); + stripe.setActualFontConfiguration(fc1); + return line.substring(m.group(1).length()); + } catch (NoSuchColorException e) { + throw new NoSuchColorRuntimeException(); + } } } diff --git a/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java b/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java index 001e54516..a299e6ffc 100644 --- a/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java +++ b/src/net/sourceforge/plantuml/creole/command/CommandCreoleColorChange.java @@ -43,6 +43,8 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.Splitter; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorRuntimeException; public class CommandCreoleColorChange implements Command { @@ -69,18 +71,23 @@ public class CommandCreoleColorChange implements Command { return m.group(2).length(); } - public String executeAndGetRemaining(String line, StripeSimple stripe) { + public String executeAndGetRemaining(String line, StripeSimple stripe) throws NoSuchColorRuntimeException { final Matcher2 m = pattern.matcher(line); if (m.find() == false) { throw new IllegalStateException(); } final FontConfiguration fc1 = stripe.getActualFontConfiguration(); - final HColor color = HColorSet.instance().getColorIfValid(m.group(2)); - final FontConfiguration fc2 = fc1.changeColor(color); - stripe.setActualFontConfiguration(fc2); - stripe.analyzeAndAdd(m.group(3)); - stripe.setActualFontConfiguration(fc1); - return line.substring(m.group(1).length()); + final String s = m.group(2); + try { + final HColor color = HColorSet.instance().getColor(s); + final FontConfiguration fc2 = fc1.changeColor(color); + stripe.setActualFontConfiguration(fc2); + stripe.analyzeAndAdd(m.group(3)); + stripe.setActualFontConfiguration(fc1); + return line.substring(m.group(1).length()); + } catch (NoSuchColorException e) { + throw new NoSuchColorRuntimeException(); + } } } diff --git a/src/net/sourceforge/plantuml/creole/command/CommandCreoleOpenIcon.java b/src/net/sourceforge/plantuml/creole/command/CommandCreoleOpenIcon.java index 15024218e..30977e83e 100644 --- a/src/net/sourceforge/plantuml/creole/command/CommandCreoleOpenIcon.java +++ b/src/net/sourceforge/plantuml/creole/command/CommandCreoleOpenIcon.java @@ -76,7 +76,7 @@ public class CommandCreoleOpenIcon implements Command { final String colorName = Parser.getColor(m.group(3)); HColor color = null; if (colorName != null) { - color = colorSet.getColorIfValid(colorName); + color = colorSet.getColorOrWhite(colorName); } stripe.addOpenIcon(src, scale, color); return line.substring(m.group(1).length()); diff --git a/src/net/sourceforge/plantuml/creole/command/CommandCreoleSprite.java b/src/net/sourceforge/plantuml/creole/command/CommandCreoleSprite.java index 9b95331e7..c349c9480 100644 --- a/src/net/sourceforge/plantuml/creole/command/CommandCreoleSprite.java +++ b/src/net/sourceforge/plantuml/creole/command/CommandCreoleSprite.java @@ -76,7 +76,7 @@ public class CommandCreoleSprite implements Command { final String colorName = Parser.getColor(m.group(3)); HColor color = null; if (colorName != null) { - color = colorSet.getColorIfValid(colorName); + color = colorSet.getColorOrWhite(colorName); } stripe.addSprite(src, scale, color); return line.substring(m.group(1).length()); diff --git a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java index 081770455..d8bbde7d9 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java @@ -40,6 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.creole.CreoleContext; import net.sourceforge.plantuml.creole.CreoleMode; @@ -52,6 +53,9 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorRuntimeException; public class CreoleParser implements SheetBuilder { @@ -144,4 +148,14 @@ public class CreoleParser implements SheetBuilder { } return sheet; } + + public static void checkColor(Display result) throws NoSuchColorException { + FontConfiguration fc = FontConfiguration.blackBlueTrue(UFont.byDefault(10)); + try { + new CreoleParser(fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty(), CreoleMode.FULL, fc) + .createSheet(result); + } catch (NoSuchColorRuntimeException e) { + throw new NoSuchColorException(); + } + } } diff --git a/src/net/sourceforge/plantuml/creole/legacy/StripeTable.java b/src/net/sourceforge/plantuml/creole/legacy/StripeTable.java index f62b442e1..b66e46e82 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/StripeTable.java +++ b/src/net/sourceforge/plantuml/creole/legacy/StripeTable.java @@ -106,7 +106,8 @@ public class StripeTable implements Stripe { } final String[] color = line.substring(idx1, idx2).split(","); if (idx < color.length) { - return skinParam.getIHtmlColorSet().getColorIfValid(color[idx]); + final String s = color[idx]; + return s == null ? null : skinParam.getIHtmlColorSet().getColorOrWhite(s); } } return null; diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java index f26b346b6..d7970bf2d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced1.java @@ -40,6 +40,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.ListIterator; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.FontParam; @@ -76,7 +78,6 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi ILeaf entity, Style style) { super(skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), new FontConfiguration(skinParam, fontParam, stereotype)); - this.style = style; this.rawBody2 = Display.create(rawBody); this.stereotype = stereotype; @@ -118,6 +119,7 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi } private static boolean isTreeOrTable(String s) { + s = StringUtils.trinNoTrace(s); return Parser.isTreeStart(s) || CreoleParser.isTableLine(s); } @@ -199,11 +201,17 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi private static List buildTreeOrTable(String init, ListIterator it) { final List result = new ArrayList(); - result.add(init); + final Pattern p = Pattern.compile("^(\\s+)"); + final Matcher m = p.matcher(init); + String start = ""; + if (m.find()) { + start = m.group(1); + } + result.add(purge(init, start)); while (it.hasNext()) { - final CharSequence s = it.next(); - if (isTreeOrTable(StringUtils.trinNoTrace(s))) { - result.add(s); + String s = it.next().toString(); + if (isTreeOrTable(s)) { + result.add(purge(s, start)); } else { it.previous(); return result; @@ -213,6 +221,13 @@ public class BodyEnhanced1 extends BodyEnhancedAbstract implements TextBlock, Wi return result; } + private static String purge(String s, String start) { + if (s.startsWith(start)) { + return s.substring(start.length()); + } + return s; + } + public Ports getPorts(StringBounder stringBounder) { final TextBlock area = getArea(stringBounder); if (area instanceof WithPorts) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java index 38e73facb..e0f72ddda 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java @@ -59,7 +59,6 @@ public class BodyEnhanced2 extends BodyEnhancedAbstract { BodyEnhanced2(Display rawBody, FontParam fontParam, ISkinSimple skinParam, HorizontalAlignment align, FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy) { super(align, titleConfig); - this.rawBody = rawBody; this.lineBreakStrategy = lineBreakStrategy; this.skinParam = skinParam; diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index c73b0b0fe..a9facdeed 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -64,6 +64,7 @@ import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; +import net.sourceforge.plantuml.creole.legacy.CreoleParser; import net.sourceforge.plantuml.graphic.CircledCharacter; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; @@ -78,6 +79,7 @@ import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class Display implements Iterable { @@ -150,12 +152,14 @@ public class Display implements Iterable { return create(Arrays.asList(s)); } - public static Display createFoo(List data) { + public static Display createFoo(List data) throws NoSuchColorException { final List tmp = new ArrayList(); for (StringLocated s : data) { tmp.add(s.getString()); } - return create(tmp); + final Display result = create(tmp); + CreoleParser.checkColor(result); + return result; } public static Display create(Collection other) { @@ -166,6 +170,12 @@ public class Display implements Iterable { return getWithNewlines(s.getName()); } + public static Display getWithNewlines2(String s) throws NoSuchColorException { + final Display result = getWithNewlines(s); + CreoleParser.checkColor(result); + return result; + } + public static Display getWithNewlines(String s) { if (s == null) { // Thread.dumpStack(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java index 0725c6fc2..8195b9bfb 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java +++ b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java @@ -206,7 +206,7 @@ public class GroupRoot implements IGroup { } public SingleStrategy getSingleStrategy() { - return SingleStrategy.SQUARRE; + return SingleStrategy.SQUARE; } public boolean isRemoved() { diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java b/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java index 6e653821c..653d8af06 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java @@ -54,7 +54,7 @@ import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryLineCrowfoot; import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryNotNavigable; import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryParenthesis; import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryPlus; -import net.sourceforge.plantuml.svek.extremity.ExtremityFactorySquarre; +import net.sourceforge.plantuml.svek.extremity.ExtremityFactorySquare; import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryTriangle; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -73,7 +73,7 @@ public enum LinkDecor { CIRCLE(0, false, 0.5), CIRCLE_FILL(0, false, 0.5), CIRCLE_CONNECT(0, false, 0.5), PARENTHESIS(0, false, OptionFlags.USE_INTERFACE_EYE2 ? 0.5 : 1.0), SQUARE(0, false, 0.5), - CIRCLE_CROSS(0, false, 0.5), PLUS(0, false, 1.5), HALF_ARROW(0, false, 1.5), SQUARRE_toberemoved(30, false, 0); + CIRCLE_CROSS(0, false, 0.5), PLUS(0, false, 1.5), HALF_ARROW(0, false, 1.5), SQUARE_toberemoved(30, false, 0); private final double arrowSize; private final int margin; @@ -147,7 +147,7 @@ public enum LinkDecor { case CIRCLE_FILL: return new ExtremityFactoryCircle(true, backgroundColor); case SQUARE: - return new ExtremityFactorySquarre(backgroundColor); + return new ExtremityFactorySquare(backgroundColor); case PARENTHESIS: return new ExtremityFactoryParenthesis(); case CIRCLE_CONNECT: @@ -156,4 +156,4 @@ public enum LinkDecor { return null; } } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java b/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java index e3d7e888b..326eb8dfa 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java @@ -70,4 +70,4 @@ public enum LinkMiddleDecor { return this; } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java index 856ac185a..a46188d52 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java @@ -64,6 +64,7 @@ import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class Stereotype implements CharSequence { private final static RegexComposed circleChar = new RegexConcat( // @@ -108,7 +109,7 @@ public class Stereotype implements CharSequence { private String spriteName; private double spriteScale; - public Stereotype(String label, double radius, UFont circledFont, HColorSet htmlColorSet) { + public Stereotype(String label, double radius, UFont circledFont, HColorSet htmlColorSet) throws NoSuchColorException { this(label, radius, circledFont, true, htmlColorSet); } @@ -129,7 +130,7 @@ public class Stereotype implements CharSequence { } public Stereotype(String label, double radius, UFont circledFont, boolean automaticPackageStyle, - HColorSet htmlColorSet) { + HColorSet htmlColorSet) throws NoSuchColorException { if (label == null) { throw new IllegalArgumentException(); } @@ -153,7 +154,7 @@ public class Stereotype implements CharSequence { local = null; } final String colName = mCircleSprite.get("COLOR", 0); - final HColor col = htmlColorSet.getColorIfValid(colName); + final HColor col = colName == null ? null : htmlColorSet.getColor(colName); this.htmlColor = col == null ? HColorUtils.BLACK : col; this.spriteName = mCircleSprite.get("NAME", 0); this.character = '\0'; @@ -165,7 +166,7 @@ public class Stereotype implements CharSequence { local = null; } final String colName = mCircleChar.get("COLOR", 0); - this.htmlColor = htmlColorSet.getColorIfValid(colName); + this.htmlColor = colName == null ? null : htmlColorSet.getColor(colName); this.character = mCircleChar.get("CHAR", 0).charAt(0); this.spriteName = null; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/WithLinkType.java b/src/net/sourceforge/plantuml/cucadiagram/WithLinkType.java index baf299459..6367bedd5 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/WithLinkType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/WithLinkType.java @@ -147,7 +147,7 @@ public abstract class WithLinkType { } else if (s.startsWith("thickness=")) { this.goThickness(Double.parseDouble(s.substring("thickness=".length()))); } else { - final HColor tmp = HColorSet.instance().getColorIfValid(s); + final HColor tmp = HColorSet.instance().getColorOrWhite(s); setSpecificColor(tmp, i); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java index 7a12b1b6c..ab7c2eb52 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsLite.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.cucadiagram.dot; import java.io.File; -import java.io.IOException; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.windowsdot.WindowsDotArchive; @@ -54,11 +53,7 @@ class GraphvizWindowsLite extends AbstractGraphviz { protected File specificDotExe() { synchronized (GraphvizWindowsLite.class) { if (specificDotExe == null) - try { - specificDotExe = new WindowsDotArchive().getWindowsExeLite(); - } catch (IOException e) { - e.printStackTrace(); - } + specificDotExe = WindowsDotArchive.getInstance().getWindowsExeLite(); return specificDotExe; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java index b53c6f84f..cd538806a 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindowsOld.java @@ -37,7 +37,6 @@ package net.sourceforge.plantuml.cucadiagram.dot; import java.io.File; import java.io.FileFilter; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -57,11 +56,7 @@ class GraphvizWindowsOld extends AbstractGraphviz { specificDotExe = specificDotExeSlow(); } if (specificDotExe == null) - try { - specificDotExe = new WindowsDotArchive().getWindowsExeLite(); - } catch (IOException e) { - e.printStackTrace(); - } + specificDotExe = WindowsDotArchive.getInstance().getWindowsExeLite(); return specificDotExe; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java index 70789e7f9..a7f53cea1 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java @@ -606,7 +606,7 @@ final public class EntityImpl implements ILeaf, IGroup { } public SingleStrategy getSingleStrategy() { - return SingleStrategy.SQUARRE; + return SingleStrategy.SQUARE; } public boolean isHidden() { diff --git a/src/net/sourceforge/plantuml/cute/VarArgs.java b/src/net/sourceforge/plantuml/cute/VarArgs.java index 6a83b68e8..55222f1c6 100644 --- a/src/net/sourceforge/plantuml/cute/VarArgs.java +++ b/src/net/sourceforge/plantuml/cute/VarArgs.java @@ -94,7 +94,7 @@ public class VarArgs { if (value == null) { return HColorUtils.BLACK; } - final HColor result = HColorSet.instance().getColorIfValid(value); + final HColor result = HColorSet.instance().getColorOrWhite(value); if (result == null) { return HColorUtils.BLACK; } diff --git a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java index 3d5a2f65f..4312f5920 100644 --- a/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java +++ b/src/net/sourceforge/plantuml/descdiagram/CommandCreateDomain.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandCreateDomain extends SingleLineCommand2 { public static final String DISPLAY_WITH_GENERIC = "[%g](.+?)(?:\\<(" + GenericRegexProducer.PATTERN + ")\\>)?[%g]"; @@ -83,7 +84,7 @@ public class CommandCreateDomain extends SingleLineCommand2 } @Override - protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { String type = arg.get("TYPE", 0); String display = arg.getLazzy("DISPLAY", 0); String codeString = arg.getLazzy("CODE", 0); @@ -91,7 +92,8 @@ public class CommandCreateDomain extends SingleLineCommand2 codeString = display; } // final String genericOption = arg.getLazzy("DISPLAY", 1); - // final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0); + // final String generic = genericOption != null ? genericOption : + // arg.get("GENERIC", 0); final String stereotype = arg.get("STEREO", 0); @@ -109,25 +111,27 @@ public class CommandCreateDomain extends SingleLineCommand2 IEntity entity; if (group != null) { final IGroup currentGroup = diagram.getCurrentGroup(); - diagram.gotoGroup(ident, code, d, type.equalsIgnoreCase("domain") ? GroupType.DOMAIN - : GroupType.REQUIREMENT, currentGroup, NamespaceStrategy.SINGLE); + diagram.gotoGroup(ident, code, d, + type.equalsIgnoreCase("domain") ? GroupType.DOMAIN : GroupType.REQUIREMENT, currentGroup, + NamespaceStrategy.SINGLE); entity = diagram.getCurrentGroup(); } else { - entity = diagram.createLeaf(ident, code, d, type.equalsIgnoreCase("domain") ? LeafType.DOMAIN - : LeafType.REQUIREMENT, null); + entity = diagram.createLeaf(ident, code, d, + type.equalsIgnoreCase("domain") ? LeafType.DOMAIN : LeafType.REQUIREMENT, null); } if (stereotype != null) { - entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram - .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam() - .getIHtmlColorSet())); + entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), + diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), + diagram.getSkinParam().getIHtmlColorSet())); } if (urlString != null) { final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT); final Url url = urlBuilder.getUrl(urlString); entity.addUrl(url); } + final String s = arg.get("COLOR", 0); entity.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); + s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); if (type.equalsIgnoreCase("domain")) { if (stereotype != null && stereotype.equalsIgnoreCase("<>")) { type = "machine"; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java index 87ccc72cb..c003c348b 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimate.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandArchimate extends SingleLineCommand2 { @@ -119,7 +120,7 @@ public class CommandArchimate extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String codeRaw = arg.getLazzy("CODE", 0); final String idShort = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw); diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java index 06adaf7aa..15309f227 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandArchimateMultilines.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandArchimateMultilines extends CommandMultilines2 { @@ -98,7 +99,7 @@ public class CommandArchimateMultilines extends CommandMultilines2 { - public static final String ALL_TYPES = "artifact|actor/|actor|folder|card|file|package|rectangle|label|node|frame|cloud|database|queue|stack|storage|agent|usecase/|usecase|component|boundary|control|entity|interface|circle|collections|port|portin|portout"; + public static final String ALL_TYPES = "artifact|actor/|actor|folder|card|file|package|rectangle|hexagon|label|node|frame|cloud|database|queue|stack|storage|agent|usecase/|usecase|component|boundary|control|entity|interface|circle|collections|port|portin|portout"; public CommandCreateElementFull() { super(getRegexConcat()); @@ -154,7 +155,7 @@ public class CommandCreateElementFull extends SingleLineCommand2 { @@ -123,7 +124,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2 { @@ -147,7 +148,7 @@ public class CommandCreateElementParenthesis extends SingleLineCommand2 { @@ -226,7 +227,7 @@ public class CommandLinkElement extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String ent1String = arg.get("ENT1", 0); final String ent2String = arg.get("ENT2", 0); final Ident ident1 = diagram.buildFullyQualified(ent1String); diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java index a3330432a..17e269478 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java @@ -63,6 +63,7 @@ import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.utils.UniqueSequence; public class CommandPackageWithUSymbol extends SingleLineCommand2 { @@ -74,7 +75,7 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2 closeComparator(String center) { - final HColorSimple centerColor = (HColorSimple) colors.getColorIfValid(center); + final HColorSimple centerColor = (HColorSimple) colors.getColorOrWhite(center); return new Comparator() { public int compare(String col1, String col2) { - final double dist1 = centerColor.distance((HColorSimple) colors.getColorIfValid(col1)); - final double dist2 = centerColor.distance((HColorSimple) colors.getColorIfValid(col2)); + final double dist1 = centerColor.distance((HColorSimple) colors.getColorOrWhite(col1)); + final double dist2 = centerColor.distance((HColorSimple) colors.getColorOrWhite(col2)); return (int) Math.signum(dist1 - dist2); } }; @@ -255,7 +255,7 @@ public class PSystemColors extends AbstractPSystem implements UDrawable { int j = 0; for (String name : colors.names()) { UGraphic tmp = getPositioned(ug, i, j); - final HColorSimple color = (HColorSimple) colors.getColorIfValid(name); + final HColorSimple color = (HColorSimple) colors.getColorOrWhite(name); applyColor(tmp, color).draw(new URectangle(rectangleWidth, rectangleHeight)); final TextBlock tt = getTextName(font, name, color); final Dimension2D dimText = tt.calculateDimension(ug.getStringBounder()); diff --git a/src/net/sourceforge/plantuml/error/PSystemError.java b/src/net/sourceforge/plantuml/error/PSystemError.java index c66aa0571..ff97309be 100644 --- a/src/net/sourceforge/plantuml/error/PSystemError.java +++ b/src/net/sourceforge/plantuml/error/PSystemError.java @@ -327,7 +327,7 @@ public abstract class PSystemError extends AbstractPSystem { private TextBlockBackcolored getMessageDedication() { final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils(); - final HColorSimple backColor = (HColorSimple) HColorSet.instance().getColorIfValid("#eae2c9"); + final HColorSimple backColor = (HColorSimple) HColorSet.instance().getColorOrWhite("#eae2c9"); final BufferedImage qrcode = smaller( utils.exportFlashcode("http://plantuml.com/dedication", Color.BLACK, backColor.getColor999())); @@ -350,7 +350,7 @@ public abstract class PSystemError extends AbstractPSystem { } private TextBlockBackcolored getMessageAdopt() { - final HColorSimple backColor = (HColorSimple) HColorSet.instance().getColorIfValid("#eff4d2"); + final HColorSimple backColor = (HColorSimple) HColorSet.instance().getColorOrWhite("#eff4d2"); final Display disp = Display.create("Adopt-a-Word and put your message here!", " ", "Details on [[http://plantuml.com/adopt]]", " "); @@ -458,8 +458,9 @@ public abstract class PSystemError extends AbstractPSystem { } - public int size() { - return trace.size(); + public int score() { + final int result = trace.size() * 10 + singleError.score(); + return result; } private BufferedImage smaller(BufferedImage im) { diff --git a/src/net/sourceforge/plantuml/error/PSystemErrorPreprocessor.java b/src/net/sourceforge/plantuml/error/PSystemErrorPreprocessor.java index bd2696ab1..991beb51b 100644 --- a/src/net/sourceforge/plantuml/error/PSystemErrorPreprocessor.java +++ b/src/net/sourceforge/plantuml/error/PSystemErrorPreprocessor.java @@ -48,12 +48,9 @@ public class PSystemErrorPreprocessor extends PSystemError { final DiagramType type = DiagramType.getTypeFromArobaseStart(input.get(0).getString()); this.setSource(new UmlSource(input, type == DiagramType.UML)); this.trace = trace; - this.singleError = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, getLastLine().getPreprocessorError(), getLastLine() - .getLocation()); + this.singleError = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, getLastLine().getPreprocessorError(), 0, + getLastLine().getLocation()); } - - - } diff --git a/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java b/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java index be30cd4e9..0a8fea7c7 100644 --- a/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java +++ b/src/net/sourceforge/plantuml/error/PSystemErrorUtils.java @@ -82,7 +82,7 @@ public class PSystemErrorUtils { private static PSystemErrorV2 mergeV2(List errorsV2) { PSystemErrorV2 result = null; for (PSystemErrorV2 err : errorsV2) { - if (result == null || result.size() < err.size()) { + if (result == null || result.score() < err.score()) { result = err; } } diff --git a/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java index 7eadc920b..a68eae270 100644 --- a/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java +++ b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java @@ -53,7 +53,8 @@ class ColorAndSizeChange implements FontChange { ColorAndSizeChange(String s) { final Matcher2 matcherColor = colorPattern.matcher(s); if (matcherColor.find()) { - color = HColorSet.instance().getColorIfValid(matcherColor.group(1)); + final String s1 = matcherColor.group(1); + color = HColorSet.instance().getColorOrWhite(s1); } else { color = null; } diff --git a/src/net/sourceforge/plantuml/graphic/ColorChange.java b/src/net/sourceforge/plantuml/graphic/ColorChange.java index eb7812a88..047dcc761 100644 --- a/src/net/sourceforge/plantuml/graphic/ColorChange.java +++ b/src/net/sourceforge/plantuml/graphic/ColorChange.java @@ -52,7 +52,8 @@ class ColorChange implements FontChange { if (matcherColor.find() == false) { throw new IllegalArgumentException(); } - this.color = HColorSet.instance().getColorIfValid(matcherColor.group(1)); + final String s1 = matcherColor.group(1); + this.color = HColorSet.instance().getColorOrWhite(s1); } HColor getColor() { diff --git a/src/net/sourceforge/plantuml/graphic/FontStyle.java b/src/net/sourceforge/plantuml/graphic/FontStyle.java index 7d36d25b1..ebf647793 100644 --- a/src/net/sourceforge/plantuml/graphic/FontStyle.java +++ b/src/net/sourceforge/plantuml/graphic/FontStyle.java @@ -127,10 +127,10 @@ public enum FontStyle { return null; } final String color = m.group(1); - if (HColorSet.instance().getColorIfValid(color) != null) { - return HColorSet.instance().getColorIfValid(color); + if (color == null) { + return null; } - return null; + return HColorSet.instance().getColorOrWhite(color); } public String getDeactivationPattern() { diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java b/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java index d69d254bd..f35ac0c33 100644 --- a/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java +++ b/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class HtmlColorAndStyle { @@ -85,7 +86,7 @@ public class HtmlColorAndStyle { return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); } - public static HtmlColorAndStyle build(ISkinParam skinParam, String definition) { + public static HtmlColorAndStyle build(ISkinParam skinParam, String definition) throws NoSuchColorException { HColor arrowColor; HColor arrowHeadColor = null; if (UseStyle.useBetaStyle()) { @@ -103,7 +104,7 @@ public class HtmlColorAndStyle { style = tmpStyle; continue; } - final HColor tmpColor = set.getColorIfValid(s); + final HColor tmpColor = s == null ? null : set.getColor(s); if (tmpColor != null) { arrowColor = tmpColor; } diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index b6892c002..73371b4a9 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -278,7 +278,19 @@ public class QuoteUtils { "Ab bar'f gnyxvat nobhg yrnivat gur fvatyr znexrg", "...rnfvrfg oht gb svk va uhzna uvfgbel", "Arire nggevohgr gb znyvpr jung pna or rkcynvarq ol fghcvqvgl", "Guvf oht nssrpgf iveghnyyl abobql", "Qba'g rire hfr gur jbeq fzneg jvgu zr", "Gur Ertrareba vf ernyyl xvpxvat va guvf zbeavat", - "V'ir frra fbsgjner fb onq gung rira vgf ohtf unq ohtf"); + "V'ir frra fbsgjner fb onq gung rira vgf ohtf unq ohtf", "Nera'g jr fhccbfrq gb ubyq nyy gur pneqf ?", + "Lbh'er abg yvxr, fbzrbar'f penml hapyr jub pna whfg pbqr jungrire", + "Gurer ner bayl 1300 Ulcbgurezvn qrnguf va gur HF cre lrne. Fgbc jrnevat pbngf!", + "Jryy, gurfr Trezna pne znahsnpgheref ner ernyyl gnxvat gurve fjrrg gvzr", + "Ibhf z'nirm ih, znvf ibhf ar z'nirm cnf ertneqr", + "Obevf whfg fraq hf na bira-ernql oht svk nobhg guvf bar!", "Crefba. Jbzna. Zna. Pnzren. GI. Oht.", + "Whfg svavfuvat hc gur frpbaq pbng abj, Ze. Ovqra", "Yn senzobvfr rfg cbapghryyr - Rg yr pvgeba, cerffr", + "Gunax lbh, lbh'ir znqr lbhe cbvag pyrne gung lbh oryvrir vg vf n qrongnoyr cbvag", + "Gur obng vf fnsre jura va cbeg, ohg gung vf abg jung obngf jrer ohvyg sbe.", + "Vg'f abg gernfba. Vg'f nygreangvir yblnygl", + "Gur zna jub zbirf n zbhagnva ortvaf ol pneelvat njnl fznyy fgbarf" + + ); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/Rainbow.java b/src/net/sourceforge/plantuml/graphic/Rainbow.java index 675125842..d622def5a 100644 --- a/src/net/sourceforge/plantuml/graphic/Rainbow.java +++ b/src/net/sourceforge/plantuml/graphic/Rainbow.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class Rainbow { @@ -105,7 +106,7 @@ public class Rainbow { return result; } - public static Rainbow build(ISkinParam skinParam, String colorString, int colorArrowSeparationSpace) { + public static Rainbow build(ISkinParam skinParam, String colorString, int colorArrowSeparationSpace) throws NoSuchColorException { if (colorString == null) { return Rainbow.none(); } diff --git a/src/net/sourceforge/plantuml/graphic/SkinParameter.java b/src/net/sourceforge/plantuml/graphic/SkinParameter.java index c63ec6c5b..e7ec28b85 100644 --- a/src/net/sourceforge/plantuml/graphic/SkinParameter.java +++ b/src/net/sourceforge/plantuml/graphic/SkinParameter.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ugraphic.UStroke; public class SkinParameter { - public static final SkinParameter DATABASE = new SkinParameter(SName.databse, "DATABASE", + public static final SkinParameter DATABASE = new SkinParameter(SName.database, "DATABASE", ColorParam.databaseBackground, ColorParam.databaseBorder, FontParam.DATABASE, FontParam.DATABASE_STEREOTYPE); @@ -100,11 +100,18 @@ public class SkinParameter { ColorParam.rectangleBackground, ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE, LineParam.rectangleBorder, CornerParam.rectangle); + public static final SkinParameter LABEL = new SkinParameter(SName.label, "LABEL", ColorParam.rectangleBackground, + ColorParam.rectangleBorder, FontParam.LABEL, FontParam.LABEL_STEREOTYPE); + + public static final SkinParameter HEXAGON = new SkinParameter(SName.rectangle, "HEXAGON", + ColorParam.hexagonBackground, ColorParam.hexagonBorder, FontParam.HEXAGON, FontParam.HEXAGON_STEREOTYPE, + LineParam.hexagonBorder, CornerParam.hexagon); + public static final SkinParameter ARCHIMATE = new SkinParameter(SName.archimate, "ARCHIMATE", ColorParam.archimateBackground, ColorParam.archimateBorder, FontParam.ARCHIMATE, FontParam.ARCHIMATE_STEREOTYPE, LineParam.archimateBorder, CornerParam.archimate); - public static final SkinParameter COLLECTIONS = new SkinParameter(SName.collection, "COLLECTIONS", + public static final SkinParameter COLLECTIONS = new SkinParameter(SName.collections, "COLLECTIONS", ColorParam.collectionsBackground, ColorParam.collectionsBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE); @@ -140,7 +147,7 @@ public class SkinParameter { private final LineParam lineParam; private final CornerParam roundParam; private final SName styleName; - + @Override public String toString() { return name; diff --git a/src/net/sourceforge/plantuml/graphic/StringBounderRaw.java b/src/net/sourceforge/plantuml/graphic/StringBounderRaw.java new file mode 100644 index 000000000..83dad329c --- /dev/null +++ b/src/net/sourceforge/plantuml/graphic/StringBounderRaw.java @@ -0,0 +1,64 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.graphic; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.text.RichText; +import net.sourceforge.plantuml.text.StyledString; +import net.sourceforge.plantuml.ugraphic.UFont; + +public abstract class StringBounderRaw implements StringBounder { + + public final Dimension2D calculateDimension(UFont font, String text) { + if (RichText.isRich(text)) { + double width = 0; + double height = 0; + for (StyledString s : StyledString.build(text)) { + final UFont newFont = s.getStyle().mutateFont(font); + final Dimension2D rect = calculateDimensionInternal(newFont, s.getText()); + width += rect.getWidth(); + height = Math.max(height, rect.getHeight()); + } + return new Dimension2DDouble(width, height); + } + return calculateDimensionInternal(font, text); + } + + protected abstract Dimension2D calculateDimensionInternal(UFont font, String text); + +} diff --git a/src/net/sourceforge/plantuml/graphic/USymbol.java b/src/net/sourceforge/plantuml/graphic/USymbol.java index b622b21f6..c26cdab78 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbol.java +++ b/src/net/sourceforge/plantuml/graphic/USymbol.java @@ -65,14 +65,15 @@ public abstract class USymbol { new USymbolFolder(SkinParameter.FOLDER, false)); public final static USymbol FILE = record("FILE", SkinParameter.FILE, new USymbolFile()); public final static USymbol RECTANGLE = record("RECTANGLE", SkinParameter.RECTANGLE, - new USymbolRect(SkinParameter.RECTANGLE)); - public final static USymbol LABEL = record("LABEL", SkinParameter.RECTANGLE, - new USymbolLabel(SkinParameter.RECTANGLE)); + new USymbolRectangle(SkinParameter.RECTANGLE)); + public final static USymbol HEXAGON = record("HEXAGON", SkinParameter.HEXAGON, new USymbolHexagon()); + public final static USymbol LABEL = record("LABEL", SkinParameter.LABEL, + new USymbolLabel(SkinParameter.LABEL)); public final static USymbol ARCHIMATE = record("ARCHIMATE", SkinParameter.ARCHIMATE, - new USymbolRect(SkinParameter.ARCHIMATE)); + new USymbolRectangle(SkinParameter.ARCHIMATE)); public final static USymbol COLLECTIONS = record("COLLECTIONS", SkinParameter.COLLECTIONS, - new USymbolCollections(SkinParameter.RECTANGLE)); - public final static USymbol AGENT = record("AGENT", SkinParameter.AGENT, new USymbolRect(SkinParameter.AGENT)); + new USymbolCollections(SkinParameter.COLLECTIONS)); + public final static USymbol AGENT = record("AGENT", SkinParameter.AGENT, new USymbolRectangle(SkinParameter.AGENT)); public final static USymbol ACTOR_STICKMAN = record("ACTOR_STICKMAN", SkinParameter.ACTOR, new USymbolActor(ActorStyle.STICKMAN)); public final static USymbol ACTOR_STICKMAN_BUSINESS = record("ACTOR_STICKMAN_BUSINESS", SkinParameter.ACTOR, @@ -198,6 +199,9 @@ public abstract class USymbol { if (s.equalsIgnoreCase("entity")) { return ENTITY_DOMAIN; } + if (s.equalsIgnoreCase("circle")) { + return INTERFACE; + } final USymbol result = all.get(StringUtils.goUpperCase(s.replaceAll("\\W", ""))); return result; } @@ -214,6 +218,8 @@ public abstract class USymbol { usymbol = USymbol.PACKAGE; } else if (symbol.equalsIgnoreCase("rectangle")) { usymbol = USymbol.RECTANGLE; + } else if (symbol.equalsIgnoreCase("hexagon")) { + usymbol = USymbol.HEXAGON; } else if (symbol.equalsIgnoreCase("label")) { usymbol = USymbol.LABEL; } else if (symbol.equalsIgnoreCase("collections")) { diff --git a/src/net/sourceforge/plantuml/graphic/USymbolHexagon.java b/src/net/sourceforge/plantuml/graphic/USymbolHexagon.java new file mode 100644 index 000000000..86cbab92a --- /dev/null +++ b/src/net/sourceforge/plantuml/graphic/USymbolHexagon.java @@ -0,0 +1,142 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.graphic; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.graphic.USymbol.Margin; +import net.sourceforge.plantuml.ugraphic.Shadowable; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class USymbolHexagon extends USymbol { + + @Override + public SkinParameter getSkinParameter() { + return SkinParameter.HEXAGON; + } + + private final double marginY = 5; + + @Override + public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, + final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) { + return new AbstractTextBlock() { + + public void drawU(UGraphic ug) { + final Dimension2D dim = calculateDimension(ug.getStringBounder()); + // ug = UGraphicStencil.create(ug, dim); + + final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, stereoAlignment); + final double deltaX = dim.getWidth() / 4; + tb.drawU(ug.apply(new UTranslate(deltaX, marginY))); + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + final Dimension2D dimLabel = label.calculateDimension(stringBounder); + final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder); + final Dimension2D full = Dimension2DDouble.mergeTB(dimStereo, dimLabel); + return new Dimension2DDouble(full.getWidth() * 2, full.getHeight() + 2 * marginY); + } + }; + } + + private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double roundCorner, + double diagonalCorner) { +// final UShape shape = new URectangle(width, height); + final UPath shape = new UPath(); + final double dx = width / 8; + shape.moveTo(0, height / 2); + shape.lineTo(dx, 0); + shape.lineTo(width - dx, 0); + shape.lineTo(width, height / 2); + shape.lineTo(width - dx, height); + shape.lineTo(dx, height); + shape.lineTo(0, height / 2); + shape.closePath(); + if (shadowing) { + shape.setDeltaShadow(3.0); + } + ug.draw(shape); + } + + private Margin getMargin() { + return new Margin(10, 10, 10, 10); + } + + + @Override + public TextBlock asBig(final TextBlock title, final HorizontalAlignment labelAlignment, final TextBlock stereotype, + final double width, final double height, final SymbolContext symbolContext, + final HorizontalAlignment stereoAlignment) { + return new AbstractTextBlock() { + public void drawU(UGraphic ug) { + final Dimension2D dim = calculateDimension(ug.getStringBounder()); + ug = symbolContext.apply(ug); + drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), + symbolContext.getRoundCorner(), 0); + final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder()); + final double posStereoX; + final double posStereoY; + if (stereoAlignment == HorizontalAlignment.RIGHT) { + posStereoX = width - dimStereo.getWidth() - getMargin().getX1() / 2; + posStereoY = getMargin().getY1() / 2; + } else { + posStereoX = (width - dimStereo.getWidth()) / 2; + posStereoY = 2; + } + stereotype.drawU(ug.apply(new UTranslate(posStereoX, posStereoY))); + final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder()); + final double posTitle; + if (labelAlignment == HorizontalAlignment.LEFT) { + posTitle = 3; + } else if (labelAlignment == HorizontalAlignment.RIGHT) { + posTitle = width - dimTitle.getWidth() - 3; + } else { + posTitle = (width - dimTitle.getWidth()) / 2; + } + title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight()))); + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return new Dimension2DDouble(width, height); + } + }; + } + +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRect.java b/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java similarity index 98% rename from src/net/sourceforge/plantuml/graphic/USymbolRect.java rename to src/net/sourceforge/plantuml/graphic/USymbolRectangle.java index 806bb3142..814bf3196 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolRect.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolRectangle.java @@ -44,11 +44,11 @@ import net.sourceforge.plantuml.ugraphic.UGraphicStencil; import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UTranslate; -class USymbolRect extends USymbol { +class USymbolRectangle extends USymbol { private final SkinParameter skinParameter; - public USymbolRect(SkinParameter skinParameter) { + public USymbolRectangle(SkinParameter skinParameter) { this.skinParameter = skinParameter; } diff --git a/src/net/sourceforge/plantuml/graphic/color/ColorParser.java b/src/net/sourceforge/plantuml/graphic/color/ColorParser.java index 37733a465..da5458240 100644 --- a/src/net/sourceforge/plantuml/graphic/color/ColorParser.java +++ b/src/net/sourceforge/plantuml/graphic/color/ColorParser.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.graphic.color; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class ColorParser { @@ -56,7 +57,7 @@ public class ColorParser { this.mainType = mainType; } - public Colors getColor(RegexResult arg, HColorSet set) { + public Colors getColor(RegexResult arg, HColorSet set) throws NoSuchColorException { if (mainType == null) { throw new IllegalStateException(); } diff --git a/src/net/sourceforge/plantuml/graphic/color/Colors.java b/src/net/sourceforge/plantuml/graphic/color/Colors.java index fb1ff4768..de8d5a23b 100644 --- a/src/net/sourceforge/plantuml/graphic/color/Colors.java +++ b/src/net/sourceforge/plantuml/graphic/color/Colors.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class Colors { @@ -80,7 +81,7 @@ public class Colors { private Colors() { } - public Colors(String data, HColorSet set, ColorType mainType) { + public Colors(String data, HColorSet set, ColorType mainType) throws NoSuchColorException { data = StringUtils.goLowerCase(data); for (final StringTokenizer st = new StringTokenizer(data, "#;"); st.hasMoreTokens();) { @@ -88,7 +89,7 @@ public class Colors { final int x = s.indexOf(':'); if (x == -1) { if (s.contains(".") == false) { - map.put(mainType, set.getColorIfValid(s)); + map.put(mainType, set.getColor(s)); } } else { final String name = s.substring(0, x); @@ -97,7 +98,7 @@ public class Colors { this.shadowing = value.equalsIgnoreCase("true"); } else { final ColorType key = ColorType.getType(name); - final HColor color = set.getColorIfValid(value); + final HColor color = set.getColor(value); map.put(key, color); } } @@ -185,7 +186,7 @@ public class Colors { return ug.apply(colors.lineStyle.getStroke3()); } - public Colors applyStereotype(Stereotype stereotype, ISkinParam skinParam, ColorParam param) { + public Colors applyStereotype(Stereotype stereotype, ISkinParam skinParam, ColorParam param) throws NoSuchColorException { if (stereotype == null) { throw new IllegalArgumentException(); } @@ -219,7 +220,7 @@ public class Colors { } public Colors applyStereotypeForNote(Stereotype stereotype, ISkinParam skinParam, FontParam fontParam, - ColorParam... params) { + ColorParam... params) throws NoSuchColorException { if (stereotype == null) { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java index fa20bca87..bdb919d59 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java +++ b/src/net/sourceforge/plantuml/jsondiagram/JsonDiagram.java @@ -75,7 +75,7 @@ public class JsonDiagram extends UmlDiagram { private final List highlighted; public JsonDiagram(UmlDiagramType type, JsonValue json, List highlighted) { - super(UmlDiagramType.JSON); + super(type); if (json != null && (json.isString() || json.isBoolean() || json.isNumber())) { this.root = new JsonArray(); ((JsonArray) this.root).add(json); diff --git a/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java b/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java index 4eba8ea81..b69d64027 100644 --- a/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java +++ b/src/net/sourceforge/plantuml/jsondiagram/TextBlockJson.java @@ -244,7 +244,7 @@ public class TextBlockJson extends AbstractTextBlock implements TextBlockBackcol final double heightOfRow = line.getHeightOfRow(stringBounder); if (line.highlighted) { final URectangle back = new URectangle(trueWidth - 2, heightOfRow).rounded(4); - final HColor yellow = skinParam.getIHtmlColorSet().getColorIfValid("#ccff02"); + final HColor yellow = skinParam.getIHtmlColorSet().getColorOrWhite("#ccff02"); ugline.apply(yellow).apply(yellow.bg()).apply(new UTranslate(1.5, 0)).draw(back); } diff --git a/src/net/sourceforge/plantuml/logo/TinyJavaLogo.java b/src/net/sourceforge/plantuml/logo/TinyJavaLogo.java index d68402f8d..4cd6fd8c0 100644 --- a/src/net/sourceforge/plantuml/logo/TinyJavaLogo.java +++ b/src/net/sourceforge/plantuml/logo/TinyJavaLogo.java @@ -54,7 +54,7 @@ public class TinyJavaLogo { } private void message(String messageText) { - //turtleGraphicsPane.message(messageText); + // turtleGraphicsPane.message(messageText); } private void error(String messageText) { @@ -191,7 +191,8 @@ public class TinyJavaLogo { case LogoToken.SETPC: token = scanner.getToken(); - final HColor newPenColor = HColorSet.instance().getColorIfValid(token.lexeme); + String s = token.lexeme; + final HColor newPenColor = s == null ? null : HColorSet.instance().getColorOrWhite(s); if (newPenColor == null) { error("Unrecognized color name"); return; diff --git a/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java b/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java index 6bd64e313..43e172835 100644 --- a/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java +++ b/src/net/sourceforge/plantuml/logo/TurtleGraphicsPane.java @@ -119,8 +119,8 @@ class TurtleGraphicsPane { poly.rotate(angle); // ug.setAntiAliasing(false); final HColorSet htmlColorSet = HColorSet.instance(); - final HColor turtleColor1 = htmlColorSet.getColorIfValid("OliveDrab"); - final HColor turtleColor2 = htmlColorSet.getColorIfValid("MediumSpringGreen"); + final HColor turtleColor1 = htmlColorSet.getColorOrWhite("OliveDrab"); + final HColor turtleColor2 = htmlColorSet.getColorOrWhite("MediumSpringGreen"); ug.apply(turtleColor1).apply(turtleColor2.bg()).apply(new UTranslate(x, -y)) .draw(poly); diff --git a/src/net/sourceforge/plantuml/math/PSystemLatex.java b/src/net/sourceforge/plantuml/math/PSystemLatex.java index fe1e28230..1a063146f 100644 --- a/src/net/sourceforge/plantuml/math/PSystemLatex.java +++ b/src/net/sourceforge/plantuml/math/PSystemLatex.java @@ -109,7 +109,7 @@ public class PSystemLatex extends AbstractPSystem { } private Color getColor(final String col) { - final HColor col2 = HColorSet.instance().getColorIfValid(col); + final HColor col2 = col == null ? null : HColorSet.instance().getColorOrWhite(col); final Color col3 = new ColorMapperIdentity().toColor(col2); return col3; } diff --git a/src/net/sourceforge/plantuml/math/PSystemMath.java b/src/net/sourceforge/plantuml/math/PSystemMath.java index 3211aeaf6..00b20602c 100644 --- a/src/net/sourceforge/plantuml/math/PSystemMath.java +++ b/src/net/sourceforge/plantuml/math/PSystemMath.java @@ -110,7 +110,7 @@ public class PSystemMath extends AbstractPSystem { } private Color getColor(final String col) { - final HColor col2 = HColorSet.instance().getColorIfValid(col); + final HColor col2 = col == null ? null : HColorSet.instance().getColorOrWhite(col); final Color col3 = new ColorMapperIdentity().toColor(col2); return col3; } diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java index 551c65757..ea95a36cd 100644 --- a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandMindMapOrgmode extends SingleLineCommand2 { @@ -62,13 +63,13 @@ public class CommandMindMapOrgmode extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(MindMapDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(MindMapDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String type = arg.get("TYPE", 0); final String label = arg.get("LABEL", 0); final String stringColor = arg.get("BACKCOLOR", 0); HColor backColor = null; if (stringColor != null) { - backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(stringColor); + backColor = diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor); } final int level = getLevel(type); return diagram.addIdea(backColor, level, Display.getWithNewlines(label), diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java index 2d14d64ef..061ab11de 100644 --- a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmodeMultiline.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandMindMapOrgmodeMultiline extends CommandMultilines2 { @@ -72,7 +73,7 @@ public class CommandMindMapOrgmodeMultiline extends CommandMultilines2 lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), @@ -88,7 +89,7 @@ public class CommandMindMapOrgmodeMultiline extends CommandMultilines2 { @@ -63,13 +64,13 @@ public class CommandMindMapPlus extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(MindMapDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(MindMapDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String type = arg.get("TYPE", 0); final String label = arg.get("LABEL", 0); final String stringColor = arg.get("BACKCOLOR", 0); HColor backColor = null; if (stringColor != null) { - backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(stringColor); + backColor = diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor); } final Direction direction = type.contains("-") ? Direction.LEFT : Direction.RIGHT; return diagram.addIdea(backColor, type.length() - 1, Display.getWithNewlines(label), diff --git a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java index 0c208971d..9d436103e 100644 --- a/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java +++ b/src/net/sourceforge/plantuml/nwdiag/NwDiagram.java @@ -145,7 +145,8 @@ public class NwDiagram extends UmlDiagram { if (already != null) { currentNetwork().addSquare(already, toSet(null)); } - addSquare(null, name2, toSet(null)); + final Square added = addSquare(null, name2, toSet(null)); + added.sameColThan(already); return CommandExecutionResult.ok(); } } @@ -353,7 +354,13 @@ public class NwDiagram extends UmlDiagram { final Square square = ent.getValue(); if (square.getMainNetwork() == current) { final Map conns = getLinks(square); - grid.add(i, j, square.asTextBlock(conns, networks)); + final Square sameCol = square.getSameCol(); + if (sameCol != null) { + square.setNumCol(sameCol.getNumCol()); + } else { + square.setNumCol(j); + } + grid.add(i, square.getNumCol(), square.asTextBlock(conns, networks)); } if (square.hasItsOwnColumn()) { j++; @@ -377,7 +384,7 @@ public class NwDiagram extends UmlDiagram { currentNetwork().setFullWidth("full".equalsIgnoreCase(value)); } if ("color".equalsIgnoreCase(property)) { - final HColor color = NwGroup.colors.getColorIfValid(value); + final HColor color = value == null ? null : NwGroup.colors.getColorOrWhite(value); if (currentGroup != null) { currentGroup.setColor(color); } else if (currentNetwork() != null) { diff --git a/src/net/sourceforge/plantuml/nwdiag/NwGroup.java b/src/net/sourceforge/plantuml/nwdiag/NwGroup.java index c546549af..4e79c577e 100644 --- a/src/net/sourceforge/plantuml/nwdiag/NwGroup.java +++ b/src/net/sourceforge/plantuml/nwdiag/NwGroup.java @@ -110,7 +110,7 @@ public class NwGroup { } HColor color = getColor(); if (color == null) { - color = colors.getColorIfValid("#AAA"); + color = colors.getColorOrWhite("#AAA"); } size.draw(ug, color); diff --git a/src/net/sourceforge/plantuml/nwdiag/Square.java b/src/net/sourceforge/plantuml/nwdiag/Square.java index eba7f9c29..c1e3d347d 100644 --- a/src/net/sourceforge/plantuml/nwdiag/Square.java +++ b/src/net/sourceforge/plantuml/nwdiag/Square.java @@ -62,6 +62,7 @@ public class Square { private final Network mainNetwork; private final ISkinSimple spriteContainer; private boolean hasItsOwnColumn = true; + private Square sameCol; @Override public String toString() { @@ -136,4 +137,22 @@ public class Square { return hasItsOwnColumn; } + public void sameColThan(Square sameCol) { + this.sameCol = sameCol; + } + + public final Square getSameCol() { + return sameCol; + } + + private int numCol = -1; + + public void setNumCol(int j) { + this.numCol = j; + } + + public final int getNumCol() { + return numCol; + } + } diff --git a/src/net/sourceforge/plantuml/nwdiag/VerticalLine2.java b/src/net/sourceforge/plantuml/nwdiag/VerticalLine2.java deleted file mode 100644 index 95411ee7a..000000000 --- a/src/net/sourceforge/plantuml/nwdiag/VerticalLine2.java +++ /dev/null @@ -1,97 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - */ -package net.sourceforge.plantuml.nwdiag; - -import java.util.Set; - -import net.sourceforge.plantuml.graphic.UDrawable; -import net.sourceforge.plantuml.ugraphic.UEllipse; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.color.HColorNone; - -public class VerticalLine2 implements UDrawable { - - private final double y1; - private final double y2; - private final Set skip; - - public VerticalLine2(double y1, double y2, Set skip) { - this.y1 = Math.min(y1, y2); - this.y2 = Math.max(y1, y2); - this.skip = skip; - } - - public void drawU(UGraphic ug) { - boolean drawn = false; - double current = y1; - for (Double step : skip) { - if (step < y1) { - continue; - } - assert step >= y1; - drawn = true; - if (step == y2) { - drawVLine(ug, current, y2); - } else { - drawVLine(ug, current, Math.min(y2, step - 3)); - if (y2 > step) { - drawArc(ug, step - 3); - } - } - current = step + 9; - if (current >= y2) { - break; - } - } - if (drawn == false) { - drawVLine(ug, y1, y2); - } - - } - - private void drawArc(UGraphic ug, double y) { - final UEllipse arc = new UEllipse(11, 11, 90, -180); - ug.apply(new HColorNone().bg()).apply(new UTranslate(-5, y)).draw(arc); - - } - - private void drawVLine(UGraphic ug, double start, double end) { - final ULine line = ULine.vline(end - start); - ug.apply(UTranslate.dy(start)).draw(line); - } - -} diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java index ec6a581da..9101431a4 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java +++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java @@ -55,6 +55,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandCreateEntityObject extends SingleLineCommand2 { @@ -77,7 +78,7 @@ public class CommandCreateEntityObject extends SingleLineCommand2 { @@ -85,7 +86,7 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2 { @@ -89,7 +90,8 @@ public class CommandCreateMap extends CommandMultilines2 { @@ -62,7 +63,7 @@ public class CommandColorTask extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(GanttDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String code = arg.get("CODE", 0); final Task task = diagram.getExistingTask(code); @@ -72,8 +73,8 @@ public class CommandColorTask extends SingleLineCommand2 { final String color1 = arg.get("COLORS", 0); final String color2 = arg.get("COLORS", 1); - final HColor col1 = diagram.getIHtmlColorSet().getColorIfValid(color1); - final HColor col2 = diagram.getIHtmlColorSet().getColorIfValid(color2); + final HColor col1 = color1 == null ? null : diagram.getIHtmlColorSet().getColor(color1); + final HColor col2 = color2 == null ? null : diagram.getIHtmlColorSet().getColor(color2); task.setColors(new CenterBorderColor(col1, col2)); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java b/src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java index d71917686..5cbe8c50e 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java +++ b/src/net/sourceforge/plantuml/project/command/CommandNoteBottom.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandMultilines; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandNoteBottom extends CommandMultilines { @@ -52,7 +53,7 @@ public class CommandNoteBottom extends CommandMultilines { return "(?i)^end[%s]*note$"; } - public CommandExecutionResult execute(GanttDiagram diagram, BlocLines lines) { + public CommandExecutionResult execute(GanttDiagram diagram, BlocLines lines) throws NoSuchColorException { lines = lines.subExtract(1, 1); lines = lines.removeEmptyColumns(); final Display strings = lines.toDisplay(); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java index 730d4a249..b565d1e7f 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java @@ -62,8 +62,8 @@ public abstract class TimeHeader { return 28; } - protected final HColor veryLightGray = HColorSet.instance().getColorIfValid("#E0E8E8"); - protected final HColor lightGray = HColorSet.instance().getColorIfValid("#909898"); + protected final HColor veryLightGray = HColorSet.instance().getColorOrWhite("#E0E8E8"); + protected final HColor lightGray = HColorSet.instance().getColorOrWhite("#909898"); private final TimeScale timeScale; protected final Day min; diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java index d013e3c2e..00b1b881f 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColors.java @@ -51,8 +51,8 @@ public class ComplementInColors implements Something { public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String color1 = arg.get("COMPLEMENT" + suffix, 0); final String color2 = arg.get("COMPLEMENT" + suffix, 1); - final HColor col1 = system.getIHtmlColorSet().getColorIfValid(color1); - final HColor col2 = system.getIHtmlColorSet().getColorIfValid(color2); + final HColor col1 = color1 == null ? null : system.getIHtmlColorSet().getColorOrWhite(color1); + final HColor col2 = color2 == null ? null : system.getIHtmlColorSet().getColorOrWhite(color2); return Failable.ok(new CenterBorderColor(col1, col2)); } } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java b/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java index 131457fd5..534449e68 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementInColors2.java @@ -51,8 +51,8 @@ public class ComplementInColors2 implements Something { public Failable getMe(GanttDiagram system, RegexResult arg, String suffix) { final String color1 = arg.get("COMPLEMENT" + suffix, 0); final String color2 = arg.get("COMPLEMENT" + suffix, 1); - final HColor col1 = system.getIHtmlColorSet().getColorIfValid(color1); - final HColor col2 = system.getIHtmlColorSet().getColorIfValid(color2); + final HColor col1 = color1 == null ? null : system.getIHtmlColorSet().getColorOrWhite(color1); + final HColor col2 = color2 == null ? null : system.getIHtmlColorSet().getColorOrWhite(color2); return Failable.ok(new CenterBorderColor(col1, col2)); } diff --git a/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java b/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java index db7137ae1..a0e7d2164 100644 --- a/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java +++ b/src/net/sourceforge/plantuml/project/lang/ComplementWithColorLink.java @@ -54,7 +54,7 @@ public class ComplementWithColorLink implements Something { final String style0 = arg.get("COMPLEMENT" + suffix, 0); final String color1 = arg.get("COMPLEMENT" + suffix, 1); final String style2 = arg.get("COMPLEMENT" + suffix, 2); - final HColor col1 = system.getIHtmlColorSet().getColorIfValid(color1); + final HColor col1 = color1 == null ? null : system.getIHtmlColorSet().getColorOrWhite(color1); final String style = style0 == null ? style2 : style0; return Failable.ok(new CenterBorderColor(col1, col1, style)); } diff --git a/src/net/sourceforge/plantuml/salt/PSystemSalt.java b/src/net/sourceforge/plantuml/salt/PSystemSalt.java index 5721dffd1..4992c0f19 100644 --- a/src/net/sourceforge/plantuml/salt/PSystemSalt.java +++ b/src/net/sourceforge/plantuml/salt/PSystemSalt.java @@ -96,6 +96,7 @@ import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class PSystemSalt extends TitledDiagram implements WithSprite { @@ -217,7 +218,10 @@ public class PSystemSalt extends TitledDiagram implements WithSprite { s = it.next(); bloc = bloc.addString(s); } while (s.equals("}") == false); - final CommandExecutionResult cmdResult = cmd.execute(this, bloc); + try { + final CommandExecutionResult cmdResult = cmd.execute(this, bloc); + } catch (NoSuchColorException e) { + } } else { result.add(s); } diff --git a/src/net/sourceforge/plantuml/salt/element/ElementButton.java b/src/net/sourceforge/plantuml/salt/element/ElementButton.java index 3e62d4b41..5a9013981 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementButton.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementButton.java @@ -69,7 +69,7 @@ public class ElementButton extends AbstractElementText implements Element { } final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0); ug = ug.apply(new UStroke(stroke)); - ug = ug.apply(HColorSet.instance().getColorIfValid("#EEEEEE").bg()); + ug = ug.apply(HColorSet.instance().getColorOrWhite("#EEEEEE").bg()); ug.apply(new UTranslate(stroke, stroke)).draw( new URectangle(dim.getWidth() - 2 * stroke, dim.getHeight() - 2 * stroke).rounded(10)); final Dimension2D dimPureText = getPureTextDimension(ug.getStringBounder()); diff --git a/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java index 216fa9ba4..591db1ebd 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java @@ -93,7 +93,7 @@ public class ElementDroplist extends AbstractElementText implements Element { public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) { final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0); if (zIndex == 0) { - ug.apply(HColorSet.instance().getColorIfValid("#EEEEEE").bg()) + ug.apply(HColorSet.instance().getColorOrWhite("#EEEEEE").bg()) .draw(new URectangle(dim.getWidth() - 1, dim.getHeight() - 1)); drawText(ug, 2, 2); final double xline = dim.getWidth() - box; @@ -112,7 +112,7 @@ public class ElementDroplist extends AbstractElementText implements Element { final Dimension2D dimOpen = Dimension2DDouble.atLeast(openDrop.calculateDimension(ug.getStringBounder()), dim.getWidth() - 1, 0); ug = ug.apply(UTranslate.dy(dim.getHeight() - 1)); - ug.apply(HColorSet.instance().getColorIfValid("#EEEEEE").bg()) + ug.apply(HColorSet.instance().getColorOrWhite("#EEEEEE").bg()) .draw(new URectangle(dimOpen.getWidth() - 1, dimOpen.getHeight() - 1)); openDrop.drawU(ug); } diff --git a/src/net/sourceforge/plantuml/salt/element/ElementLine.java b/src/net/sourceforge/plantuml/salt/element/ElementLine.java index bc52b4e3f..06d4e8e87 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementLine.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementLine.java @@ -61,7 +61,7 @@ public class ElementLine extends AbstractElement { if (zIndex != 0) { return; } - ug = ug.apply(HColorSet.instance().getColorIfValid("#AAAAAA")); + ug = ug.apply(HColorSet.instance().getColorOrWhite("#AAAAAA")); double y2 = dimToUse.getHeight() / 2; if (separator == '=') { y2 = y2 - 1; diff --git a/src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java b/src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java index 0e048ebd8..5479fc457 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java @@ -105,7 +105,7 @@ public class ElementMenuBar extends AbstractElement { double x1 = 0; if (zIndex == 0) { - ug.apply(HColorSet.instance().getColorIfValid("#DDDDDD").bg()).draw( + ug.apply(HColorSet.instance().getColorOrWhite("#DDDDDD").bg()).draw( new URectangle(dimToUse.getWidth(), dimToUse.getHeight())); for (ElementMenuEntry entry : entries) { entry.drawU(ug.apply(UTranslate.dx(x1)), zIndex, dimToUse); @@ -118,7 +118,7 @@ public class ElementMenuBar extends AbstractElement { if (zIndex == 1) { for (ElementMenuEntry entry : popups.keySet()) { - entry.setBackground(HColorSet.instance().getColorIfValid("#BBBBBB")); + entry.setBackground(HColorSet.instance().getColorOrWhite("#BBBBBB")); } final double y1 = preferred.getHeight(); diff --git a/src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java b/src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java index 197340170..e52bec1d8 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java @@ -79,7 +79,7 @@ public class ElementMenuPopup extends AbstractElement { if (zIndex != 1) { return; } - ug.apply(HColorSet.instance().getColorIfValid("#DDDDDD").bg()).draw( + ug.apply(HColorSet.instance().getColorOrWhite("#DDDDDD").bg()).draw( new URectangle(dimToUse.getWidth(), dimToUse.getHeight())); double y1 = 0; diff --git a/src/net/sourceforge/plantuml/salt/element/ElementTree.java b/src/net/sourceforge/plantuml/salt/element/ElementTree.java index a120b94cb..5a6110a97 100644 --- a/src/net/sourceforge/plantuml/salt/element/ElementTree.java +++ b/src/net/sourceforge/plantuml/salt/element/ElementTree.java @@ -144,7 +144,7 @@ public class ElementTree extends AbstractElement { yvar += h; rows.add(yvar); } - ug = ug.apply(HColorSet.instance().getColorIfValid("#888888")); + ug = ug.apply(HColorSet.instance().getColorOrWhite("#888888")); skeleton.draw(ug, 0, 0); if (strategy != TableStrategy.DRAW_NONE) { final Grid2 grid = new Grid2(rows, cols, strategy); diff --git a/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java b/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java index d72e65d66..096a13baf 100644 --- a/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java +++ b/src/net/sourceforge/plantuml/sdot/CucaDiagramFileMakerSmetana.java @@ -101,7 +101,7 @@ import net.sourceforge.plantuml.svek.DotStringFactory; import net.sourceforge.plantuml.svek.GeneralImageBuilder; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.IEntityImage; -import net.sourceforge.plantuml.svek.Node; +import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.ImageParameter; @@ -147,7 +147,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { final ST_Agnode_s agnode = ent.getValue(); final Point2D corner = getCorner(agnode); - final Node node = dotStringFactory.getBibliotekon().getNode(leaf); + final SvekNode node = dotStringFactory.getBibliotekon().getNode(leaf); final IEntityImage image = node.getImage(); image.drawU(ug.apply(new UTranslate(corner))); } @@ -303,7 +303,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { } private void exportEntity(ST_Agraph_s g, ILeaf leaf) { - final Node node = dotStringFactory.getBibliotekon().getNode(leaf); + final SvekNode node = dotStringFactory.getBibliotekon().getNode(leaf); if (node == null) { System.err.println("CANNOT FIND NODE"); return; @@ -324,7 +324,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { throw new IllegalStateException(); } final IEntityImage image = printEntityInternal(ent); - final Node node = getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), stringBounder); + final SvekNode node = getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), stringBounder); dotStringFactory.addNode(node); } @@ -373,7 +373,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { } private void printCluster(ST_Agraph_s g, Cluster cluster) { - for (Node node : cluster.getNodes()) { + for (SvekNode node : cluster.getNodes()) { final ST_Agnode_s agnode = agnode(g, new CString(node.getUid()), true); agsafeset(agnode, new CString("shape"), new CString("box"), new CString("")); final String width = "" + (node.getWidth() / 72); @@ -641,7 +641,7 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker { return; } final IEntityImage image = printEntityInternal(ent); - final Node shape = getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), stringBounder); + final SvekNode shape = getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), stringBounder); // dotStringFactory.addShape(shape); } diff --git a/src/net/sourceforge/plantuml/security/SFile.java b/src/net/sourceforge/plantuml/security/SFile.java index 99247ab48..67e4d0b08 100644 --- a/src/net/sourceforge/plantuml/security/SFile.java +++ b/src/net/sourceforge/plantuml/security/SFile.java @@ -75,7 +75,7 @@ public class SFile implements Comparable { public static char separatorChar = File.separatorChar; - public final File internal; + private final File internal; @Override public String toString() { @@ -315,7 +315,7 @@ public class SFile implements Comparable { return null; } - public File conv() throws FileNotFoundException { + public File conv() { return internal; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java index 5044ff8d4..bf0023ce8 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java +++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java @@ -154,8 +154,12 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle return lifeEventsType.contains(LifeEventType.DEACTIVATE); } + public boolean isDestroy() { + return lifeEventsType.contains(LifeEventType.DESTROY); + } + private boolean isDeactivateOrDestroy() { - return lifeEventsType.contains(LifeEventType.DEACTIVATE) || lifeEventsType.contains(LifeEventType.DESTROY); + return isDeactivate() || isDestroy(); } public final boolean isActivateAndDeactive() { diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java index f351f8fdb..3c6906b96 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.sequencediagram.LifeEventType; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandActivate extends SingleLineCommand2 { @@ -70,12 +71,14 @@ public class CommandActivate extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final LifeEventType type = LifeEventType.valueOf(StringUtils.goUpperCase(arg.get("TYPE", 0))); final Participant p = diagram.getOrCreateParticipant(StringUtils .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("WHO", 0))); - final HColor backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("BACK", 0)); - final HColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINE", 0)); + String s = arg.get("BACK", 0); + final HColor backColor = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); + String s1 = arg.get("LINE", 0); + final HColor lineColor = s1 == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s1); final String error = diagram.activate(p, type, backColor, lineColor); if (error == null) { return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java index 40e012b29..346b35cbc 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.sequencediagram.LifeEventType; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandActivate2 extends SingleLineCommand2 { @@ -58,15 +59,17 @@ public class CommandActivate2 extends SingleLineCommand2 { RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("TYPE", "(\\+\\+|--)"), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("COLOR", "(#\\w+)?"), RegexLeaf.end()); // + new RegexLeaf("COLOR", "(#\\w+)?"), // + RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final LifeEventType type = arg.get("TYPE", 0).equals("++") ? LifeEventType.ACTIVATE : LifeEventType.DEACTIVATE; final Participant p = diagram.getOrCreateParticipant(arg.get("NAME", 0)); + final String s = arg.get("COLOR", 0); final String error = diagram.activate(p, type, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); + s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s)); if (error == null) { return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java index 142d6d55b..333931914 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java @@ -63,6 +63,7 @@ import net.sourceforge.plantuml.skin.ArrowHead; import net.sourceforge.plantuml.skin.ArrowPart; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandArrow extends SingleLineCommand2 { @@ -156,7 +157,7 @@ public class CommandArrow extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { Participant p1; Participant p2; @@ -269,9 +270,10 @@ public class CommandArrow extends SingleLineCommand2 { if (error != null) { return CommandExecutionResult.error(error); } + final String s = arg.get("LIFECOLOR", 0); - final HColor activationColor = diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(arg.get("LIFECOLOR", 0)); + final HColor activationColor = s == null ? null + : diagram.getSkinParam().getIHtmlColorSet().getColor(s); if (activationSpec != null) { switch (activationSpec.charAt(0)) { @@ -311,7 +313,7 @@ public class CommandArrow extends SingleLineCommand2 { return sa.length() + sb.length(); } - public static ArrowConfiguration applyStyle(String arrowStyle, ArrowConfiguration config) { + public static ArrowConfiguration applyStyle(String arrowStyle, ArrowConfiguration config) throws NoSuchColorException { if (arrowStyle == null) { return config; } @@ -330,7 +332,7 @@ public class CommandArrow extends SingleLineCommand2 { config = config.withBody(ArrowBody.HIDDEN); // link.goHidden(); } else { - config = config.withColor(HColorSet.instance().getColorIfValid(s)); + config = config.withColor(HColorSet.instance().getColor(s)); } } return config; diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java index 55636a5c5..c6e960f0b 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandBoxStart extends SingleLineCommand2 { @@ -79,7 +80,7 @@ public class CommandBoxStart extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { if (diagram.isBoxPending()) { return CommandExecutionResult.error("Box cannot be nested"); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java index d701c470f..6e5cb9be1 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.skin.ArrowDecoration; import net.sourceforge.plantuml.skin.ArrowHead; import net.sourceforge.plantuml.skin.ArrowPart; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; abstract class CommandExoArrowAny extends SingleLineCommand2 { @@ -64,7 +65,7 @@ abstract class CommandExoArrowAny extends SingleLineCommand2 { } @Override - final protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { + final protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String body = arg.getLazzy("ARROW_BODYA", 0) + arg.getLazzy("ARROW_BODYB", 0); final String dressing = arg.getLazzy("ARROW_DRESSING", 0); final Participant p = diagram.getOrCreateParticipant( @@ -150,9 +151,10 @@ abstract class CommandExoArrowAny extends SingleLineCommand2 { if (error != null) { return CommandExecutionResult.error(error); } + final String s = arg.get("LIFECOLOR", 0); - final HColor activationColor = diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(arg.get("LIFECOLOR", 0)); + final HColor activationColor = s == null ? null + : diagram.getSkinParam().getIHtmlColorSet().getColor(s); if (activationSpec != null) { switch (activationSpec.charAt(0)) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java index e28ff1a0a..e48886384 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java @@ -50,6 +50,8 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.sequencediagram.GroupingType; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandGrouping extends SingleLineCommand2 { @@ -70,12 +72,19 @@ public class CommandGrouping extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { String type = StringUtils.goLowerCase(arg.get("TYPE", 0)); - final HColor backColorElement = diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(arg.get("COLORS", 0)); - final HColor backColorGeneral = diagram.getSkinParam().getIHtmlColorSet() - .getColorIfValid(arg.get("COLORS", 1), diagram.getSkinParam().getBackgroundColor(true)); + final String s = arg.get("COLORS", 0); + final HColorSet colorSet = diagram.getSkinParam().getIHtmlColorSet(); + HColor backColorElement = null; + if (s != null) { + backColorElement = colorSet.getColor(s, null); + } + final String s2 = arg.get("COLORS", 1); + HColor backColorGeneral = null; + if (s2 != null) { + backColorGeneral = colorSet.getColor(s2, diagram.getSkinParam().getBackgroundColor(true)); + } String comment = arg.get("COMMENT", 0); final GroupingType groupingType = GroupingType.getType(type); if ("group".equals(type)) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java index e8f8b5e05..bcfd93336 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.ParticipantType; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public abstract class CommandParticipant extends SingleLineCommand2 { @@ -82,7 +83,7 @@ public abstract class CommandParticipant extends SingleLineCommand2 { public CommandReferenceMultilinesOverSeveral() { - super( - "(?i)^ref(#\\w+)?[%s]+over[%s]+((?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g]))*)[%s]*(#\\w+)?$"); + super("(?i)^ref(#\\w+)?[%s]+over[%s]+((?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g]))*)[%s]*(#\\w+)?$"); } @Override @@ -63,11 +63,14 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines line0 = StringUtils.getSplit(getStartingPattern(), lines.getFirst().getTrimmed() - .getString()); - final HColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get(0)); - // final HtmlColor backColorGeneral = HtmlColorSetSimple.instance().getColorIfValid(line0.get(1)); + public CommandExecutionResult execute(final SequenceDiagram diagram, BlocLines lines) throws NoSuchColorException { + final List line0 = StringUtils.getSplit(getStartingPattern(), + lines.getFirst().getTrimmed().getString()); + final String s1 = line0.get(0); + final HColor backColorElement = s1 == null ? null + : diagram.getSkinParam().getIHtmlColorSet().getColor(s1); + // final HtmlColor backColorGeneral = + // HtmlColorSetSimple.instance().getColorIfValid(line0.get(1)); final List participants = StringUtils.splitComma(line0.get(1)); final List p = new ArrayList(); @@ -89,8 +92,8 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines { @@ -76,8 +77,9 @@ public class CommandReferenceOverSeveral extends SingleLineCommand2 participants = StringUtils.splitComma(arg.get("PARTS", 0)); diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java index 815bfa4de..835775a23 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.skin.ArrowBody; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandReturn extends SingleLineCommand2 { @@ -75,7 +76,7 @@ public class CommandReturn extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { AbstractMessage message1 = diagram.getActivatingMessage(); boolean doDeactivation = true; @@ -91,15 +92,15 @@ public class CommandReturn extends SingleLineCommand2 { ArrowConfiguration arrow = message1.getArrowConfiguration().withBody(ArrowBody.DOTTED); final String color = arg.get("COLOR", 0); if (color != null) { - arrow = arrow.withColor(HColorSet.instance().getColorIfValid(color)); + arrow = arrow.withColor(HColorSet.instance().getColor(color)); } final Display display = Display.getWithNewlines(arg.get("MESSAGE", 0)); final AbstractMessage message2; if (message1 instanceof MessageExo) { final MessageExo exo1 = (MessageExo) message1; - message2 = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), exo1.getParticipant(), exo1 - .getType().reverse(), display, arrow, diagram.getNextMessageNumber(), false); + message2 = new MessageExo(diagram.getSkinParam().getCurrentStyleBuilder(), exo1.getParticipant(), + exo1.getType().reverse(), display, arrow, diagram.getNextMessageNumber(), false); } else { message2 = new Message(diagram.getSkinParam().getCurrentStyleBuilder(), message1.getParticipant2(), message1.getParticipant1(), display, arrow, diagram.getNextMessageNumber()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java index 7db19bc75..3c959ca0c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java @@ -106,17 +106,12 @@ public class CommunicationTileSelf extends AbstractTile implements TileWithUpdat if (message.isActivate()) { livingSpace1.addStepForLivebox(getEvent(), y + p2.getY()); - Log.info("CommunicationTileSelf::updateStairs activate y=" + (y + p2.getY()) + " " + message); } else if (message.isDeactivate()) { livingSpace1.addStepForLivebox(getEvent(), y + p1.getY()); - Log.info("CommunicationTileSelf::updateStairs deactivate y=" + (y + p1.getY()) + " " + message); + } else if (message.isDestroy()) { + livingSpace1.addStepForLivebox(getEvent(), y + p2.getY()); } - // livingSpace1.addStep(y + arrowY, level1); - // livingSpace1.addStep(y + dim.getHeight(), level1); - // final int level2 = livingSpace2.getLevelAt(this); - // livingSpace2.addStep(y + arrowY, level2); - // livingSpace2.addStep(y + dim.getHeight(), level2); } public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java b/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java index 5e0a3e5db..7fe52dcb2 100644 --- a/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java +++ b/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java @@ -70,6 +70,7 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; 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.NoSuchColorException; public class StdlibDiagram extends UmlDiagram { @@ -148,7 +149,11 @@ public class StdlibDiagram extends UmlDiagram { for (String s : all) { // System.err.println("s="+s); final BlocLines bloc = BlocLines.fromArray(s.split("\n")); - cmd.execute(this, bloc); + try { + cmd.execute(this, bloc); + } catch (NoSuchColorException e) { + e.printStackTrace(); + } // System.err.println("nb=" + nb); nb++; } diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java index b8db908bd..feed44448 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java @@ -60,6 +60,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandCreatePackageState extends SingleLineCommand2 { @@ -68,8 +69,7 @@ public class CommandCreatePackageState extends SingleLineCommand2 } private static IRegex getRegexConcat() { - return RegexConcat.build(CommandCreatePackageState.class.getName(), - RegexLeaf.start(), // + return RegexConcat.build(CommandCreatePackageState.class.getName(), RegexLeaf.start(), // new RegexLeaf("state"), // RegexLeaf.spaceOneOrMore(), // new RegexOr(// @@ -83,7 +83,7 @@ public class CommandCreatePackageState extends SingleLineCommand2 new RegexOptional(new RegexConcat( // new RegexLeaf("DISPLAY2", "[%g]([^%g]+)[%g]"), RegexLeaf.spaceOneOrMore(), // new RegexLeaf("as"), RegexLeaf.spaceOneOrMore() // - )), // + )), // new RegexLeaf("CODE2", "([\\p{L}0-9_.]+)"))), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // @@ -108,7 +108,7 @@ public class CommandCreatePackageState extends SingleLineCommand2 } @Override - protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final IGroup currentPackage = diagram.getCurrentGroup(); final String idShort = getNotNull(arg, "CODE1", "CODE2"); final Ident idNewLong = diagram.buildLeafIdentSpecial(idShort); @@ -132,8 +132,9 @@ public class CommandCreatePackageState extends SingleLineCommand2 } Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + final String s = arg.get("LINECOLOR", 1); - final HColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)); + final HColor lineColor = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); if (lineColor != null) { colors = colors.add(ColorType.LINE, lineColor); } @@ -143,9 +144,11 @@ public class CommandCreatePackageState extends SingleLineCommand2 p.setColors(colors); // p.setSpecificColorTOBEREMOVED(ColorType.BACK, - // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); + // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", + // 0))); // p.setSpecificColorTOBEREMOVED(ColorType.LINE, - // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1))); + // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", + // 1))); // p.applyStroke(arg.get("LINECOLOR", 0)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java index 437376169..9a1c344d6 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandCreateState extends SingleLineCommand2 { @@ -103,7 +104,7 @@ public class CommandCreateState extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String idShort = arg.getLazzy("CODE", 0); final Ident ident = diagram.buildLeafIdent(idShort); final Code code = diagram.V1972() ? ident : diagram.buildCode(idShort); @@ -131,8 +132,9 @@ public class CommandCreateState extends SingleLineCommand2 { } Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + final String s = arg.get("LINECOLOR", 1); - final HColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)); + final HColor lineColor = s == null ? null : diagram.getSkinParam().getIHtmlColorSet().getColor(s); if (lineColor != null) { colors = colors.add(ColorType.LINE, lineColor); } @@ -142,9 +144,11 @@ public class CommandCreateState extends SingleLineCommand2 { ent.setColors(colors); // ent.setSpecificColorTOBEREMOVED(ColorType.BACK, - // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0))); + // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", + // 0))); // ent.setSpecificColorTOBEREMOVED(ColorType.LINE, - // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1))); + // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", + // 1))); // ent.applyStroke(arg.get("LINECOLOR", 0)); final String addFields = arg.get("ADDFIELD", 0); diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java index 5cf3bab32..a99cda267 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java @@ -58,6 +58,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.statediagram.StateDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandLinkState extends SingleLineCommand2 { @@ -96,7 +97,7 @@ public class CommandLinkState extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(StateDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String ent1 = arg.get("ENT1", 0); final String ent2 = arg.get("ENT2", 0); @@ -115,15 +116,17 @@ public class CommandLinkState extends SingleLineCommand2 { cl1.setStereotype(new Stereotype(arg.get("ENT1", 1))); } if (arg.get("ENT1", 2) != null) { + final String s = arg.get("ENT1", 2); cl1.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("ENT1", 2))); + diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } if (arg.get("ENT2", 1) != null) { cl2.setStereotype(new Stereotype(arg.get("ENT2", 1))); } if (arg.get("ENT2", 2) != null) { + final String s = arg.get("ENT2", 2); cl2.setSpecificColorTOBEREMOVED(ColorType.BACK, - diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("ENT2", 2))); + diagram.getSkinParam().getIHtmlColorSet().getColor(s)); } String queue = arg.get("ARROW_BODY1", 0) + arg.get("ARROW_BODY2", 0); diff --git a/src/net/sourceforge/plantuml/style/SName.java b/src/net/sourceforge/plantuml/style/SName.java index 55c2719b1..53e5c5f2d 100644 --- a/src/net/sourceforge/plantuml/style/SName.java +++ b/src/net/sourceforge/plantuml/style/SName.java @@ -59,7 +59,6 @@ public enum SName { componentDiagram, // control, // database, // - databse, // delay, // destroy, // diamond, // @@ -77,6 +76,7 @@ public enum SName { interface_, // jsonDiagram, // gitDiagram, // + label, // leafNode, // legend, // lifeLine, // diff --git a/src/net/sourceforge/plantuml/style/ValueImpl.java b/src/net/sourceforge/plantuml/style/ValueImpl.java index 32d2b9014..9a9d2e292 100644 --- a/src/net/sourceforge/plantuml/style/ValueImpl.java +++ b/src/net/sourceforge/plantuml/style/ValueImpl.java @@ -48,6 +48,9 @@ public class ValueImpl implements Value { private final int priority; public ValueImpl(String value, AutomaticCounter counter) { + if (value == null) { + throw new IllegalArgumentException(); + } this.value = value; this.priority = counter.getNextInt(); } @@ -68,7 +71,10 @@ public class ValueImpl implements Value { if ("transparent".equalsIgnoreCase(value)) { return HColorUtils.transparent(); } - return set.getColorIfValid(value); + if (value == null) { + return null; + } + return set.getColorOrWhite(value); } public boolean asBoolean() { diff --git a/src/net/sourceforge/plantuml/svek/Bibliotekon.java b/src/net/sourceforge/plantuml/svek/Bibliotekon.java index f0ba99438..63db03b9c 100644 --- a/src/net/sourceforge/plantuml/svek/Bibliotekon.java +++ b/src/net/sourceforge/plantuml/svek/Bibliotekon.java @@ -53,14 +53,14 @@ public class Bibliotekon { private final List allCluster = new ArrayList(); - private final Map nodeMap = new LinkedHashMap();; + private final Map nodeMap = new LinkedHashMap();; private final List lines0 = new ArrayList(); private final List lines1 = new ArrayList(); private final List allLines = new ArrayList(); - public Node createNode(ILeaf ent, IEntityImage image, ColorSequence colorSequence, StringBounder stringBounder) { - final Node node = new Node(ent, image, colorSequence, stringBounder); + public SvekNode createNode(ILeaf ent, IEntityImage image, ColorSequence colorSequence, StringBounder stringBounder) { + final SvekNode node = new SvekNode(ent, image, colorSequence, stringBounder); nodeMap.put(ent, node); return node; } @@ -107,12 +107,12 @@ public class Bibliotekon { allCluster.add(current); } - public Node getNode(IEntity ent) { + public SvekNode getNode(IEntity ent) { return nodeMap.get(ent); } public String getNodeUid(ILeaf ent) { - final Node result = getNode(ent); + final SvekNode result = getNode(ent); if (result != null) { String uid = result.getUid(); if (result.isShielded()) { @@ -134,8 +134,8 @@ public class Bibliotekon { public String getWarningOrError(int warningOrError) { final StringBuilder sb = new StringBuilder(); - for (Map.Entry ent : nodeMap.entrySet()) { - final Node sh = ent.getValue(); + for (Map.Entry ent : nodeMap.entrySet()) { + final SvekNode sh = ent.getValue(); final double maxX = sh.getMinX() + sh.getWidth(); if (maxX > warningOrError) { final IEntity entity = ent.getKey(); @@ -149,8 +149,8 @@ public class Bibliotekon { public Map getMaxX() { final Map result = new HashMap(); - for (Map.Entry ent : nodeMap.entrySet()) { - final Node sh = ent.getValue(); + for (Map.Entry ent : nodeMap.entrySet()) { + final SvekNode sh = ent.getValue(); final double maxX = sh.getMinX() + sh.getWidth(); final IEntity entity = ent.getKey(); result.put(entity.getCodeGetName(), maxX); @@ -174,7 +174,7 @@ public class Bibliotekon { return Collections.unmodifiableList(allCluster); } - public Collection allNodes() { + public Collection allNodes() { return Collections.unmodifiableCollection(nodeMap.values()); } @@ -207,8 +207,8 @@ public class Bibliotekon { return null; } - public ILeaf getLeaf(Node node) { - for (Map.Entry ent : nodeMap.entrySet()) { + public ILeaf getLeaf(SvekNode node) { + for (Map.Entry ent : nodeMap.entrySet()) { if (ent.getValue() == node) { return ent.getKey(); } diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java index 55adf81dd..a95279e7e 100644 --- a/src/net/sourceforge/plantuml/svek/Cluster.java +++ b/src/net/sourceforge/plantuml/svek/Cluster.java @@ -98,7 +98,7 @@ public class Cluster implements Moveable { private final Cluster parentCluster; private final IGroup group; - private final List nodes = new ArrayList(); + private final List nodes = new ArrayList(); private final List children = new ArrayList(); private final int color; private final int colorTitle; @@ -129,7 +129,7 @@ public class Cluster implements Moveable { private Set entityPositionsExceptNormal() { final Set result = EnumSet.noneOf(EntityPosition.class); - for (Node sh : nodes) { + for (SvekNode sh : nodes) { if (sh.getEntityPosition() != EntityPosition.NORMAL) { result.add(sh.getEntityPosition()); } @@ -166,7 +166,7 @@ public class Cluster implements Moveable { return parentCluster; } - public void addNode(Node node) { + public void addNode(SvekNode node) { if (node == null) { throw new IllegalArgumentException(); } @@ -174,17 +174,17 @@ public class Cluster implements Moveable { node.setCluster(this); } - public final List getNodes() { + public final List getNodes() { return Collections.unmodifiableList(nodes); } - private List getNodesOrderedTop(Collection lines) { - final List firsts = new ArrayList(); + private List getNodesOrderedTop(Collection lines) { + final List firsts = new ArrayList(); final Set tops = new HashSet(); - final Map shs = new HashMap(); + final Map shs = new HashMap(); - for (final Iterator it = nodes.iterator(); it.hasNext();) { - final Node node = it.next(); + for (final Iterator it = nodes.iterator(); it.hasNext();) { + final SvekNode node = it.next(); shs.put(node.getUid(), node); if (node.isTop() && node.getEntityPosition() == EntityPosition.NORMAL) { firsts.add(node); @@ -194,14 +194,14 @@ public class Cluster implements Moveable { for (Line l : lines) { if (tops.contains(l.getStartUidPrefix())) { - final Node sh = shs.get(l.getEndUidPrefix()); + final SvekNode sh = shs.get(l.getEndUidPrefix()); if (sh != null && sh.getEntityPosition() == EntityPosition.NORMAL) { firsts.add(0, sh); } } if (l.isInverted()) { - final Node sh = shs.get(l.getStartUidPrefix()); + final SvekNode sh = shs.get(l.getStartUidPrefix()); if (sh != null && sh.getEntityPosition() == EntityPosition.NORMAL) { firsts.add(0, sh); } @@ -211,13 +211,13 @@ public class Cluster implements Moveable { return firsts; } - private List getNodesOrderedWithoutTop(Collection lines) { - final List all = new ArrayList(nodes); + private List getNodesOrderedWithoutTop(Collection lines) { + final List all = new ArrayList(nodes); final Set tops = new HashSet(); - final Map shs = new HashMap(); + final Map shs = new HashMap(); - for (final Iterator it = all.iterator(); it.hasNext();) { - final Node sh = it.next(); + for (final Iterator it = all.iterator(); it.hasNext();) { + final SvekNode sh = it.next(); if (sh.getEntityPosition() != EntityPosition.NORMAL) { it.remove(); continue; @@ -231,14 +231,14 @@ public class Cluster implements Moveable { for (Line l : lines) { if (tops.contains(l.getStartUidPrefix())) { - final Node sh = shs.get(l.getEndUidPrefix()); + final SvekNode sh = shs.get(l.getEndUidPrefix()); if (sh != null) { all.remove(sh); } } if (l.isInverted()) { - final Node sh = shs.get(l.getStartUidPrefix()); + final SvekNode sh = shs.get(l.getStartUidPrefix()); if (sh != null) { all.remove(sh); } @@ -421,7 +421,7 @@ public class Cluster implements Moveable { public void manageEntryExitPoint(StringBounder stringBounder) { final Collection insides = new ArrayList(); final List points = new ArrayList(); - for (Node sh : nodes) { + for (SvekNode sh : nodes) { if (sh.getEntityPosition() == EntityPosition.NORMAL) { insides.add(sh.getClusterPosition()); } else { @@ -527,7 +527,7 @@ public class Cluster implements Moveable { } public void printCluster1(StringBuilder sb, Collection lines, StringBounder stringBounder) { - for (Node node : getNodesOrderedTop(lines)) { + for (SvekNode node : getNodesOrderedTop(lines)) { node.appendShape(sb, stringBounder); } } @@ -592,7 +592,7 @@ public class Cluster implements Moveable { private List withPositionProtected(StringBounder stringBounder, Set targets) { - final List result = withPosition(targets); + final List result = withPosition(targets); final double maxWith = getMaxWidthFromLabelForEntryExit(result, stringBounder); final double naturalSpace = 70; if (maxWith > naturalSpace) { @@ -601,10 +601,10 @@ public class Cluster implements Moveable { return result; } - private List withPosition(Set positions) { - final List result = new ArrayList(); - for (final Iterator it = nodes.iterator(); it.hasNext();) { - final Node sh = it.next(); + private List withPosition(Set positions) { + final List result = new ArrayList(); + for (final Iterator it = nodes.iterator(); it.hasNext();) { + final SvekNode sh = it.next(); if (positions.contains(sh.getEntityPosition())) { result.add(sh); } @@ -618,11 +618,11 @@ public class Cluster implements Moveable { printRanks(RANK_SINK, withPositionProtected(stringBounder, EntityPosition.getOutputs()), sb, stringBounder); } - public Node printCluster2(StringBuilder sb, Collection lines, StringBounder stringBounder, DotMode dotMode, + public SvekNode printCluster2(StringBuilder sb, Collection lines, StringBounder stringBounder, DotMode dotMode, GraphvizVersion graphvizVersion, UmlDiagramType type) { - Node added = null; - for (Node node : getNodesOrderedWithoutTop(lines)) { + SvekNode added = null; + for (SvekNode node : getNodesOrderedWithoutTop(lines)) { node.appendShape(sb, stringBounder); added = node; } @@ -665,7 +665,7 @@ public class Cluster implements Moveable { } public void fillRankMin(Set rankMin) { - for (Node sh : getNodes()) { + for (SvekNode sh : getNodes()) { if (sh.isTop()) { rankMin.add(sh.getUid()); } @@ -677,7 +677,7 @@ public class Cluster implements Moveable { } private boolean isInCluster(String uid) { - for (Node node : nodes) { + for (SvekNode node : nodes) { if (node.getUid().equals(uid)) { return true; } @@ -827,7 +827,7 @@ public class Cluster implements Moveable { SvekUtils.println(sb); printCluster1(sb, lines, stringBounder); - final Node added = printCluster2(sb, lines, stringBounder, dotMode, graphvizVersion, type); + final SvekNode added = printCluster2(sb, lines, stringBounder, dotMode, graphvizVersion, type); if (entityPositionsExceptNormal.size() > 0) { if (hasPort()) { sb.append(empty() + " [shape=rect,width=.01,height=.01,label="); diff --git a/src/net/sourceforge/plantuml/svek/DotStringFactory.java b/src/net/sourceforge/plantuml/svek/DotStringFactory.java index efe29f51b..f6d0e6e31 100644 --- a/src/net/sourceforge/plantuml/svek/DotStringFactory.java +++ b/src/net/sourceforge/plantuml/svek/DotStringFactory.java @@ -106,7 +106,7 @@ public class DotStringFactory implements Moveable { this.current = root; } - public void addNode(Node node) { + public void addNode(SvekNode node) { current.addNode(node); } @@ -363,7 +363,7 @@ public class DotStringFactory implements Moveable { final Point2DFunction move = new YDelta(fullHeight); final SvgResult svgResult = new SvgResult(svg, move); - for (Node node : bibliotekon.allNodes()) { + for (SvekNode node : bibliotekon.allNodes()) { int idx = svg.indexOf("" + node.getUid() + ""); if (node.getType() == ShapeType.RECTANGLE || node.getType() == ShapeType.RECTANGLE_HTML_FOR_PORTS || node.getType() == ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE || node.getType() == ShapeType.FOLDER @@ -392,7 +392,7 @@ public class DotStringFactory implements Moveable { final double minY = SvekUtils.getMinY(points); // corner1.manage(minX, minY); node.moveSvek(minX, minY); - } else if (node.getType() == ShapeType.OCTAGON) { + } else if (node.getType() == ShapeType.OCTAGON || node.getType() == ShapeType.HEXAGON) { idx = svg.indexOf("points=\"", idx + 1); final int starting = idx; final List points = svgResult.substring(starting).extractList(SvgResult.POINTS_EQUALS); @@ -400,7 +400,7 @@ public class DotStringFactory implements Moveable { final double minY = SvekUtils.getMinY(points); // corner1.manage(minX, minY); node.moveSvek(minX, minY); - node.setOctagon(minX, minY, points); + node.setPolygon(minX, minY, points); } else if (node.getType() == ShapeType.CIRCLE || node.getType() == ShapeType.CIRCLE_IN_RECT || node.getType() == ShapeType.OVAL) { final double cx = SvekUtils.getValue(svg, idx, "cx"); @@ -490,7 +490,7 @@ public class DotStringFactory implements Moveable { } public void moveSvek(double deltaX, double deltaY) { - for (Node sh : bibliotekon.allNodes()) { + for (SvekNode sh : bibliotekon.allNodes()) { sh.moveSvek(deltaX, deltaY); } for (Line line : bibliotekon.allLines()) { diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index bb5effe61..a8d9851a1 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -99,6 +99,7 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockEmpty; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.graphic.USymbolHexagon; import net.sourceforge.plantuml.graphic.USymbolInterface; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; @@ -201,7 +202,7 @@ public final class GeneralImageBuilder { } if (leaf.getLeafType() == LeafType.CIRCLE) { return new EntityImageDescription(leaf, skinParam, portionShower, links, umlDiagramType.getStyleName(), - null); + null, bibliotekon); } if (leaf.getLeafType() == LeafType.DESCRIPTION) { @@ -214,7 +215,7 @@ public final class GeneralImageBuilder { ? getForcedStroke(leaf.getStereotype(), skinParam) : null; return new EntityImageDescription(leaf, skinParam, portionShower, links, umlDiagramType.getStyleName(), - forced); + forced, bibliotekon); } } if (leaf.getLeafType() == LeafType.USECASE) { @@ -250,7 +251,8 @@ public final class GeneralImageBuilder { final HColor black = SkinParamUtils.getColor(skinParam, leaf.getStereotype(), leaf.getUSymbol().getColorParamBorder()); return new EntityImageDescription(leaf, new SkinParamForecolored(skinParam, black), portionShower, - links, umlDiagramType.getStyleName(), getForcedStroke(leaf.getStereotype(), skinParam)); + links, umlDiagramType.getStyleName(), getForcedStroke(leaf.getStereotype(), skinParam), + bibliotekon); } return new EntityImageEmptyPackage(leaf, skinParam, portionShower, umlDiagramType.getStyleName()); } @@ -395,7 +397,7 @@ public final class GeneralImageBuilder { if (dotData.isDegeneratedWithFewEntities(1) && dotData.getUmlDiagramType() != UmlDiagramType.STATE) { final ILeaf single = dotData.getLeafs().iterator().next(); final IGroup group = single.getParentContainer(); - if (group instanceof GroupRoot) { + if (group instanceof GroupRoot && single.getUSymbol() instanceof USymbolHexagon == false) { final IEntityImage tmp = GeneralImageBuilder.createEntityImageBlock(single, dotData.getSkinParam(), dotData.isHideEmptyDescriptionForState(), dotData, null, null, dotData.getUmlDiagramType(), dotData.getLinks()); @@ -429,15 +431,15 @@ public final class GeneralImageBuilder { dotStringFactory.getBibliotekon().addLine(line); if (isOpalisable(link.getEntity1())) { - final Node node = dotStringFactory.getBibliotekon().getNode(link.getEntity1()); - final Node other = dotStringFactory.getBibliotekon().getNode(link.getEntity2()); + final SvekNode node = dotStringFactory.getBibliotekon().getNode(link.getEntity1()); + final SvekNode other = dotStringFactory.getBibliotekon().getNode(link.getEntity2()); if (other != null) { ((EntityImageNote) node.getImage()).setOpaleLine(line, node, other); line.setOpale(true); } } else if (isOpalisable(link.getEntity2())) { - final Node node = dotStringFactory.getBibliotekon().getNode(link.getEntity2()); - final Node other = dotStringFactory.getBibliotekon().getNode(link.getEntity1()); + final SvekNode node = dotStringFactory.getBibliotekon().getNode(link.getEntity2()); + final SvekNode other = dotStringFactory.getBibliotekon().getNode(link.getEntity1()); if (other != null) { ((EntityImageNote) node.getImage()).setOpaleLine(line, node, other); line.setOpale(true); @@ -542,7 +544,7 @@ public final class GeneralImageBuilder { throw new IllegalStateException(); } final IEntityImage image = printEntityInternal(dotStringFactory, ent); - final Node node = dotStringFactory.getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), + final SvekNode node = dotStringFactory.getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), stringBounder); dotStringFactory.addNode(node); } diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index fb8901ac5..08cd97ccd 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -457,7 +457,7 @@ public class Line implements Moveable, Hideable, GuideLine { } private UDrawable getExtremity(LinkDecor decor, PointListIterator pointListIterator, final Point2D center, - double angle, Cluster cluster, Node nodeContact) { + double angle, Cluster cluster, SvekNode nodeContact) { final ExtremityFactory extremityFactory = decor.getExtremityFactory(backgroundColor); if (cluster != null) { @@ -870,9 +870,9 @@ public class Line implements Moveable, Hideable, GuideLine { return strategy.getResult() + getDecorDzeta(); } - public void manageCollision(Collection allNodes) { + public void manageCollision(Collection allNodes) { - for (Node sh : allNodes) { + for (SvekNode sh : allNodes) { final Positionable cl = PositionableUtils.addMargin(sh, 8, 8); if (startTailText != null && startTailLabelXY != null && PositionableUtils.intersect(cl, startTailLabelXY)) { @@ -903,7 +903,7 @@ public class Line implements Moveable, Hideable, GuideLine { } - private void avoid(Point2D.Double move, Positionable pos, Node sh) { + private void avoid(Point2D.Double move, Positionable pos, SvekNode sh) { final Oscillator oscillator = new Oscillator(); final Point2D.Double orig = new Point2D.Double(move.x, move.y); while (cut(pos, sh)) { @@ -912,7 +912,7 @@ public class Line implements Moveable, Hideable, GuideLine { } } - private boolean cut(Positionable pos, Node sh) { + private boolean cut(Positionable pos, SvekNode sh) { return BezierUtils.intersect(pos, sh) || tooClose(pos); } @@ -1018,4 +1018,4 @@ public class Line implements Moveable, Hideable, GuideLine { return null; } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/ShapeType.java b/src/net/sourceforge/plantuml/svek/ShapeType.java index 9d7823bbf..349917ffe 100644 --- a/src/net/sourceforge/plantuml/svek/ShapeType.java +++ b/src/net/sourceforge/plantuml/svek/ShapeType.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.svek; public enum ShapeType { - RECTANGLE, RECTANGLE_WITH_CIRCLE_INSIDE, RECTANGLE_HTML_FOR_PORTS, ROUND_RECTANGLE, CIRCLE, CIRCLE_IN_RECT, OVAL, DIAMOND, OCTAGON, FOLDER + RECTANGLE, RECTANGLE_WITH_CIRCLE_INSIDE, RECTANGLE_HTML_FOR_PORTS, ROUND_RECTANGLE, CIRCLE, CIRCLE_IN_RECT, OVAL, + DIAMOND, OCTAGON, FOLDER, HEXAGON } diff --git a/src/net/sourceforge/plantuml/svek/SingleStrategy.java b/src/net/sourceforge/plantuml/svek/SingleStrategy.java index 98f6b909e..01c558109 100644 --- a/src/net/sourceforge/plantuml/svek/SingleStrategy.java +++ b/src/net/sourceforge/plantuml/svek/SingleStrategy.java @@ -39,7 +39,7 @@ package net.sourceforge.plantuml.svek; public enum SingleStrategy { - SQUARRE, HLINE, VLINE; + SQUARE, HLINE, VLINE; // private Collection generateLinks(List standalones) { // return putInSquare(standalones); diff --git a/src/net/sourceforge/plantuml/svek/Node.java b/src/net/sourceforge/plantuml/svek/SvekNode.java similarity index 95% rename from src/net/sourceforge/plantuml/svek/Node.java rename to src/net/sourceforge/plantuml/svek/SvekNode.java index 97ea93dd2..bff3f30af 100644 --- a/src/net/sourceforge/plantuml/svek/Node.java +++ b/src/net/sourceforge/plantuml/svek/SvekNode.java @@ -54,7 +54,7 @@ import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterface; import net.sourceforge.plantuml.ugraphic.Shadowable; import net.sourceforge.plantuml.ugraphic.UPolygon; -public class Node implements Positionable, IShapePseudo, Hideable { +public class SvekNode implements Positionable, IShapePseudo, Hideable { private final ShapeType type; private final double width; @@ -94,7 +94,7 @@ public class Node implements Positionable, IShapePseudo, Hideable { private final ILeaf leaf; private final IGroup group; - Node(ILeaf ent, IEntityImage image, ColorSequence colorSequence, StringBounder stringBounder) { + SvekNode(ILeaf ent, IEntityImage image, ColorSequence colorSequence, StringBounder stringBounder) { final Dimension2D dim = image.calculateDimension(stringBounder); this.entityPosition = ent.getEntityPosition(); this.image = image; @@ -258,6 +258,8 @@ public class Node implements Positionable, IShapePseudo, Hideable { throw new UnsupportedOperationException(); } else if (type == ShapeType.OCTAGON) { sb.append("shape=octagon"); + } else if (type == ShapeType.HEXAGON) { + sb.append("shape=hexagon"); } else if (type == ShapeType.DIAMOND) { sb.append("shape=diamond"); } else if (type == ShapeType.CIRCLE) { @@ -331,14 +333,14 @@ public class Node implements Positionable, IShapePseudo, Hideable { return image.isHidden(); } - private Shadowable octagon; + private Shadowable polygon; - public void setOctagon(double minX, double minY, List points) { - this.octagon = new UPolygon(points).translate(-minX, -minY); + public void setPolygon(double minX, double minY, List points) { + this.polygon = new UPolygon(points).translate(-minX, -minY); } - public Shadowable getOctagon() { - return octagon; + public Shadowable getPolygon() { + return polygon; } public Point2D getPoint2D(double x, double y) { diff --git a/src/net/sourceforge/plantuml/svek/SvekResult.java b/src/net/sourceforge/plantuml/svek/SvekResult.java index 9b96c1ffd..2819a0bb5 100644 --- a/src/net/sourceforge/plantuml/svek/SvekResult.java +++ b/src/net/sourceforge/plantuml/svek/SvekResult.java @@ -86,7 +86,7 @@ public final class SvekResult extends AbstractTextBlock implements IEntityImage } color = HColorUtils.noGradient(color); - for (Node node : dotStringFactory.getBibliotekon().allNodes()) { + for (SvekNode node : dotStringFactory.getBibliotekon().allNodes()) { final double minX = node.getMinX(); final double minY = node.getMinY(); final UGraphic ug2 = node.isHidden() ? ug.apply(UHidden.HIDDEN) : ug; diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java index 90ea1c321..ab36f04d7 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java @@ -83,4 +83,4 @@ class ExtremityArrowAndCircle extends Extremity { .draw(new UEllipse(radius * 2, radius * 2)); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java index 5c6a1c52f..d0c1202f8 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java @@ -83,4 +83,4 @@ class ExtremityCircle extends Extremity { ug.draw(new UEllipse(radius * 2, radius * 2)); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java index 9db56c7ba..c81fda51e 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java @@ -88,4 +88,4 @@ class ExtremityCircleConnect extends Extremity { // // } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java index fd1f9bfc3..36aa022e9 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java @@ -84,4 +84,4 @@ class ExtremityCircleCross extends Extremity { } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java index afa746aa3..0c15ad155 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java @@ -54,4 +54,4 @@ public class ExtremityFactoryArrowAndCircle extends AbstractExtremityFactory imp final Point2D center = new Point2D.Double((p0.getX() + p2.getX()) / 2, (p0.getY() + p2.getY()) / 2); return new ExtremityArrowAndCircle(p1, ortho, center, backgroundColor); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java index fd931aafa..2e4718ab0 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java @@ -63,4 +63,4 @@ public class ExtremityFactoryCircle extends AbstractExtremityFactory implements return ExtremityCircle.create(p1, fill, ortho, backgroundColor); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java index db63bfdf4..1ca169ac1 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java @@ -61,4 +61,4 @@ public class ExtremityFactoryCircleConnect extends AbstractExtremityFactory impl return new ExtremityCircleConnect(p1, ortho, backgroundColor); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java index 2040a399a..8567e0bd3 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java @@ -55,4 +55,4 @@ public class ExtremityFactoryCircleCross extends AbstractExtremityFactory implem return new ExtremityCircleCross(p1, backgroundColor); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java index 41f9ca89c..0f71168b7 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java @@ -60,4 +60,4 @@ public class ExtremityFactoryPlus extends AbstractExtremityFactory implements Ex return ExtremityPlus.create(p1, ortho, backgroundColor); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquarre.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquare.java similarity index 87% rename from src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquarre.java rename to src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquare.java index 3e0603bdb..38c941a1b 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquarre.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquare.java @@ -42,22 +42,22 @@ import net.sourceforge.plantuml.svek.AbstractExtremityFactory; import net.sourceforge.plantuml.svek.Side; import net.sourceforge.plantuml.ugraphic.color.HColor; -public class ExtremityFactorySquarre extends AbstractExtremityFactory implements ExtremityFactory { +public class ExtremityFactorySquare extends AbstractExtremityFactory implements ExtremityFactory { private final HColor backgroundColor; - public ExtremityFactorySquarre(HColor backgroundColor) { + public ExtremityFactorySquare(HColor backgroundColor) { this.backgroundColor = backgroundColor; } @Override public UDrawable createUDrawable(Point2D p0, double angle, Side side) { - return new ExtremitySquarre(p0, backgroundColor); + return new ExtremitySquare(p0, backgroundColor); } public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { // final double ortho = atan2(p0, p2); - return new ExtremitySquarre(p1, backgroundColor); + return new ExtremitySquare(p1, backgroundColor); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java index fef73f286..a88332398 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java @@ -92,4 +92,4 @@ class ExtremityPlus extends Extremity { } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremitySquarre.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremitySquare.java similarity index 95% rename from src/net/sourceforge/plantuml/svek/extremity/ExtremitySquarre.java rename to src/net/sourceforge/plantuml/svek/extremity/ExtremitySquare.java index 0a1a591be..450b9aae7 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremitySquarre.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremitySquare.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; -class ExtremitySquarre extends Extremity { +class ExtremitySquare extends Extremity { private final HColor backgroundColor; private final Point2D dest; @@ -54,7 +54,7 @@ class ExtremitySquarre extends Extremity { return dest; } - public ExtremitySquarre(Point2D p1, HColor backgroundColor) { + public ExtremitySquare(Point2D p1, HColor backgroundColor) { this.dest = new Point2D.Double(p1.getX(), p1.getY()); this.backgroundColor = backgroundColor; } @@ -63,4 +63,4 @@ class ExtremitySquarre extends Extremity { ug.apply(new UStroke(1.5)).apply(backgroundColor.bg()).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new URectangle(radius * 2, radius * 2)); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java index c84119e2b..515c60235 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java +++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java @@ -89,4 +89,4 @@ class MiddleCircleCircled extends Extremity { ug.apply(new UTranslate(-radius1, -radius1)).draw(circle); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java index 290c2edd3..9ba445215 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java +++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java @@ -54,4 +54,4 @@ public class MiddleFactoryCircleCircled implements MiddleFactory { return new MiddleCircleCircled(angle, mode, backColor, diagramBackColor); } -} +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java index 674fc4111..7d62fe258 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java @@ -57,7 +57,7 @@ import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.Bibliotekon; -import net.sourceforge.plantuml.svek.Node; +import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.Shadowable; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -120,8 +120,8 @@ public class EntityImageActivity extends AbstractEntityImage { } private UGraphic drawOctagon(UGraphic ug) { - final Node node = bibliotekon.getNode(getEntity()); - final Shadowable octagon = node.getOctagon(); + final SvekNode node = bibliotekon.getNode(getEntity()); + final Shadowable octagon = node.getPolygon(); if (octagon == null) { return drawNormal(ug); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java index c5cb97d8c..3033cf535 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java @@ -70,8 +70,11 @@ import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.AbstractEntityImage; +import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Margins; +import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.svek.ShapeType; +import net.sourceforge.plantuml.ugraphic.Shadowable; import net.sourceforge.plantuml.ugraphic.UComment; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; @@ -97,11 +100,14 @@ public class EntityImageDescription extends AbstractEntityImage { private final Collection links; private final boolean useRankSame; private final boolean fixCircleLabelOverlapping; + private final Bibliotekon bibliotekon; + private final SymbolContext ctx; public EntityImageDescription(ILeaf entity, ISkinParam skinParam, PortionShower portionShower, - Collection links, SName styleName, UStroke forceStroke) { + Collection links, SName styleName, UStroke forceStroke, Bibliotekon bibliotekon) { super(entity, entity.getColors(skinParam).mute(skinParam)); this.useRankSame = getSkinParam().useRankSame(); + this.bibliotekon = bibliotekon; this.fixCircleLabelOverlapping = getSkinParam().fixCircleLabelOverlapping(); this.links = links; @@ -109,6 +115,8 @@ public class EntityImageDescription extends AbstractEntityImage { USymbol symbol = getUSymbol(entity); if (symbol == USymbol.FOLDER) { this.shapeType = ShapeType.FOLDER; + } else if (symbol == USymbol.HEXAGON) { + this.shapeType = ShapeType.HEXAGON; } else if (symbol == USymbol.INTERFACE) { this.shapeType = getSkinParam().fixCircleLabelOverlapping() ? ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE : ShapeType.RECTANGLE; @@ -130,6 +138,7 @@ public class EntityImageDescription extends AbstractEntityImage { final FontConfiguration fcStereo; Style style = null; + final HorizontalAlignment defaultAlign; if (UseStyle.useBetaStyle()) { final StyleSignature tmp = StyleSignature.of(SName.root, SName.element, styleName, symbol.getSkinParameter().getStyleName()); @@ -146,6 +155,7 @@ public class EntityImageDescription extends AbstractEntityImage { stroke = style.getStroke(); fcTitle = style.getFontConfiguration(getSkinParam().getIHtmlColorSet()); fcStereo = styleStereo.getFontConfiguration(getSkinParam().getIHtmlColorSet()); + defaultAlign = style.getHorizontalAlignment(); } else { forecolor = SkinParamUtils.getColor(getSkinParam(), stereotype, symbol.getColorParamBorder()); if (backcolor == null) { @@ -161,21 +171,21 @@ public class EntityImageDescription extends AbstractEntityImage { } fcTitle = new FontConfiguration(getSkinParam(), symbol.getFontParam(), stereotype); fcStereo = new FontConfiguration(getSkinParam(), symbol.getFontParamStereotype(), stereotype); + defaultAlign = HorizontalAlignment.LEFT; } assert getStereo() == stereotype; - final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(stroke).withShadow(deltaShadow) - .withCorner(roundCorner, diagonalCorner); + ctx = new SymbolContext(backcolor, forecolor).withStroke(stroke).withShadow(deltaShadow).withCorner(roundCorner, + diagonalCorner); final Display codeDisplay = Display.getWithNewlines(entity.getCodeGetName()); if ((entity.getDisplay().equals(codeDisplay) && symbol.getSkinParameter() == SkinParameter.PACKAGE) || entity.getDisplay().isWhite()) { desc = TextBlockUtils.empty(getSkinParam().minClassWidth(), 0); } else { - - desc = BodyFactory.create3(entity.getDisplay(), symbol.getFontParam(), getSkinParam(), - getSkinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), fcTitle, + final HorizontalAlignment align = getSkinParam().getDefaultTextAlignment(defaultAlign); + desc = BodyFactory.create3(entity.getDisplay(), symbol.getFontParam(), getSkinParam(), align, fcTitle, getSkinParam().wrapWidth()); } @@ -287,7 +297,11 @@ public class EntityImageDescription extends AbstractEntityImage { if (url != null) { ug.startUrl(url); } + if (shapeType == ShapeType.HEXAGON) { + drawHexagon(ctx.apply(ug)); + } asSmall.drawU(ug); + if (hideText) { final double space = 8; final Dimension2D dimSmall = asSmall.calculateDimension(ug.getStringBounder()); @@ -308,6 +322,16 @@ public class EntityImageDescription extends AbstractEntityImage { } } + private void drawHexagon(UGraphic ug) { + if (bibliotekon == null) { + throw new IllegalStateException(); + } + final SvekNode node = bibliotekon.getNode(getEntity()); + final Shadowable hexagon = node.getPolygon(); + hexagon.setDeltaShadow(ctx.getDeltaShadow()); + ug.draw(hexagon); + } + public ShapeType getShapeType() { return shapeType; } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java index 1cb1c5eb2..737cf9b79 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java @@ -72,7 +72,7 @@ import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.Line; -import net.sourceforge.plantuml.svek.Node; +import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; @@ -295,10 +295,10 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil { } private Line opaleLine; - private Node node; - private Node other; + private SvekNode node; + private SvekNode other; - public void setOpaleLine(Line line, Node node, Node other) { + public void setOpaleLine(Line line, SvekNode node, SvekNode other) { if (other == null) { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java b/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java index e708a5636..1c0003dfe 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImagePort.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Cluster; -import net.sourceforge.plantuml.svek.Node; +import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.Shadowable; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -66,7 +66,7 @@ public class EntityImagePort extends AbstractEntityImageBorder { private boolean upPosition() { final Point2D clusterCenter = parent.getClusterPosition().getPointCenter(); - final Node node = bibliotekon.getNode(getEntity()); + final SvekNode node = bibliotekon.getNode(getEntity()); return node.getMinY() < clusterCenter.getY(); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java index 6369e557b..b723da869 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.svek.Bibliotekon; import net.sourceforge.plantuml.svek.Cluster; -import net.sourceforge.plantuml.svek.Node; +import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -62,7 +62,7 @@ public class EntityImageStateBorder extends AbstractEntityImageBorder { private boolean upPosition() { final Point2D clusterCenter = parent.getClusterPosition().getPointCenter(); - final Node node = bibliotekon.getNode(getEntity()); + final SvekNode node = bibliotekon.getNode(getEntity()); return node.getMinY() < clusterCenter.getY(); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java index 9648ffb01..d627ec108 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java @@ -60,7 +60,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.Bibliotekon; -import net.sourceforge.plantuml.svek.Node; +import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -120,8 +120,8 @@ public class EntityImageTips extends AbstractEntityImage { final IEntity other = bibliotekon.getOnlyOther(getEntity()); - final Node nodeMe = bibliotekon.getNode(getEntity()); - final Node nodeOther = bibliotekon.getNode(other); + final SvekNode nodeMe = bibliotekon.getNode(getEntity()); + final SvekNode nodeOther = bibliotekon.getNode(other); final Point2D positionMe = nodeMe.getPosition(); if (nodeOther == null) { System.err.println("Error in EntityImageTips"); diff --git a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java index a733b78d0..18eec59c9 100644 --- a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java +++ b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java @@ -136,6 +136,7 @@ public class LanguageDescriptor { keyword.add("up"); keyword.add("down"); keyword.add("if"); + keyword.add("then"); keyword.add("else"); keyword.add("elseif"); keyword.add("endif"); diff --git a/src/net/sourceforge/plantuml/text/RichText.java b/src/net/sourceforge/plantuml/text/RichText.java new file mode 100644 index 000000000..0080ddd77 --- /dev/null +++ b/src/net/sourceforge/plantuml/text/RichText.java @@ -0,0 +1,52 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.text; + +import net.sourceforge.plantuml.StringUtils; + +public class RichText { + + public static boolean isRich(String text) { + if (text.indexOf(StringUtils.BOLD_START) != -1) { + return true; + } + if (text.indexOf(StringUtils.BOLD_END) != -1) { + return true; + } + return false; + } + +} diff --git a/src/net/sourceforge/plantuml/graphic/StyledString.java b/src/net/sourceforge/plantuml/text/StyledString.java similarity index 96% rename from src/net/sourceforge/plantuml/graphic/StyledString.java rename to src/net/sourceforge/plantuml/text/StyledString.java index fba2d7255..5323acc03 100644 --- a/src/net/sourceforge/plantuml/graphic/StyledString.java +++ b/src/net/sourceforge/plantuml/text/StyledString.java @@ -33,13 +33,14 @@ * * */ -package net.sourceforge.plantuml.graphic; +package net.sourceforge.plantuml.text; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.graphic.FontStyle; public class StyledString { diff --git a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java index 8898591df..253964864 100644 --- a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java +++ b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java @@ -358,6 +358,8 @@ public class TikzGraphics { text = text.replaceAll("&", "\\\\&"); text = text.replaceAll("%", "\\\\%"); text = text.replace("$", "\\$"); + text = text.replace("{", "\\{"); + text = text.replace("}", "\\}"); // text = text.replaceAll("~", "\\\\~{}"); text = text.replace("~", "{\\raise.35ex\\hbox{$\\scriptstyle\\mathtt{\\sim}$}}"); // {\raise.35ex\hbox{$\scriptstyle\mathtt{\sim}$}} diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java b/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java index b990c80b3..137b1984b 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java @@ -68,7 +68,7 @@ public class TimingRuler { static UGraphic applyForVLines(UGraphic ug) { final UStroke stroke = new UStroke(3, 5, 0.5); - final HColor color = HColorSet.instance().getColorIfValid("#AAA"); + final HColor color = HColorSet.instance().getColorOrWhite("#AAA"); return ug.apply(stroke).apply(color); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeState.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeState.java index e0fcebc1f..aced0c408 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeState.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeState.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.timingdiagram.Player; import net.sourceforge.plantuml.timingdiagram.TimeTick; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; abstract class CommandChangeState extends SingleLineCommand2 { @@ -61,7 +62,7 @@ abstract class CommandChangeState extends SingleLineCommand2 { } protected CommandExecutionResult addState(TimingDiagram diagram, RegexResult arg, final Player player, - final TimeTick now) { + final TimeTick now) throws NoSuchColorException { final String comment = arg.get("COMMENT", 0); final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); player.setState(now, comment, colors, getStates(arg)); diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java index 700c3f2cf..a69dfa87b 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.timingdiagram.Player; import net.sourceforge.plantuml.timingdiagram.TimeTick; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandChangeStateByPlayerCode extends CommandChangeState { @@ -73,7 +74,7 @@ public class CommandChangeStateByPlayerCode extends CommandChangeState { } @Override - final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) { + final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String code = arg.get("CODE", 0); final Player player = diagram.getPlayer(code); if (player == null) { diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java index 996020532..2784dc58a 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.timingdiagram.Player; import net.sourceforge.plantuml.timingdiagram.TimeTick; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandChangeStateByTime extends CommandChangeState { @@ -74,7 +75,7 @@ public class CommandChangeStateByTime extends CommandChangeState { } @Override - final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) { + final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final Player player = diagram.getLastPlayer(); if (player == null) { return CommandExecutionResult.error("Missing @ line before this"); diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandHighlight.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandHighlight.java index 2c2502d4b..90ef82a4e 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandHighlight.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandHighlight.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.timingdiagram.TimeTick; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandHighlight extends SingleLineCommand2 { @@ -83,7 +84,7 @@ public class CommandHighlight extends SingleLineCommand2 { } @Override - final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) { + final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final TimeTick tickFrom = TimeTickBuilder.parseTimeTick("FROM", arg, diagram); final TimeTick tickTo = TimeTickBuilder.parseTimeTick("TO", arg, diagram); final Display display = Display.getWithNewlines(arg.get("CAPTION", 0)); diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandNoteLong.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandNoteLong.java index 4f1d8dbe7..20a839dd0 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandNoteLong.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandNoteLong.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.timingdiagram.Player; import net.sourceforge.plantuml.timingdiagram.TimeTick; import net.sourceforge.plantuml.timingdiagram.TimingDiagram; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandNoteLong extends CommandMultilines2 { @@ -61,7 +62,7 @@ public class CommandNoteLong extends CommandMultilines2 { } @Override - protected CommandExecutionResult executeNow(final TimingDiagram diagram, BlocLines lines) { + protected CommandExecutionResult executeNow(final TimingDiagram diagram, BlocLines lines) throws NoSuchColorException { final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); lines = lines.subExtract(1, 1); diff --git a/src/net/sourceforge/plantuml/ugraphic/FontChecker.java b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java index c9df3eab4..08a81f53d 100644 --- a/src/net/sourceforge/plantuml/ugraphic/FontChecker.java +++ b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java @@ -68,7 +68,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class FontChecker { final private UFont font; - private static final Set SQUARRE = new HashSet( + private static final Set SQUARE = new HashSet( Arrays.asList("MI=I=XM=I=IX", "MI=I=XM=I=IXMI=I=XM=I=IX")); public FontChecker(UFont font) { @@ -76,7 +76,7 @@ public class FontChecker { } public boolean isCharOk(char c) { - return SQUARRE.contains(getCharDesc(c)) == false; + return SQUARE.contains(getCharDesc(c)) == false; } static private String getType(int type, double oldX, double oldY, double x, double y) { diff --git a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java index 4236f1374..c96ec34f1 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java @@ -102,15 +102,30 @@ public class UImageSvg implements UShape { } public int getData(String name) { - final Pattern p = Pattern.compile("(?i)" + name + "\\W+(\\d+)"); + final Pattern p = Pattern.compile("(?i)]+" + name + "\\W+(\\d+)"); final Matcher m = p.matcher(svg); if (m.find()) { final String s = m.group(1); return Integer.parseInt(s); } + final Pattern p2 = Pattern.compile("viewBox[= \"\']+([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)"); + final Matcher m2 = p2.matcher(svg); + if (m2.find()) { + if ("width".equals(name)) { + final String s = m2.group(3); + final int width = (int) Double.parseDouble(s); + return width; + } + if ("height".equals(name)) { + final String s = m2.group(4); + final int result = (int) Double.parseDouble(s); + return result; + } + } + throw new IllegalStateException("Cannot find " + name); } - + public int getHeight() { return this.getData("height"); } @@ -119,7 +134,6 @@ public class UImageSvg implements UShape { return this.getData("width"); } - public double getScale() { return scale; } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java index 70f007285..16d4e15c6 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperIdentity.java @@ -46,10 +46,6 @@ public class ColorMapperIdentity extends AbstractColorMapper implements ColorMap if (color instanceof HColorBackground) { throw new UnsupportedOperationException(); } - if (color instanceof HColorUserDef) { - // Impact on JCCKIT - return Color.WHITE; - } if (color instanceof HColorGradient) { return toColor(((HColorGradient) color).getColor1()); } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java index 782ac4a97..0dfb7f059 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/ColorMapperLightnessInverse.java @@ -46,10 +46,6 @@ public class ColorMapperLightnessInverse extends AbstractColorMapper implements if (color instanceof HColorBackground) { throw new UnsupportedOperationException(); } - if (color instanceof HColorUserDef) { - // Impact on JCCKIT - return Color.WHITE; - } if (color instanceof HColorGradient) { return toColor(((HColorGradient) color).getColor1()); } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java index a4972fa39..5c20b3822 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColorSet.java @@ -227,35 +227,106 @@ public class HColorSet { names.add(s); } - public HColor getColorIfValid(String s) { - return getColorIfValid(s, null); + class Gradient { + private final String s1; + private final char sep; + private final String s2; + + Gradient(String s1, char sep, String s2) { + this.s1 = s1; + this.sep = sep; + this.s2 = s2; + } + + boolean isGradientValid() { + return isColorValid(s1) && isColorValid(s2); + } + + HColorGradient buildGradient(HColor background) { + return new HColorGradient(build(s1, background), build(s2, background), sep); + } + } - public HColor getColorIfValid(String s, HColor background) { - if (s == null) { - return null; - } - final boolean acceptTransparent = background != null; - if (acceptTransparent && background == null) { - throw new IllegalArgumentException(); - } + private Gradient fromString(String s) { final Matcher2 m = MyPattern.cmpile("[-\\\\|/]").matcher(s); if (m.find()) { final char sep = m.group(0).charAt(0); final int idx = s.indexOf(sep); final String s1 = s.substring(0, idx); final String s2 = s.substring(idx + 1); - if (isValid(s1, false) == false || isValid(s2, false) == false) { - return null; - } - return new HColorGradient(build(s1, background), build(s2, background), sep); + return new Gradient(s1, sep, s2); } - if (isValid(s, acceptTransparent) == false) { - return new HColorUserDef(); + return null; + } + + public HColor getColorOrWhite(String s) { + return getColorOrWhite(s, null); + } + + public HColor getColorOrWhite(String s, HColor background) { + if (s == null) { + throw new IllegalArgumentException(); } + if (isColorValid(s) == false) { + return HColorUtils.WHITE; + } + try { + return getColor(s, background); + } catch (NoSuchColorException e) { + assert false; + return HColorUtils.WHITE; + } + } + + public HColor getColor(String s) throws NoSuchColorException { + return getColor(s, null); + } + + public HColor getColor(String s, HColor background) throws NoSuchColorException { + if (s == null) { + throw new IllegalArgumentException(); + } + if (isColorValid(s) == false) { + throw new NoSuchColorException(); + } + final Gradient gradient = fromString(s); + if (gradient != null) { + return gradient.buildGradient(background); + } + if (background == null && (s.equalsIgnoreCase("#transparent") || s.equalsIgnoreCase("transparent"))) + s = "#00000000"; return build(s, background); } + private boolean isColorValid(String s) { + s = removeFirstDieseAndgoLowerCase(s); + final Gradient gradient = fromString(s); + if (gradient != null) { + return gradient.isGradientValid(); + } + if (s.matches("[0-9A-Fa-f]{3}")) { + return true; + } + if (s.matches("[0-9A-Fa-f]{6}")) { + return true; + } + if (s.matches("[0-9A-Fa-f]{8}")) { + return true; + } + if (s.equalsIgnoreCase("automatic")) { + return true; + } + if (s.equalsIgnoreCase("transparent")) { + return true; + } + if (htmlNames.containsKey(s)) { + return true; + } + return false; + + } + private HColor build(String s, HColor background) { s = removeFirstDieseAndgoLowerCase(s); final Color color; @@ -292,30 +363,6 @@ public class HColorSet { return new Color(red, green, blue, alpha); } - private boolean isValid(String s, boolean acceptTransparent) { - s = removeFirstDieseAndgoLowerCase(s); - if (s.matches("[0-9A-Fa-f]{3}")) { - return true; - } - if (s.matches("[0-9A-Fa-f]{6}")) { - return true; - } - if (s.matches("[0-9A-Fa-f]{8}")) { - return true; - } - if (s.equalsIgnoreCase("automatic")) { - return true; - } - if (acceptTransparent && s.equalsIgnoreCase("transparent")) { - return true; - } - if (htmlNames.containsKey(s)) { - return true; - } - return false; - - } - private String removeFirstDieseAndgoLowerCase(String s) { s = StringUtils.goLowerCase(s); if (s.startsWith("#")) { diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java b/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java index 9db034fec..6456c0fe0 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/HColorUtils.java @@ -81,40 +81,40 @@ public class HColorUtils { final HColorSet set = HColorSet.instance(); - BLACK = set.getColorIfValid("black"); - WHITE = set.getColorIfValid("white"); - RED_LIGHT = set.getColorIfValid("#FEF6F3"); - RED_DARK = set.getColorIfValid("#CD0A0A"); - RED = set.getColorIfValid("#FF0000"); - GREEN = set.getColorIfValid("#00FF00"); - BLUE = set.getColorIfValid("#0000FF"); - GRAY = set.getColorIfValid("#808080"); - LIGHT_GRAY = set.getColorIfValid("#C0C0C0"); - MY_YELLOW = set.getColorIfValid("#FEFECE"); - MY_RED = set.getColorIfValid("#A80036"); - MY_GREEN = set.getColorIfValid("#33FF02"); + BLACK = set.getColorOrWhite("black"); + WHITE = set.getColorOrWhite("white"); + RED_LIGHT = set.getColorOrWhite("#FEF6F3"); + RED_DARK = set.getColorOrWhite("#CD0A0A"); + RED = set.getColorOrWhite("#FF0000"); + GREEN = set.getColorOrWhite("#00FF00"); + BLUE = set.getColorOrWhite("#0000FF"); + GRAY = set.getColorOrWhite("#808080"); + LIGHT_GRAY = set.getColorOrWhite("#C0C0C0"); + MY_YELLOW = set.getColorOrWhite("#FEFECE"); + MY_RED = set.getColorOrWhite("#A80036"); + MY_GREEN = set.getColorOrWhite("#33FF02"); - COL_C82930 = set.getColorIfValid("#C82930"); - COL_F24D5C = set.getColorIfValid("#F24D5C"); - COL_1963A0 = set.getColorIfValid("#1963A0"); - COL_4177AF = set.getColorIfValid("#4177AF"); - COL_B38D22 = set.getColorIfValid("#B38D22"); - COL_FFFF44 = set.getColorIfValid("#FFFF44"); - COL_038048 = set.getColorIfValid("#038048"); - COL_84BE84 = set.getColorIfValid("#84BE84"); - COL_DDDDDD = set.getColorIfValid("#DDDDDD"); - COL_EEEEEE = set.getColorIfValid("#EEEEEE"); - COL_FBFB77 = set.getColorIfValid("#FBFB77"); - COL_ADD1B2 = set.getColorIfValid("#ADD1B2"); - COL_A9DCDF = set.getColorIfValid("#A9DCDF"); - COL_E3664A = set.getColorIfValid("#E3664A"); - COL_EB937F = set.getColorIfValid("#EB937F"); - COL_B4A7E5 = set.getColorIfValid("#B4A7E5"); - COL_527BC6 = set.getColorIfValid("#527BC6"); - COL_D1DBEF = set.getColorIfValid("#D1DBEF"); - COL_D7E0F2 = set.getColorIfValid("#D7E0F2"); - COL_989898 = set.getColorIfValid("#989898"); - COL_BBBBBB = set.getColorIfValid("#BBBBBB"); + COL_C82930 = set.getColorOrWhite("#C82930"); + COL_F24D5C = set.getColorOrWhite("#F24D5C"); + COL_1963A0 = set.getColorOrWhite("#1963A0"); + COL_4177AF = set.getColorOrWhite("#4177AF"); + COL_B38D22 = set.getColorOrWhite("#B38D22"); + COL_FFFF44 = set.getColorOrWhite("#FFFF44"); + COL_038048 = set.getColorOrWhite("#038048"); + COL_84BE84 = set.getColorOrWhite("#84BE84"); + COL_DDDDDD = set.getColorOrWhite("#DDDDDD"); + COL_EEEEEE = set.getColorOrWhite("#EEEEEE"); + COL_FBFB77 = set.getColorOrWhite("#FBFB77"); + COL_ADD1B2 = set.getColorOrWhite("#ADD1B2"); + COL_A9DCDF = set.getColorOrWhite("#A9DCDF"); + COL_E3664A = set.getColorOrWhite("#E3664A"); + COL_EB937F = set.getColorOrWhite("#EB937F"); + COL_B4A7E5 = set.getColorOrWhite("#B4A7E5"); + COL_527BC6 = set.getColorOrWhite("#527BC6"); + COL_D1DBEF = set.getColorOrWhite("#D1DBEF"); + COL_D7E0F2 = set.getColorOrWhite("#D7E0F2"); + COL_989898 = set.getColorOrWhite("#989898"); + COL_BBBBBB = set.getColorOrWhite("#BBBBBB"); } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/HColorUserDef.java b/src/net/sourceforge/plantuml/ugraphic/color/NoSuchColorException.java similarity index 94% rename from src/net/sourceforge/plantuml/ugraphic/color/HColorUserDef.java rename to src/net/sourceforge/plantuml/ugraphic/color/NoSuchColorException.java index 3f1c563ae..a23671c67 100644 --- a/src/net/sourceforge/plantuml/ugraphic/color/HColorUserDef.java +++ b/src/net/sourceforge/plantuml/ugraphic/color/NoSuchColorException.java @@ -30,11 +30,11 @@ * * * Original Author: Arnaud Roques - * * + * */ package net.sourceforge.plantuml.ugraphic.color; -public class HColorUserDef extends HColorAbstract implements HColor { +public class NoSuchColorException extends Exception { } diff --git a/src/net/sourceforge/plantuml/ugraphic/color/NoSuchColorRuntimeException.java b/src/net/sourceforge/plantuml/ugraphic/color/NoSuchColorRuntimeException.java new file mode 100644 index 000000000..7d1a6be32 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/color/NoSuchColorRuntimeException.java @@ -0,0 +1,40 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.ugraphic.color; + +public class NoSuchColorRuntimeException extends RuntimeException { + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java index f84a061d0..03d4439cd 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java @@ -53,7 +53,7 @@ import net.sourceforge.plantuml.TikzFontDistortion; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontStyle; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.StyledString; +import net.sourceforge.plantuml.text.StyledString; import net.sourceforge.plantuml.ugraphic.UDriver; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UParam; diff --git a/src/net/sourceforge/plantuml/version/License.java b/src/net/sourceforge/plantuml/version/License.java index 5484a3f56..ca62fdcb7 100644 --- a/src/net/sourceforge/plantuml/version/License.java +++ b/src/net/sourceforge/plantuml/version/License.java @@ -40,6 +40,7 @@ import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.OptionFlags; +import net.sourceforge.plantuml.windowsdot.WindowsDotArchive; public enum License { @@ -521,6 +522,15 @@ public enum License { text.add("(more info on https://plantuml.com/statistics-report)"); } text.add(" "); + if (WindowsDotArchive.getInstance().isThereArchive()) { + text.add("This distribution bundles a minimal set of GraphViz files and may install them"); + text.add(" if needed in the local temporary directory."); + } else { + text.add("This is the IGY distribution (Install GraphViz by Yourself)."); + text.add("You have to install GraphViz and to setup the GRAPHVIZ_DOT environment variable"); + } + text.add("(see https://plantuml.com/graphviz-dot )"); + text.add(" "); text.add("Icons provided by OpenIconic : https://useiconic.com/open"); text.add("Archimate sprites provided by Archi : http://www.archimatetool.com"); text.add("Stdlib AWS provided by https://github.com/milo-minderbinder/AWS-PlantUML"); diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 809d1a4c9..0777873f7 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -44,7 +44,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202100; + return 1202101; } public static int versionPatched() { @@ -93,7 +93,7 @@ public class Version { } public static long compileTime() { - return 1610274305536L; + return 1612252508814L; } public static String compileTimeString() { diff --git a/src/net/sourceforge/plantuml/wbs/CommandWBSOrgmode.java b/src/net/sourceforge/plantuml/wbs/CommandWBSOrgmode.java index 9dbff9059..b58d64113 100644 --- a/src/net/sourceforge/plantuml/wbs/CommandWBSOrgmode.java +++ b/src/net/sourceforge/plantuml/wbs/CommandWBSOrgmode.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.mindmap.IdeaShape; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandWBSOrgmode extends SingleLineCommand2 { @@ -63,13 +64,13 @@ public class CommandWBSOrgmode extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(WBSDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(WBSDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String type = arg.get("TYPE", 0); final String label = arg.get("LABEL", 0); final String stringColor = arg.get("BACKCOLOR", 0); HColor backColor = null; if (stringColor != null) { - backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(stringColor); + backColor = diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor); } final String direction = arg.get("DIRECTION", 0); final Direction dir = "<".equals(direction) ? Direction.LEFT : Direction.RIGHT; diff --git a/src/net/sourceforge/plantuml/wbs/CommandWBSPlus.java b/src/net/sourceforge/plantuml/wbs/CommandWBSPlus.java index 73a31dc16..dd72aa237 100644 --- a/src/net/sourceforge/plantuml/wbs/CommandWBSPlus.java +++ b/src/net/sourceforge/plantuml/wbs/CommandWBSPlus.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.mindmap.IdeaShape; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandWBSPlus extends SingleLineCommand2 { @@ -63,14 +64,14 @@ public class CommandWBSPlus extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(WBSDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(WBSDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String type = arg.get("TYPE", 0); final String label = arg.get("LABEL", 0); final Direction dir = type.contains("-") ? Direction.LEFT : Direction.RIGHT; final String stringColor = arg.get("BACKCOLOR", 0); HColor backColor = null; if (stringColor != null) { - backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(stringColor); + backColor = diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor); } return diagram.addIdea(backColor, type.length() - 1, label, dir, IdeaShape.fromDesc(arg.get("SHAPE", 0))); } diff --git a/src/net/sourceforge/plantuml/wbs/CommandWBSTabulation.java b/src/net/sourceforge/plantuml/wbs/CommandWBSTabulation.java index 8ed061a4b..c326d370c 100644 --- a/src/net/sourceforge/plantuml/wbs/CommandWBSTabulation.java +++ b/src/net/sourceforge/plantuml/wbs/CommandWBSTabulation.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.mindmap.IdeaShape; import net.sourceforge.plantuml.ugraphic.color.HColor; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandWBSTabulation extends SingleLineCommand2 { @@ -63,14 +64,14 @@ public class CommandWBSTabulation extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(WBSDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(WBSDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String type = arg.get("TYPE", 0); final String label = arg.get("LABEL", 0); final Direction dir = type.contains("-") ? Direction.LEFT : Direction.RIGHT; final String stringColor = arg.get("BACKCOLOR", 0); HColor backColor = null; if (stringColor != null) { - backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(stringColor); + backColor = diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor); } return diagram.addIdea(backColor, type.length() - 1, label, dir, IdeaShape.fromDesc(arg.get("SHAPE", 0))); } diff --git a/src/net/sourceforge/plantuml/windowsdot/WindowsDotArchive.java b/src/net/sourceforge/plantuml/windowsdot/WindowsDotArchive.java index 7b60651a7..bf9975cfd 100644 --- a/src/net/sourceforge/plantuml/windowsdot/WindowsDotArchive.java +++ b/src/net/sourceforge/plantuml/windowsdot/WindowsDotArchive.java @@ -44,9 +44,25 @@ import java.io.OutputStream; import net.sourceforge.plantuml.brotli.BrotliInputStream; -public class WindowsDotArchive { +public final class WindowsDotArchive { - final public String readString(InputStream is) throws IOException { + private static WindowsDotArchive singleton = null; + + private Boolean isThereArchive; + private File exe; + + private WindowsDotArchive() { + + } + + public final synchronized static WindowsDotArchive getInstance() { + if (singleton == null) { + singleton = new WindowsDotArchive(); + } + return singleton; + } + + final static public String readString(InputStream is) throws IOException { int len = readByte(is); final StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { @@ -56,19 +72,19 @@ public class WindowsDotArchive { return sb.toString(); } - final public int readNumber(InputStream is) throws IOException { + final static public int readNumber(InputStream is) throws IOException { int result = readByte(is); result = result * 256 + readByte(is); result = result * 256 + readByte(is); return result; } - private int readByte(InputStream is) throws IOException { + private static int readByte(InputStream is) throws IOException { return is.read(); } - private void extract(File dir) throws IOException { - final InputStream raw = getClass().getResourceAsStream("graphviz.dat"); + private static void extract(File dir) throws IOException { + final InputStream raw = WindowsDotArchive.class.getResourceAsStream("graphviz.dat"); final BrotliInputStream is = new BrotliInputStream(raw); while (true) { @@ -85,11 +101,32 @@ public class WindowsDotArchive { is.close(); } - public File getWindowsExeLite() throws IOException { - final File tmp = new File(System.getProperty("java.io.tmpdir"), "_graphviz"); - tmp.mkdirs(); - extract(tmp); - return new File(tmp, "dot.exe"); + public synchronized boolean isThereArchive() { + if (isThereArchive == null) + try { + final InputStream raw = WindowsDotArchive.class.getResourceAsStream("graphviz.dat"); + isThereArchive = raw != null; + raw.close(); + } catch (Exception e) { + isThereArchive = false; + } + return isThereArchive; + } + + public synchronized File getWindowsExeLite() { + if (isThereArchive() == false) { + return null; + } + if (exe == null) + try { + final File tmp = new File(System.getProperty("java.io.tmpdir"), "_graphviz"); + tmp.mkdirs(); + extract(tmp); + exe = new File(tmp, "dot.exe"); + } catch (IOException e) { + e.printStackTrace(); + } + return exe; } } diff --git a/src/net/sourceforge/plantuml/wire/CommandComponent.java b/src/net/sourceforge/plantuml/wire/CommandComponent.java index 65ca8d28d..24fe4d429 100644 --- a/src/net/sourceforge/plantuml/wire/CommandComponent.java +++ b/src/net/sourceforge/plantuml/wire/CommandComponent.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandComponent extends SingleLineCommand2 { @@ -74,7 +75,7 @@ public class CommandComponent extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(WireDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(WireDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String indent = arg.get("INDENT", 0); final String name = arg.get("NAME", 0); @@ -90,7 +91,7 @@ public class CommandComponent extends SingleLineCommand2 { final String stringColor = arg.get("COLOR", 0); HColor color = null; if (stringColor != null) { - color = HColorSet.instance().getColorIfValid(stringColor); + color = HColorSet.instance().getColor(stringColor); } return diagram.addComponent(indent, name, width, height, color); diff --git a/src/net/sourceforge/plantuml/wire/CommandSpot.java b/src/net/sourceforge/plantuml/wire/CommandSpot.java index 446dec8d5..eeb613bf9 100644 --- a/src/net/sourceforge/plantuml/wire/CommandSpot.java +++ b/src/net/sourceforge/plantuml/wire/CommandSpot.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandSpot extends SingleLineCommand2 { @@ -77,13 +78,13 @@ public class CommandSpot extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(WireDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(WireDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String name = arg.get("NAME", 0); final String stringColor = arg.get("COLOR", 0); HColor color = null; if (stringColor != null) { - color = HColorSet.instance().getColorIfValid(stringColor); + color = HColorSet.instance().getColor(stringColor); } final String x = arg.get("X", 0); diff --git a/src/net/sourceforge/plantuml/wire/CommandWLink.java b/src/net/sourceforge/plantuml/wire/CommandWLink.java index 528e2211f..d5c9dc33a 100644 --- a/src/net/sourceforge/plantuml/wire/CommandWLink.java +++ b/src/net/sourceforge/plantuml/wire/CommandWLink.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; +import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; public class CommandWLink extends SingleLineCommand2 { @@ -81,7 +82,7 @@ public class CommandWLink extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(WireDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(WireDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { final String name1 = arg.get("NAME1", 0); final String x1 = arg.get("X1", 0); @@ -96,7 +97,7 @@ public class CommandWLink extends SingleLineCommand2 { final String stringColor = arg.get("COLOR", 0); HColor color = null; if (stringColor != null) { - color = HColorSet.instance().getColorIfValid(stringColor); + color = HColorSet.instance().getColor(stringColor); } final Display label; diff --git a/src/net/sourceforge/plantuml/yaml/SimpleYamlParser.java b/src/net/sourceforge/plantuml/yaml/SimpleYamlParser.java index e844baaf0..f9c630c32 100644 --- a/src/net/sourceforge/plantuml/yaml/SimpleYamlParser.java +++ b/src/net/sourceforge/plantuml/yaml/SimpleYamlParser.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.json.JsonValue; public class SimpleYamlParser { - private static final String KEY = "([_0-9\\w][- _0-9\\w]*)"; + private static final String KEY = "([_0-9\\w][- _0-9\\w./]*)"; private JsonObject result; private final List pendingIndents = new ArrayList();