This commit is contained in:
Arnaud Roques 2022-12-16 17:20:14 +01:00
parent 800ead7a8f
commit 8ff88645d4
148 changed files with 646 additions and 607 deletions

View File

@ -175,10 +175,9 @@ public class BlockUml {
if (system == null) { if (system == null) {
if (preprocessorError) if (preprocessorError)
system = new PSystemErrorPreprocessor(data, debug); system = new PSystemErrorPreprocessor(data, debug);
else { else
system = new PSystemBuilder().createPSystem(data, rawSource, system = new PSystemBuilder().createPSystem(data, rawSource,
skinParam == null ? Collections.<String, String>emptyMap() : skinParam.values()); skinParam == null ? Collections.<String, String>emptyMap() : skinParam.values());
}
} }
return system; return system;
} }

View File

@ -212,8 +212,7 @@ public class PSystemBuilder {
if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) { if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) {
factories.add(new PSystemXearthFactory()); factories.add(new PSystemXearthFactory());
} }
factories.add(new GanttDiagramFactory(DiagramType.GANTT)); factories.add(new GanttDiagramFactory());
GanttDiagramFactory.clearCache();
factories.add(new FlowDiagramFactory()); factories.add(new FlowDiagramFactory());
// factories.add(new PSystemTreeFactory(DiagramType.JUNGLE)); // factories.add(new PSystemTreeFactory(DiagramType.JUNGLE));
// factories.add(new PSystemCuteFactory(DiagramType.CUTE)); // factories.add(new PSystemCuteFactory(DiagramType.CUTE));

View File

@ -143,7 +143,7 @@ final public class StringLocated {
public long getFoxSignature() { public long getFoxSignature() {
if (fox == -1) if (fox == -1)
fox = FoxSignature.getFoxSignature(getString()); fox = FoxSignature.getFoxSignatureFromRealString(getString());
return fox; return fox;
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.activitydiagram; package net.sourceforge.plantuml.activitydiagram;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -64,8 +63,7 @@ public class ActivityDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
cmds.add(new CommandFootboxIgnored()); cmds.add(new CommandFootboxIgnored());
CommonCommands.addCommonCommands1(cmds); CommonCommands.addCommonCommands1(cmds);
cmds.add(new CommandRankDir()); cmds.add(new CommandRankDir());
@ -90,8 +88,6 @@ public class ActivityDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandHideShow2()); cmds.add(new CommandHideShow2());
// addCommand(new CommandInnerConcurrent(system)); // addCommand(new CommandInnerConcurrent(system));
return cmds;
} }
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.activitydiagram3; package net.sourceforge.plantuml.activitydiagram3;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -93,9 +92,8 @@ import net.sourceforge.plantuml.core.UmlSource;
public class ActivityDiagramFactory3 extends PSystemCommandFactory { public class ActivityDiagramFactory3 extends PSystemCommandFactory {
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
cmds.add(new CommandFootboxIgnored()); cmds.add(new CommandFootboxIgnored());
CommonCommands.addCommonCommands1(cmds); CommonCommands.addCommonCommands1(cmds);
@ -155,8 +153,6 @@ public class ActivityDiagramFactory3 extends PSystemCommandFactory {
cmds.add(new CommandLabel()); cmds.add(new CommandLabel());
cmds.add(new CommandGoto()); cmds.add(new CommandGoto());
cmds.add(CommandDecoratorMultine.create(new CommandElseIf2(), 50)); cmds.add(CommandDecoratorMultine.create(new CommandElseIf2(), 50));
return cmds;
} }
@Override @Override

View File

@ -89,7 +89,7 @@ public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
color().getRegex(), // color().getRegex(), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf(":"), // new RegexLeaf(":"), //
new RegexLeaf("LABEL", "(.*)"), // new RegexLeaf("LABEL", "(.*)"), //

View File

@ -78,7 +78,7 @@ public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
color("BACK2").getRegex())), // color("BACK2").getRegex())), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\{?"), // new RegexLeaf("\\{?"), //
RegexLeaf.end()); RegexLeaf.end());

View File

@ -62,7 +62,7 @@ public class CommandRepeat3 extends SingleLineCommand2<ActivityDiagram3> {
static IRegex getRegexConcat() { static IRegex getRegexConcat() {
return RegexConcat.build(CommandRepeat3.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandRepeat3.class.getName(), RegexLeaf.start(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
ColorParser.exp4(), // ColorParser.exp4(), //
new RegexLeaf("repeat"), // new RegexLeaf("repeat"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -46,7 +46,6 @@ import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
@ -60,7 +59,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInsi
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.awt.geom.XPoint2D; import net.sourceforge.plantuml.awt.geom.XPoint2D;
import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2; import net.sourceforge.plantuml.creole.SheetBlock2;

View File

@ -103,9 +103,7 @@ class FtileIfLongHorizontal extends AbstractFtile {
} }
private static List<Ftile> alignDiamonds(List<Ftile> diamonds, StringBounder stringBounder) { private static List<Ftile> alignDiamonds(List<Ftile> diamonds, StringBounder stringBounder) {
double maxOutY = 0; final double maxOutY = getMaxOutY(diamonds, stringBounder);
for (Ftile diamond : diamonds)
maxOutY = Math.max(maxOutY, diamond.calculateDimension(stringBounder).getOutY());
final List<Ftile> result = new ArrayList<>(); final List<Ftile> result = new ArrayList<>();
for (int i = 0; i < diamonds.size(); i++) { for (int i = 0; i < diamonds.size(); i++) {
@ -118,6 +116,13 @@ class FtileIfLongHorizontal extends AbstractFtile {
return result; return result;
} }
private static double getMaxOutY(List<Ftile> diamonds, StringBounder stringBounder) {
double maxOutY = 0;
for (Ftile diamond : diamonds)
maxOutY = Math.max(maxOutY, diamond.calculateDimension(stringBounder).getOutY());
return maxOutY;
}
public Set<Swimlane> getSwimlanes() { public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<>(); final Set<Swimlane> result = new HashSet<>();
if (getSwimlaneIn() != null) if (getSwimlaneIn() != null)
@ -508,9 +513,9 @@ class FtileIfLongHorizontal extends AbstractFtile {
if (leftOut == null) if (leftOut == null)
return new double[] { Double.NaN, Double.NaN }; return new double[] { Double.NaN, Double.NaN };
if (current == -1) if (current == -1)
throw new IllegalStateException(); throw new IllegalStateException();
final int first = getFirstSwimlane(stringBounder, allTiles, allSwimlanes); final int first = getFirstSwimlane(stringBounder, allTiles, allSwimlanes);
final int last = getLastSwimlane(stringBounder, allTiles, allSwimlanes); final int last = getLastSwimlane(stringBounder, allTiles, allSwimlanes);
if (current < first || current > last) if (current < first || current > last)
@ -660,14 +665,17 @@ class FtileIfLongHorizontal extends AbstractFtile {
} }
private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) { private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) {
final double maxOutY = getMaxOutY(diamonds, stringBounder);
XDimension2D result = new XDimension2D(0, 0); XDimension2D result = new XDimension2D(0, 0);
for (Ftile couple : couples) for (Ftile couple : couples)
result = result.mergeLR(couple.calculateDimension(stringBounder)); result = result.mergeLR(couple.calculateDimension(stringBounder));
XDimension2D dimTile2 = tile2.calculateDimension(stringBounder); XDimension2D dimTile2 = tile2.calculateDimension(stringBounder);
dimTile2 = dimTile2.delta(0, getDiamondsHeight(stringBounder) / 2); dimTile2 = dimTile2.delta(0, getDiamondsHeight(stringBounder) / 2);
result = result.mergeLR(dimTile2); result = result.mergeLR(dimTile2);
result = result.delta(xSeparation * couples.size(), 100); result = result.delta(xSeparation * couples.size(), Math.max(100, maxOutY));
return new FtileGeometry(result, result.getWidth() / 2, 0); return new FtileGeometry(result, result.getWidth() / 2, 0);
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.board; package net.sourceforge.plantuml.board;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -52,9 +51,7 @@ public class BoardDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
CommonCommands.addCommonCommands1(cmds); CommonCommands.addCommonCommands1(cmds);
cmds.add(new CommandBoardPlus()); cmds.add(new CommandBoardPlus());
// cmds.add(new CommandMindMapTabulation()); // cmds.add(new CommandMindMapTabulation());
@ -63,8 +60,6 @@ public class BoardDiagramFactory extends PSystemCommandFactory {
// cmds.add(new CommandMindMapRoot()); // cmds.add(new CommandMindMapRoot());
// cmds.add(new CommandMindMapPlus()); // cmds.add(new CommandMindMapPlus());
// cmds.add(new CommandMindMapDirection()); // cmds.add(new CommandMindMapDirection());
return cmds;
} }
@Override @Override

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.bpm; package net.sourceforge.plantuml.bpm;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -52,8 +51,7 @@ public class BpmDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> result) {
final List<Command> result = new ArrayList<>();
result.add(new CommandDockedEvent()); result.add(new CommandDockedEvent());
result.add(new CommandMerge()); result.add(new CommandMerge());
result.add(new CommandResume()); result.add(new CommandResume());
@ -61,7 +59,6 @@ public class BpmDiagramFactory extends PSystemCommandFactory {
result.add(new CommandNewBranch()); result.add(new CommandNewBranch());
result.add(new CommandElseBranch()); result.add(new CommandElseBranch());
result.add(new CommandEndBranch()); result.add(new CommandEndBranch());
return result;
} }
@Override @Override

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.classdiagram; package net.sourceforge.plantuml.classdiagram;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -91,8 +90,7 @@ public class ClassDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
cmds.add(new CommandFootboxIgnored()); cmds.add(new CommandFootboxIgnored());
cmds.add(new CommandRankDir()); cmds.add(new CommandRankDir());
@ -161,7 +159,5 @@ public class ClassDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandCreateElementMultilines(1)); cmds.add(new CommandCreateElementMultilines(1));
CommonCommands.addTitleCommands(cmds); CommonCommands.addTitleCommands(cmds);
CommonCommands.addCommonCommands2(cmds); CommonCommands.addCommonCommands2(cmds);
return cmds;
} }
} }

View File

@ -105,7 +105,7 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -59,7 +59,9 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> { public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
public CommandHideShowByGender() { public static final CommandHideShowByGender ME = new CommandHideShowByGender();
private CommandHideShowByGender() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -54,7 +54,9 @@ import net.sourceforge.plantuml.skin.VisibilityModifier;
public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram> { public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram> {
public CommandHideShowByVisibility() { public static final CommandHideShowByVisibility ME = new CommandHideShowByVisibility();
private CommandHideShowByVisibility() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -46,7 +46,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandAffineTransform extends SingleLineCommand2<UmlDiagram> { public class CommandAffineTransform extends SingleLineCommand2<UmlDiagram> {
public CommandAffineTransform() { public static final CommandAffineTransform ME = new CommandAffineTransform();
private CommandAffineTransform() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -39,7 +39,9 @@ import net.sourceforge.plantuml.TitledDiagram;
public class CommandAffineTransformMultiline extends CommandMultilines<TitledDiagram> { public class CommandAffineTransformMultiline extends CommandMultilines<TitledDiagram> {
public CommandAffineTransformMultiline() { public static final CommandAffineTransformMultiline ME = new CommandAffineTransformMultiline();
private CommandAffineTransformMultiline() {
super("^!transformation[%s]+\\{[%s]*$"); super("^!transformation[%s]+\\{[%s]*$");
} }

View File

@ -44,7 +44,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandAssumeTransparent extends SingleLineCommand2<TitledDiagram> { public class CommandAssumeTransparent extends SingleLineCommand2<TitledDiagram> {
public CommandAssumeTransparent() { public static final CommandAssumeTransparent ME = new CommandAssumeTransparent();
private CommandAssumeTransparent() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -49,7 +49,9 @@ import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandCaption extends SingleLineCommand2<TitledDiagram> { public class CommandCaption extends SingleLineCommand2<TitledDiagram> {
public CommandCaption() { public static final CommandCaption ME = new CommandCaption();
private CommandCaption() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -49,7 +49,9 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CommandFooter extends SingleLineCommand2<TitledDiagram> { public class CommandFooter extends SingleLineCommand2<TitledDiagram> {
public CommandFooter() { public static final CommandFooter ME = new CommandFooter();
private CommandFooter() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -49,7 +49,9 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CommandHeader extends SingleLineCommand2<TitledDiagram> { public class CommandHeader extends SingleLineCommand2<TitledDiagram> {
public CommandHeader() { public static final CommandHeader ME = new CommandHeader();
private CommandHeader() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -49,7 +49,9 @@ import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandLegend extends SingleLineCommand2<TitledDiagram> { public class CommandLegend extends SingleLineCommand2<TitledDiagram> {
public CommandLegend() { public static final CommandLegend ME = new CommandLegend();
private CommandLegend() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -46,7 +46,9 @@ import net.sourceforge.plantuml.cucadiagram.Display;
public class CommandMainframe extends SingleLineCommand2<TitledDiagram> { public class CommandMainframe extends SingleLineCommand2<TitledDiagram> {
public CommandMainframe() { public static final CommandMainframe ME = new CommandMainframe();
private CommandMainframe() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -44,7 +44,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandMinwidth extends SingleLineCommand2<UmlDiagram> { public class CommandMinwidth extends SingleLineCommand2<UmlDiagram> {
public CommandMinwidth() { public static final CommandMinwidth ME = new CommandMinwidth();
private CommandMinwidth() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -44,7 +44,9 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandMultilinesCaption extends CommandMultilines<TitledDiagram> { public class CommandMultilinesCaption extends CommandMultilines<TitledDiagram> {
public CommandMultilinesCaption() { public static final CommandMultilinesCaption ME = new CommandMultilinesCaption();
private CommandMultilinesCaption() {
super("^caption$"); super("^caption$");
} }
@ -58,7 +60,8 @@ public class CommandMultilinesCaption extends CommandMultilines<TitledDiagram> {
lines = lines.removeEmptyColumns(); lines = lines.removeEmptyColumns();
final Display strings = lines.toDisplay(); final Display strings = lines.toDisplay();
if (strings.size() > 0) { if (strings.size() > 0) {
diagram.setCaption(DisplayPositioned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM)); diagram.setCaption(DisplayPositioned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM));
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
return CommandExecutionResult.error("No caption defined"); return CommandExecutionResult.error("No caption defined");

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandMultilinesFooter extends CommandMultilines<TitledDiagram> { public class CommandMultilinesFooter extends CommandMultilines<TitledDiagram> {
public CommandMultilinesFooter() { public static final CommandMultilinesFooter ME = new CommandMultilinesFooter();
private CommandMultilinesFooter() {
super("^(?:(left|right|center)?[%s]*)footer$"); super("^(?:(left|right|center)?[%s]*)footer$");
} }

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandMultilinesHeader extends CommandMultilines<TitledDiagram> { public class CommandMultilinesHeader extends CommandMultilines<TitledDiagram> {
public CommandMultilinesHeader() { public static final CommandMultilinesHeader ME = new CommandMultilinesHeader();
private CommandMultilinesHeader() {
super("^(?:(left|right|center)?[%s]*)header$"); super("^(?:(left|right|center)?[%s]*)header$");
} }

View File

@ -49,7 +49,9 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandMultilinesLegend extends CommandMultilines2<TitledDiagram> { public class CommandMultilinesLegend extends CommandMultilines2<TitledDiagram> {
public CommandMultilinesLegend() { public static final CommandMultilinesLegend ME = new CommandMultilinesLegend();
private CommandMultilinesLegend() {
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.BOTH); super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE, Trim.BOTH);
} }

View File

@ -44,7 +44,9 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandMultilinesTitle extends CommandMultilines<TitledDiagram> { public class CommandMultilinesTitle extends CommandMultilines<TitledDiagram> {
public CommandMultilinesTitle() { public static final CommandMultilinesTitle ME = new CommandMultilinesTitle();
private CommandMultilinesTitle() {
super("^title$"); super("^title$");
} }
@ -58,7 +60,8 @@ public class CommandMultilinesTitle extends CommandMultilines<TitledDiagram> {
lines = lines.removeEmptyColumns(); lines = lines.removeEmptyColumns();
final Display strings = lines.toDisplay(); final Display strings = lines.toDisplay();
if (strings.size() > 0) { if (strings.size() > 0) {
diagram.setTitle(DisplayPositioned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER, VerticalAlignment.TOP)); diagram.setTitle(DisplayPositioned.single(strings.replaceBackslashT(), HorizontalAlignment.CENTER,
VerticalAlignment.TOP));
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
return CommandExecutionResult.error("No title defined"); return CommandExecutionResult.error("No title defined");

View File

@ -60,6 +60,8 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandNamespace extends SingleLineCommand2<ClassDiagram> { public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
public static final String NAMESPACE_REGEX = "([%pLN_][-%pLN_.:\\\\/]*)";
public CommandNamespace() { public CommandNamespace() {
super(getRegexConcat()); super(getRegexConcat());
} }
@ -68,7 +70,7 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
return RegexConcat.build(CommandNamespace.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandNamespace.class.getName(), RegexLeaf.start(), //
new RegexLeaf("namespace"), // new RegexLeaf("namespace"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("NAME", "([%pLN_][-%pLN_.:\\\\]*)"), // new RegexLeaf("NAME", NAMESPACE_REGEX), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -74,7 +74,7 @@ public class CommandNamespace2 extends SingleLineCommand2<ClassDiagram> {
new RegexLeaf("as"), // new RegexLeaf("as"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("NAME", "([%pLN_][-%pLN_.:\\\\]*)"), // new RegexLeaf("NAME", CommandNamespace.NAMESPACE_REGEX), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -110,8 +110,7 @@ public class CommandNamespace2 extends SingleLineCommand2<ClassDiagram> {
final String color = arg.get("COLOR", 0); final String color = arg.get("COLOR", 0);
if (color != null) { if (color != null) {
p.setSpecificColorTOBEREMOVED(ColorType.BACK, p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(color));
diagram.getSkinParam().getIHtmlColorSet().getColor(color));
} }
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }

View File

@ -66,7 +66,7 @@ public class CommandNamespaceEmpty extends SingleLineCommand2<ClassDiagram> {
return RegexConcat.build(CommandNamespaceEmpty.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandNamespaceEmpty.class.getName(), RegexLeaf.start(), //
new RegexLeaf("namespace"), // new RegexLeaf("namespace"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("NAME", "([%pLN_][-%pLN_.:\\\\]*)"), // new RegexLeaf("NAME", CommandNamespace.NAMESPACE_REGEX), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -104,8 +104,7 @@ public class CommandNamespaceEmpty extends SingleLineCommand2<ClassDiagram> {
final String color = arg.get("COLOR", 0); final String color = arg.get("COLOR", 0);
if (color != null) { if (color != null) {
p.setSpecificColorTOBEREMOVED(ColorType.BACK, p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColor(color));
diagram.getSkinParam().getIHtmlColorSet().getColor(color));
} }
diagram.endGroup(); diagram.endGroup();
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();

View File

@ -44,7 +44,9 @@ import net.sourceforge.plantuml.core.Diagram;
public class CommandNope extends SingleLineCommand2<Diagram> { public class CommandNope extends SingleLineCommand2<Diagram> {
public CommandNope() { public static final CommandNope ME = new CommandNope();
private CommandNope() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -44,7 +44,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandPage extends SingleLineCommand2<AbstractPSystem> { public class CommandPage extends SingleLineCommand2<AbstractPSystem> {
public CommandPage() { public static final CommandPage ME = new CommandPage();
private CommandPage() {
super(getRegexConcat()); super(getRegexConcat());
} }
@ -60,14 +62,13 @@ public class CommandPage extends SingleLineCommand2<AbstractPSystem> {
} }
@Override @Override
protected CommandExecutionResult executeArg(AbstractPSystem system, LineLocation location, protected CommandExecutionResult executeArg(AbstractPSystem system, LineLocation location, RegexResult arg) {
RegexResult arg) {
final int horizontal = Integer.parseInt(arg.get("NB1", 0)); final int horizontal = Integer.parseInt(arg.get("NB1", 0));
final int vertical = Integer.parseInt(arg.get("NB2", 0)); final int vertical = Integer.parseInt(arg.get("NB2", 0));
if (horizontal <= 0 || vertical <= 0) { if (horizontal <= 0 || vertical <= 0)
return CommandExecutionResult.error("Argument must be positive"); return CommandExecutionResult.error("Argument must be positive");
}
system.setSplitPagesHorizontal(horizontal); system.setSplitPagesHorizontal(horizontal);
system.setSplitPagesVertical(vertical); system.setSplitPagesVertical(vertical);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();

View File

@ -49,7 +49,9 @@ import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
public class CommandPragma extends SingleLineCommand2<TitledDiagram> { public class CommandPragma extends SingleLineCommand2<TitledDiagram> {
public CommandPragma() { public static final CommandPragma ME = new CommandPragma();
private CommandPragma() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -44,7 +44,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandRotate extends SingleLineCommand2<UmlDiagram> { public class CommandRotate extends SingleLineCommand2<UmlDiagram> {
public CommandRotate() { public static final CommandRotate ME = new CommandRotate();
private CommandRotate() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -46,7 +46,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandScale extends SingleLineCommand2<AbstractPSystem> { public class CommandScale extends SingleLineCommand2<AbstractPSystem> {
public CommandScale() { public static final CommandScale ME = new CommandScale();
private CommandScale() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandScaleMaxHeight extends SingleLineCommand2<AbstractPSystem> { public class CommandScaleMaxHeight extends SingleLineCommand2<AbstractPSystem> {
public CommandScaleMaxHeight() { public static final CommandScaleMaxHeight ME = new CommandScaleMaxHeight();
private CommandScaleMaxHeight() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandScaleMaxWidth extends SingleLineCommand2<AbstractPSystem> { public class CommandScaleMaxWidth extends SingleLineCommand2<AbstractPSystem> {
public CommandScaleMaxWidth() { public static final CommandScaleMaxWidth ME = new CommandScaleMaxWidth();
private CommandScaleMaxWidth() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandScaleMaxWidthAndHeight extends SingleLineCommand2<AbstractPSystem> { public class CommandScaleMaxWidthAndHeight extends SingleLineCommand2<AbstractPSystem> {
public CommandScaleMaxWidthAndHeight() { public static final CommandScaleMaxWidthAndHeight ME = new CommandScaleMaxWidthAndHeight();
private CommandScaleMaxWidthAndHeight() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandScaleWidthAndHeight extends SingleLineCommand2<AbstractPSystem> { public class CommandScaleWidthAndHeight extends SingleLineCommand2<AbstractPSystem> {
public CommandScaleWidthAndHeight() { public static final CommandScaleWidthAndHeight ME = new CommandScaleWidthAndHeight();
private CommandScaleWidthAndHeight() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -46,7 +46,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class CommandScaleWidthOrHeight extends SingleLineCommand2<AbstractPSystem> { public class CommandScaleWidthOrHeight extends SingleLineCommand2<AbstractPSystem> {
public CommandScaleWidthOrHeight() { public static final CommandScaleWidthOrHeight ME = new CommandScaleWidthOrHeight();
private CommandScaleWidthOrHeight() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.style.NoStyleAvailableException;
public class CommandSkinParam extends SingleLineCommand2<TitledDiagram> { public class CommandSkinParam extends SingleLineCommand2<TitledDiagram> {
public CommandSkinParam() { public static final CommandSkinParam ME = new CommandSkinParam();
private CommandSkinParam() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -42,16 +42,18 @@ import net.sourceforge.plantuml.command.regex.MyPattern;
public class CommandSkinParamMultilines extends CommandMultilinesBracket<TitledDiagram> { public class CommandSkinParamMultilines extends CommandMultilinesBracket<TitledDiagram> {
public CommandSkinParamMultilines() { public static final CommandSkinParamMultilines ME = new CommandSkinParamMultilines();
private CommandSkinParamMultilines() {
super("^skinparam[%s]*(?:[%s]+([\\w.]*(?:\\<\\<.*\\>\\>)?[\\w.]*))?[%s]*\\{$"); super("^skinparam[%s]*(?:[%s]+([\\w.]*(?:\\<\\<.*\\>\\>)?[\\w.]*))?[%s]*\\{$");
} }
@Override @Override
protected boolean isLineConsistent(String line, int level) { protected boolean isLineConsistent(String line, int level) {
line = StringUtils.trin(line); line = StringUtils.trin(line);
if (hasStartingQuote(line)) { if (hasStartingQuote(line))
return true; return true;
}
return SkinLoader.p1.matcher(line).matches(); return SkinLoader.p1.matcher(line).matches();
} }
@ -64,9 +66,9 @@ public class CommandSkinParamMultilines extends CommandMultilinesBracket<TitledD
final SkinLoader skinLoader = new SkinLoader(diagram); final SkinLoader skinLoader = new SkinLoader(diagram);
final Matcher2 mStart = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString()); final Matcher2 mStart = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
if (mStart.find() == false) { if (mStart.find() == false)
throw new IllegalStateException(); throw new IllegalStateException();
}
final String group1 = mStart.group(1); final String group1 = mStart.group(1);
return skinLoader.execute(lines, group1); return skinLoader.execute(lines, group1);

View File

@ -58,7 +58,9 @@ import net.sourceforge.plantuml.sprite.SpriteSvg;
public class CommandSpriteFile extends SingleLineCommand2<TitledDiagram> { public class CommandSpriteFile extends SingleLineCommand2<TitledDiagram> {
public CommandSpriteFile() { public static final CommandSpriteFile ME = new CommandSpriteFile();
private CommandSpriteFile() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -45,7 +45,9 @@ import net.sourceforge.plantuml.emoji.SvgNanoParser;
public class CommandSpriteSvg extends SingleLineCommand2<TitledDiagram> { public class CommandSpriteSvg extends SingleLineCommand2<TitledDiagram> {
public CommandSpriteSvg() { public static final CommandSpriteSvg ME = new CommandSpriteSvg();
private CommandSpriteSvg() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -46,7 +46,9 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandSpriteSvgMultiline extends CommandMultilines2<TitledDiagram> { public class CommandSpriteSvgMultiline extends CommandMultilines2<TitledDiagram> {
public CommandSpriteSvgMultiline() { public static final CommandSpriteSvgMultiline ME = new CommandSpriteSvgMultiline();
private CommandSpriteSvgMultiline() {
super(getRegexConcat(), MultilinesStrategy.KEEP_STARTING_QUOTE, Trim.BOTH); super(getRegexConcat(), MultilinesStrategy.KEEP_STARTING_QUOTE, Trim.BOTH);
} }

View File

@ -49,7 +49,9 @@ import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandTitle extends SingleLineCommand2<TitledDiagram> { public class CommandTitle extends SingleLineCommand2<TitledDiagram> {
public CommandTitle() { public static final CommandTitle ME = new CommandTitle();
private CommandTitle() {
super(getRegexConcat()); super(getRegexConcat());
} }

View File

@ -56,56 +56,56 @@ public final class CommonCommands {
} }
static public void addCommonCommands2(List<Command> cmds) { static public void addCommonCommands2(List<Command> cmds) {
cmds.add(new CommandNope()); cmds.add(CommandNope.ME);
cmds.add(new CommandPragma()); cmds.add(CommandPragma.ME);
cmds.add(new CommandAssumeTransparent()); cmds.add(CommandAssumeTransparent.ME);
cmds.add(new CommandSkinParam()); cmds.add(CommandSkinParam.ME);
cmds.add(new CommandSkinParamMultilines()); cmds.add(CommandSkinParamMultilines.ME);
cmds.add(new CommandSkin()); cmds.add(CommandSkin.ME);
cmds.add(new CommandMinwidth()); cmds.add(CommandMinwidth.ME);
cmds.add(new CommandPage()); cmds.add(CommandPage.ME);
cmds.add(new CommandRotate()); cmds.add(CommandRotate.ME);
cmds.add(new CommandScale()); cmds.add(CommandScale.ME);
cmds.add(new CommandScaleWidthAndHeight()); cmds.add(CommandScaleWidthAndHeight.ME);
cmds.add(new CommandScaleWidthOrHeight()); cmds.add(CommandScaleWidthOrHeight.ME);
cmds.add(new CommandScaleMaxWidth()); cmds.add(CommandScaleMaxWidth.ME);
cmds.add(new CommandScaleMaxHeight()); cmds.add(CommandScaleMaxHeight.ME);
cmds.add(new CommandScaleMaxWidthAndHeight()); cmds.add(CommandScaleMaxWidthAndHeight.ME);
cmds.add(new CommandAffineTransform()); cmds.add(CommandAffineTransform.ME);
cmds.add(new CommandAffineTransformMultiline()); cmds.add(CommandAffineTransformMultiline.ME);
final CommandFactorySprite factorySpriteCommand = new CommandFactorySprite(); final CommandFactorySprite factorySpriteCommand = new CommandFactorySprite();
cmds.add(factorySpriteCommand.createMultiLine(false)); cmds.add(factorySpriteCommand.createMultiLine(false));
cmds.add(factorySpriteCommand.createSingleLine()); cmds.add(factorySpriteCommand.createSingleLine());
cmds.add(new CommandSpriteSvg()); cmds.add(CommandSpriteSvg.ME);
cmds.add(new CommandSpriteFile()); cmds.add(CommandSpriteFile.ME);
cmds.add(new CommandSpriteSvgMultiline()); cmds.add(CommandSpriteSvgMultiline.ME);
cmds.add(new CommandStyleMultilinesCSS()); cmds.add(CommandStyleMultilinesCSS.ME);
cmds.add(new CommandStyleImport()); cmds.add(CommandStyleImport.ME);
} }
static public void addCommonHides(List<Command> cmds) { static public void addCommonHides(List<Command> cmds) {
cmds.add(new CommandHideEmptyDescription()); cmds.add(CommandHideEmptyDescription.ME);
cmds.add(new CommandHideShowByVisibility()); cmds.add(CommandHideShowByVisibility.ME);
cmds.add(new CommandHideShowByGender()); cmds.add(CommandHideShowByGender.ME);
} }
static public void addTitleCommands(List<Command> cmds) { static public void addTitleCommands(List<Command> cmds) {
cmds.add(new CommandTitle()); cmds.add(CommandTitle.ME);
cmds.add(new CommandMainframe()); cmds.add(CommandMainframe.ME);
cmds.add(new CommandCaption()); cmds.add(CommandCaption.ME);
cmds.add(new CommandMultilinesCaption()); cmds.add(CommandMultilinesCaption.ME);
cmds.add(new CommandMultilinesTitle()); cmds.add(CommandMultilinesTitle.ME);
cmds.add(new CommandMultilinesLegend()); cmds.add(CommandMultilinesLegend.ME);
cmds.add(new CommandLegend()); cmds.add(CommandLegend.ME);
cmds.add(new CommandFooter()); cmds.add(CommandFooter.ME);
cmds.add(new CommandMultilinesFooter()); cmds.add(CommandMultilinesFooter.ME);
cmds.add(new CommandHeader()); cmds.add(CommandHeader.ME);
cmds.add(new CommandMultilinesHeader()); cmds.add(CommandMultilinesHeader.ME);
} }
} }

View File

@ -35,6 +35,7 @@
*/ */
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -55,9 +56,9 @@ import net.sourceforge.plantuml.version.IteratorCounter2;
public abstract class PSystemCommandFactory extends PSystemAbstractFactory { public abstract class PSystemCommandFactory extends PSystemAbstractFactory {
private List<Command> cmds; private final List<Command> cmds = new ArrayList<>();
protected abstract List<Command> createCommands(); protected abstract void initCommandsList(List<Command> cmds);
public abstract AbstractPSystem createEmptyDiagram(UmlSource source, Map<String, String> skinParam); public abstract AbstractPSystem createEmptyDiagram(UmlSource source, Map<String, String> skinParam);
@ -149,8 +150,10 @@ public abstract class PSystemCommandFactory extends PSystemAbstractFactory {
private Step getCandidate(final IteratorCounter2 it) { private Step getCandidate(final IteratorCounter2 it) {
final BlocLines single = BlocLines.single(it.peek()); final BlocLines single = BlocLines.single(it.peek());
if (cmds == null) synchronized (cmds) {
cmds = createCommands(); if (cmds.size() == 0)
initCommandsList(cmds);
}
for (Command cmd : cmds) { for (Command cmd : cmds) {
final CommandControl result = cmd.isValid(single); final CommandControl result = cmd.isValid(single);

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.command.note; package net.sourceforge.plantuml.command.note;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.baraye.IEntity; import net.sourceforge.plantuml.baraye.IEntity;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
@ -72,7 +71,7 @@ public final class CommandFactoryNote implements SingleMultiFactoryCommand<Abstr
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
ColorParser.exp1(), // ColorParser.exp1(), //
RegexLeaf.end() // RegexLeaf.end() //
@ -93,7 +92,7 @@ public final class CommandFactoryNote implements SingleMultiFactoryCommand<Abstr
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
ColorParser.exp1(), // ColorParser.exp1(), //
RegexLeaf.end() // RegexLeaf.end() //

View File

@ -94,7 +94,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -129,7 +129,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -155,7 +155,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -68,7 +68,7 @@ public final class CommandFactoryNoteOnLink implements SingleMultiFactoryCommand
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("POSITION", "(right|left|top|bottom)?"), // new RegexLeaf("POSITION", "(right|left|top|bottom)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("o[nf]"), // new RegexLeaf("(on|of)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("link"), // new RegexLeaf("link"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -85,7 +85,7 @@ public final class CommandFactoryNoteOnLink implements SingleMultiFactoryCommand
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("POSITION", "(right|left|top|bottom)?"), // new RegexLeaf("POSITION", "(right|left|top|bottom)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("o[nf]"), // new RegexLeaf("(on|of)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("link"), // new RegexLeaf("link"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -90,7 +90,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -113,7 +113,7 @@ public final class CommandFactoryTipOnEntity implements SingleMultiFactoryComman
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS1", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), // new RegexLeaf("TAGS2", Stereotag.pattern() + "?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -71,7 +71,7 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ACROSS", "(accross|across)"), // new RegexLeaf("ACROSS", "(accross|across)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -87,7 +87,7 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("ACROSS", "(accross|across)"), // new RegexLeaf("ACROSS", "(accross|across)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -74,7 +74,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("POSITION", "(right|left|over)"), // new RegexLeaf("POSITION", "(right|left|over)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
@ -92,7 +92,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("POSITION", "(right|left|over)"), // new RegexLeaf("POSITION", "(right|left|over)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //

View File

@ -75,7 +75,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("POSITION", "(right|left|bottom|top)"), // new RegexLeaf("POSITION", "(right|left|bottom|top)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -89,7 +89,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("POSITION", "(right|left|bottom|top)"), // new RegexLeaf("POSITION", "(right|left|bottom|top)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -73,7 +73,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO1", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("over"), // new RegexLeaf("over"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
@ -83,7 +83,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("P2", "([%pLN_.@]+|[%g][^%g]+[%g])"), // new RegexLeaf("P2", "([%pLN_.@]+|[%g][^%g]+[%g])"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO2", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
color().getRegex(), // color().getRegex(), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
@ -98,7 +98,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), // new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO1", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO1", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("over"), // new RegexLeaf("over"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
@ -108,7 +108,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("P2", "([%pLN_.@]+|[%g][^%g]+[%g])"), // new RegexLeaf("P2", "([%pLN_.@]+|[%g][^%g]+[%g])"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREO2", "(\\<{2}.*\\>{2})?"), // new RegexLeaf("STEREO2", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //
color().getRegex(), // color().getRegex(), //
RegexLeaf.spaceZeroOrMore(), // RegexLeaf.spaceZeroOrMore(), //

View File

@ -38,53 +38,101 @@ package net.sourceforge.plantuml.command.regex;
public class FoxSignature { public class FoxSignature {
private static final long masks[] = new long[127]; private static final long masks[] = new long[127];
private static final long MASK_SPACES;
private static final long MASK_SPECIAL1;
static { static {
final String full = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0!\"#$%&\'()*+,-./:;<=>?@[\\]^_{|}~"; final String full = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0!\"#$%&\'()*+,-./:;<=>?@[\\]^_{|}~";
long m = 1L; long m = 1L;
MASK_SPACES = m;
m = m << 1;
MASK_SPECIAL1 = m;
m = m << 1;
for (int i = 0; i < full.length(); i++) { for (int i = 0; i < full.length(); i++) {
char ch = full.charAt(i); char ch = full.charAt(i);
masks[ch] = m; masks[ch] = m;
if (ch >= 'A' && ch <= 'Z') { if (ch >= 'A' && ch <= 'Z') {
ch = (char) (ch + ('a' - 'A')); ch = (char) (ch + ('a' - 'A'));
masks[ch] = m; masks[ch] = m;
} } else if (ch == '.' || ch == '=' || ch == '-' || ch == '~')
masks[ch] |= MASK_SPECIAL1;
m = m << 1; m = m << 1;
} }
masks[' '] = MASK_SPACES;
masks['\t'] = MASK_SPACES;
masks['\r'] = MASK_SPACES;
masks['\n'] = MASK_SPACES;
masks['\f'] = MASK_SPACES;
}
public static long getSpecialSpaces() {
return MASK_SPACES;
}
public static long getSpecial1() {
return MASK_SPECIAL1;
} }
public static void printMe() { public static void printMe() {
for (int i = 0; i < masks.length; i++) { for (int i = 0; i < masks.length; i++)
if (masks[i] > 0) { if (masks[i] > 0) {
final char ch = (char) i; final char ch = (char) i;
System.err.println("ch=" + ch + " " + masks[i]); System.err.println("ch=" + ch + " " + masks[i]);
} }
}
} }
private static long getMask(char ch) { private static long getMask(char ch) {
if (ch < masks.length) { if (ch < masks.length)
return masks[ch]; return masks[ch];
} else if (ch == '\u00A0')
return MASK_SPACES;
return 0L; return 0L;
} }
public static long getFoxSignature(String s) { public static long getFoxSignatureFromRealString(String s) {
long result = 0;
for (int i = 0; i < s.length(); i++)
result = result | getMask(s.charAt(i));
return result;
}
public static long getFoxSignatureFromRegex(String s) {
long result = 0; long result = 0;
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
result = result | getMask(s.charAt(i)); if (s.charAt(i) == '.') {
if (s.charAt(i + 1) == '+' || s.charAt(i + 1) == '*')
i++;
else
throw new IllegalArgumentException(s);
} else if (s.charAt(i) == '\\') {
if (s.charAt(i + 1) == 'b')
i++;
else if (Character.isLetterOrDigit(s.charAt(i + 1)))
throw new IllegalArgumentException(s);
} else {
if (i + 1 < s.length() && (s.charAt(i + 1) == '?' || s.charAt(i + 1) == '*')) {
i++;
continue;
}
result = result | getMask(s.charAt(i));
if (i + 1 < s.length() && s.charAt(i + 1) == '+') {
i++;
}
}
} }
return result; return result;
} }
public static String backToString(long check) { public static String backToString(long check) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (int i = 0; i < masks.length; i++) { for (int i = 0; i < masks.length; i++)
if (masks[i] != 0L && (check & masks[i]) != 0L) { if (masks[i] != 0L && (check & masks[i]) != 0L) {
final char ch = (char) i; final char ch = (char) i;
sb.append(ch); sb.append(ch);
} }
}
return sb.toString(); return sb.toString();
} }

View File

@ -41,14 +41,16 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.StringLocated;
public abstract class RegexComposed implements IRegex { public abstract class RegexComposed implements IRegex {
protected static final AtomicInteger nbCreateMatches = new AtomicInteger(); // protected static final AtomicInteger nbCreateMatches = new AtomicInteger();
// protected static final AtomicInteger vtot = new AtomicInteger();
// protected static final AtomicInteger vescaped = new AtomicInteger();
private final List<IRegex> partials; private final List<IRegex> partials;
protected final List<IRegex> partials() { protected final List<IRegex> partials() {
@ -78,7 +80,7 @@ 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));

View File

@ -35,34 +35,38 @@
*/ */
package net.sourceforge.plantuml.command.regex; package net.sourceforge.plantuml.command.regex;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.StringLocated;
public final class RegexConcat extends RegexComposed implements IRegex { public final class RegexConcat extends RegexComposed implements IRegex {
private static final ConcurrentMap<Object, RegexConcat> cache = new ConcurrentHashMap<Object, RegexConcat>();
private final AtomicLong foxRegex = new AtomicLong(-1L); private final AtomicLong foxRegex = new AtomicLong(-1L);
private int limitSize; private int limitSize;
// private static final Set<String> PRINTED2 = new HashSet<>(); // private static final Set<String> PRINTED2 = new HashSet<>();
public static void printCacheInfo() { public static void printCacheInfo() {
int nbCompiled = 0; // if (OptionFlags.getInstance().isVerbose())
int nbInvoked = 0; // synchronized (cache) {
for (RegexConcat reg : cache.values()) { //
if (reg.isCompiled()) // final NumberFormat nf = NumberFormat.getInstance(Locale.US);
nbCompiled++; //
// int nbCompiled = 0;
if (reg.invoked()) // int nbInvoked = 0;
nbInvoked++; // for (RegexConcat reg : cache.values()) {
// if (reg.isCompiled())
} // nbCompiled++;
Log.info("Regex total/invoked/compiled " + cache.size() + "/" + nbInvoked + "/" + nbCompiled); //
Log.info("Matches created " + nbCreateMatches.get()); // if (reg.invoked())
// nbInvoked++;
//
// }
// Log.info("Regex total/invoked/compiled " + nf.format(cache.size()) + "/" + nf.format(nbInvoked) + "/"
// + nf.format(nbCompiled));
// Log.info("Matches escaped " + nf.format(vescaped.get()) + "/" + nf.format(vtot.get()));
// Log.info("Matches created " + nf.format(nbCreateMatches.get()));
// }
} }
public RegexConcat(IRegex... partials) { public RegexConcat(IRegex... partials) {
@ -70,7 +74,8 @@ public final class RegexConcat extends RegexComposed implements IRegex {
} }
private long foxRegex() { private long foxRegex() {
if (foxRegex.get() == -1L) { final long result = foxRegex.get();
if (result == -1L) {
long tmp = 0L; long tmp = 0L;
for (int i = 1; i < partials().size() - 1; i++) { for (int i = 1; i < partials().size() - 1; i++) {
final IRegex part = partials().get(i); final IRegex part = partials().get(i);
@ -80,26 +85,27 @@ public final class RegexConcat extends RegexComposed implements IRegex {
} }
} }
foxRegex.set(tmp); foxRegex.set(tmp);
return tmp;
} }
return foxRegex.get(); return result;
} }
public static RegexConcat build(String key, IRegex... partials) { public static RegexConcat build(String key, IRegex... partials) {
// return buildInternal(partials); return buildInternal(partials);
RegexConcat result = cache.get(key); // RegexConcat result = cache.get(key);
if (result == null) { // if (result == null) {
cache.putIfAbsent(key, buildInternal(partials)); // cache.putIfAbsent(key, buildInternal(partials));
result = cache.get(key); // result = cache.get(key);
// System.err.println("cache size=" + cache.size()); // // System.err.println("cache size=" + cache.size());
// } else { // // } else {
// synchronized (PRINTED2) { // // synchronized (PRINTED2) {
// if (PRINTED2.contains(key) == false) { // // if (PRINTED2.contains(key) == false) {
// System.err.println("if (key.equals(\"" + key + "\")) return // // System.err.println("if (key.equals(\"" + key + "\")) return
// buildInternal(partials);"); // // buildInternal(partials);");
// } // // }
// PRINTED2.add(key); // // PRINTED2.add(key);
} // }
return result; // return result;
} }
private static RegexConcat buildInternal(IRegex... partials) { private static RegexConcat buildInternal(IRegex... partials) {
@ -113,20 +119,35 @@ public final class RegexConcat extends RegexComposed implements IRegex {
return foxRegex.get() != -1L; return foxRegex.get() != -1L;
} }
// static private final Set<String> PRINTED = new HashSet<>();
// static private final Set<String> ZERO = new HashSet<>();
@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;
// vtot.incrementAndGet();
final long foxRegex = foxRegex(); final long foxRegex = foxRegex();
// synchronized (PRINTED) {
// final String full = getFullSlow();
// final boolean added = PRINTED.add(full);
// if (added && foxRegex == 0L) {
// ZERO.add(full);
// System.err.println("PR " + ZERO.size() + "/" + PRINTED.size() + " "
// + FoxSignature.backToString(foxRegex) + " " + full);
// }
// }
if (foxRegex != 0L) { if (foxRegex != 0L) {
final long foxLine = s.getFoxSignature(); final long foxLine = s.getFoxSignature();
final long check = foxRegex & foxLine; final long check = foxRegex & foxLine;
// 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) {
// vescaped.incrementAndGet();
return false; return false;
}
} }
return super.match(s); return super.match(s);

View File

@ -41,6 +41,7 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.StringLocated;
@ -95,9 +96,9 @@ public class RegexLeaf implements IRegex {
} }
public int count() { public int count() {
if (count == -1) { if (count == -1)
count = MyPattern.cmpile(pattern).matcher("").groupCount(); count = MyPattern.cmpile(pattern).matcher("").groupCount();
}
return count; return count;
} }
@ -107,9 +108,9 @@ public class RegexLeaf implements IRegex {
final String group = it.next(); final String group = it.next();
m.add(group); m.add(group);
} }
if (name == null) { if (name == null)
return Collections.emptyMap(); return Collections.emptyMap();
}
return Collections.singletonMap(name, m); return Collections.singletonMap(name, m);
} }
@ -121,63 +122,52 @@ public class RegexLeaf implements IRegex {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
static private final Set<String> UNKNOWN = new HashSet<>(); // static private final Set<String> UNKNOWN = new HashSet<>();
static private final Pattern p1 = Pattern.compile("^[-0A-Za-z_!:@;/=,\"]+$"); static private final Pattern p1 = Pattern.compile(
static private final Pattern p2 = Pattern.compile("^[-0A-Za-z_!:@;/=,\"]+\\?$"); "^\\(?((?:[-0A-Za-z_!:@;/=,\" ][?+*]?|\\\\[b$(){}<>|*.+^\\[\\]][?+*]?|\\.\\*|\\.\\+)+)(?:\\)\\+|\\))?$");
static private final Pattern p3 = Pattern
.compile("^\\(?[-0A-Za-z_!:@;/=\" ]+\\??(\\|[-0A-Za-z_!:@;/=,\" ]+\\??)+\\)?$");
private static long getSignatureP3(String s) { static private final Pattern p2 = Pattern.compile("^\\([-?a-z ]+(\\|[-?a-z ]+)+\\)$");
static private final Pattern p3 = Pattern.compile("^\\(?\\[[-=.~]+\\]\\+\\)?$");
private static long getSignatureP2(String s) {
long result = -1L; long result = -1L;
for (StringTokenizer st = new StringTokenizer(s, "()|"); st.hasMoreTokens();) { for (StringTokenizer st = new StringTokenizer(s, "()|"); st.hasMoreTokens();) {
final String val = st.nextToken(); final String val = st.nextToken();
final long sig = FoxSignature.getFoxSignature(val.endsWith("?") ? val.substring(0, val.length() - 2) : val); result = result & FoxSignature.getFoxSignatureFromRegex(val);
result = result & sig;
} }
return result; return result;
} }
public long getFoxSignatureNone() {
return 0;
}
public long getFoxSignature() { public long getFoxSignature() {
if (p1.matcher(pattern).matches()) if (pattern.equals("[%s]+"))
return FoxSignature.getFoxSignature(pattern); return FoxSignature.getSpecialSpaces();
if (pattern.equals("[%s]*"))
if (p2.matcher(pattern).matches())
return FoxSignature.getFoxSignature(pattern.substring(0, pattern.length() - 2));
if (p3.matcher(pattern).matches())
return getSignatureP3(pattern);
if (pattern.length() == 2 && pattern.startsWith("\\") && Character.isLetterOrDigit(pattern.charAt(1)) == false)
return FoxSignature.getFoxSignature(pattern.substring(1));
if (pattern.equals("\\<\\>") || pattern.equals("(\\<\\<.*\\>\\>)"))
return FoxSignature.getFoxSignature("<>");
if (pattern.equals("\\<-\\>"))
return FoxSignature.getFoxSignature("<->");
if (pattern.equals("(-+)"))
return FoxSignature.getFoxSignature("-");
if (pattern.equals("\\|+") || pattern.equals("\\|\\|"))
return FoxSignature.getFoxSignature("|");
if (pattern.equals("([*]+)"))
return FoxSignature.getFoxSignature("*");
if (pattern.equals("[%s]+") || pattern.equals("[%s]*"))
return 0; return 0;
final String pattern2 = pattern.replaceAll("\\[%s\\][+*?]?|\\(\\[([^\\\\\\[\\]])+\\]\\)[+*?]?", "");
final Matcher m1 = p1.matcher(pattern2);
if (m1.matches())
return FoxSignature.getFoxSignatureFromRegex(m1.group(1));
final Matcher m2 = p2.matcher(pattern2);
if (m2.matches())
return getSignatureP2(pattern2);
final Matcher m3 = p3.matcher(pattern2);
if (m3.matches())
return FoxSignature.getSpecial1();
// synchronized (UNKNOWN) { // synchronized (UNKNOWN) {
// final boolean changed = UNKNOWN.add(pattern); // final boolean changed = UNKNOWN.add(pattern2);
// if (changed) // if (changed) {
// System.err.println("unknow=" + pattern); // if (pattern.equals(pattern2))
// // System.err.println("unknow=" + UNKNOWN.size() + " " + pattern);
// else
// System.err.println("unknow=" + UNKNOWN.size() + " " + pattern2 + " " + pattern);
// // Thread.dumpStack();
// }
// } // }
return 0; return 0;
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.compositediagram; package net.sourceforge.plantuml.compositediagram;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -58,15 +57,12 @@ public class CompositeDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
cmds.add(new CommandCreateBlock()); cmds.add(new CommandCreateBlock());
cmds.add(new CommandLinkBlock()); cmds.add(new CommandLinkBlock());
cmds.add(new CommandCreatePackageBlock()); cmds.add(new CommandCreatePackageBlock());
cmds.add(new CommandEndPackageBlock()); cmds.add(new CommandEndPackageBlock());
CommonCommands.addCommonCommands1(cmds); CommonCommands.addCommonCommands1(cmds);
return cmds;
} }
@Override @Override

View File

@ -61,22 +61,22 @@ public class CommandCreoleImg implements Command {
public int matchingSize(String line) { public int matchingSize(String line) {
final Matcher2 m = pattern.matcher(line); final Matcher2 m = pattern.matcher(line);
if (m.find() == false) { if (m.find() == false)
return 0; return 0;
}
return m.group(1).length(); return m.group(1).length();
} }
public String executeAndGetRemaining(String line, StripeSimple stripe) { public String executeAndGetRemaining(String line, StripeSimple stripe) {
final Matcher2 m = pattern.matcher(line); final Matcher2 m = pattern.matcher(line);
if (m.find() == false) { if (m.find() == false)
throw new IllegalStateException(); throw new IllegalStateException();
}
String src = m.group(2); String src = m.group(2);
final double scale = Parser.getScale(m.group(3), 1); final double scale = Parser.getScale(m.group(3), 1);
if (src.toLowerCase().startsWith("src=")) { if (src.toLowerCase().startsWith("src="))
src = src.substring(4); src = src.substring(4);
}
src = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(src, "\""); src = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(src, "\"");
stripe.addImage(src, scale); stripe.addImage(src, scale);
return line.substring(m.group(1).length()); return line.substring(m.group(1).length());

View File

@ -57,7 +57,6 @@ import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2; import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2; import net.sourceforge.plantuml.creole.SheetBlock2;

View File

@ -518,16 +518,6 @@ public class Link extends WithLinkType implements Hideable, Removeable {
} }
private UmlDiagramType umlType;
public void setUmlDiagramType(UmlDiagramType type) {
this.umlType = type;
}
public UmlDiagramType getUmlDiagramType() {
return umlType;
}
private LinkConstraint linkConstraint; private LinkConstraint linkConstraint;
public void setLinkConstraint(LinkConstraint linkConstraint) { public void setLinkConstraint(LinkConstraint linkConstraint) {

View File

@ -44,7 +44,6 @@ import java.util.List;
import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.EmbeddedDiagram;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.awt.geom.XDimension2D; import net.sourceforge.plantuml.awt.geom.XDimension2D;

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.descdiagram; package net.sourceforge.plantuml.descdiagram;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -74,9 +73,7 @@ public class DescriptionDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
cmds.add(new CommandFootboxIgnored()); cmds.add(new CommandFootboxIgnored());
cmds.add(new CommandNamespaceSeparator()); cmds.add(new CommandNamespaceSeparator());
cmds.add(new CommandRankDir()); cmds.add(new CommandRankDir());
@ -126,8 +123,6 @@ public class DescriptionDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandArchimate()); cmds.add(new CommandArchimate());
cmds.add(new CommandArchimateMultilines()); cmds.add(new CommandArchimateMultilines());
cmds.add(new CommandCreateDomain()); cmds.add(new CommandCreateDomain());
return cmds;
} }
} }

View File

@ -42,7 +42,6 @@ import net.sourceforge.plantuml.awt.geom.XDimension2D;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class ETileAlternation extends ETile { public class ETileAlternation extends ETile {

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.ebnf; package net.sourceforge.plantuml.ebnf;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -52,9 +51,7 @@ public class PSystemEbnfFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
CommonCommands.addCommonCommands1(cmds); CommonCommands.addCommonCommands1(cmds);
cmds.add(new CommandComment()); cmds.add(new CommandComment());
cmds.add(new CommandCommentMultilines2()); cmds.add(new CommandCommentMultilines2());
@ -62,8 +59,6 @@ public class PSystemEbnfFactory extends PSystemCommandFactory {
cmds.add(new CommandEBnfSingleLine()); cmds.add(new CommandEBnfSingleLine());
cmds.add(new CommandEbnfMultilines()); cmds.add(new CommandEbnfMultilines());
// cmds.add(new CommandNoteMultilines()); // cmds.add(new CommandNoteMultilines());
return cmds;
} }
@Override @Override

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.flowdiagram; package net.sourceforge.plantuml.flowdiagram;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -56,11 +55,9 @@ public class FlowDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
cmds.add(new CommandLineSimple()); cmds.add(new CommandLineSimple());
cmds.add(new CommandLink()); cmds.add(new CommandLink());
return cmds;
} }
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.help; package net.sourceforge.plantuml.help;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -51,10 +50,7 @@ public class HelpFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
cmds.add(new CommandHelp()); cmds.add(new CommandHelp());
cmds.add(new CommandHelpColor()); cmds.add(new CommandHelpColor());
cmds.add(new CommandHelpFont()); cmds.add(new CommandHelpFont());
@ -62,8 +58,6 @@ public class HelpFactory extends PSystemCommandFactory {
cmds.add(new CommandHelpSkinparam()); cmds.add(new CommandHelpSkinparam());
cmds.add(new CommandHelpType()); cmds.add(new CommandHelpType());
cmds.add(new CommandHelpTheme()); cmds.add(new CommandHelpTheme());
return cmds;
} }
} }

View File

@ -99,6 +99,7 @@ public class LatexBuilder implements ScientificEquation {
this.icon = icon; this.icon = icon;
} }
@Override
public BufferedImage getImage() { public BufferedImage getImage() {
if (cache == null) { if (cache == null) {
cache = new BufferedImage((int) (icon.getIconWidth() * scale), (int) (icon.getIconHeight() * scale), cache = new BufferedImage((int) (icon.getIconWidth() * scale), (int) (icon.getIconHeight() * scale),
@ -133,6 +134,11 @@ public class LatexBuilder implements ScientificEquation {
return this; return this;
} }
@Override
public double getScale() {
return scale;
}
} }
public String getSource() { public String getSource() {

View File

@ -55,7 +55,7 @@ public class CommandMindMapOrgmode extends SingleLineCommand2<MindMapDiagram> {
static IRegex getRegexConcat() { static IRegex getRegexConcat() {
return RegexConcat.build(CommandMindMapOrgmode.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandMindMapOrgmode.class.getName(), RegexLeaf.start(), //
new RegexLeaf("TYPE", "([ \t]*[*]+)"), // new RegexLeaf("TYPE", "([ \t]*\\*+)"), //
new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), // new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), //
new RegexLeaf("SHAPE", "(_)?"), // new RegexLeaf("SHAPE", "(_)?"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //

View File

@ -60,7 +60,7 @@ public class CommandMindMapOrgmodeMultiline extends CommandMultilines2<MindMapDi
static IRegex getRegexConcat() { static IRegex getRegexConcat() {
return RegexConcat.build(CommandMindMapOrgmodeMultiline.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandMindMapOrgmodeMultiline.class.getName(), RegexLeaf.start(), //
new RegexLeaf("TYPE", "([*]+)"), // new RegexLeaf("TYPE", "(\\*+)"), //
new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), // new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), //
new RegexLeaf("SHAPE", "(_)?"), // new RegexLeaf("SHAPE", "(_)?"), //
new RegexLeaf(":"), // new RegexLeaf(":"), //

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.mindmap; package net.sourceforge.plantuml.mindmap;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -53,9 +52,7 @@ public class MindMapDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
CommonCommands.addCommonCommands1(cmds); CommonCommands.addCommonCommands1(cmds);
// cmds.add(new CommandMindMapTabulation()); // cmds.add(new CommandMindMapTabulation());
cmds.add(new CommandRankDir()); cmds.add(new CommandRankDir());
@ -64,8 +61,6 @@ public class MindMapDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandMindMapRoot()); cmds.add(new CommandMindMapRoot());
cmds.add(new CommandMindMapPlus()); cmds.add(new CommandMindMapPlus());
cmds.add(new CommandMindMapDirection()); cmds.add(new CommandMindMapDirection());
return cmds;
} }
@Override @Override

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.nwdiag; package net.sourceforge.plantuml.nwdiag;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -58,9 +57,7 @@ public class NwDiagramFactory extends PSystemCommandFactory {
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
CommonCommands.addCommonCommands1(cmds); CommonCommands.addCommonCommands1(cmds);
cmds.add(new CommandNwDiagInit()); cmds.add(new CommandNwDiagInit());
cmds.add(new CommandComment()); cmds.add(new CommandComment());
@ -71,7 +68,6 @@ public class NwDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandProperty()); cmds.add(new CommandProperty());
cmds.add(new CommandEndSomething()); cmds.add(new CommandEndSomething());
cmds.add(new CommandFootboxIgnored()); cmds.add(new CommandFootboxIgnored());
return cmds;
} }
} }

View File

@ -35,9 +35,7 @@
*/ */
package net.sourceforge.plantuml.project; package net.sourceforge.plantuml.project;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -81,27 +79,25 @@ import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS;
public class GanttDiagramFactory extends PSystemCommandFactory { public class GanttDiagramFactory extends PSystemCommandFactory {
static private final List<Subject> subjects() { static private final List<Subject> subjects() {
return Arrays.<Subject>asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek(), return Arrays.<Subject>asList(SubjectTask.ME, SubjectProject.ME, SubjectDayOfWeek.ME, SubjectDayAsDate.ME,
new SubjectDayAsDate(), new SubjectDaysAsDates(), new SubjectResource(), new SubjectToday(), SubjectDaysAsDates.ME, SubjectResource.ME, SubjectToday.ME, SubjectSeparator.ME);
new SubjectSeparator());
} }
public GanttDiagramFactory(DiagramType type) { public GanttDiagramFactory() {
super(type); super(DiagramType.GANTT);
} }
@Override @Override
protected List<Command> createCommands() { protected void initCommandsList(List<Command> cmds) {
final List<Command> cmds = new ArrayList<>();
CommonCommands.addTitleCommands(cmds); CommonCommands.addTitleCommands(cmds);
CommonCommands.addCommonCommands2(cmds); CommonCommands.addCommonCommands2(cmds);
cmds.add(new CommandStyleMultilinesCSS()); cmds.add(CommandStyleMultilinesCSS.ME);
cmds.add(new CommandStyleImport()); cmds.add(CommandStyleImport.ME);
cmds.add(new CommandNope()); cmds.add(CommandNope.ME);
cmds.addAll(getLanguageCommands()); addLanguageCommands(cmds);
cmds.add(new CommandGanttArrow()); cmds.add(new CommandGanttArrow());
cmds.add(new CommandGanttArrow2()); cmds.add(new CommandGanttArrow2());
@ -119,48 +115,32 @@ public class GanttDiagramFactory extends PSystemCommandFactory {
cmds.add(new CommandLabelOnColumn()); cmds.add(new CommandLabelOnColumn());
cmds.add(new CommandHideResourceName()); cmds.add(new CommandHideResourceName());
cmds.add(new CommandHideResourceFootbox()); cmds.add(new CommandHideResourceFootbox());
return cmds;
} }
static private final Collection<Command> cache = new ArrayList<>(); private void addLanguageCommands(List<Command> cmd) {
for (Subject subject : subjects())
for (SentenceSimple sentenceA : subject.getSentences()) {
cmd.add(NaturalCommand.create(sentenceA));
for (SentenceSimple sentenceB : subject.getSentences()) {
final String signatureA = sentenceA.getSignature();
final String signatureB = sentenceB.getSignature();
if (signatureA.equals(signatureB) == false)
cmd.add(NaturalCommand.create(new SentenceAnd(sentenceA, sentenceB)));
public static void clearCache() { }
cache.clear();
}
private static Collection<Command> getLanguageCommands() {
// Useless synchronized now
synchronized (cache) {
if (cache.size() == 0) {
for (Subject subject : subjects())
for (SentenceSimple sentenceA : subject.getSentences()) {
cache.add(NaturalCommand.create(sentenceA));
for (SentenceSimple sentenceB : subject.getSentences()) {
final String signatureA = sentenceA.getSignature();
final String signatureB = sentenceB.getSignature();
if (signatureA.equals(signatureB) == false)
cache.add(NaturalCommand.create(new SentenceAnd(sentenceA, sentenceB)));
}
}
for (Subject subject : subjects())
for (SentenceSimple sentenceA : subject.getSentences())
for (SentenceSimple sentenceB : subject.getSentences())
for (SentenceSimple sentenceC : subject.getSentences()) {
final String signatureA = sentenceA.getSignature();
final String signatureB = sentenceB.getSignature();
final String signatureC = sentenceC.getSignature();
if (signatureA.equals(signatureB) == false && signatureA.equals(signatureC) == false
&& signatureC.equals(signatureB) == false)
cache.add(
NaturalCommand.create(new SentenceAndAnd(sentenceA, sentenceB, sentenceC)));
}
} }
}
return cache; for (Subject subject : subjects())
for (SentenceSimple sentenceA : subject.getSentences())
for (SentenceSimple sentenceB : subject.getSentences())
for (SentenceSimple sentenceC : subject.getSentences()) {
final String signatureA = sentenceA.getSignature();
final String signatureB = sentenceB.getSignature();
final String signatureC = sentenceC.getSignature();
if (signatureA.equals(signatureB) == false && signatureA.equals(signatureC) == false
&& signatureC.equals(signatureB) == false)
cmd.add(NaturalCommand.create(new SentenceAndAnd(sentenceA, sentenceB, sentenceC)));
}
} }
@Override @Override

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.project.core.Task;
public class SentenceDisplayOnSameRowAs extends SentenceSimple { public class SentenceDisplayOnSameRowAs extends SentenceSimple {
public SentenceDisplayOnSameRowAs() { public SentenceDisplayOnSameRowAs() {
super(new SubjectTask(), Verbs.displayOnSameRowAs(), new ComplementNamed()); super(SubjectTask.ME, Verbs.displayOnSameRowAs, new ComplementNamed());
} }
@Override @Override

View File

@ -45,7 +45,7 @@ import net.sourceforge.plantuml.project.core.TaskInstant;
public class SentenceEnds extends SentenceSimple { public class SentenceEnds extends SentenceSimple {
public SentenceEnds() { public SentenceEnds() {
super(new SubjectTask(), Verbs.ends(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); super(SubjectTask.ME, Verbs.ends, new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
} }
@Override @Override

View File

@ -44,7 +44,7 @@ import net.sourceforge.plantuml.project.core.TaskInstant;
public class SentenceHappens extends SentenceSimple { public class SentenceHappens extends SentenceSimple {
public SentenceHappens() { public SentenceHappens() {
super(new SubjectTask(), Verbs.happens(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); super(SubjectTask.ME, Verbs.happens, new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
} }
@Override @Override

View File

@ -44,7 +44,7 @@ import net.sourceforge.plantuml.project.time.Day;
public class SentenceHappensDate extends SentenceSimple { public class SentenceHappensDate extends SentenceSimple {
public SentenceHappensDate() { public SentenceHappensDate() {
super(new SubjectTask(), Verbs.happens(), new ComplementDate()); super(SubjectTask.ME, Verbs.happens, new ComplementDate());
} }
@Override @Override

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.project.core.Task;
public class SentenceIsColored extends SentenceSimple { public class SentenceIsColored extends SentenceSimple {
public SentenceIsColored() { public SentenceIsColored() {
super(new SubjectTask(), Verbs.isColored(), new ComplementInColors()); super(SubjectTask.ME, Verbs.isColored, new ComplementInColors());
} }
@Override @Override

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.project.core.Task;
public class SentenceIsColoredForCompletion extends SentenceSimple { public class SentenceIsColoredForCompletion extends SentenceSimple {
public SentenceIsColoredForCompletion() { public SentenceIsColoredForCompletion() {
super(new SubjectTask(), Verbs.isColoredForCompletion(), new ComplementInColorsFromTo()); super(SubjectTask.ME, Verbs.isColoredForCompletion, new ComplementInColorsFromTo());
} }
@Override @Override

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.project.core.Task;
public class SentenceIsDeleted extends SentenceSimple { public class SentenceIsDeleted extends SentenceSimple {
public SentenceIsDeleted() { public SentenceIsDeleted() {
super(new SubjectTask(), Verbs.isDeleted(), new ComplementEmpty()); super(SubjectTask.ME, Verbs.isDeleted, new ComplementEmpty());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.core.Task;
public class SentenceIsForTask extends SentenceSimple { public class SentenceIsForTask extends SentenceSimple {
public SentenceIsForTask() { public SentenceIsForTask() {
super(new SubjectTask(), Verbs.is(), new ComplementCompleted()); super(SubjectTask.ME, Verbs.is, new ComplementCompleted());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.core.Task;
public class SentenceLasts extends SentenceSimple { public class SentenceLasts extends SentenceSimple {
public SentenceLasts() { public SentenceLasts() {
super(new SubjectTask(), Verbs.lasts(), new ComplementSeveralDays()); super(SubjectTask.ME, Verbs.lasts, new ComplementSeveralDays());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.core.Task;
public class SentenceLinksTo extends SentenceSimple { public class SentenceLinksTo extends SentenceSimple {
public SentenceLinksTo() { public SentenceLinksTo() {
super(new SubjectTask(), Verbs.linksTo(), new ComplementUrl()); super(SubjectTask.ME, Verbs.linksTo, new ComplementUrl());
} }
@Override @Override

View File

@ -45,7 +45,7 @@ import net.sourceforge.plantuml.project.core.TaskInstant;
public class SentenceOccurs extends SentenceSimple { public class SentenceOccurs extends SentenceSimple {
public SentenceOccurs() { public SentenceOccurs() {
super(new SubjectTask(), Verbs.occurs(), new ComplementFromTo()); super(SubjectTask.ME, Verbs.occurs, new ComplementFromTo());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.time.Day;
public class SentencePausesDate extends SentenceSimple { public class SentencePausesDate extends SentenceSimple {
public SentencePausesDate() { public SentencePausesDate() {
super(new SubjectTask(), Verbs.pauses(), new ComplementDate()); super(SubjectTask.ME, Verbs.pauses, new ComplementDate());
} }
@Override @Override

View File

@ -44,7 +44,7 @@ import net.sourceforge.plantuml.project.time.Day;
public class SentencePausesDates extends SentenceSimple { public class SentencePausesDates extends SentenceSimple {
public SentencePausesDates() { public SentencePausesDates() {
super(new SubjectTask(), Verbs.pauses(), new ComplementDates()); super(SubjectTask.ME, Verbs.pauses, new ComplementDates());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.time.DayOfWeek;
public class SentencePausesDayOfWeek extends SentenceSimple { public class SentencePausesDayOfWeek extends SentenceSimple {
public SentencePausesDayOfWeek() { public SentencePausesDayOfWeek() {
super(new SubjectTask(), Verbs.pauses(), new ComplementDayOfWeek()); super(SubjectTask.ME, Verbs.pauses, new ComplementDayOfWeek());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.time.Day;
public class SentenceTaskEndsAbsolute extends SentenceSimple { public class SentenceTaskEndsAbsolute extends SentenceSimple {
public SentenceTaskEndsAbsolute() { public SentenceTaskEndsAbsolute() {
super(new SubjectTask(), Verbs.ends2(), new ComplementDate()); super(SubjectTask.ME, Verbs.ends2, new ComplementDate());
} }
@Override @Override

View File

@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class SentenceTaskStarts extends SentenceSimple { public class SentenceTaskStarts extends SentenceSimple {
public SentenceTaskStarts() { public SentenceTaskStarts() {
super(new SubjectTask(), Verbs.starts2(), new ComplementBeforeOrAfterOrAtTaskStartOrEnd()); super(SubjectTask.ME, Verbs.starts2, new ComplementBeforeOrAfterOrAtTaskStartOrEnd());
} }
@Override @Override

View File

@ -43,7 +43,7 @@ import net.sourceforge.plantuml.project.time.Day;
public class SentenceTaskStartsAbsolute extends SentenceSimple { public class SentenceTaskStartsAbsolute extends SentenceSimple {
public SentenceTaskStartsAbsolute() { public SentenceTaskStartsAbsolute() {
super(new SubjectTask(), Verbs.starts3(), new ComplementDate()); super(SubjectTask.ME, Verbs.starts3, new ComplementDate());
} }
@Override @Override

View File

@ -46,7 +46,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class SentenceTaskStartsWithColor extends SentenceSimple { public class SentenceTaskStartsWithColor extends SentenceSimple {
public SentenceTaskStartsWithColor() { public SentenceTaskStartsWithColor() {
super(new SubjectTask(), Verbs.starts2(), super(SubjectTask.ME, Verbs.starts2,
new PairOfSomething(new ComplementBeforeOrAfterOrAtTaskStartOrEnd(), new ComplementWithColorLink())); new PairOfSomething(new ComplementBeforeOrAfterOrAtTaskStartOrEnd(), new ComplementWithColorLink()));
} }

View File

@ -51,13 +51,18 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class SubjectDayAsDate implements Subject { public class SubjectDayAsDate implements Subject {
public static final Subject ME = new SubjectDayAsDate();
private SubjectDayAsDate() {
}
public Failable<Day> getMe(GanttDiagram project, RegexResult arg) { public Failable<Day> getMe(GanttDiagram project, RegexResult arg) {
if (arg.get("BDAY", 0) != null) { if (arg.get("BDAY", 0) != null)
return Failable.ok(resultB(arg)); return Failable.ok(resultB(arg));
}
if (arg.get("ECOUNT", 0) != null) { if (arg.get("ECOUNT", 0) != null)
return Failable.ok(resultE(project, arg)); return Failable.ok(resultE(project, arg));
}
throw new IllegalStateException(); throw new IllegalStateException();
} }
@ -81,7 +86,7 @@ public class SubjectDayAsDate implements Subject {
class Close extends SentenceSimple { class Close extends SentenceSimple {
public Close() { public Close() {
super(SubjectDayAsDate.this, Verbs.isOrAre(), new ComplementClose()); super(SubjectDayAsDate.this, Verbs.isOrAre, new ComplementClose());
} }
@Override @Override
@ -93,7 +98,7 @@ public class SubjectDayAsDate implements Subject {
class Open extends SentenceSimple { class Open extends SentenceSimple {
public Open() { public Open() {
super(SubjectDayAsDate.this, Verbs.isOrAre(), new ComplementOpen()); super(SubjectDayAsDate.this, Verbs.isOrAre, new ComplementOpen());
} }
@Override @Override
@ -106,7 +111,7 @@ public class SubjectDayAsDate implements Subject {
class InColor extends SentenceSimple { class InColor extends SentenceSimple {
public InColor() { public InColor() {
super(SubjectDayAsDate.this, Verbs.isOrAre(), new ComplementInColors2()); super(SubjectDayAsDate.this, Verbs.isOrAre, new ComplementInColors2());
} }
@Override @Override

View File

@ -49,6 +49,11 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class SubjectDayOfWeek implements Subject { public class SubjectDayOfWeek implements Subject {
public static final Subject ME = new SubjectDayOfWeek();
private SubjectDayOfWeek() {
}
public IRegex toRegex() { public IRegex toRegex() {
return new RegexLeaf("SUBJECT", "(" + DayOfWeek.getRegexString() + ")"); return new RegexLeaf("SUBJECT", "(" + DayOfWeek.getRegexString() + ")");
} }
@ -64,7 +69,7 @@ public class SubjectDayOfWeek implements Subject {
class AreOpen extends SentenceSimple { class AreOpen extends SentenceSimple {
public AreOpen() { public AreOpen() {
super(SubjectDayOfWeek.this, Verbs.are(), new ComplementOpen()); super(SubjectDayOfWeek.this, Verbs.are, new ComplementOpen());
} }
@Override @Override
@ -78,7 +83,7 @@ public class SubjectDayOfWeek implements Subject {
class AreClose extends SentenceSimple { class AreClose extends SentenceSimple {
public AreClose() { public AreClose() {
super(SubjectDayOfWeek.this, Verbs.are(), new ComplementClose()); super(SubjectDayOfWeek.this, Verbs.are, new ComplementClose());
} }
@Override @Override
@ -93,7 +98,7 @@ public class SubjectDayOfWeek implements Subject {
class InColor extends SentenceSimple { class InColor extends SentenceSimple {
public InColor() { public InColor() {
super(SubjectDayOfWeek.this, Verbs.isOrAre(), new ComplementInColors2()); super(SubjectDayOfWeek.this, Verbs.isOrAre, new ComplementInColors2());
} }
@Override @Override

View File

@ -52,6 +52,11 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
public class SubjectDaysAsDates implements Subject { public class SubjectDaysAsDates implements Subject {
public static final Subject ME = new SubjectDaysAsDates();
private SubjectDaysAsDates() {
}
public IRegex toRegex() { public IRegex toRegex() {
return new RegexOr(toRegexB(), toRegexE(), andRegex(), thenRegex()); return new RegexOr(toRegexB(), toRegexE(), andRegex(), thenRegex());
} }
@ -153,7 +158,7 @@ public class SubjectDaysAsDates implements Subject {
class Close extends SentenceSimple { class Close extends SentenceSimple {
public Close() { public Close() {
super(SubjectDaysAsDates.this, Verbs.isOrAre(), new ComplementClose()); super(SubjectDaysAsDates.this, Verbs.isOrAre, new ComplementClose());
} }
@Override @Override
@ -169,7 +174,7 @@ public class SubjectDaysAsDates implements Subject {
class Open extends SentenceSimple { class Open extends SentenceSimple {
public Open() { public Open() {
super(SubjectDaysAsDates.this, Verbs.isOrAre(), new ComplementOpen()); super(SubjectDaysAsDates.this, Verbs.isOrAre, new ComplementOpen());
} }
@Override @Override
@ -186,7 +191,7 @@ public class SubjectDaysAsDates implements Subject {
class InColor extends SentenceSimple { class InColor extends SentenceSimple {
public InColor() { public InColor() {
super(SubjectDaysAsDates.this, Verbs.isOrAre(), new ComplementInColors2()); super(SubjectDaysAsDates.this, Verbs.isOrAre, new ComplementInColors2());
} }
@Override @Override
@ -204,7 +209,7 @@ public class SubjectDaysAsDates implements Subject {
class Named extends SentenceSimple { class Named extends SentenceSimple {
public Named() { public Named() {
super(SubjectDaysAsDates.this, Verbs.isOrAreNamed(), new ComplementNamed()); super(SubjectDaysAsDates.this, Verbs.isOrAreNamed, new ComplementNamed());
} }
@Override @Override

Some files were not shown because too many files have changed in this diff Show More