From 780e31ed7790d734268dab86db75d3227b357616 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Thu, 20 Oct 2022 18:58:12 +0200 Subject: [PATCH] wip --- .../sourceforge/plantuml/PSystemBuilder.java | 2 +- .../plantuml/command/regex/RegexComposed.java | 15 +++---- .../plantuml/command/regex/RegexConcat.java | 19 ++++---- .../plantuml/command/regex/RegexLeaf.java | 44 +++++++++---------- .../plantuml/project/lang/SentenceSimple.java | 11 +++-- .../CommandChangeStateByPlayerCode.java | 7 +-- .../command/CommandChangeStateByTime.java | 7 +-- .../timingdiagram/graphic/Ribbon.java | 3 ++ .../sourceforge/plantuml/version/Version.java | 2 +- 9 files changed, 54 insertions(+), 56 deletions(-) diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 15fab4dd5..63280653e 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -212,7 +212,7 @@ public class PSystemBuilder { factories.add(new PSystemXearthFactory()); } factories.add(new GanttDiagramFactory(DiagramType.GANTT)); - factories.add(new GanttDiagramFactory(DiagramType.UML)); + // factories.add(new GanttDiagramFactory(DiagramType.UML)); GanttDiagramFactory.clearCache(); factories.add(new FlowDiagramFactory()); // factories.add(new PSystemTreeFactory(DiagramType.JUNGLE)); diff --git a/src/net/sourceforge/plantuml/command/regex/RegexComposed.java b/src/net/sourceforge/plantuml/command/regex/RegexComposed.java index 2d0fa31b7..02944446b 100644 --- a/src/net/sourceforge/plantuml/command/regex/RegexComposed.java +++ b/src/net/sourceforge/plantuml/command/regex/RegexComposed.java @@ -80,17 +80,17 @@ public abstract class RegexComposed implements IRegex { public Map createPartialMatch(Iterator it) { nbCreateMatches.incrementAndGet(); final Map result = new HashMap(); - for (IRegex r : partials) { + for (IRegex r : partials) result.putAll(r.createPartialMatch(it)); - } + return result; } final public int count() { int cpt = getStartCount(); - for (IRegex r : partials) { + for (IRegex r : partials) cpt += r.count(); - } + return cpt; } @@ -100,9 +100,8 @@ public abstract class RegexComposed implements IRegex { public RegexResult matcher(String s) { final Matcher2 matcher = getPattern2().matcher(s); - if (matcher.find() == false) { + if (matcher.find() == false) return null; - } final Iterator it = new MatcherIterator(matcher); return new RegexResult(createPartialMatch(it)); @@ -111,9 +110,9 @@ public abstract class RegexComposed implements IRegex { public boolean match(StringLocated s) { final String tmp = s.getString(); final Matcher2 matcher = getPattern2().matcher(tmp); - if (matcher == null) { + if (matcher == null) return false; - } + return matcher.find(); } diff --git a/src/net/sourceforge/plantuml/command/regex/RegexConcat.java b/src/net/sourceforge/plantuml/command/regex/RegexConcat.java index d063f9ca8..9863437a0 100644 --- a/src/net/sourceforge/plantuml/command/regex/RegexConcat.java +++ b/src/net/sourceforge/plantuml/command/regex/RegexConcat.java @@ -54,12 +54,12 @@ public final class RegexConcat extends RegexComposed implements IRegex { int nbCompiled = 0; int nbInvoked = 0; for (RegexConcat reg : cache.values()) { - if (reg.isCompiled()) { + if (reg.isCompiled()) nbCompiled++; - } - if (reg.invoked()) { + + if (reg.invoked()) nbInvoked++; - } + } Log.info("Regex total/invoked/compiled " + cache.size() + "/" + nbInvoked + "/" + nbCompiled); Log.info("Matches created " + nbCreateMatches.get()); @@ -115,9 +115,9 @@ public final class RegexConcat extends RegexComposed implements IRegex { @Override public boolean match(StringLocated s) { - if (limitSize != 0 && s.getString().length() > limitSize) { + if (limitSize != 0 && s.getString().length() > limitSize) return false; - } + final long foxRegex = foxRegex(); if (foxRegex != 0L) { final long foxLine = s.getFoxSignature(); @@ -125,9 +125,8 @@ public final class RegexConcat extends RegexComposed implements IRegex { // System.err.println("r=" + getFullSlow() + " s=" + s + " line=" + foxLine + " // regex" + foxRegex + " " // + check + " <" + FoxSignature.backToString(check) + ">"); - if (check != foxRegex) { + if (check != foxRegex) return false; - } } return super.match(s); @@ -136,9 +135,9 @@ public final class RegexConcat extends RegexComposed implements IRegex { @Override protected String getFullSlow() { final StringBuilder sb = new StringBuilder(); - for (IRegex p : partials()) { + for (IRegex p : partials()) sb.append(p.getPattern()); - } + return sb.toString(); } diff --git a/src/net/sourceforge/plantuml/command/regex/RegexLeaf.java b/src/net/sourceforge/plantuml/command/regex/RegexLeaf.java index 887148f60..5126fcc0d 100644 --- a/src/net/sourceforge/plantuml/command/regex/RegexLeaf.java +++ b/src/net/sourceforge/plantuml/command/regex/RegexLeaf.java @@ -143,40 +143,36 @@ public class RegexLeaf implements IRegex { } public long getFoxSignature() { - if (p1.matcher(pattern).matches()) { + if (p1.matcher(pattern).matches()) return FoxSignature.getFoxSignature(pattern); - } - if (p2.matcher(pattern).matches()) { + + if (p2.matcher(pattern).matches()) return FoxSignature.getFoxSignature(pattern.substring(0, pattern.length() - 2)); - } - if (p3.matcher(pattern).matches()) { - // System.err.println("special " + pattern); - // System.err.println("result " + - // FoxSignature.backToString(getSignatureP3(pattern))); + + if (p3.matcher(pattern).matches()) return getSignatureP3(pattern); - } - if (pattern.length() == 2 && pattern.startsWith("\\") - && Character.isLetterOrDigit(pattern.charAt(1)) == false) { + + if (pattern.length() == 2 && pattern.startsWith("\\") && Character.isLetterOrDigit(pattern.charAt(1)) == false) return FoxSignature.getFoxSignature(pattern.substring(1)); - } - if (pattern.equals("\\<\\>") || pattern.equals("(\\<\\<.*\\>\\>)")) { + + if (pattern.equals("\\<\\>") || pattern.equals("(\\<\\<.*\\>\\>)")) return FoxSignature.getFoxSignature("<>"); - } - if (pattern.equals("\\<-\\>")) { + + if (pattern.equals("\\<-\\>")) return FoxSignature.getFoxSignature("<->"); - } - if (pattern.equals("(-+)")) { + + if (pattern.equals("(-+)")) return FoxSignature.getFoxSignature("-"); - } - if (pattern.equals("\\|+") || pattern.equals("\\|\\|")) { + + if (pattern.equals("\\|+") || pattern.equals("\\|\\|")) return FoxSignature.getFoxSignature("|"); - } - if (pattern.equals("([*]+)")) { + + if (pattern.equals("([*]+)")) return FoxSignature.getFoxSignature("*"); - } - if (pattern.equals("[%s]+") || pattern.equals("[%s]*")) { + + if (pattern.equals("[%s]+") || pattern.equals("[%s]*")) return 0; - } + // synchronized (UNKNOWN) { // final boolean changed = UNKNOWN.add(pattern); // if (changed) diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java b/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java index 07bf1d6f4..100e171c0 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceSimple.java @@ -56,7 +56,7 @@ public abstract class SentenceSimple implements Sentence { } public final IRegex toRegex() { - if (complementii instanceof ComplementEmpty) { + if (complementii instanceof ComplementEmpty) return new RegexConcat(// RegexLeaf.start(), // subjectii.toRegex(), // @@ -64,7 +64,6 @@ public abstract class SentenceSimple implements Sentence { verb, // RegexLeaf.end()); - } return new RegexConcat(// RegexLeaf.start(), // subjectii.toRegex(), // @@ -77,13 +76,13 @@ public abstract class SentenceSimple implements Sentence { public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { final Failable subject = subjectii.getMe(project, arg); - if (subject.isFail()) { + if (subject.isFail()) return CommandExecutionResult.error(subject.getError()); - } + final Failable complement = complementii.getMe(project, arg, "0"); - if (complement.isFail()) { + if (complement.isFail()) return CommandExecutionResult.error(complement.getError()); - } + return execute(project, subject.get(), complement.get()); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java index 790a8e843..84e01b940 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByPlayerCode.java @@ -74,12 +74,13 @@ public class CommandChangeStateByPlayerCode extends CommandChangeState { } @Override - final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + 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) { + if (player == null) return CommandExecutionResult.error("Unkown \"" + code + "\""); - } + final TimeTick now = diagram.getNow(); return addState(diagram, arg, player, now); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java index a53880136..d4fea6570 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandChangeStateByTime.java @@ -75,11 +75,12 @@ public class CommandChangeStateByTime extends CommandChangeState { } @Override - final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) throws NoSuchColorException { + final protected CommandExecutionResult executeArg(TimingDiagram diagram, LineLocation location, RegexResult arg) + throws NoSuchColorException { final Player player = diagram.getLastPlayer(); - if (player == null) { + if (player == null) return CommandExecutionResult.error("Missing @ line before this"); - } + final TimeTick tick = TimeTickBuilder.parseTimeTick("TIME", arg, diagram); diagram.addTime(tick, null); return addState(diagram, arg, player, tick); diff --git a/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java b/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java index dfde33bc1..52e613758 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java +++ b/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java @@ -187,6 +187,9 @@ public class Ribbon implements PDrawing { final HColor back = initialColors.getColor(ColorType.BACK); if (back != null) context = context.withBackColor(back); + final HColor line = initialColors.getColor(ColorType.LINE); + if (line != null) + context = context.withForeColor(line); final PentaAShape shape = PentaAShape.create(len, getRibbonHeight(), context); shape.drawU(ug); diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index b48369726..adfba00fd 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 1; + final int beta = 2; return beta; }