All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.plantuml.command.CommandSpriteSvg Maven / Gradle / Ivy

There is a newer version: 1.2025.0
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.command;

import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.emoji.SvgNanoParser;
import net.sourceforge.plantuml.regex.IRegex;
import net.sourceforge.plantuml.regex.RegexConcat;
import net.sourceforge.plantuml.regex.RegexLeaf;
import net.sourceforge.plantuml.regex.RegexResult;
import net.sourceforge.plantuml.utils.LineLocation;

public class CommandSpriteSvg extends SingleLineCommand2 {

	public static final CommandSpriteSvg ME = new CommandSpriteSvg();

	private CommandSpriteSvg() {
		super(getRegexConcat());
	}

	private static IRegex getRegexConcat() {
		return RegexConcat.build(CommandSpriteSvg.class.getName(), RegexLeaf.start(), //
				new RegexLeaf("sprite"), //
				RegexLeaf.spaceOneOrMore(), //
				new RegexLeaf("\\$?"), //
				new RegexLeaf("NAME", "([-%pLN_]+)"), //
				RegexLeaf.spaceOneOrMore(), //
				new RegexLeaf("SVG", "(\\)"), RegexLeaf.end());
	}

	@Override
	protected CommandExecutionResult executeArg(TitledDiagram system, LineLocation location, RegexResult arg) {
		final String svg = arg.get("SVG", 0);
		final SvgNanoParser nanoParser = new SvgNanoParser(svg, true);
		system.addSprite(arg.get("NAME", 0), nanoParser);

		return CommandExecutionResult.ok();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy