1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-05 21:17:52 +00:00
This commit is contained in:
Arnaud Roques 2022-10-20 18:58:12 +02:00
parent 5c4b6b7fef
commit 780e31ed77
9 changed files with 54 additions and 56 deletions

View File

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

View File

@ -80,17 +80,17 @@ public abstract class RegexComposed implements IRegex {
public Map<String, RegexPartialMatch> createPartialMatch(Iterator<String> it) {
nbCreateMatches.incrementAndGet();
final Map<String, RegexPartialMatch> result = new HashMap<String, RegexPartialMatch>();
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<String> 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();
}

View File

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

View File

@ -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)

View File

@ -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<? extends Object> subject = subjectii.getMe(project, arg);
if (subject.isFail()) {
if (subject.isFail())
return CommandExecutionResult.error(subject.getError());
}
final Failable<? extends Object> complement = complementii.getMe(project, arg, "0");
if (complement.isFail()) {
if (complement.isFail())
return CommandExecutionResult.error(complement.getError());
}
return execute(project, subject.get(), complement.get());
}

View File

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

View File

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

View File

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

View File

@ -81,7 +81,7 @@ public class Version {
}
public static int beta() {
final int beta = 1;
final int beta = 2;
return beta;
}