diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2020-03-10 16:38:20 +0100 |
---|---|---|
committer | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2020-03-10 16:38:20 +0100 |
commit | 7cc8c823de644a510fcc434f39b53e5fffe66bfd (patch) | |
tree | 8f4d027284bb366734f610040c621a0c5dd0a12a /src/net/sourceforge/plantuml/command/CommandScaleMaxWidthAndHeight.java | |
parent | 567b200b91537405689ae0ca944f121201360a6b (diff) |
New upstream version 1.2020.2
Diffstat (limited to 'src/net/sourceforge/plantuml/command/CommandScaleMaxWidthAndHeight.java')
-rw-r--r-- | src/net/sourceforge/plantuml/command/CommandScaleMaxWidthAndHeight.java | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/net/sourceforge/plantuml/command/CommandScaleMaxWidthAndHeight.java b/src/net/sourceforge/plantuml/command/CommandScaleMaxWidthAndHeight.java index e777c3b..05ec0ed 100644 --- a/src/net/sourceforge/plantuml/command/CommandScaleMaxWidthAndHeight.java +++ b/src/net/sourceforge/plantuml/command/CommandScaleMaxWidthAndHeight.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * (C) Copyright 2009-2017, Arnaud Roques + * (C) Copyright 2009-2020, Arnaud Roques * * Project Info: http://plantuml.com * @@ -35,21 +35,37 @@ */ package net.sourceforge.plantuml.command; -import java.util.List; - import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.ScaleMaxWidthAndHeight; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; -public class CommandScaleMaxWidthAndHeight extends SingleLineCommand<AbstractPSystem> { +public class CommandScaleMaxWidthAndHeight extends SingleLineCommand2<AbstractPSystem> { public CommandScaleMaxWidthAndHeight() { - super("(?i)^scale[%s]+max[%s]+([0-9.]+)[%s]*[*x][%s]*([0-9.]+)$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandScaleMaxWidthAndHeight.class.getName(), RegexLeaf.start(), // + new RegexLeaf("scale"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("max"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("WIDTH", "([0-9.]+)"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("[*x]"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("HEIGHT", "([0-9.]+)"), RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(AbstractPSystem diagram, List<String> arg) { - final double width = Double.parseDouble(arg.get(0)); - final double height = Double.parseDouble(arg.get(1)); + protected CommandExecutionResult executeArg(AbstractPSystem diagram, LineLocation location, RegexResult arg) { + final double width = Double.parseDouble(arg.get("WIDTH", 0)); + final double height = Double.parseDouble(arg.get("HEIGHT", 0)); diagram.setScale(new ScaleMaxWidthAndHeight(width, height)); return CommandExecutionResult.ok(); } |