Skip to content

Commit

Permalink
Adding contribution from Hisashi Miyashita for SysML v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed May 7, 2020
1 parent f2529b8 commit e9fb57c
Show file tree
Hide file tree
Showing 215 changed files with 4,945 additions and 1,867 deletions.
14 changes: 9 additions & 5 deletions src/net/sourceforge/plantuml/AnnotatedWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public TextBlock addFrame(final TextBlock original) {
final double y1 = 10;
final double y2 = 10;

final SymbolContext symbolContext = new SymbolContext(getSkinParam().getBackgroundColor(false), HColorUtils.BLACK)
final SymbolContext symbolContext = new SymbolContext(getBackgroundColor(), HColorUtils.BLACK)
.withShadow(getSkinParam().shadowing(null) ? 3 : 0);
final MinMax originalMinMax = TextBlockUtils.getMinMax(original, stringBounder, false);
final TextBlock title = mainFrame.create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null),
Expand Down Expand Up @@ -137,6 +137,10 @@ public HColor getBackcolor() {
};
}

private HColor getBackgroundColor() {
return getSkinParam().getBackgroundColor(false);
}

private TextBlock addLegend(TextBlock original) {
final DisplayPositionned legend = annotated.getLegend();
if (legend.isNull()) {
Expand Down Expand Up @@ -166,8 +170,8 @@ public TextBlock getCaption() {
return TextBlockUtils.empty(0, 0);
}
if (SkinParam.USE_STYLES()) {
final Style style = StyleSignature.of(SName.root, SName.caption).getMergedStyle(
skinParam.getCurrentStyleBuilder());
final Style style = StyleSignature.of(SName.root, SName.caption)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam);
}
return caption.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null),
Expand All @@ -182,8 +186,8 @@ private TextBlock addTitle(TextBlock original) {

final TextBlock block;
if (SkinParam.USE_STYLES()) {
final Style style = StyleSignature.of(SName.root, SName.title).getMergedStyle(
skinParam.getCurrentStyleBuilder());
final Style style = StyleSignature.of(SName.root, SName.title)
.getMergedStyle(skinParam.getCurrentStyleBuilder());
block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(), skinParam);
} else {
final ISkinParam skinParam = getSkinParam();
Expand Down
13 changes: 10 additions & 3 deletions src/net/sourceforge/plantuml/FileFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
Expand All @@ -58,7 +59,8 @@
*
*/
public enum FileFormat {
PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, SCXML, PDF, MJPEG, ANIMATED_GIF, HTML, HTML5, VDX, LATEX, LATEX_NO_PREAMBLE, BASE64, BRAILLE_PNG, PREPROC;
PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, SCXML, PDF, MJPEG, ANIMATED_GIF, HTML, HTML5,
VDX, LATEX, LATEX_NO_PREAMBLE, BASE64, BRAILLE_PNG, PREPROC;

/**
* Returns the file format to be used for that format.
Expand Down Expand Up @@ -89,6 +91,10 @@ public String getFileSuffix() {

final static private BufferedImage imDummy = new BufferedImage(800, 100, BufferedImage.TYPE_INT_RGB);
final static private Graphics2D gg = imDummy.createGraphics();
static {
// KEY_FRACTIONALMETRICS
gg.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}

public StringBounder getDefaultStringBounder(TikzFontDistortion tikzFontDistortion) {
if (this == LATEX || this == LATEX_NO_PREAMBLE) {
Expand Down Expand Up @@ -178,8 +184,8 @@ public String changeName(String fileName, int cpt) {
if (cpt == 0) {
return changeName(fileName, getFileSuffix());
}
return changeName(fileName, OptionFlags.getInstance().getFileSeparator() + String.format("%03d", cpt)
+ getFileSuffix());
return changeName(fileName,
OptionFlags.getInstance().getFileSeparator() + String.format("%03d", cpt) + getFileSuffix());
}

private File computeFilename(File pngFile, int i) {
Expand Down Expand Up @@ -233,4 +239,5 @@ public boolean equalsMetadata(String currentMetadata, File existingFile) {
}
return false;
}

}
7 changes: 4 additions & 3 deletions src/net/sourceforge/plantuml/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.code.NoPlantumlCompressionException;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
Expand All @@ -78,7 +79,7 @@ public class Run {

private static Cypher cypher;

public static void main(String[] argsArray) throws IOException, InterruptedException {
public static void main(String[] argsArray) throws NoPlantumlCompressionException, IOException, InterruptedException {
System.setProperty("log4j.debug", "false");
final long start = System.currentTimeMillis();
if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) {
Expand Down Expand Up @@ -358,7 +359,7 @@ private static void managePipe(Option option, ErrorStatus error) throws IOExcept
new Pipe(option, System.out, System.in, charset).managePipe(error);
}

private static void manageAllFiles(Option option, ErrorStatus error) throws IOException, InterruptedException {
private static void manageAllFiles(Option option, ErrorStatus error) throws NoPlantumlCompressionException, InterruptedException {

File lockFile = null;
try {
Expand All @@ -377,7 +378,7 @@ private static void manageAllFiles(Option option, ErrorStatus error) throws IOEx

}

private static void processArgs(Option option, ErrorStatus error) throws IOException, InterruptedException {
private static void processArgs(Option option, ErrorStatus error) throws NoPlantumlCompressionException, InterruptedException {
if (option.isDecodeurl() == false && option.getNbThreads() > 1 && option.isCheckOnly() == false
&& OptionFlags.getInstance().isExtractFromMetadata() == false) {
multithread(option, error);
Expand Down
11 changes: 10 additions & 1 deletion src/net/sourceforge/plantuml/SkinParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ static public boolean USE_STYLES() {
return result;
}

static public void setBetaStyle(boolean betastyle) {
USE_STYLE2.set(betastyle);
}

public static int zeroMargin(int defaultValue) {
return defaultValue;
}

private static final String stereoPatternString = "\\<\\<(.*?)\\>\\>";
private static final Pattern2 stereoPattern = MyPattern.cmpile(stereoPatternString);

Expand All @@ -176,7 +184,8 @@ public void setParam(String key, String value) {
for (String key2 : cleanForKey(key)) {
params.put(key2, StringUtils.trin(value));
if (key2.startsWith("usebetastyle")) {
USE_STYLE2.set("true".equalsIgnoreCase(value));
final boolean betastyle = "true".equalsIgnoreCase(value);
setBetaStyle(betastyle);
}
if (USE_STYLES()) {
final FromSkinparamToStyle convertor = new FromSkinparamToStyle(key2, value, getCurrentStyleBuilder());
Expand Down
21 changes: 12 additions & 9 deletions src/net/sourceforge/plantuml/SourceStringReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ public class SourceStringReader {
final private List<BlockUml> blocks;

public SourceStringReader(String source) {
this(Defines.createEmpty(), source, Collections.<String> emptyList());
this(Defines.createEmpty(), source, Collections.<String>emptyList());
}

public SourceStringReader(String source, String charset) {
this(Defines.createEmpty(), source, "UTF-8", Collections.<String> emptyList());
this(Defines.createEmpty(), source, "UTF-8", Collections.<String>emptyList());
}

public SourceStringReader(Defines defines, String source, List<String> config) {
this(defines, source, "UTF-8", config);
}

public SourceStringReader(Defines defines, String source) {
this(defines, source, "UTF-8", Collections.<String> emptyList());
this(defines, source, "UTF-8", Collections.<String>emptyList());
}

public SourceStringReader(String source, File newCurrentDir) {
this(Defines.createEmpty(), source, "UTF-8", Collections.<String> emptyList(), newCurrentDir);
this(Defines.createEmpty(), source, "UTF-8", Collections.<String>emptyList(), newCurrentDir);
}

public SourceStringReader(Defines defines, String source, String charset, List<String> config) {
Expand Down Expand Up @@ -157,7 +157,8 @@ public DiagramDescription outputImage(OutputStream os, int numImage, FileFormatO
// final CMapData cmap = new CMapData();
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
// if (imageData.containsCMapData()) {
// return system.getDescription().getDescription() + BackSlash.BS_N + imageData.getCMapData("plantuml");
// return system.getDescription().getDescription() + BackSlash.BS_N +
// imageData.getCMapData("plantuml");
// }
return system.getDescription();
}
Expand All @@ -176,9 +177,11 @@ public DiagramDescription generateDiagramDescription(int numImage, FileFormatOpt
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
if (numImage < nbInSystem) {
// final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
// final ImageData imageData = system.exportDiagram(os, numImage,
// fileFormatOption);
// if (imageData.containsCMapData()) {
// return system.getDescription().withCMapData(imageData.getCMapData("plantuml"));
// return
// system.getDescription().withCMapData(imageData.getCMapData("plantuml"));
// }
return system.getDescription();
}
Expand Down Expand Up @@ -223,8 +226,8 @@ public String getCMapData(int numImage, FileFormatOption fileFormatOption) throw
private void noStartumlFound(OutputStream os, FileFormatOption fileFormatOption, long seed) throws IOException {
final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList("No @startuml/@enduml found"),
fileFormatOption.isUseRedForError());
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null,
null, 0, 0, null, false);
final ImageBuilder imageBuilder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null, null, null,
1.0, error.getBackcolor());
imageBuilder.setUDrawable(error);
imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
}
Expand Down
4 changes: 4 additions & 0 deletions src/net/sourceforge/plantuml/StringLocated.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public StringLocated getTrimmed() {
return trimmed;
}

// public StringLocated getTrimmedRight() {
// return new StringLocated(StringUtils.trinEnding(this.getString()), location, preprocessorError);
// }

public StringLocated removeInnerComment() {
final String string = s.toString();
final String trim = string.replace('\t', ' ').trim();
Expand Down
21 changes: 18 additions & 3 deletions src/net/sourceforge/plantuml/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,18 +456,33 @@ public static String trin(String arg) {
if (arg.length() == 0) {
return arg;
}
return trinEndingInternal(arg, getPositionStartNonSpace(arg));
}

private static int getPositionStartNonSpace(String arg) {
int i = 0;
while (i < arg.length() && isSpaceOrTabOrNull(arg.charAt(i))) {
i++;
}
return i;
}

private static String trinEnding(String arg) {
if (arg.length() == 0) {
return arg;
}
return trinEndingInternal(arg, 0);
}

private static String trinEndingInternal(String arg, int from) {
int j = arg.length() - 1;
while (j >= i && isSpaceOrTabOrNull(arg.charAt(j))) {
while (j >= from && isSpaceOrTabOrNull(arg.charAt(j))) {
j--;
}
if (i == 0 && j == arg.length() - 1) {
if (from == 0 && j == arg.length() - 1) {
return arg;
}
return arg.substring(i, j + 1);
return arg.substring(from, j + 1);
}

private static boolean isSpaceOrTabOrNull(char c) {
Expand Down
7 changes: 5 additions & 2 deletions src/net/sourceforge/plantuml/UmlDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ final protected ImageData exportDiagramNow(OutputStream os, int index, FileForma
} catch (Exception e) {
e.printStackTrace();
exportDiagramError(os, e, fileFormatOption, seed, null);
} catch (Error e) {
e.printStackTrace();
exportDiagramError(os, e, fileFormatOption, seed, null);
}
return ImageDataSimple.error();
}
Expand All @@ -227,8 +230,8 @@ public static void exportDiagramError(OutputStream os, Throwable exception, File

strings.addAll(CommandExecutionResult.getStackTrace(exception));

final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HColorUtils.WHITE, metadata,
null, 0, 0, null, false);
final ImageBuilder imageBuilder = ImageBuilder.buildA(new ColorMapperIdentity(), false,
null, metadata, null, 1.0, HColorUtils.WHITE);

final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage im = utils.exportFlashcode(flash, Color.BLACK, Color.WHITE);
Expand Down
36 changes: 35 additions & 1 deletion src/net/sourceforge/plantuml/UmlDiagramType.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,40 @@
*/
package net.sourceforge.plantuml;

import net.sourceforge.plantuml.style.SName;

public enum UmlDiagramType {
SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG, MINDMAP, WBS, WIRE, HELP
SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG, MINDMAP, WBS, WIRE,
HELP;

public SName getStyleName() {
if (this == SEQUENCE) {
return SName.sequenceDiagram;
}
if (this == STATE) {
return SName.stateDiagram;
}
if (this == CLASS) {
return SName.classDiagram;
}
if (this == OBJECT) {
return SName.objectDiagram;
}
if (this == ACTIVITY) {
return SName.activityDiagram;
}
if (this == DESCRIPTION) {
return SName.componentDiagram;
}
if (this == COMPOSITE) {
return SName.componentDiagram;
}
if (this == MINDMAP) {
return SName.mindmapDiagram;
}
if (this == WBS) {
return SName.wbsDiagram;
}
return SName.activityDiagram;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ static IRegex getRegexConcat() {

@Override
protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) {
lines = lines.trim(false);
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString());
lines = lines.trim();
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());

final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
if (entity1 == null) {
Expand Down Expand Up @@ -157,7 +157,7 @@ protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocL
}
}

final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast499()
final List<String> 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) {
Expand Down
Loading

0 comments on commit e9fb57c

Please sign in to comment.