1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-31 15:40:48 +00:00
plantuml/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java

122 lines
4.6 KiB
Java
Raw Normal View History

2013-12-10 19:36:50 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2015-04-07 18:18:37 +00:00
* (C) Copyright 2009-2014, Arnaud Roques
2013-12-10 19:36:50 +00:00
*
* 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: 7920 $
*
*/
package net.sourceforge.plantuml.descdiagram;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.classdiagram.command.CommandUrl;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandEndPackage;
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.command.CommandFootboxIgnored;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.command.CommandPackage;
import net.sourceforge.plantuml.command.CommandPage;
import net.sourceforge.plantuml.command.CommandRankDir;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
import net.sourceforge.plantuml.command.note.FactoryNoteCommand;
import net.sourceforge.plantuml.command.note.FactoryNoteOnEntityCommand;
import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.descdiagram.command.CommandCreateElementFull;
import net.sourceforge.plantuml.descdiagram.command.CommandCreateElementMultilines;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
2015-04-07 18:18:37 +00:00
import net.sourceforge.plantuml.descdiagram.command.CommandNamespaceSeparator;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.descdiagram.command.CommandNewpage;
import net.sourceforge.plantuml.descdiagram.command.CommandPackageWithUSymbol;
public class DescriptionDiagramFactory extends UmlDiagramFactory {
@Override
public DescriptionDiagram createEmptyDiagram() {
return new DescriptionDiagram();
}
@Override
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
2015-04-07 18:18:37 +00:00
cmds.add(new CommandFootboxIgnored());
cmds.add(new CommandNamespaceSeparator());
2013-12-10 19:36:50 +00:00
cmds.add(new CommandRankDir());
cmds.add(new CommandNewpage(this));
addCommonCommands(cmds);
cmds.add(new CommandPage());
cmds.add(new CommandLinkElement());
//
cmds.add(new CommandPackageWithUSymbol());
cmds.add(new CommandEndPackage());
final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
cmds.add(factoryNoteCommand.createMultiLine());
final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexOr(
"ENTITY", //
new RegexLeaf("[\\p{L}0-9_.]+"), //
2015-04-07 18:18:37 +00:00
new RegexLeaf("\\(\\)[%s]*[\\p{L}0-9_.]+"), //
new RegexLeaf("\\(\\)[%s]*[%g][^%g]+[%g]"), //
2013-12-10 19:36:50 +00:00
new RegexLeaf("\\[[^\\]*]+[^\\]]*\\]"), //
new RegexLeaf("\\((?!\\*\\))[^\\)]+\\)"), //
new RegexLeaf(":[^:]+:"), //
2015-04-07 18:18:37 +00:00
new RegexLeaf("[%g][^%g]+[%g]") //
2013-12-10 19:36:50 +00:00
));
cmds.add(factoryNoteOnEntityCommand.createSingleLine());
cmds.add(factoryNoteCommand.createSingleLine());
cmds.add(new CommandUrl());
cmds.add(new CommandCreateElementFull());
2015-07-11 09:32:49 +00:00
cmds.add(new CommandCreateElementMultilines(0));
cmds.add(new CommandCreateElementMultilines(1));
2013-12-10 19:36:50 +00:00
cmds.add(factoryNoteOnEntityCommand.createMultiLine());
cmds.add(factoryNoteCommand.createMultiLine());
final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
cmds.add(factoryNoteOnLinkCommand.createSingleLine());
cmds.add(factoryNoteOnLinkCommand.createMultiLine());
return cmds;
}
@Override
public String checkFinalError(AbstractPSystem system) {
if (system instanceof DescriptionDiagram) {
((DescriptionDiagram) system).applySingleStrategy();
}
return super.checkFinalError(system);
}
}