Skip to content

Commit

Permalink
feat: work on chronology
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Dec 11, 2023
1 parent d7727c5 commit c20b3d9
Show file tree
Hide file tree
Showing 192 changed files with 2,806 additions and 611 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Warning, "version" should be the same in gradle.properties and Version.java
# Any idea anyone how to magically synchronize those :-) ?
version = 1.2023.13beta3
version = 1.2023.13beta4
org.gradle.workers.max = 3
3 changes: 2 additions & 1 deletion src/com/plantuml/api/cheerpj/v1/DirectDraw.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import net.sourceforge.plantuml.BlockUmlBuilder;
import net.sourceforge.plantuml.ErrorUml;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.error.PSystemError;
import net.sourceforge.plantuml.klimt.color.ColorMapper;
Expand Down Expand Up @@ -122,7 +123,7 @@ public static Object draw(String mode, String text) {
ug.apply(back).apply(back.bg()).draw(URectangle.build(frameWidth, frameHeight));
WasmLog.log("...drawing...");

system.exportDiagramGraphic(ug);
system.exportDiagramGraphic(ug, new FileFormatOption(FileFormat.PNG));

WasmLog.log("done!");

Expand Down
5 changes: 3 additions & 2 deletions src/com/plantuml/api/cheerpj/v1/Raw.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.ErrorUml;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
Expand Down Expand Up @@ -124,7 +125,7 @@ public static Object convertToBlob(String mode, String text, String pathOut) {
ug.resetMax();
WasmLog.log("...drawing...");

system.exportDiagramGraphic(ug);
system.exportDiagramGraphic(ug, new FileFormatOption(FileFormat.PNG));

final int width = (int) (2 + ug.getMaxX());
final int height = (int) (2 + ug.getMaxY());
Expand Down Expand Up @@ -208,7 +209,7 @@ public static Object convert(String mode, String text) {
ug.resetMax();
WasmLog.log("...drawing...");

system.exportDiagramGraphic(ug);
system.exportDiagramGraphic(ug, new FileFormatOption(FileFormat.PNG));

final int width = (int) (2 + ug.getMaxX());
final int height = (int) (2 + ug.getMaxY());
Expand Down
4 changes: 2 additions & 2 deletions src/net/atmp/CucaDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,13 @@ private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) t
// ::done

@Override
final public void exportDiagramGraphic(UGraphic ug) {
final public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) {
final CucaDiagramFileMaker maker = new CucaDiagramFileMakerSmetana(this, ug.getStringBounder());
maker.createOneGraphic(ug);
}

@Override
final protected TextBlock getTextBlock() {
final protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) {
throw new UnsupportedOperationException();
}

Expand Down
18 changes: 9 additions & 9 deletions src/net/sourceforge/plantuml/AbstractPSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ private String getVersion() {
}

final public String getMetadata() {
if (source == null)
if (source == null)
return getVersion();

final String rawString = source.getRawString("\n");
final String plainString = source.getPlainString("\n");
if (rawString != null && rawString.equals(plainString))
if (rawString != null && rawString.equals(plainString))
return rawString + BackSlash.NEWLINE + getVersion();

return rawString + BackSlash.NEWLINE + plainString + BackSlash.NEWLINE + getVersion();
}

Expand All @@ -130,9 +130,9 @@ final public UmlSource getSource() {
}

final public long seed() {
if (source == null)
if (source == null)
return 42;

return getSource().seed();
}

Expand All @@ -159,9 +159,9 @@ public void setSplitPagesVertical(int splitPagesVertical) {
}

public DisplayPositionned getTitle() {
if (source == null)
if (source == null)
return DisplayPositioned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);

return DisplayPositioned.single(source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
}

Expand Down Expand Up @@ -247,7 +247,7 @@ public Display getTitleDisplay() {
}

@Override
public void exportDiagramGraphic(UGraphic ug) {
public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) {
final UFont font = UFont.monospaced(14);
final FontConfiguration fc = FontConfiguration.blackBlueTrue(font);
final UText text = UText.build("Not implemented yet for " + getClass().getName(), fc);
Expand Down
2 changes: 2 additions & 0 deletions src/net/sourceforge/plantuml/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,11 @@ else if (nb.matches("\\d+"))

} else if (s.equalsIgnoreCase("-preproc")) {
preprocessorOutput = OptionPreprocOutputMode.NORMAL;
setFileFormatOption(new FileFormatOption(FileFormat.PREPROC));

} else if (s.equalsIgnoreCase("-cypher")) {
preprocessorOutput = OptionPreprocOutputMode.CYPHER;
setFileFormatOption(new FileFormatOption(FileFormat.PREPROC));

} else if (s.equalsIgnoreCase("-checkmetadata")) {
checkMetadata = true;
Expand Down
8 changes: 6 additions & 2 deletions src/net/sourceforge/plantuml/PSystemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import net.sourceforge.plantuml.api.PSystemFactory;
import net.sourceforge.plantuml.board.BoardDiagramFactory;
import net.sourceforge.plantuml.bpm.BpmDiagramFactory;
import net.sourceforge.plantuml.chronology.ChronologyDiagramFactory;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
Expand Down Expand Up @@ -223,7 +224,8 @@ final public Diagram createPSystem(List<StringLocated> source, List<StringLocate
// factories.add(new PSystemSudokuFactory());
// ::done

// ::comment when __CORE__ or __MIT__ or __EPL__ or __BSD__ or __ASL__ or __LGPL__
// ::comment when __CORE__ or __MIT__ or __EPL__ or __BSD__ or __ASL__ or
// __LGPL__
factories.add(new PSystemJcckitFactory());
factories.add(new PSystemSudokuFactory());
// ::done
Expand All @@ -247,11 +249,13 @@ final public Diagram createPSystem(List<StringLocated> source, List<StringLocate
// ::done

factories.add(new PSystemCharlieFactory());
// ::comment when __CORE__ or __MIT__ or __EPL__ or __BSD__ or __ASL__ or __LGPL__
// ::comment when __CORE__ or __MIT__ or __EPL__ or __BSD__ or __ASL__ or
// __LGPL__
factories.add(new PSystemXearthFactory());
// ::done

factories.add(new GanttDiagramFactory());
factories.add(new ChronologyDiagramFactory());
factories.add(new FlowDiagramFactory());

// ::comment when __CORE__
Expand Down
7 changes: 3 additions & 4 deletions src/net/sourceforge/plantuml/PlainDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,13 @@ protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOptio
}

@Override
public void exportDiagramGraphic(UGraphic ug) {
final FileFormatOption option = new FileFormatOption(FileFormat.PNG);
public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) {
try {
final UDrawable rootDrawable = getRootDrawable(option);
final UDrawable rootDrawable = getRootDrawable(fileFormatOption);
rootDrawable.drawU(ug);
} catch (IOException e) {
e.printStackTrace();
super.exportDiagramGraphic(ug);
super.exportDiagramGraphic(ug, fileFormatOption);
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/net/sourceforge/plantuml/SourceStringReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import net.sourceforge.plantuml.klimt.shape.TextBlock;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.text.StringLocated;
import net.sourceforge.plantuml.utils.Log;

public class SourceStringReader {
Expand Down Expand Up @@ -157,6 +158,14 @@ public DiagramDescription outputImage(OutputStream os, int numImage, FileFormatO
noValidStartFound(os, fileFormatOption);
return null;
}
if (fileFormatOption.getFileFormat() == FileFormat.PREPROC) {
final BlockUml first = blocks.get(0);
for (StringLocated s : first.getData()) {
os.write(s.getString().getBytes(UTF_8));
os.write("\n".getBytes(UTF_8));
}
return new DiagramDescription("PREPROC");
}
for (BlockUml b : blocks) {
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
Expand Down Expand Up @@ -231,7 +240,8 @@ public String getCMapData(int numImage, FileFormatOption fileFormatOption) throw
}

public ImageData noValidStartFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
final TextBlock error = GraphicStrings.createForError(Arrays.asList("No valid @start/@end found, please check the version"),
final TextBlock error = GraphicStrings.createForError(
Arrays.asList("No valid @start/@end found, please check the version"),
fileFormatOption.isUseRedForError());

return plainImageBuilder(error, fileFormatOption).write(os);
Expand Down
6 changes: 3 additions & 3 deletions src/net/sourceforge/plantuml/TitledDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ protected ColorMapper muteColorMapper(ColorMapper init) {

}

protected abstract TextBlock getTextBlock();
protected abstract TextBlock getTextMainBlock(FileFormatOption fileFormatOption);

@Override
public void exportDiagramGraphic(UGraphic ug) {
final TextBlock textBlock = getTextBlock();
public void exportDiagramGraphic(UGraphic ug, FileFormatOption fileFormatOption) {
final TextBlock textBlock = getTextMainBlock(fileFormatOption);
textBlock.drawU(ug);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import net.sourceforge.plantuml.regex.RegexPartialMatch;
import net.sourceforge.plantuml.regex.RegexResult;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.stereo.StereotypePattern;
import net.sourceforge.plantuml.url.Url;
import net.sourceforge.plantuml.url.UrlBuilder;
import net.sourceforge.plantuml.url.UrlMode;
Expand All @@ -81,9 +82,7 @@ private static IRegex getRegexConcat() {
new RegexLeaf("CODE", "([%pLN][%pLN_.]*)"), //
new RegexLeaf("BAR", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN_.]+))?"))), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
StereotypePattern.optional("STEREOTYPE"), //
ColorParser.exp2(), //
RegexLeaf.spaceZeroOrMore(), //
UrlBuilder.OPTIONAL, //
Expand All @@ -105,9 +104,7 @@ private static IRegex getRegexConcat() {
new RegexLeaf("BAR2", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED2", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN][%pLN_.]*))?"), //
new RegexLeaf("QUOTED_INVISIBLE2", "(\\w.*?)")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
StereotypePattern.optional("STEREOTYPE2"), //
new RegexOptional( //
new RegexConcat( //
new RegexLeaf("in"), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import net.sourceforge.plantuml.regex.RegexOr;
import net.sourceforge.plantuml.regex.RegexResult;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.stereo.StereotypePattern;
import net.sourceforge.plantuml.text.BackSlash;
import net.sourceforge.plantuml.text.StringLocated;
import net.sourceforge.plantuml.url.Url;
Expand Down Expand Up @@ -91,9 +92,7 @@ static IRegex getRegexConcat() {
new RegexLeaf("CODE", "([%pLN][%pLN_.]*)"), //
new RegexLeaf("BAR", "(?:==+)[%s]*([%pLN_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([%pLN_.]+))?"))), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
StereotypePattern.optional("STEREOTYPE"), //
new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
RegexLeaf.spaceZeroOrMore(), //
UrlBuilder.OPTIONAL, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import net.sourceforge.plantuml.regex.RegexOr;
import net.sourceforge.plantuml.regex.RegexResult;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.stereo.StereotypePattern;
import net.sourceforge.plantuml.utils.LineLocation;

public class CommandPartition extends SingleLineCommand2<ActivityDiagram> {
Expand All @@ -69,9 +70,7 @@ private static IRegex getRegexConcat() {
new RegexOr(//
color().getRegex(), //
new RegexLeaf("LEGACYCOLORIGNORED", "(#[0-9a-fA-F]{6}|#?\\w+)?")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
StereotypePattern.optional("STEREOTYPE"), //
new RegexLeaf("\\{?"), //
RegexLeaf.end());
}
Expand All @@ -89,12 +88,10 @@ protected CommandExecutionResult executeArg(ActivityDiagram diagram, LineLocatio
final Entity p = diagram.getCurrentGroup();

final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
if (colors.isEmpty() == false) {
if (colors.isEmpty() == false)
p.setColors(colors);
}
if (arg.get("STEREOTYPE", 0) != null) {
p.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0)));
}

p.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0)));

return CommandExecutionResult.ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import java.util.Map;
import java.util.Objects;

import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
Expand Down Expand Up @@ -208,8 +207,7 @@ protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormat
}

@Override
protected TextBlock getTextBlock() {
final FileFormatOption fileFormatOption = new FileFormatOption(FileFormat.PNG);
protected TextBlock getTextMainBlock(FileFormatOption fileFormatOption) {
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
return getTextBlock(stringBounder);
}
Expand Down Expand Up @@ -318,10 +316,10 @@ public CommandExecutionResult endSwitch() {
return CommandExecutionResult.error("Cannot find switch");
}

public void startIf(Display test, Display whenThen, HColor color, Url url) {
public void startIf(Display test, Display whenThen, HColor color, Url url, Stereotype stereotype) {
manageSwimlaneStrategy();
final InstructionIf instructionIf = new InstructionIf(swinlanes.getCurrentSwimlane(), current(), test,
LinkRendering.none().withDisplay(whenThen), nextLinkRenderer(), color, getSkinParam(), url);
LinkRendering.none().withDisplay(whenThen), nextLinkRenderer(), color, getSkinParam(), url, stereotype);
current().add(instructionIf);
setNextLinkRendererInternal(LinkRendering.none());
setCurrent(instructionIf);
Expand Down Expand Up @@ -392,7 +390,8 @@ public CommandExecutionResult backward(Display label, BoxStyle boxStyle, LinkRen
manageSwimlaneStrategy();
if (current() instanceof InstructionRepeat) {
final InstructionRepeat instructionRepeat = (InstructionRepeat) current();
instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming1, incoming2, stereotype);
instructionRepeat.setBackward(label, swinlanes.getCurrentSwimlane(), boxStyle, incoming1, incoming2,
stereotype);
return CommandExecutionResult.ok();
}
if (current() instanceof InstructionWhile) {
Expand Down
5 changes: 3 additions & 2 deletions src/net/sourceforge/plantuml/activitydiagram3/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import net.sourceforge.plantuml.klimt.shape.TextBlockUtils;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.sequencediagram.NoteType;
import net.sourceforge.plantuml.stereo.Stereotype;
import net.sourceforge.plantuml.style.ISkinParam;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
Expand Down Expand Up @@ -95,12 +96,12 @@ public boolean containsBreak() {
}

public Branch(StyleBuilder styleBuilder, Swimlane swimlane, LinkRendering labelPositive, Display labelTest,
HColor color, LinkRendering inlabel) {
HColor color, LinkRendering inlabel, Stereotype stereotype) {
this.inlabel = Objects.requireNonNull(inlabel);
this.labelTest = Objects.requireNonNull(labelTest);
this.labelPositive = Objects.requireNonNull(labelPositive);

final Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(styleBuilder);
final Style style = getDefaultStyleDefinitionDiamond().withTOBECHANGED(stereotype).getMergedStyle(styleBuilder);
this.color = color == null
? style.value(PName.BackGroundColor).asColor(styleBuilder.getSkinParam().getIHtmlColorSet())
: color;
Expand Down
Loading

0 comments on commit c20b3d9

Please sign in to comment.