1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-02 00:20:49 +00:00
plantuml/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java

79 lines
2.9 KiB
Java
Raw Normal View History

2017-02-01 18:55:51 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2023-02-22 18:43:48 +00:00
* (C) Copyright 2009-2024, Arnaud Roques
2017-02-01 18:55:51 +00:00
*
2023-02-22 18:43:48 +00:00
* Project Info: https://plantuml.com
2017-02-01 18:55:51 +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:
*
2023-02-22 18:43:48 +00:00
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
2017-03-15 19:13:31 +00:00
*
2017-02-01 18:55:51 +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
*
*
*/
2019-03-01 22:16:29 +00:00
package net.sourceforge.plantuml.mindmap;
2017-02-01 18:55:51 +00:00
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.color.NoSuchColorException;
2023-02-22 18:43:48 +00:00
import net.sourceforge.plantuml.klimt.creole.Display;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.regex.IRegex;
import net.sourceforge.plantuml.regex.RegexConcat;
import net.sourceforge.plantuml.regex.RegexLeaf;
import net.sourceforge.plantuml.regex.RegexOptional;
import net.sourceforge.plantuml.regex.RegexResult;
2022-12-17 11:01:10 +00:00
import net.sourceforge.plantuml.utils.LineLocation;
2017-02-01 18:55:51 +00:00
2019-03-01 22:16:29 +00:00
public class CommandMindMapOrgmode extends SingleLineCommand2<MindMapDiagram> {
2017-02-01 18:55:51 +00:00
2019-03-01 22:16:29 +00:00
public CommandMindMapOrgmode() {
super(false, getRegexConcat());
2017-02-01 18:55:51 +00:00
}
2019-06-26 19:24:49 +00:00
static IRegex getRegexConcat() {
return RegexConcat.build(CommandMindMapOrgmode.class.getName(), RegexLeaf.start(), //
new RegexLeaf("TYPE", "([ \t]*[*#]+)"), //
2019-06-26 19:24:49 +00:00
new RegexOptional(new RegexLeaf("BACKCOLOR", "\\[(#\\w+)\\]")), //
2019-03-01 22:16:29 +00:00
new RegexLeaf("SHAPE", "(_)?"), //
2019-06-26 19:24:49 +00:00
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("LABEL", "([^%s].*)"), RegexLeaf.end());
2017-02-01 18:55:51 +00:00
}
@Override
2021-05-06 21:23:05 +00:00
protected CommandExecutionResult executeArg(MindMapDiagram diagram, LineLocation location, RegexResult arg)
throws NoSuchColorException {
2019-03-01 22:16:29 +00:00
final String type = arg.get("TYPE", 0);
final String label = arg.get("LABEL", 0);
2019-06-26 19:24:49 +00:00
final String stringColor = arg.get("BACKCOLOR", 0);
2020-03-18 10:50:02 +00:00
HColor backColor = null;
2022-10-18 20:57:44 +00:00
if (stringColor != null)
2022-09-18 17:08:06 +00:00
backColor = diagram.getSkinParam().getIHtmlColorSet().getColor(stringColor);
2022-10-18 20:57:44 +00:00
2021-05-06 21:23:05 +00:00
return diagram.addIdea(backColor, diagram.getSmartLevel(type), Display.getWithNewlines(label),
2019-09-22 17:20:16 +00:00
IdeaShape.fromDesc(arg.get("SHAPE", 0)));
2017-02-01 18:55:51 +00:00
}
}