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

net.sourceforge.plantuml.sequencediagram.command.CommandArrowCrossX Maven / Gradle / Ivy

Go to download

PlantUML is a component that allows to quickly write : * sequence diagram, * use case diagram, * class diagram, * activity diagram, * component diagram, * state diagram * object diagram

There is a newer version: 8059
Show newest version
/* ========================================================================
 * PlantUML : a free UML diagram generator
 * ========================================================================
 *
 * (C) Copyright 2009-2013, Arnaud Roques
 *
 * Project Info:  http://plantuml.sourceforge.net
 * 
 * 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.
 *
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
 * in the United States and other countries.]
 *
 * Original Author:  Arnaud Roques
 * 
 * Revision $Revision: 5424 $
 *
 */
package net.sourceforge.plantuml.sequencediagram.command;

import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.sequencediagram.Message;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowDecoration;

public class CommandArrowCrossX extends SingleLineCommand2 {

	public CommandArrowCrossX() {
		super(getRegexConcat());
	}

	static RegexConcat getRegexConcat() {
		return new RegexConcat(new RegexLeaf("^"), //
				new RegexOr("PART1", //
						new RegexLeaf("PART1CODE", "([\\p{L}0-9_.@]+)"), //
						new RegexLeaf("PART1LONG", "\"([^\"]+)\""), //
						new RegexLeaf("PART1LONGCODE", "\"([^\"]+)\"\\s*as\\s+([\\p{L}0-9_.@]+)"), //
						new RegexLeaf("PART1CODELONG", "([\\p{L}0-9_.@]+)\\s+as\\s*\"([^\"]+)\"")), new RegexLeaf(
						"\\s*"), //
				new RegexLeaf("\\s+"), // 
				new RegexLeaf("ARROW", "([=-]+(>?x)|(x>") || arrow.startsWith("<<")
		// || arrow.contains("\\\\")
		// || arrow.contains("//");

		final boolean dotted = arrow.contains("--");

		final Display labels;
		if (arg2.get("MESSAGE", 0) == null) {
			labels = Display.asList("");
		} else {
			labels = Display.getWithNewlines(arg2.get("MESSAGE", 0));
		}

		ArrowConfiguration config = ArrowConfiguration.withDirectionNormal();
		if (dotted) {
			config = config.withDotted();
		}
		config = config.withDecorationEnd(ArrowDecoration.CROSSX_toberemoved);
		// if (sync) {
		// config = config.withAsync();
		// }
		// if (arrow.endsWith("\\") || arrow.startsWith("/")) {
		// config = config.withPart(ArrowPart.TOP_PART);
		// }
		// if (arrow.endsWith("/") || arrow.startsWith("\\")) {
		// config = config.withPart(ArrowPart.BOTTOM_PART);
		// }

		final String error = system.addMessage(
				new Message(p1, p2, labels, config, system.getNextMessageNumber()));
		if (error != null) {
			return CommandExecutionResult.error(error);
		}

		// if (system.isAutoactivate()) {
		// if (p1 != p2 && config.isASync() == false) {
		// if (config.isDotted()) {
		// system.activate(p1, LifeEventType.DEACTIVATE, null);
		// } else {
		// system.activate(p2, LifeEventType.ACTIVATE, null);
		// }
		// }
		// } else {
		// if (deactivatep1) {
		// system.activate(p1, LifeEventType.DEACTIVATE, null);
		// }
		// if (activatep2) {
		// system.activate(p2, LifeEventType.ACTIVATE, null);
		// }
		// }
		return CommandExecutionResult.ok();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy