1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-29 22:50:48 +00:00
plantuml/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java

108 lines
3.8 KiB
Java
Raw Normal View History

2013-12-10 19:36:50 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2019-01-16 18:34:41 +00:00
* (C) Copyright 2009-2020, Arnaud Roques
2013-12-10 19:36:50 +00:00
*
2016-03-06 16:47:34 +00:00
* Project Info: http://plantuml.com
2013-12-10 19:36:50 +00:00
*
2017-03-15 19:13:31 +00:00
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
2013-12-10 19:36:50 +00:00
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.activitydiagram3.command;
import java.util.List;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
2015-06-20 10:54:49 +00:00
import net.sourceforge.plantuml.command.BlocLines;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines2;
import net.sourceforge.plantuml.command.MultilinesStrategy;
2019-06-26 19:24:49 +00:00
import net.sourceforge.plantuml.command.regex.IRegex;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.command.regex.RegexOr;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.command.regex.RegexResult;
2019-01-16 18:34:41 +00:00
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
2016-05-19 18:41:37 +00:00
import net.sourceforge.plantuml.graphic.Rainbow;
2013-12-10 19:36:50 +00:00
public class CommandArrowLong3 extends CommandMultilines2<ActivityDiagram3> {
public CommandArrowLong3() {
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
}
@Override
public String getPatternEnd() {
return "^(.*);$";
}
2019-06-26 19:24:49 +00:00
static IRegex getRegexConcat() {
return RegexConcat.build(CommandArrowLong3.class.getName(), RegexLeaf.start(), //
2015-04-07 18:18:37 +00:00
new RegexOr(//
new RegexLeaf("->"), //
2019-01-16 18:34:41 +00:00
new RegexLeaf("COLOR", CommandLinkElement.STYLE_COLORS_MULTIPLES)), //
2019-06-26 19:24:49 +00:00
RegexLeaf.spaceZeroOrMore(), //
2013-12-10 19:36:50 +00:00
new RegexLeaf("LABEL", "(.*)"), //
2019-06-26 19:24:49 +00:00
RegexLeaf.end());
2013-12-10 19:36:50 +00:00
}
2019-09-22 17:20:16 +00:00
@Override
2018-06-12 20:50:45 +00:00
protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
2015-06-20 10:54:49 +00:00
lines = lines.removeEmptyColumns();
2019-06-26 19:24:49 +00:00
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString());
2016-05-19 18:41:37 +00:00
// final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
2019-08-26 17:07:21 +00:00
// diagram.setColorNextArrow(Rainbow.fromColor(color));
2016-05-19 18:41:37 +00:00
final String colorString = line0.get("COLOR", 0);
if (colorString != null) {
Rainbow rainbow = Rainbow.build(diagram.getSkinParam(), colorString, diagram.getSkinParam()
.colorArrowSeparationSpace());
diagram.setColorNextArrow(rainbow);
}
2015-06-20 10:54:49 +00:00
lines = lines.removeStartingAndEnding2(line0.get("LABEL", 0));
diagram.setLabelNextArrow(lines.toDisplay());
2013-12-10 19:36:50 +00:00
return CommandExecutionResult.ok();
}
2015-06-20 10:54:49 +00:00
private <CS extends CharSequence> void removeStarting(List<CS> lines, String data) {
2013-12-10 19:36:50 +00:00
if (lines.size() == 0) {
return;
}
2016-05-11 21:31:47 +00:00
lines.set(0, (CS) data);
2013-12-10 19:36:50 +00:00
}
2015-06-20 10:54:49 +00:00
private <CS extends CharSequence> void removeEnding(List<CS> lines) {
2013-12-10 19:36:50 +00:00
if (lines.size() == 0) {
return;
}
final int n = lines.size() - 1;
2015-06-20 10:54:49 +00:00
final CharSequence s = lines.get(n);
2016-05-11 21:31:47 +00:00
lines.set(n, (CS) s.subSequence(0, s.length() - 1));
2013-12-10 19:36:50 +00:00
}
}