Skip to content

Commit

Permalink
Import version 1.2021.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Feb 2, 2021
1 parent 55f005f commit 0dc13cc
Show file tree
Hide file tree
Showing 238 changed files with 1,499 additions and 834 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2021.1-SNAPSHOT</version>
<version>1.2021.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>PlantUML</name>
Expand Down
9 changes: 7 additions & 2 deletions src/jcckit/util/ConfigParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;


/**
Expand Down Expand Up @@ -302,8 +303,12 @@ private Color parseColor(String value, String key) {

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);
}
Expand Down
7 changes: 6 additions & 1 deletion src/net/sourceforge/plantuml/AbstractPSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
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;

Expand Down Expand Up @@ -126,7 +127,11 @@ public boolean isOk() {

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() {
Expand Down
2 changes: 2 additions & 0 deletions src/net/sourceforge/plantuml/ColorParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/CornerParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/net/sourceforge/plantuml/EmbeddedDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ public static String getEmbeddedType(CharSequence s) {
if (s.equals("{{json")) {
return "json";
}
if (s.equals("{{yaml")) {
return "yaml";
}
if (s.equals("{{wire")) {
return "wire";
}
return null;
}

Expand Down
9 changes: 7 additions & 2 deletions src/net/sourceforge/plantuml/ErrorUml.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 13 additions & 24 deletions src/net/sourceforge/plantuml/FileFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@

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;
Expand Down Expand Up @@ -116,12 +115,12 @@ public StringBounder getDefaultStringBounder(TikzFontDistortion tikzFontDistorti
}

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);
}
Expand All @@ -130,44 +129,34 @@ public Dimension2D calculateDimension(UFont font, String text) {
}

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);
}

};
}

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;
Expand All @@ -178,13 +167,13 @@ public Dimension2D calculateDimension(UFont font, String text) {
}

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);
Expand Down
19 changes: 11 additions & 8 deletions src/net/sourceforge/plantuml/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FileSystem {

private final static FileSystem singleton = new FileSystem();

private final ThreadLocal<SFile> currentDir = new ThreadLocal<SFile>();
private ThreadLocal<String> currentDir = new ThreadLocal<String>();

private FileSystem() {
reset();
Expand All @@ -55,24 +55,27 @@ public static FileSystem getInstance() {
}

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);
Expand Down
4 changes: 4 additions & 0 deletions src/net/sourceforge/plantuml/FontParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -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), //
Expand Down Expand Up @@ -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), //
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/GeneratedImageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public GeneratedImageImpl(SFile pngFile, String description, BlockUml blockUml,
}

public File getPngFile() {
return pngFile.internal;
return pngFile.conv();
}

public String getDescription() {
Expand Down
3 changes: 2 additions & 1 deletion src/net/sourceforge/plantuml/ISkinParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
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 {

Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/net/sourceforge/plantuml/LineParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public enum LineParam {
titleBorder,
diagramBorder,
rectangleBorder,
hexagonBorder,
archimateBorder,
componentBorder,
cardBorder,
Expand Down
33 changes: 19 additions & 14 deletions src/net/sourceforge/plantuml/NewpagedDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
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 {

Expand Down Expand Up @@ -74,22 +75,26 @@ public Diagram getLastDiagram() {

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() {
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/PSystemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final public Diagram createPSystem(ISkinSimple skinParam, List<StringLocated> so
// 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.<String>emptyList(), source);
}
Expand Down
Loading

0 comments on commit 0dc13cc

Please sign in to comment.