1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 21:15:09 +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 PSystemXearthFactory());
} }
factories.add(new GanttDiagramFactory(DiagramType.GANTT)); factories.add(new GanttDiagramFactory(DiagramType.GANTT));
factories.add(new GanttDiagramFactory(DiagramType.UML)); // factories.add(new GanttDiagramFactory(DiagramType.UML));
GanttDiagramFactory.clearCache(); GanttDiagramFactory.clearCache();
factories.add(new FlowDiagramFactory()); factories.add(new FlowDiagramFactory());
// factories.add(new PSystemTreeFactory(DiagramType.JUNGLE)); // 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) { public Map<String, RegexPartialMatch> createPartialMatch(Iterator<String> it) {
nbCreateMatches.incrementAndGet(); nbCreateMatches.incrementAndGet();
final Map<String, RegexPartialMatch> result = new HashMap<String, RegexPartialMatch>(); final Map<String, RegexPartialMatch> result = new HashMap<String, RegexPartialMatch>();
for (IRegex r : partials) { for (IRegex r : partials)
result.putAll(r.createPartialMatch(it)); result.putAll(r.createPartialMatch(it));
}
return result; return result;
} }
final public int count() { final public int count() {
int cpt = getStartCount(); int cpt = getStartCount();
for (IRegex r : partials) { for (IRegex r : partials)
cpt += r.count(); cpt += r.count();
}
return cpt; return cpt;
} }
@ -100,9 +100,8 @@ public abstract class RegexComposed implements IRegex {
public RegexResult matcher(String s) { public RegexResult matcher(String s) {
final Matcher2 matcher = getPattern2().matcher(s); final Matcher2 matcher = getPattern2().matcher(s);
if (matcher.find() == false) { if (matcher.find() == false)
return null; return null;
}
final Iterator<String> it = new MatcherIterator(matcher); final Iterator<String> it = new MatcherIterator(matcher);
return new RegexResult(createPartialMatch(it)); return new RegexResult(createPartialMatch(it));
@ -111,9 +110,9 @@ public abstract class RegexComposed implements IRegex {
public boolean match(StringLocated s) { public boolean match(StringLocated s) {
final String tmp = s.getString(); final String tmp = s.getString();
final Matcher2 matcher = getPattern2().matcher(tmp); final Matcher2 matcher = getPattern2().matcher(tmp);
if (matcher == null) { if (matcher == null)
return false; return false;
}
return matcher.find(); return matcher.find();
} }

View File

@ -54,12 +54,12 @@ public final class RegexConcat extends RegexComposed implements IRegex {
int nbCompiled = 0; int nbCompiled = 0;
int nbInvoked = 0; int nbInvoked = 0;
for (RegexConcat reg : cache.values()) { for (RegexConcat reg : cache.values()) {
if (reg.isCompiled()) { if (reg.isCompiled())
nbCompiled++; nbCompiled++;
}
if (reg.invoked()) { if (reg.invoked())
nbInvoked++; nbInvoked++;
}
} }
Log.info("Regex total/invoked/compiled " + cache.size() + "/" + nbInvoked + "/" + nbCompiled); Log.info("Regex total/invoked/compiled " + cache.size() + "/" + nbInvoked + "/" + nbCompiled);
Log.info("Matches created " + nbCreateMatches.get()); Log.info("Matches created " + nbCreateMatches.get());
@ -115,9 +115,9 @@ public final class RegexConcat extends RegexComposed implements IRegex {
@Override @Override
public boolean match(StringLocated s) { public boolean match(StringLocated s) {
if (limitSize != 0 && s.getString().length() > limitSize) { if (limitSize != 0 && s.getString().length() > limitSize)
return false; return false;
}
final long foxRegex = foxRegex(); final long foxRegex = foxRegex();
if (foxRegex != 0L) { if (foxRegex != 0L) {
final long foxLine = s.getFoxSignature(); 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 + " // System.err.println("r=" + getFullSlow() + " s=" + s + " line=" + foxLine + "
// regex" + foxRegex + " " // regex" + foxRegex + " "
// + check + " <" + FoxSignature.backToString(check) + ">"); // + check + " <" + FoxSignature.backToString(check) + ">");
if (check != foxRegex) { if (check != foxRegex)
return false; return false;
}
} }
return super.match(s); return super.match(s);
@ -136,9 +135,9 @@ public final class RegexConcat extends RegexComposed implements IRegex {
@Override @Override
protected String getFullSlow() { protected String getFullSlow() {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (IRegex p : partials()) { for (IRegex p : partials())
sb.append(p.getPattern()); sb.append(p.getPattern());
}
return sb.toString(); return sb.toString();
} }

View File

@ -143,40 +143,36 @@ public class RegexLeaf implements IRegex {
} }
public long getFoxSignature() { public long getFoxSignature() {
if (p1.matcher(pattern).matches()) { if (p1.matcher(pattern).matches())
return FoxSignature.getFoxSignature(pattern); return FoxSignature.getFoxSignature(pattern);
}
if (p2.matcher(pattern).matches()) { if (p2.matcher(pattern).matches())
return FoxSignature.getFoxSignature(pattern.substring(0, pattern.length() - 2)); return FoxSignature.getFoxSignature(pattern.substring(0, pattern.length() - 2));
}
if (p3.matcher(pattern).matches()) { if (p3.matcher(pattern).matches())
// System.err.println("special " + pattern);
// System.err.println("result " +
// FoxSignature.backToString(getSignatureP3(pattern)));
return getSignatureP3(pattern); return getSignatureP3(pattern);
}
if (pattern.length() == 2 && pattern.startsWith("\\") if (pattern.length() == 2 && pattern.startsWith("\\") && Character.isLetterOrDigit(pattern.charAt(1)) == false)
&& Character.isLetterOrDigit(pattern.charAt(1)) == false) {
return FoxSignature.getFoxSignature(pattern.substring(1)); return FoxSignature.getFoxSignature(pattern.substring(1));
}
if (pattern.equals("\\<\\>") || pattern.equals("(\\<\\<.*\\>\\>)")) { if (pattern.equals("\\<\\>") || pattern.equals("(\\<\\<.*\\>\\>)"))
return FoxSignature.getFoxSignature("<>"); return FoxSignature.getFoxSignature("<>");
}
if (pattern.equals("\\<-\\>")) { if (pattern.equals("\\<-\\>"))
return FoxSignature.getFoxSignature("<->"); return FoxSignature.getFoxSignature("<->");
}
if (pattern.equals("(-+)")) { if (pattern.equals("(-+)"))
return FoxSignature.getFoxSignature("-"); return FoxSignature.getFoxSignature("-");
}
if (pattern.equals("\\|+") || pattern.equals("\\|\\|")) { if (pattern.equals("\\|+") || pattern.equals("\\|\\|"))
return FoxSignature.getFoxSignature("|"); return FoxSignature.getFoxSignature("|");
}
if (pattern.equals("([*]+)")) { if (pattern.equals("([*]+)"))
return FoxSignature.getFoxSignature("*"); return FoxSignature.getFoxSignature("*");
}
if (pattern.equals("[%s]+") || pattern.equals("[%s]*")) { if (pattern.equals("[%s]+") || pattern.equals("[%s]*"))
return 0; return 0;
}
// synchronized (UNKNOWN) { // synchronized (UNKNOWN) {
// final boolean changed = UNKNOWN.add(pattern); // final boolean changed = UNKNOWN.add(pattern);
// if (changed) // if (changed)

View File

@ -56,7 +56,7 @@ public abstract class SentenceSimple implements Sentence {
} }
public final IRegex toRegex() { public final IRegex toRegex() {
if (complementii instanceof ComplementEmpty) { if (complementii instanceof ComplementEmpty)
return new RegexConcat(// return new RegexConcat(//
RegexLeaf.start(), // RegexLeaf.start(), //
subjectii.toRegex(), // subjectii.toRegex(), //
@ -64,7 +64,6 @@ public abstract class SentenceSimple implements Sentence {
verb, // verb, //
RegexLeaf.end()); RegexLeaf.end());
}
return new RegexConcat(// return new RegexConcat(//
RegexLeaf.start(), // RegexLeaf.start(), //
subjectii.toRegex(), // subjectii.toRegex(), //
@ -77,13 +76,13 @@ public abstract class SentenceSimple implements Sentence {
public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) { public final CommandExecutionResult execute(GanttDiagram project, RegexResult arg) {
final Failable<? extends Object> subject = subjectii.getMe(project, arg); final Failable<? extends Object> subject = subjectii.getMe(project, arg);
if (subject.isFail()) { if (subject.isFail())
return CommandExecutionResult.error(subject.getError()); return CommandExecutionResult.error(subject.getError());
}
final Failable<? extends Object> complement = complementii.getMe(project, arg, "0"); final Failable<? extends Object> complement = complementii.getMe(project, arg, "0");
if (complement.isFail()) { if (complement.isFail())
return CommandExecutionResult.error(complement.getError()); return CommandExecutionResult.error(complement.getError());
}
return execute(project, subject.get(), complement.get()); return execute(project, subject.get(), complement.get());
} }

View File

@ -74,12 +74,13 @@ public class CommandChangeStateByPlayerCode extends CommandChangeState {
} }
@Override @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 String code = arg.get("CODE", 0);
final Player player = diagram.getPlayer(code); final Player player = diagram.getPlayer(code);
if (player == null) { if (player == null)
return CommandExecutionResult.error("Unkown \"" + code + "\""); return CommandExecutionResult.error("Unkown \"" + code + "\"");
}
final TimeTick now = diagram.getNow(); final TimeTick now = diagram.getNow();
return addState(diagram, arg, player, now); return addState(diagram, arg, player, now);
} }

View File

@ -75,11 +75,12 @@ public class CommandChangeStateByTime extends CommandChangeState {
} }
@Override @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(); final Player player = diagram.getLastPlayer();
if (player == null) { if (player == null)
return CommandExecutionResult.error("Missing @ line before this"); return CommandExecutionResult.error("Missing @ line before this");
}
final TimeTick tick = TimeTickBuilder.parseTimeTick("TIME", arg, diagram); final TimeTick tick = TimeTickBuilder.parseTimeTick("TIME", arg, diagram);
diagram.addTime(tick, null); diagram.addTime(tick, null);
return addState(diagram, arg, player, tick); return addState(diagram, arg, player, tick);

View File

@ -187,6 +187,9 @@ public class Ribbon implements PDrawing {
final HColor back = initialColors.getColor(ColorType.BACK); final HColor back = initialColors.getColor(ColorType.BACK);
if (back != null) if (back != null)
context = context.withBackColor(back); 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); final PentaAShape shape = PentaAShape.create(len, getRibbonHeight(), context);
shape.drawU(ug); shape.drawU(ug);

View File

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