summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/classdiagram
diff options
context:
space:
mode:
authorChristopher Hoskin <mans0954@debian.org>2017-09-08 19:57:06 +0100
committerChristopher Hoskin <mans0954@debian.org>2017-09-08 19:57:06 +0100
commit277c886dbbaa9ac62798e87272c7ead5795033f8 (patch)
tree309f666741dddb2f914ab224d98b6ca32d8e228a /src/net/sourceforge/plantuml/classdiagram
parentf9dab4abce6df0e9b5121895cc6e94823c2dece3 (diff)
New upstream version 1.2017.15
Diffstat (limited to 'src/net/sourceforge/plantuml/classdiagram')
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java137
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java488
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java327
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/FullLayout.java123
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/RowLayout.java143
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java127
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java125
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java377
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java474
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java409
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java125
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java (renamed from src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow.java)401
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java (renamed from src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow3.java)281
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java162
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java135
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java223
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java125
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java1179
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java456
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java119
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java127
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java147
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java113
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java175
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java223
25 files changed, 3395 insertions, 3326 deletions
diff --git a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java
index c02fd34..9a85d95 100644
--- a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java
+++ b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java
@@ -1,64 +1,73 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import net.sourceforge.plantuml.core.DiagramDescription;
-import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
-import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
-
-public abstract class AbstractEntityDiagram extends CucaDiagram {
-
- final protected List<String> getDotStrings() {
- final List<String> def = Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];",
- "node [fontsize=11,height=.35,width=.55];");
- if (getPragma().isDefine("graphattributes") == false) {
- return def;
- }
- final String attribute = getPragma().getValue("graphattributes");
- final List<String> result = new ArrayList<String>(def);
- result.add(attribute);
- return Collections.unmodifiableList(result);
- }
-
- final public DiagramDescription getDescription() {
- return new DiagramDescriptionImpl("(" + getLeafssize() + " entities)", getClass());
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+
+public abstract class AbstractEntityDiagram extends CucaDiagram {
+
+ final protected List<String> getDotStrings() {
+ final List<String> def = Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];",
+ "node [fontsize=11,height=.35,width=.55];");
+ if (getPragma().isDefine("graphattributes") == false) {
+ return def;
+ }
+ final String attribute = getPragma().getValue("graphattributes");
+ final List<String> result = new ArrayList<String>(def);
+ result.add(attribute);
+ return Collections.unmodifiableList(result);
+ }
+
+ final public DiagramDescription getDescription() {
+ final StringBuilder result = new StringBuilder("(" + getLeafssize() + " entities");
+ if (getSource() != null) {
+ final String id = getSource().getId();
+ if (id != null) {
+ result.append(", ");
+ result.append(id);
+ }
+ }
+ result.append(")");
+ return new DiagramDescription(result.toString());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java
index 9db21b3..40e4312 100644
--- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java
+++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java
@@ -1,236 +1,252 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import net.sourceforge.plantuml.FileFormatOption;
-import net.sourceforge.plantuml.UmlDiagramType;
-import net.sourceforge.plantuml.core.ImageData;
-import net.sourceforge.plantuml.creole.CreoleMode;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.EntityUtils;
-import net.sourceforge.plantuml.cucadiagram.GroupType;
-import net.sourceforge.plantuml.cucadiagram.IGroup;
-import net.sourceforge.plantuml.cucadiagram.ILeaf;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-import net.sourceforge.plantuml.graphic.HtmlColorUtils;
-import net.sourceforge.plantuml.graphic.TextBlock;
-import net.sourceforge.plantuml.graphic.USymbol;
-import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
-import net.sourceforge.plantuml.svek.image.EntityImageClass;
-import net.sourceforge.plantuml.ugraphic.ImageBuilder;
-
-public class ClassDiagram extends AbstractClassOrObjectDiagram {
-
- private String namespaceSeparator = ".";
-
- @Override
- public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
- if (namespaceSeparator != null) {
- code = code.withSeparator(namespaceSeparator);
- }
- if (type == null) {
- code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
- if (namespaceSeparator == null) {
- return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
- }
- code = code.getFullyQualifiedCode(getCurrentGroup());
- if (super.leafExist(code)) {
- return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
- }
- return createEntityWithNamespace(code, Display.getWithNewlines(code.getShortName(getLeafs())),
- LeafType.CLASS, symbol);
- }
- if (namespaceSeparator == null) {
- return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
- }
- code = code.getFullyQualifiedCode(getCurrentGroup());
- if (super.leafExist(code)) {
- return getOrCreateLeafDefault(code, type, symbol);
- }
- return createEntityWithNamespace(code, Display.getWithNewlines(code.getShortName(getLeafs())), type, symbol);
- }
-
- public IGroup getOrCreateNamespace(Code namespace, Display display, GroupType type, IGroup parent) {
- if (namespaceSeparator != null) {
- namespace = namespace.withSeparator(namespaceSeparator).getFullyQualifiedCode(getCurrentGroup());
- }
- final IGroup g = getOrCreateNamespaceInternal(namespace, display, type, parent);
- currentGroup = g;
- return g;
- }
-
- private IGroup getOrCreateNamespaceInternal(Code namespace, Display display, GroupType type, IGroup parent) {
- IGroup result = entityFactory.getGroups().get(namespace);
- if (result != null) {
- return result;
- }
- if (entityFactory.getLeafs().containsKey(namespace)) {
- result = entityFactory.muteToGroup(namespace, namespace, type, parent);
- result.setDisplay(display);
- } else {
- result = entityFactory.createGroup(namespace, display, namespace, type, parent, getHides(),
- getNamespaceSeparator());
- }
- entityFactory.addGroup(result);
- return result;
- }
-
- @Override
- public ILeaf createLeaf(Code code, Display display, LeafType type, USymbol symbol) {
- if (namespaceSeparator != null) {
- code = code.withSeparator(namespaceSeparator);
- }
- if (type != LeafType.ABSTRACT_CLASS && type != LeafType.ANNOTATION && type != LeafType.CLASS
- && type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP
- && type != LeafType.NOTE) {
- return super.createLeaf(code, display, type, symbol);
- }
- if (namespaceSeparator == null) {
- return super.createLeaf(code, display, type, symbol);
- }
- code = code.getFullyQualifiedCode(getCurrentGroup());
- if (super.leafExist(code)) {
- throw new IllegalArgumentException("Already known: " + code);
- }
- return createEntityWithNamespace(code, display, type, symbol);
- }
-
- private ILeaf createEntityWithNamespace(Code fullyCode, Display display, LeafType type, USymbol symbol) {
- IGroup group = getCurrentGroup();
- final String namespace = getNamespace(fullyCode);
- if (namespace != null
- && (EntityUtils.groupRoot(group) || group.getCode().getFullName().equals(namespace) == false)) {
- final Code namespace2 = Code.of(namespace);
- group = getOrCreateNamespaceInternal(namespace2, Display.getWithNewlines(namespace), GroupType.PACKAGE,
- getRootGroup());
- }
- return createLeafInternal(
- fullyCode,
- Display.isNull(display) ? Display.getWithNewlines(fullyCode.getShortName(getLeafs())).withCreoleMode(
- CreoleMode.SIMPLE_LINE) : display, type, group, symbol);
- }
-
- private final String getNamespace(Code fullyCode) {
- String name = fullyCode.getFullName();
- do {
- final int x = name.lastIndexOf(namespaceSeparator);
- if (x == -1) {
- return null;
- }
- name = name.substring(0, x);
- } while (getLeafs().containsKey(Code.of(name, namespaceSeparator)));
- return name;
- }
-
- @Override
- public final boolean leafExist(Code code) {
- if (namespaceSeparator == null) {
- return super.leafExist(code);
- }
- code = code.withSeparator(namespaceSeparator);
- return super.leafExist(code.getFullyQualifiedCode(getCurrentGroup()));
- }
-
- @Override
- public UmlDiagramType getUmlDiagramType() {
- return UmlDiagramType.CLASS;
- }
-
- public void setNamespaceSeparator(String namespaceSeparator) {
- this.namespaceSeparator = namespaceSeparator;
- }
-
- public String getNamespaceSeparator() {
- return namespaceSeparator;
- }
-
- private boolean allowMixing;
-
- public void setAllowMixing(boolean allowMixing) {
- this.allowMixing = allowMixing;
- }
-
- public boolean isAllowMixing() {
- return allowMixing;
- }
-
- private int useLayoutExplicit = 0;
-
- public void layoutNewLine() {
- useLayoutExplicit++;
- incRawLayout();
- }
-
- @Override
- final protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
- throws IOException {
- if (useLayoutExplicit != 0) {
- return exportLayoutExplicit(os, index, fileFormatOption);
- }
- return super.exportDiagramInternal(os, index, fileFormatOption);
- }
-
- final protected ImageData exportLayoutExplicit(OutputStream os, int index, FileFormatOption fileFormatOption)
- throws IOException {
- final FullLayout fullLayout = new FullLayout();
- for (int i = 0; i <= useLayoutExplicit; i++) {
- final RowLayout rawLayout = getRawLayout(i);
- fullLayout.addRowLayout(rawLayout);
- }
- final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam().getColorMapper(), 1, HtmlColorUtils.WHITE,
- null, null, 0, 10, null, getSkinParam().handwritten());
- imageBuilder.setUDrawable(fullLayout);
- return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
- }
-
- private RowLayout getRawLayout(int raw) {
- final RowLayout rawLayout = new RowLayout();
- for (ILeaf leaf : getLeafs().values()) {
- if (leaf.getRawLayout() == raw) {
- rawLayout.addLeaf(getEntityImageClass(leaf));
- }
- }
- return rawLayout;
- }
-
- private TextBlock getEntityImageClass(ILeaf entity) {
- return new EntityImageClass(null, entity, getSkinParam(), this);
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.creole.CreoleMode;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
+import net.sourceforge.plantuml.svek.image.EntityImageClass;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+
+public class ClassDiagram extends AbstractClassOrObjectDiagram {
+
+ private String namespaceSeparator = ".";
+
+ @Override
+ public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
+ if (namespaceSeparator != null) {
+ code = code.withSeparator(namespaceSeparator);
+ }
+ if (type == null) {
+ code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
+ if (namespaceSeparator == null) {
+ return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
+ }
+ code = code.getFullyQualifiedCode(getCurrentGroup());
+ if (super.leafExist(code)) {
+ return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
+ }
+ return createEntityWithNamespace(code, Display.getWithNewlines(code.getShortName(getLeafs())),
+ LeafType.CLASS, symbol);
+ }
+ if (namespaceSeparator == null) {
+ return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
+ }
+ code = code.getFullyQualifiedCode(getCurrentGroup());
+ if (super.leafExist(code)) {
+ return getOrCreateLeafDefault(code, type, symbol);
+ }
+ return createEntityWithNamespace(code, Display.getWithNewlines(code.getShortName(getLeafs())), type, symbol);
+ }
+
+ public IGroup getOrCreateNamespace(Code namespace, Display display, GroupType type, IGroup parent) {
+ if (namespaceSeparator != null) {
+ namespace = namespace.withSeparator(namespaceSeparator).getFullyQualifiedCode(getCurrentGroup());
+ }
+ final IGroup g = getOrCreateNamespaceInternal(namespace, display, type, parent);
+ currentGroup = g;
+ return g;
+ }
+
+ private IGroup getOrCreateNamespaceInternal(Code namespace, Display display, GroupType type, IGroup parent) {
+ IGroup result = entityFactory.getGroups().get(namespace);
+ if (result != null) {
+ return result;
+ }
+ if (entityFactory.getLeafs().containsKey(namespace)) {
+ result = entityFactory.muteToGroup(namespace, namespace, type, parent);
+ result.setDisplay(display);
+ } else {
+ result = entityFactory.createGroup(namespace, display, namespace, type, parent, getHides(),
+ getNamespaceSeparator());
+ }
+ entityFactory.addGroup(result);
+ return result;
+ }
+
+ @Override
+ public ILeaf createLeaf(Code code, Display display, LeafType type, USymbol symbol) {
+ if (namespaceSeparator != null) {
+ code = code.withSeparator(namespaceSeparator);
+ }
+ if (type != LeafType.ABSTRACT_CLASS && type != LeafType.ANNOTATION && type != LeafType.CLASS
+ && type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP
+ && type != LeafType.NOTE) {
+ return super.createLeaf(code, display, type, symbol);
+ }
+ if (namespaceSeparator == null) {
+ return super.createLeaf(code, display, type, symbol);
+ }
+ code = code.getFullyQualifiedCode(getCurrentGroup());
+ if (super.leafExist(code)) {
+ throw new IllegalArgumentException("Already known: " + code);
+ }
+ return createEntityWithNamespace(code, display, type, symbol);
+ }
+
+ private ILeaf createEntityWithNamespace(Code fullyCode, Display display, LeafType type, USymbol symbol) {
+ IGroup group = getCurrentGroup();
+ final String namespace = getNamespace(fullyCode);
+ if (namespace != null
+ && (EntityUtils.groupRoot(group) || group.getCode().getFullName().equals(namespace) == false)) {
+ final Code namespace2 = Code.of(namespace);
+ group = getOrCreateNamespaceInternal(namespace2, Display.getWithNewlines(namespace), GroupType.PACKAGE,
+ getRootGroup());
+ }
+ return createLeafInternal(
+ fullyCode,
+ Display.isNull(display) ? Display.getWithNewlines(fullyCode.getShortName(getLeafs())).withCreoleMode(
+ CreoleMode.SIMPLE_LINE) : display, type, group, symbol);
+ }
+
+ private final String getNamespace(Code fullyCode) {
+ String name = fullyCode.getFullName();
+ do {
+ final int x = name.lastIndexOf(namespaceSeparator);
+ if (x == -1) {
+ return null;
+ }
+ name = name.substring(0, x);
+ } while (getLeafs().containsKey(Code.of(name, namespaceSeparator)));
+ return name;
+ }
+
+ @Override
+ public final boolean leafExist(Code code) {
+ if (namespaceSeparator == null) {
+ return super.leafExist(code);
+ }
+ code = code.withSeparator(namespaceSeparator);
+ return super.leafExist(code.getFullyQualifiedCode(getCurrentGroup()));
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.CLASS;
+ }
+
+ public void setNamespaceSeparator(String namespaceSeparator) {
+ this.namespaceSeparator = namespaceSeparator;
+ }
+
+ public String getNamespaceSeparator() {
+ return namespaceSeparator;
+ }
+
+ private boolean allowMixing;
+
+ public void setAllowMixing(boolean allowMixing) {
+ this.allowMixing = allowMixing;
+ }
+
+ public boolean isAllowMixing() {
+ return allowMixing;
+ }
+
+ private int useLayoutExplicit = 0;
+
+ public void layoutNewLine() {
+ useLayoutExplicit++;
+ incRawLayout();
+ }
+
+ @Override
+ final protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException {
+ if (useLayoutExplicit != 0) {
+ return exportLayoutExplicit(os, index, fileFormatOption);
+ }
+ return super.exportDiagramInternal(os, index, fileFormatOption);
+ }
+
+ final protected ImageData exportLayoutExplicit(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException {
+ final FullLayout fullLayout = new FullLayout();
+ for (int i = 0; i <= useLayoutExplicit; i++) {
+ final RowLayout rawLayout = getRawLayout(i);
+ fullLayout.addRowLayout(rawLayout);
+ }
+ final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), 1, null, null, 0, 10, null);
+ imageBuilder.setUDrawable(fullLayout);
+ return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
+ }
+
+ private RowLayout getRawLayout(int raw) {
+ final RowLayout rawLayout = new RowLayout();
+ for (ILeaf leaf : getLeafs().values()) {
+ if (leaf.getRawLayout() == raw) {
+ rawLayout.addLeaf(getEntityImageClass(leaf));
+ }
+ }
+ return rawLayout;
+ }
+
+ private TextBlock getEntityImageClass(ILeaf entity) {
+ return new EntityImageClass(null, entity, getSkinParam(), this);
+ }
+
+ @Override
+ public String checkFinalError() {
+ for (Link link : this.getLinks()) {
+ final int len = link.getLength();
+ if (len == 1) {
+ for (Link link2 : this.getLinks()) {
+ if (link2.sameConnections(link) && link2.getLength() != 1) {
+ link2.setLength(1);
+ }
+ }
+ }
+ }
+ this.applySingleStrategy();
+ return super.checkFinalError();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java
index 7a22415..ffa50c6 100644
--- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java
+++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java
@@ -1,179 +1,148 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sourceforge.plantuml.AbstractPSystem;
-import net.sourceforge.plantuml.NewpagedDiagram;
-import net.sourceforge.plantuml.UmlDiagramType;
-import net.sourceforge.plantuml.classdiagram.command.CommandAddMethod;
-import net.sourceforge.plantuml.classdiagram.command.CommandAllowMixing;
-import net.sourceforge.plantuml.classdiagram.command.CommandCreateClass;
-import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
-import net.sourceforge.plantuml.classdiagram.command.CommandCreateElementFull2;
-import net.sourceforge.plantuml.classdiagram.command.CommandCreateElementFull2.Mode;
-import net.sourceforge.plantuml.classdiagram.command.CommandDiamondAssociation;
-import net.sourceforge.plantuml.classdiagram.command.CommandHideShowSpecificClass;
-import net.sourceforge.plantuml.classdiagram.command.CommandHideShowSpecificStereotype;
-import net.sourceforge.plantuml.classdiagram.command.CommandImport;
-import net.sourceforge.plantuml.classdiagram.command.CommandLayoutNewLine;
-import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
-import net.sourceforge.plantuml.classdiagram.command.CommandLinkLollipop;
-import net.sourceforge.plantuml.classdiagram.command.CommandNamespaceSeparator;
-import net.sourceforge.plantuml.classdiagram.command.CommandStereotype;
-import net.sourceforge.plantuml.classdiagram.command.CommandUrl;
-import net.sourceforge.plantuml.command.Command;
-import net.sourceforge.plantuml.command.CommandEndPackage;
-import net.sourceforge.plantuml.command.CommandFootboxIgnored;
-import net.sourceforge.plantuml.command.CommandNamespace;
-import net.sourceforge.plantuml.command.CommandPackage;
-import net.sourceforge.plantuml.command.CommandPackageEmpty;
-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.note.FactoryTipOnEntityCommand;
-import net.sourceforge.plantuml.command.regex.RegexLeaf;
-import net.sourceforge.plantuml.core.Diagram;
-import net.sourceforge.plantuml.cucadiagram.Link;
-import net.sourceforge.plantuml.descdiagram.command.CommandNewpage;
-import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObject;
-import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObjectMultilines;
-
-public class ClassDiagramFactory extends UmlDiagramFactory {
-
- @Override
- public ClassDiagram createEmptyDiagram() {
- return new ClassDiagram();
-
- }
-
- @Override
- protected List<Command> createCommands() {
- final List<Command> cmds = new ArrayList<Command>();
- cmds.add(new CommandFootboxIgnored());
- addCommonCommands(cmds);
-
- cmds.add(new CommandRankDir());
- cmds.add(new CommandNewpage(this));
- cmds.add(new CommandHideShowSpecificStereotype());
- cmds.add(new CommandPage());
- cmds.add(new CommandAddMethod());
-
- cmds.add(new CommandCreateClass());
- cmds.add(new CommandCreateEntityObject());
-
- cmds.add(new CommandAllowMixing());
- cmds.add(new CommandLayoutNewLine());
-
- cmds.add(new CommandCreateElementFull2(Mode.NORMAL_KEYWORD));
- cmds.add(new CommandCreateElementFull2(Mode.WITH_MIX_PREFIX));
- final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
- cmds.add(factoryNoteCommand.createSingleLine());
-
- cmds.add(new CommandPackage());
- cmds.add(new CommandEndPackage());
- cmds.add(new CommandPackageEmpty());
-
- cmds.add(new CommandNamespace());
- cmds.add(new CommandStereotype());
-
- cmds.add(new CommandLinkClass(UmlDiagramType.CLASS));
- cmds.add(new CommandLinkLollipop(UmlDiagramType.CLASS));
-
- cmds.add(new CommandImport());
-
- final FactoryTipOnEntityCommand factoryTipOnEntityCommand = new FactoryTipOnEntityCommand(new RegexLeaf(
- "ENTITY", "(" + CommandCreateClass.CODE_NO_DOTDOT + "|[%g][^%g]+[%g])::([^%s]+)"));
- cmds.add(factoryTipOnEntityCommand.createMultiLine(true));
- cmds.add(factoryTipOnEntityCommand.createMultiLine(false));
-
- final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexLeaf(
- "ENTITY", "(" + CommandCreateClass.CODE + "|[%g][^%g]+[%g])"));
- cmds.add(factoryNoteOnEntityCommand.createSingleLine());
- cmds.add(new CommandUrl());
-
- cmds.add(factoryNoteOnEntityCommand.createMultiLine(true));
- cmds.add(factoryNoteOnEntityCommand.createMultiLine(false));
- cmds.add(factoryNoteCommand.createMultiLine(false));
-
- cmds.add(new CommandCreateClassMultilines());
- cmds.add(new CommandCreateEntityObjectMultilines());
-
- final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
- cmds.add(factoryNoteOnLinkCommand.createSingleLine());
- cmds.add(factoryNoteOnLinkCommand.createMultiLine(false));
-
- cmds.add(new CommandDiamondAssociation());
-
- cmds.add(new CommandHideShowSpecificClass());
-
- cmds.add(new CommandNamespaceSeparator());
-
- return cmds;
- }
-
- @Override
- public String checkFinalError(AbstractPSystem sys) {
- if (sys instanceof NewpagedDiagram) {
- for (Diagram p : ((NewpagedDiagram) sys).getDiagrams()) {
- checkFinal((ClassDiagram) p);
- }
- } else {
- final ClassDiagram system = (ClassDiagram) sys;
- checkFinal(system);
- }
- return super.checkFinalError(sys);
- }
-
- private void checkFinal(final ClassDiagram system) {
- for (Link link : system.getLinks()) {
- final int len = link.getLength();
- if (len == 1) {
- for (Link link2 : system.getLinks()) {
- if (link2.sameConnections(link) && link2.getLength() != 1) {
- link2.setLength(1);
- }
- }
- }
- }
- system.applySingleStrategy();
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.classdiagram.command.CommandAddMethod;
+import net.sourceforge.plantuml.classdiagram.command.CommandAllowMixing;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateClass;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateElementFull2;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateElementFull2.Mode;
+import net.sourceforge.plantuml.classdiagram.command.CommandDiamondAssociation;
+import net.sourceforge.plantuml.classdiagram.command.CommandHideShowSpecificClass;
+import net.sourceforge.plantuml.classdiagram.command.CommandHideShowSpecificStereotype;
+import net.sourceforge.plantuml.classdiagram.command.CommandImport;
+import net.sourceforge.plantuml.classdiagram.command.CommandLayoutNewLine;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkLollipop;
+import net.sourceforge.plantuml.classdiagram.command.CommandNamespaceSeparator;
+import net.sourceforge.plantuml.classdiagram.command.CommandStereotype;
+import net.sourceforge.plantuml.classdiagram.command.CommandUrl;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandEndPackage;
+import net.sourceforge.plantuml.command.CommandFootboxIgnored;
+import net.sourceforge.plantuml.command.CommandNamespace;
+import net.sourceforge.plantuml.command.CommandPackage;
+import net.sourceforge.plantuml.command.CommandPackageEmpty;
+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.note.FactoryTipOnEntityCommand;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.descdiagram.command.CommandNewpage;
+import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObject;
+import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObjectMultilines;
+
+public class ClassDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ public ClassDiagram createEmptyDiagram() {
+ return new ClassDiagram();
+
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandFootboxIgnored());
+ addCommonCommands(cmds);
+
+ cmds.add(new CommandRankDir());
+ cmds.add(new CommandNewpage(this));
+ cmds.add(new CommandHideShowSpecificStereotype());
+ cmds.add(new CommandPage());
+ cmds.add(new CommandAddMethod());
+
+ cmds.add(new CommandCreateClass());
+ cmds.add(new CommandCreateEntityObject());
+
+ cmds.add(new CommandAllowMixing());
+ cmds.add(new CommandLayoutNewLine());
+
+ cmds.add(new CommandCreateElementFull2(Mode.NORMAL_KEYWORD));
+ cmds.add(new CommandCreateElementFull2(Mode.WITH_MIX_PREFIX));
+ final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
+ cmds.add(factoryNoteCommand.createSingleLine());
+
+ cmds.add(new CommandPackage());
+ cmds.add(new CommandEndPackage());
+ cmds.add(new CommandPackageEmpty());
+
+ cmds.add(new CommandNamespace());
+ cmds.add(new CommandStereotype());
+
+ cmds.add(new CommandLinkClass(UmlDiagramType.CLASS));
+ cmds.add(new CommandLinkLollipop(UmlDiagramType.CLASS));
+
+ cmds.add(new CommandImport());
+
+ final FactoryTipOnEntityCommand factoryTipOnEntityCommand = new FactoryTipOnEntityCommand(new RegexLeaf(
+ "ENTITY", "(" + CommandCreateClass.CODE_NO_DOTDOT + "|[%g][^%g]+[%g])::([%g][^%g]+[%g]|[^%s]+)"));
+ cmds.add(factoryTipOnEntityCommand.createMultiLine(true));
+ cmds.add(factoryTipOnEntityCommand.createMultiLine(false));
+
+ final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexLeaf(
+ "ENTITY", "(" + CommandCreateClass.CODE + "|[%g][^%g]+[%g])"));
+ cmds.add(factoryNoteOnEntityCommand.createSingleLine());
+ cmds.add(new CommandUrl());
+
+ cmds.add(factoryNoteOnEntityCommand.createMultiLine(true));
+ cmds.add(factoryNoteOnEntityCommand.createMultiLine(false));
+ cmds.add(factoryNoteCommand.createMultiLine(false));
+
+ cmds.add(new CommandCreateClassMultilines());
+ cmds.add(new CommandCreateEntityObjectMultilines());
+
+ final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
+ cmds.add(factoryNoteOnLinkCommand.createSingleLine());
+ cmds.add(factoryNoteOnLinkCommand.createMultiLine(false));
+
+ cmds.add(new CommandDiamondAssociation());
+
+ cmds.add(new CommandHideShowSpecificClass());
+
+ cmds.add(new CommandNamespaceSeparator());
+
+ return cmds;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/FullLayout.java b/src/net/sourceforge/plantuml/classdiagram/FullLayout.java
index c3b6462..a73158d 100644
--- a/src/net/sourceforge/plantuml/classdiagram/FullLayout.java
+++ b/src/net/sourceforge/plantuml/classdiagram/FullLayout.java
@@ -1,61 +1,62 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sourceforge.plantuml.graphic.UDrawable;
-import net.sourceforge.plantuml.ugraphic.UGraphic;
-import net.sourceforge.plantuml.ugraphic.UTranslate;
-
-public class FullLayout implements UDrawable {
-
- private final List<RowLayout> all = new ArrayList<RowLayout>();
-
- public void addRowLayout(RowLayout rawLayout) {
- this.all.add(rawLayout);
- }
-
- public void drawU(UGraphic ug) {
- double y = 0;
- for (RowLayout rawLayout : all) {
- rawLayout.drawU(ug.apply(new UTranslate(0, y)));
- y += rawLayout.getHeight(ug.getStringBounder()) + 20;
- }
-
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FullLayout implements UDrawable {
+
+ private final List<RowLayout> all = new ArrayList<RowLayout>();
+
+ public void addRowLayout(RowLayout rawLayout) {
+ this.all.add(rawLayout);
+ }
+
+ public void drawU(UGraphic ug) {
+ double y = 0;
+ for (RowLayout rawLayout : all) {
+ rawLayout.drawU(ug.apply(new UTranslate(0, y)));
+ y += rawLayout.getHeight(ug.getStringBounder()) + 20;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/RowLayout.java b/src/net/sourceforge/plantuml/classdiagram/RowLayout.java
index 4312e3d..c549a2e 100644
--- a/src/net/sourceforge/plantuml/classdiagram/RowLayout.java
+++ b/src/net/sourceforge/plantuml/classdiagram/RowLayout.java
@@ -1,71 +1,72 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sourceforge.plantuml.graphic.StringBounder;
-import net.sourceforge.plantuml.graphic.TextBlock;
-import net.sourceforge.plantuml.graphic.UDrawable;
-import net.sourceforge.plantuml.ugraphic.UGraphic;
-import net.sourceforge.plantuml.ugraphic.UTranslate;
-
-public class RowLayout implements UDrawable {
-
- private final List<TextBlock> all = new ArrayList<TextBlock>();
-
- public void addLeaf(TextBlock entityImageClass) {
- this.all.add(entityImageClass);
- }
-
- public double getHeight(StringBounder stringBounder) {
- double y = 0;
- for (TextBlock leaf : all) {
- y = Math.max(y, leaf.calculateDimension(stringBounder).getHeight());
- }
- return y;
- }
-
- public void drawU(UGraphic ug) {
- double x = 0;
- for (TextBlock leaf : all) {
- leaf.drawU(ug.apply(new UTranslate(x, 0)));
- x += leaf.calculateDimension(ug.getStringBounder()).getWidth() + 20;
- }
-
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class RowLayout implements UDrawable {
+
+ private final List<TextBlock> all = new ArrayList<TextBlock>();
+
+ public void addLeaf(TextBlock entityImageClass) {
+ this.all.add(entityImageClass);
+ }
+
+ public double getHeight(StringBounder stringBounder) {
+ double y = 0;
+ for (TextBlock leaf : all) {
+ y = Math.max(y, leaf.calculateDimension(stringBounder).getHeight());
+ }
+ return y;
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ for (TextBlock leaf : all) {
+ leaf.drawU(ug.apply(new UTranslate(x, 0)));
+ x += leaf.calculateDimension(ug.getStringBounder()).getWidth() + 20;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java
index 0d53039..d5420cb 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java
@@ -1,63 +1,64 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.List;
-
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.skin.VisibilityModifier;
-
-public class CommandAddMethod extends SingleLineCommand<ClassDiagram> {
-
- public CommandAddMethod() {
- super("(?i)^([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]+:[%s]+(.*)$");
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram system, List<String> arg) {
- final IEntity entity = system.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
-
- final String field = arg.get(1);
- if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field.charAt(0))) {
- system.setVisibilityModifierPresent(true);
- }
- entity.getBodier().addFieldOrMethod(field);
- return CommandExecutionResult.ok();
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class CommandAddMethod extends SingleLineCommand<ClassDiagram> {
+
+ public CommandAddMethod() {
+ super("(?i)^([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]+:[%s]+(.*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram system, List<String> arg) {
+ final IEntity entity = system.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
+
+ final String field = arg.get(1);
+ if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) {
+ system.setVisibilityModifierPresent(true);
+ }
+ entity.getBodier().addFieldOrMethod(field, entity);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java
index 2dd6d3d..4c4f0e2 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java
@@ -1,62 +1,63 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-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.RegexResult;
-
-public class CommandAllowMixing extends SingleLineCommand2<ClassDiagram> {
-
- public CommandAllowMixing() {
- super(getRegexConcat());
- }
-
- private static RegexConcat getRegexConcat() {
-
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("allow_mixing"), //
- new RegexLeaf("$"));
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
- diagram.setAllowMixing(true);
- return CommandExecutionResult.ok();
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+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.RegexResult;
+
+public class CommandAllowMixing extends SingleLineCommand2<ClassDiagram> {
+
+ public CommandAllowMixing() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("allow_mixing"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ diagram.setAllowMixing(true);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java
index d9cd85f..4e4f20d 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java
@@ -1,186 +1,191 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import net.sourceforge.plantuml.FontParam;
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.Url;
-import net.sourceforge.plantuml.UrlBuilder;
-import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-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.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.ILeaf;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-import net.sourceforge.plantuml.cucadiagram.Stereotype;
-import net.sourceforge.plantuml.graphic.HtmlColor;
-import net.sourceforge.plantuml.graphic.color.ColorParser;
-import net.sourceforge.plantuml.graphic.color.ColorType;
-import net.sourceforge.plantuml.graphic.color.Colors;
-
-public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
-
- public static final String CODE = "[^%s{}%g<>]+";
- public static final String CODE_NO_DOTDOT = "[^%s{}%g<>:]+";
-
- enum Mode {
- EXTENDS, IMPLEMENTS
- };
-
- public CommandCreateClass() {
- super(getRegexConcat());
- }
-
- private static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("TYPE", //
- "(interface|enum|annotation|abstract[%s]+class|abstract|class)[%s]+"), //
- new RegexOr(//
- new RegexConcat(//
- new RegexLeaf("DISPLAY1", "[%g](.+)[%g]"), //
- new RegexLeaf("[%s]+as[%s]+"), //
- new RegexLeaf("CODE1", "(" + CODE + ")")), //
- new RegexConcat(//
- new RegexLeaf("CODE2", "(" + CODE + ")"), //
- new RegexLeaf("[%s]+as[%s]+"), // //
- new RegexLeaf("DISPLAY2", "[%g](.+)[%g]")), //
- new RegexLeaf("CODE3", "(" + CODE + ")"), //
- new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
- new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- color().getRegex(), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
- new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), //
- new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), //
- new RegexLeaf("$"));
- }
-
- private static ColorParser color() {
- return ColorParser.simpleColor(ColorType.BACK);
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
- final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
- final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
- final String display = arg.getLazzy("DISPLAY", 0);
-
- final String stereotype = arg.get("STEREO", 0);
- final String generic = arg.get("GENERIC", 0);
- final ILeaf entity;
- if (diagram.leafExist(code)) {
- entity = diagram.getOrCreateLeaf(code, type, null);
- entity.muteToType(type, null);
- } else {
- entity = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
- }
- if (stereotype != null) {
- entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
- .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
- .getIHtmlColorSet()));
- }
- if (generic != null) {
- entity.setGeneric(generic);
- }
-
- final String urlString = arg.get("URL", 0);
- if (urlString != null) {
- final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
- final Url url = urlBuilder.getUrl(urlString);
- entity.addUrl(url);
- }
-
- Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
-
- final HtmlColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1));
- if (lineColor != null) {
- colors = colors.add(ColorType.LINE, lineColor);
- }
- if (arg.get("LINECOLOR", 0) != null) {
- colors = colors.addLegacyStroke(arg.get("LINECOLOR", 0));
- }
- entity.setColors(colors);
-
- // entity.setSpecificColorTOBEREMOVED(ColorType.LINE, lineColor);
- // entity.setSpecificColorTOBEREMOVED(ColorType.HEADER, colors.getColor(ColorType.HEADER));
- //
- // if (colors.getLineStyle() != null) {
- // entity.setSpecificLineStroke(LinkStyle.getStroke(colors.getLineStyle()));
- // }
- //
- // if (arg.get("LINECOLOR", 0) != null) {
- // entity.applyStroke(arg.get("LINECOLOR", 0));
- // }
-
- // manageExtends(diagram, arg, entity);
- CommandCreateClassMultilines.manageExtends("EXTENDS", diagram, arg, entity);
- CommandCreateClassMultilines.manageExtends("IMPLEMENTS", diagram, arg, entity);
-
- return CommandExecutionResult.ok();
- }
- // public static void manageExtends(ClassDiagram system, RegexResult arg, final IEntity entity) {
- // if (arg.get("EXTENDS", 1) != null) {
- // final Mode mode = arg.get("EXTENDS", 1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS;
- // final Code other = Code.of(arg.get("EXTENDS", 2));
- // LeafType type2 = LeafType.CLASS;
- // if (mode == Mode.IMPLEMENTS) {
- // type2 = LeafType.INTERFACE;
- // }
- // if (mode == Mode.EXTENDS && entity.getEntityType() == LeafType.INTERFACE) {
- // type2 = LeafType.INTERFACE;
- // }
- // final IEntity cl2 = system.getOrCreateLeaf(other, type2, null);
- // LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
- // if (type2 == LeafType.INTERFACE && entity.getEntityType() != LeafType.INTERFACE) {
- // typeLink = typeLink.getDashed();
- // }
- // final Link link = new Link(cl2, entity, typeLink, null, 2, null, null, system.getLabeldistance(),
- // system.getLabelangle());
- // system.addLink(link);
- // }
- // }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+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.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.color.ColorParser;
+import net.sourceforge.plantuml.graphic.color.ColorType;
+import net.sourceforge.plantuml.graphic.color.Colors;
+
+public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
+
+ public static final String DISPLAY_WITH_GENERIC = "[%g](.+?)(?:\\<(" + GenericRegexProducer.PATTERN + ")\\>)?[%g]";
+ public static final String CODE = "[^%s{}%g<>]+";
+ public static final String CODE_NO_DOTDOT = "[^%s{}%g<>:]+";
+
+ enum Mode {
+ EXTENDS, IMPLEMENTS
+ };
+
+ public CommandCreateClass() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", //
+ "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|circle)[%s]+"), //
+ new RegexOr(//
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY1", DISPLAY_WITH_GENERIC), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("CODE1", "(" + CODE + ")")), //
+ new RegexConcat(//
+ new RegexLeaf("CODE2", "(" + CODE + ")"), //
+ new RegexLeaf("[%s]+as[%s]+"), // //
+ new RegexLeaf("DISPLAY2", DISPLAY_WITH_GENERIC)), //
+ new RegexLeaf("CODE3", "(" + CODE + ")"), //
+ new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ color().getRegex(), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
+ new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), //
+ new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static ColorParser color() {
+ return ColorParser.simpleColor(ColorType.BACK);
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
+ final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
+ final String display = arg.getLazzy("DISPLAY", 0);
+ final String genericOption = arg.getLazzy("DISPLAY", 1);
+ final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
+
+ final String stereotype = arg.get("STEREO", 0);
+ final ILeaf entity;
+ if (diagram.leafExist(code)) {
+ entity = diagram.getOrCreateLeaf(code, type, null);
+ if (entity.muteToType(type, null) == false) {
+ return CommandExecutionResult.error("Bad name");
+ }
+ } else {
+ entity = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
+ }
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+ if (generic != null) {
+ entity.setGeneric(generic);
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ }
+
+ Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
+
+ final HtmlColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1));
+ if (lineColor != null) {
+ colors = colors.add(ColorType.LINE, lineColor);
+ }
+ if (arg.get("LINECOLOR", 0) != null) {
+ colors = colors.addLegacyStroke(arg.get("LINECOLOR", 0));
+ }
+ entity.setColors(colors);
+
+ // entity.setSpecificColorTOBEREMOVED(ColorType.LINE, lineColor);
+ // entity.setSpecificColorTOBEREMOVED(ColorType.HEADER, colors.getColor(ColorType.HEADER));
+ //
+ // if (colors.getLineStyle() != null) {
+ // entity.setSpecificLineStroke(LinkStyle.getStroke(colors.getLineStyle()));
+ // }
+ //
+ // if (arg.get("LINECOLOR", 0) != null) {
+ // entity.applyStroke(arg.get("LINECOLOR", 0));
+ // }
+
+ // manageExtends(diagram, arg, entity);
+ CommandCreateClassMultilines.manageExtends("EXTENDS", diagram, arg, entity);
+ CommandCreateClassMultilines.manageExtends("IMPLEMENTS", diagram, arg, entity);
+
+ return CommandExecutionResult.ok();
+ }
+ // public static void manageExtends(ClassDiagram system, RegexResult arg, final IEntity entity) {
+ // if (arg.get("EXTENDS", 1) != null) {
+ // final Mode mode = arg.get("EXTENDS", 1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS;
+ // final Code other = Code.of(arg.get("EXTENDS", 2));
+ // LeafType type2 = LeafType.CLASS;
+ // if (mode == Mode.IMPLEMENTS) {
+ // type2 = LeafType.INTERFACE;
+ // }
+ // if (mode == Mode.EXTENDS && entity.getEntityType() == LeafType.INTERFACE) {
+ // type2 = LeafType.INTERFACE;
+ // }
+ // final IEntity cl2 = system.getOrCreateLeaf(other, type2, null);
+ // LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
+ // if (type2 == LeafType.INTERFACE && entity.getEntityType() != LeafType.INTERFACE) {
+ // typeLink = typeLink.getDashed();
+ // }
+ // final Link link = new Link(cl2, entity, typeLink, null, 2, null, null, system.getLabeldistance(),
+ // system.getLabelangle());
+ // system.addLink(link);
+ // }
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java
index 1a932ed..cbdab30 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java
@@ -1,232 +1,242 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import net.sourceforge.plantuml.FontParam;
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.Url;
-import net.sourceforge.plantuml.UrlBuilder;
-import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-import net.sourceforge.plantuml.command.BlocLines;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.CommandMultilines2;
-import net.sourceforge.plantuml.command.MultilinesStrategy;
-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.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.cucadiagram.ILeaf;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-import net.sourceforge.plantuml.cucadiagram.Link;
-import net.sourceforge.plantuml.cucadiagram.LinkDecor;
-import net.sourceforge.plantuml.cucadiagram.LinkType;
-import net.sourceforge.plantuml.cucadiagram.Stereotype;
-import net.sourceforge.plantuml.graphic.HtmlColor;
-import net.sourceforge.plantuml.graphic.color.ColorParser;
-import net.sourceforge.plantuml.graphic.color.ColorType;
-import net.sourceforge.plantuml.graphic.color.Colors;
-import net.sourceforge.plantuml.skin.VisibilityModifier;
-
-public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagram> {
-
- private static final String CODE = CommandLinkClass.getSeparator() + "?[\\p{L}0-9_]+" + "(?:"
- + CommandLinkClass.getSeparator() + "[\\p{L}0-9_]+)*";
- public static final String CODES = CODE + "(?:\\s*,\\s*" + CODE + ")*";
-
- enum Mode {
- EXTENDS, IMPLEMENTS
- };
-
- public CommandCreateClassMultilines() {
- super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
- }
-
- @Override
- public String getPatternEnd() {
- return "(?i)^[%s]*\\}[%s]*$";
- }
-
- private static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("TYPE", "(interface|enum|abstract[%s]+class|abstract|class)[%s]+"), //
- new RegexOr(//
- new RegexConcat(//
- new RegexLeaf("DISPLAY1", "[%g](.+)[%g]"), //
- new RegexLeaf("[%s]+as[%s]+"), //
- new RegexLeaf("CODE1", "(" + CommandCreateClass.CODE + ")")), //
- new RegexConcat(//
- new RegexLeaf("CODE2", "(" + CommandCreateClass.CODE + ")"), //
- new RegexLeaf("[%s]+as[%s]+"), // //
- new RegexLeaf("DISPLAY2", "[%g](.+)[%g]")), //
- new RegexLeaf("CODE3", "(" + CommandCreateClass.CODE + ")"), //
- new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
- new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- color().getRegex(), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
- new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CODES + "))?"), //
- new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CODES + "))?"), //
- new RegexLeaf("[%s]*\\{[%s]*$"));
- }
-
- private static ColorParser color() {
- return ColorParser.simpleColor(ColorType.BACK);
- }
-
- public CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines lines) {
- lines = lines.trimSmart(1);
- lines = lines.removeComments();
- final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
- final IEntity entity = executeArg0(diagram, line0);
- if (entity == null) {
- return CommandExecutionResult.error("No such entity");
- }
- if (lines.size() > 1) {
- lines = lines.subExtract(1, 1);
- final Url url;
- if (lines.size() > 0) {
- final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
- url = urlBuilder.getUrl(lines.getFirst499().toString());
- } else {
- url = null;
- }
- if (url != null) {
- lines = lines.subExtract(1, 0);
- }
- for (CharSequence s : lines) {
- if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
- diagram.setVisibilityModifierPresent(true);
- }
- entity.getBodier().addFieldOrMethod(s.toString());
- }
- if (url != null) {
- entity.addUrl(url);
- }
- }
-
- manageExtends("EXTENDS", diagram, line0, entity);
- manageExtends("IMPLEMENTS", diagram, line0, entity);
-
- return CommandExecutionResult.ok();
- }
-
- public static void manageExtends(String keyword, ClassDiagram system, RegexResult arg, final IEntity entity) {
- if (arg.get(keyword, 1) != null) {
- final Mode mode = arg.get(keyword, 1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS;
- LeafType type2 = LeafType.CLASS;
- if (mode == Mode.IMPLEMENTS) {
- type2 = LeafType.INTERFACE;
- }
- if (mode == Mode.EXTENDS && entity.getEntityType() == LeafType.INTERFACE) {
- type2 = LeafType.INTERFACE;
- }
- final String codes = arg.get(keyword, 2);
- for (String s : codes.split(",")) {
- final Code other = Code.of(StringUtils.trin(s));
- final IEntity cl2 = system.getOrCreateLeaf(other, type2, null);
- LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
- if (type2 == LeafType.INTERFACE && entity.getEntityType() != LeafType.INTERFACE) {
- typeLink = typeLink.getDashed();
- }
- final Link link = new Link(cl2, entity, typeLink, Display.NULL, 2, null, null,
- system.getLabeldistance(), system.getLabelangle());
- system.addLink(link);
- }
- }
- }
-
- private IEntity executeArg0(ClassDiagram diagram, RegexResult arg) {
-
- final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
-
- final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
- final String display = arg.getLazzy("DISPLAY", 0);
-
- final String stereotype = arg.get("STEREO", 0);
- final String generic = arg.get("GENERIC", 0);
-
- final ILeaf result;
- if (diagram.leafExist(code)) {
- result = diagram.getOrCreateLeaf(code, null, null);
- result.muteToType(type, null);
- } else {
- result = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
- }
- if (stereotype != null) {
- result.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
- .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
- .getIHtmlColorSet()));
- }
-
- final String urlString = arg.get("URL", 0);
- if (urlString != null) {
- final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
- final Url url = urlBuilder.getUrl(urlString);
- result.addUrl(url);
- }
-
- Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
-
- final HtmlColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1));
- if (lineColor != null) {
- colors = colors.add(ColorType.LINE, lineColor);
- }
- if (arg.get("LINECOLOR", 0) != null) {
- colors = colors.addLegacyStroke(arg.get("LINECOLOR", 0));
- }
- result.setColors(colors);
-
- // result.setSpecificColorTOBEREMOVED(ColorType.BACK,
- // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
- // result.setSpecificColorTOBEREMOVED(ColorType.LINE,
- // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)));
- // result.applyStroke(arg.get("LINECOLOR", 0));
-
- if (generic != null) {
- result.setGeneric(generic);
- }
- return result;
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.BlocLines;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+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.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.color.ColorParser;
+import net.sourceforge.plantuml.graphic.color.ColorType;
+import net.sourceforge.plantuml.graphic.color.Colors;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagram> {
+
+ private static final String CODE = CommandLinkClass.getSeparator() + "?[\\p{L}0-9_]+" + "(?:"
+ + CommandLinkClass.getSeparator() + "[\\p{L}0-9_]+)*";
+ public static final String CODES = CODE + "(?:\\s*,\\s*" + CODE + ")*";
+
+ enum Mode {
+ EXTENDS, IMPLEMENTS
+ };
+
+ public CommandCreateClassMultilines() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*\\}[%s]*$";
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), //
+ new RegexLeaf("TYPE", "(interface|enum|abstract[%s]+class|abstract|class|entity)[%s]+"), //
+ new RegexOr(//
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY1", CommandCreateClass.DISPLAY_WITH_GENERIC), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("CODE1", "(" + CommandCreateClass.CODE + ")")), //
+ new RegexConcat(//
+ new RegexLeaf("CODE2", "(" + CommandCreateClass.CODE + ")"), //
+ new RegexLeaf("[%s]+as[%s]+"), // //
+ new RegexLeaf("DISPLAY2", CommandCreateClass.DISPLAY_WITH_GENERIC)), //
+ new RegexLeaf("CODE3", "(" + CommandCreateClass.CODE + ")"), //
+ new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ color().getRegex(), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
+ new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CODES + "))?"), //
+ new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CODES + "))?"), //
+ new RegexLeaf("[%s]*\\{[%s]*$"));
+ }
+
+ private static ColorParser color() {
+ return ColorParser.simpleColor(ColorType.BACK);
+ }
+
+ public CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines lines) {
+ lines = lines.trimSmart(1);
+ lines = lines.removeComments();
+ final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
+ final IEntity entity = executeArg0(diagram, line0);
+ if (entity == null) {
+ return CommandExecutionResult.error("No such entity");
+ }
+ if (lines.size() > 1) {
+ lines = lines.subExtract(1, 1);
+ final Url url = null;
+// if (lines.size() > 0) {
+// final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+// url = urlBuilder.getUrl(lines.getFirst499().toString());
+// } else {
+// url = null;
+// }
+// if (url != null) {
+// lines = lines.subExtract(1, 0);
+// }
+ for (CharSequence s : lines) {
+ if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s)) {
+ diagram.setVisibilityModifierPresent(true);
+ }
+ entity.getBodier().addFieldOrMethod(s.toString(), entity);
+ }
+ if (url != null) {
+ entity.addUrl(url);
+ }
+ }
+
+ manageExtends("EXTENDS", diagram, line0, entity);
+ manageExtends("IMPLEMENTS", diagram, line0, entity);
+
+ return CommandExecutionResult.ok();
+ }
+
+ public static void manageExtends(String keyword, ClassDiagram system, RegexResult arg, final IEntity entity) {
+ if (arg.get(keyword, 1) != null) {
+ final Mode mode = arg.get(keyword, 1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS;
+ LeafType type2 = LeafType.CLASS;
+ if (mode == Mode.IMPLEMENTS) {
+ type2 = LeafType.INTERFACE;
+ }
+ if (mode == Mode.EXTENDS && entity.getLeafType() == LeafType.INTERFACE) {
+ type2 = LeafType.INTERFACE;
+ }
+ final String codes = arg.get(keyword, 2);
+ for (String s : codes.split(",")) {
+ final Code other = Code.of(StringUtils.trin(s));
+ final IEntity cl2 = system.getOrCreateLeaf(other, type2, null);
+ LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
+ if (type2 == LeafType.INTERFACE && entity.getLeafType() != LeafType.INTERFACE) {
+ typeLink = typeLink.getDashed();
+ }
+ final Link link = new Link(cl2, entity, typeLink, Display.NULL, 2, null, null,
+ system.getLabeldistance(), system.getLabelangle());
+ system.addLink(link);
+ }
+ }
+ }
+
+ private IEntity executeArg0(ClassDiagram diagram, RegexResult arg) {
+
+ final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
+ final String visibilityString = arg.get("VISIBILITY", 0);
+ VisibilityModifier visibilityModifier = null;
+ if (visibilityString != null) {
+ visibilityModifier = VisibilityModifier.getVisibilityModifier(visibilityString + "FOO", false);
+ }
+
+ final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
+ final String display = arg.getLazzy("DISPLAY", 0);
+ final String genericOption = arg.getLazzy("DISPLAY", 1);
+ final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
+
+ final String stereotype = arg.get("STEREO", 0);
+
+ final ILeaf result;
+ if (diagram.leafExist(code)) {
+ result = diagram.getOrCreateLeaf(code, null, null);
+ if (result.muteToType(type, null) == false) {
+ return null;
+ }
+ } else {
+ result = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
+ }
+ result.setVisibilityModifier(visibilityModifier);
+ if (stereotype != null) {
+ result.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ result.addUrl(url);
+ }
+
+ Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
+
+ final HtmlColor lineColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1));
+ if (lineColor != null) {
+ colors = colors.add(ColorType.LINE, lineColor);
+ }
+ if (arg.get("LINECOLOR", 0) != null) {
+ colors = colors.addLegacyStroke(arg.get("LINECOLOR", 0));
+ }
+ result.setColors(colors);
+
+ // result.setSpecificColorTOBEREMOVED(ColorType.BACK,
+ // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ // result.setSpecificColorTOBEREMOVED(ColorType.LINE,
+ // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)));
+ // result.applyStroke(arg.get("LINECOLOR", 0));
+
+ if (generic != null) {
+ result.setGeneric(generic);
+ }
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java
index 1fabff5..6f0dbfc 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java
@@ -1,225 +1,184 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import net.sourceforge.plantuml.FontParam;
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.Url;
-import net.sourceforge.plantuml.UrlBuilder;
-import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-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.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-import net.sourceforge.plantuml.cucadiagram.Stereotype;
-import net.sourceforge.plantuml.graphic.USymbol;
-import net.sourceforge.plantuml.graphic.color.ColorParser;
-import net.sourceforge.plantuml.graphic.color.ColorType;
-
-public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram> {
-
- private final Mode mode;
-
- public static enum Mode {
- NORMAL_KEYWORD, WITH_MIX_PREFIX
- }
-
- public CommandCreateElementFull2(Mode mode) {
- super(getRegexConcat(mode));
- this.mode = mode;
- }
-
- private static RegexConcat getRegexConcat(Mode mode) {
-
- String regex = "(?:(actor|usecase|component)[%s]+)";
- if (mode == Mode.WITH_MIX_PREFIX) {
- regex = "mix_" + regex;
- }
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("SYMBOL", regex), //
- new RegexLeaf("[%s]*"), //
- new RegexOr(//
- new RegexLeaf("CODE1", CODE_WITH_QUOTE) //
- ), //
- new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
- new RegexLeaf("[%s]*"), //
- ColorParser.exp1(), //
- new RegexLeaf("$"));
- }
-
- private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
- private static final String CODE = "(" + CODE_CORE + ")";
- private static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
-
- private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
- private static final String DISPLAY = "(" + DISPLAY_CORE + ")";
- private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
-
- @Override
- final protected boolean isForbidden(CharSequence line) {
- if (line.toString().matches("^[\\p{L}0-9_.]+$")) {
- return true;
- }
- return false;
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
- if (mode == Mode.NORMAL_KEYWORD && diagram.isAllowMixing() == false) {
- return CommandExecutionResult
- .error("Use 'allow_mixing' if you want to mix classes and other UML elements.");
- }
- String codeRaw = arg.getLazzy("CODE", 0);
- final String displayRaw = arg.getLazzy("DISPLAY", 0);
- final char codeChar = getCharEncoding(codeRaw);
- final char codeDisplay = getCharEncoding(displayRaw);
- final String symbol;
- if (codeRaw.startsWith("()")) {
- symbol = "interface";
- codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(codeRaw.substring(2)));
- } else if (codeChar == '(' || codeDisplay == '(') {
- symbol = "usecase";
- } else if (codeChar == ':' || codeDisplay == ':') {
- symbol = "actor";
- } else if (codeChar == '[' || codeDisplay == '[') {
- symbol = "component";
- } else {
- symbol = arg.get("SYMBOL", 0);
- }
-
- final LeafType type;
- final USymbol usymbol;
-
- if (symbol == null) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.ACTOR;
- } else if (symbol.equalsIgnoreCase("artifact")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.ARTIFACT;
- } else if (symbol.equalsIgnoreCase("folder")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.FOLDER;
- } else if (symbol.equalsIgnoreCase("package")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.PACKAGE;
- } else if (symbol.equalsIgnoreCase("rectangle")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.RECTANGLE;
- } else if (symbol.equalsIgnoreCase("node")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.NODE;
- } else if (symbol.equalsIgnoreCase("frame")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.FRAME;
- } else if (symbol.equalsIgnoreCase("cloud")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.CLOUD;
- } else if (symbol.equalsIgnoreCase("database")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.DATABASE;
- } else if (symbol.equalsIgnoreCase("storage")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.STORAGE;
- } else if (symbol.equalsIgnoreCase("agent")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.AGENT;
- } else if (symbol.equalsIgnoreCase("actor")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.ACTOR;
- } else if (symbol.equalsIgnoreCase("component")) {
- type = LeafType.DESCRIPTION;
- usymbol = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
- } else if (symbol.equalsIgnoreCase("boundary")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.BOUNDARY;
- } else if (symbol.equalsIgnoreCase("control")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.CONTROL;
- } else if (symbol.equalsIgnoreCase("entity")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.ENTITY_DOMAIN;
- } else if (symbol.equalsIgnoreCase("interface")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.INTERFACE;
- } else if (symbol.equalsIgnoreCase("()")) {
- type = LeafType.DESCRIPTION;
- usymbol = USymbol.INTERFACE;
- } else if (symbol.equalsIgnoreCase("usecase")) {
- type = LeafType.USECASE;
- usymbol = null;
- } else {
- throw new IllegalStateException();
- }
-
- final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw));
- String display = displayRaw;
- if (display == null) {
- display = code.getFullName();
- }
- display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
- final String stereotype = arg.getLazzy("STEREOTYPE", 0);
- final IEntity entity = diagram.getOrCreateLeaf(code, type, usymbol);
- entity.setDisplay(Display.getWithNewlines(display));
- entity.setUSymbol(usymbol);
- if (stereotype != null) {
- entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
- .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
- .getIHtmlColorSet()));
- }
-
- final String urlString = arg.get("URL", 0);
- if (urlString != null) {
- final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
- final Url url = urlBuilder.getUrl(urlString);
- entity.addUrl(url);
- }
-
- entity.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
- return CommandExecutionResult.ok();
- }
-
- private char getCharEncoding(final String codeRaw) {
- return codeRaw != null && codeRaw.length() > 2 ? codeRaw.charAt(0) : 0;
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+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.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.descdiagram.command.CommandCreateElementFull;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.graphic.color.ColorParser;
+import net.sourceforge.plantuml.graphic.color.ColorType;
+
+public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram> {
+
+ private final Mode mode;
+
+ public static enum Mode {
+ NORMAL_KEYWORD, WITH_MIX_PREFIX
+ }
+
+ public CommandCreateElementFull2(Mode mode) {
+ super(getRegexConcat(mode));
+ this.mode = mode;
+ }
+
+ private static RegexConcat getRegexConcat(Mode mode) {
+
+ // String regex = "(?:(actor|usecase|component)[%s]+)";
+ String regex = "(?:(state|" + CommandCreateElementFull.ALL_TYPES + ")[%s]+)";
+ if (mode == Mode.WITH_MIX_PREFIX) {
+ regex = "mix_" + regex;
+ }
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("SYMBOL", regex), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("CODE1", CommandCreateElementFull.CODE_WITH_QUOTE), //
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY2", CommandCreateElementFull.DISPLAY), //
+ new RegexLeaf("STEREOTYPE2", "(?:[%s]+(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]*as[%s]+"), //
+ new RegexLeaf("CODE2", CommandCreateElementFull.CODE)) //
+ ), //
+ new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ ColorParser.exp1(), //
+ new RegexLeaf("$"));
+ }
+
+
+
+ @Override
+ final protected boolean isForbidden(CharSequence line) {
+ if (line.toString().matches("^[\\p{L}0-9_.]+$")) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ if (mode == Mode.NORMAL_KEYWORD && diagram.isAllowMixing() == false) {
+ return CommandExecutionResult
+ .error("Use 'allow_mixing' if you want to mix classes and other UML elements.");
+ }
+ String codeRaw = arg.getLazzy("CODE", 0);
+ final String displayRaw = arg.getLazzy("DISPLAY", 0);
+ final char codeChar = getCharEncoding(codeRaw);
+ final char codeDisplay = getCharEncoding(displayRaw);
+ final String symbol;
+ if (codeRaw.startsWith("()")) {
+ symbol = "interface";
+ codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(codeRaw.substring(2)));
+ } else if (codeChar == '(' || codeDisplay == '(') {
+ symbol = "usecase";
+ } else if (codeChar == ':' || codeDisplay == ':') {
+ symbol = "actor";
+ } else if (codeChar == '[' || codeDisplay == '[') {
+ symbol = "component";
+ } else {
+ symbol = arg.get("SYMBOL", 0);
+ }
+
+ final LeafType type;
+ final USymbol usymbol;
+
+ if (symbol == null) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ACTOR;
+ } else if (symbol.equalsIgnoreCase("usecase")) {
+ type = LeafType.USECASE;
+ usymbol = null;
+ } else if (symbol.equalsIgnoreCase("state")) {
+ type = LeafType.STATE;
+ usymbol = null;
+ } else {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.getFromString(symbol, diagram.getSkinParam().useUml2ForComponent());
+ if (usymbol == null) {
+ throw new IllegalStateException();
+ }
+ }
+
+ final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw));
+ String display = displayRaw;
+ if (display == null) {
+ display = code.getFullName();
+ }
+ display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
+ final String stereotype = arg.getLazzy("STEREOTYPE", 0);
+ final IEntity entity = diagram.getOrCreateLeaf(code, type, usymbol);
+ entity.setDisplay(Display.getWithNewlines(display));
+ entity.setUSymbol(usymbol);
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ }
+
+ entity.setSpecificColorTOBEREMOVED(ColorType.BACK,
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ return CommandExecutionResult.ok();
+ }
+
+ private char getCharEncoding(final String codeRaw) {
+ return codeRaw != null && codeRaw.length() > 2 ? codeRaw.charAt(0) : 0;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java
index 55a38ca..e46a4eb 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java
@@ -1,62 +1,63 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.List;
-
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-
-public class CommandDiamondAssociation extends SingleLineCommand<ClassDiagram> {
-
- public CommandDiamondAssociation() {
- super("(?i)^\\<\\>[%s]*([\\p{L}0-9_.]+)$");
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
- final Code code = Code.of(arg.get(0));
- if (diagram.leafExist(code)) {
- return CommandExecutionResult.error("Already existing : "+code.getFullName());
- }
- diagram.createLeaf(code, Display.NULL, LeafType.ASSOCIATION, null);
-
- return CommandExecutionResult.ok();
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+public class CommandDiamondAssociation extends SingleLineCommand<ClassDiagram> {
+
+ public CommandDiamondAssociation() {
+ super("(?i)^\\<\\>[%s]*([\\p{L}0-9_.]+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
+ final Code code = Code.of(arg.get(0));
+ if (diagram.leafExist(code)) {
+ return CommandExecutionResult.error("Already existing : "+code.getFullName());
+ }
+ diagram.createLeaf(code, Display.NULL, LeafType.ASSOCIATION, null);
+
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java
index 45fed88..13f09ce 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByGender.java
@@ -1,188 +1,213 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.EnumSet;
-import java.util.Set;
-
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.UmlDiagram;
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-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.RegexResult;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.EntityGender;
-import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils;
-import net.sourceforge.plantuml.cucadiagram.EntityPortion;
-import net.sourceforge.plantuml.cucadiagram.EntityUtils;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
-
-public class CommandHideShow extends SingleLineCommand2<UmlDiagram> {
-
- private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
- private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
- EntityPortion.METHOD);
- private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
-
- public CommandHideShow() {
- super(getRegexConcat());
- }
-
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("COMMAND", "(hide|show)"), //
- new RegexLeaf("[%s]+"), //
- new RegexLeaf("GENDER",
- "(?:(class|interface|enum|annotation|abstract|[\\p{L}0-9_.]+|[%g][^%g]+[%g]|\\<\\<.*\\>\\>)[%s]+)*?"), //
- new RegexLeaf("EMPTY", "(?:(empty)[%s]+)?"), //
- new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)"), //
- new RegexLeaf("$"));
- }
-
- private final EntityGender emptyByGender(Set<EntityPortion> portion) {
- if (portion == PORTION_METHOD) {
- return EntityGenderUtils.emptyMethods();
- }
- if (portion == PORTION_FIELD) {
- return EntityGenderUtils.emptyFields();
- }
- if (portion == PORTION_MEMBER) {
- return EntityGenderUtils.emptyMembers();
- }
- return EntityGenderUtils.all();
- }
-
- @Override
- protected CommandExecutionResult executeArg(UmlDiagram classDiagram, RegexResult arg) {
- if (classDiagram instanceof ClassDiagram) {
- return executeClassDiagram((ClassDiagram) classDiagram, arg);
- }
- if (classDiagram instanceof DescriptionDiagram) {
- return executeDescriptionDiagram((DescriptionDiagram) classDiagram, arg);
- }
- // Just ignored
- return CommandExecutionResult.ok();
- }
-
- private CommandExecutionResult executeDescriptionDiagram(DescriptionDiagram diagram, RegexResult arg) {
- final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
- final EntityGender gender;
- final String arg1 = arg.get("GENDER", 0);
- if (arg1 == null) {
- gender = EntityGenderUtils.all();
- } else if (arg1.equalsIgnoreCase("class")) {
- gender = EntityGenderUtils.byEntityType(LeafType.CLASS);
- } else if (arg1.equalsIgnoreCase("interface")) {
- gender = EntityGenderUtils.byEntityType(LeafType.INTERFACE);
- } else if (arg1.equalsIgnoreCase("enum")) {
- gender = EntityGenderUtils.byEntityType(LeafType.ENUM);
- } else if (arg1.equalsIgnoreCase("abstract")) {
- gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
- } else if (arg1.equalsIgnoreCase("annotation")) {
- gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
- } else if (arg1.startsWith("<<")) {
- gender = EntityGenderUtils.byStereotype(arg1);
- } else {
- final IEntity entity = diagram.getOrCreateLeaf(Code.of(arg1), null, null);
- gender = EntityGenderUtils.byEntityAlone(entity);
- }
-
- diagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
- return CommandExecutionResult.ok();
- }
-
- private CommandExecutionResult executeClassDiagram(ClassDiagram classDiagram, RegexResult arg) {
-
- final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
-
- EntityGender gender = null;
- final String arg1 = arg.get("GENDER", 0);
- if (arg1 == null) {
- gender = EntityGenderUtils.all();
- } else if (arg1.equalsIgnoreCase("class")) {
- gender = EntityGenderUtils.byEntityType(LeafType.CLASS);
- } else if (arg1.equalsIgnoreCase("interface")) {
- gender = EntityGenderUtils.byEntityType(LeafType.INTERFACE);
- } else if (arg1.equalsIgnoreCase("enum")) {
- gender = EntityGenderUtils.byEntityType(LeafType.ENUM);
- } else if (arg1.equalsIgnoreCase("abstract")) {
- gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
- } else if (arg1.equalsIgnoreCase("annotation")) {
- gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
- } else if (arg1.startsWith("<<")) {
- gender = EntityGenderUtils.byStereotype(arg1);
- } else {
- final IEntity entity = classDiagram.getOrCreateLeaf(Code.of(arg1), null, null);
- gender = EntityGenderUtils.byEntityAlone(entity);
- }
- if (gender != null) {
- final boolean empty = arg.get("EMPTY", 0) != null;
- if (empty == true) {
- gender = EntityGenderUtils.and(gender, emptyByGender(portion));
- }
- if (EntityUtils.groupRoot(classDiagram.getCurrentGroup()) == false) {
- gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(classDiagram.getCurrentGroup()));
- }
- classDiagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
- }
- return CommandExecutionResult.ok();
- }
-
- private Set<EntityPortion> getEntityPortion(String s) {
- final String sub = StringUtils.goLowerCase(s.substring(0, 3));
- if (sub.equals("met")) {
- return PORTION_METHOD;
- }
- if (sub.equals("mem")) {
- return PORTION_MEMBER;
- }
- if (sub.equals("att") || sub.equals("fie")) {
- return PORTION_FIELD;
- }
- if (sub.equals("cir")) {
- return EnumSet.<EntityPortion> of(EntityPortion.CIRCLED_CHARACTER);
- }
- if (sub.equals("ste")) {
- return EnumSet.<EntityPortion> of(EntityPortion.STEREOTYPE);
- }
- throw new IllegalArgumentException();
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+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.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.EntityGender;
+import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
+import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
+
+ private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
+ EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
+
+ public CommandHideShowByGender() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COMMAND", "(hide|show)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("GENDER",
+ "(?:(class|object|interface|enum|annotation|abstract|[\\p{L}0-9_.]+|[%g][^%g]+[%g]|\\<\\<.*\\>\\>)[%s]+)*?"), //
+ new RegexLeaf("EMPTY", "(?:(empty)[%s]+)?"), //
+ new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)"), //
+ new RegexLeaf("$"));
+ }
+
+ private final EntityGender emptyByGender(Set<EntityPortion> portion) {
+ if (portion == PORTION_METHOD) {
+ return EntityGenderUtils.emptyMethods();
+ }
+ if (portion == PORTION_FIELD) {
+ return EntityGenderUtils.emptyFields();
+ }
+ if (portion == PORTION_MEMBER) {
+ throw new IllegalArgumentException();
+ // return EntityGenderUtils.emptyMembers();
+ }
+ return EntityGenderUtils.all();
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, RegexResult arg) {
+ if (diagram instanceof AbstractClassOrObjectDiagram) {
+ return executeClassDiagram((AbstractClassOrObjectDiagram) diagram, arg);
+ }
+ if (diagram instanceof DescriptionDiagram) {
+ return executeDescriptionDiagram((DescriptionDiagram) diagram, arg);
+ }
+ if (diagram instanceof SequenceDiagram) {
+ return executeSequenceDiagram((SequenceDiagram) diagram, arg);
+ }
+ // Just ignored
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeSequenceDiagram(SequenceDiagram diagram, RegexResult arg) {
+ final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
+ diagram.hideOrShow(portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeDescriptionDiagram(DescriptionDiagram diagram, RegexResult arg) {
+ final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
+ final EntityGender gender;
+ final String arg1 = arg.get("GENDER", 0);
+ if (arg1 == null) {
+ gender = EntityGenderUtils.all();
+ } else if (arg1.equalsIgnoreCase("class")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.CLASS);
+ } else if (arg1.equalsIgnoreCase("object")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.OBJECT);
+ } else if (arg1.equalsIgnoreCase("interface")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.INTERFACE);
+ } else if (arg1.equalsIgnoreCase("enum")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ENUM);
+ } else if (arg1.equalsIgnoreCase("abstract")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
+ } else if (arg1.equalsIgnoreCase("annotation")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
+ } else if (arg1.startsWith("<<")) {
+ gender = EntityGenderUtils.byStereotype(arg1);
+ } else {
+ final IEntity entity = diagram.getOrCreateLeaf(Code.of(arg1), null, null);
+ gender = EntityGenderUtils.byEntityAlone(entity);
+ }
+
+ diagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeClassDiagram(AbstractClassOrObjectDiagram classDiagram, RegexResult arg) {
+
+ final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
+
+ EntityGender gender = null;
+ final String arg1 = arg.get("GENDER", 0);
+ if (arg1 == null) {
+ gender = EntityGenderUtils.all();
+ } else if (arg1.equalsIgnoreCase("class")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.CLASS);
+ } else if (arg1.equalsIgnoreCase("object")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.OBJECT);
+ } else if (arg1.equalsIgnoreCase("interface")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.INTERFACE);
+ } else if (arg1.equalsIgnoreCase("enum")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ENUM);
+ } else if (arg1.equalsIgnoreCase("abstract")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
+ } else if (arg1.equalsIgnoreCase("annotation")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
+ } else if (arg1.startsWith("<<")) {
+ gender = EntityGenderUtils.byStereotype(arg1);
+ } else {
+ final IEntity entity = classDiagram.getOrCreateLeaf(Code.of(arg1), null, null);
+ gender = EntityGenderUtils.byEntityAlone(entity);
+ }
+ if (gender != null) {
+ final boolean empty = arg.get("EMPTY", 0) != null;
+ final boolean emptyMembers = empty && portion == PORTION_MEMBER;
+ if (empty == true && emptyMembers == false) {
+ gender = EntityGenderUtils.and(gender, emptyByGender(portion));
+ }
+ if (EntityUtils.groupRoot(classDiagram.getCurrentGroup()) == false) {
+ gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(classDiagram.getCurrentGroup()));
+ }
+
+ if (emptyMembers) {
+ classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(PORTION_FIELD)), PORTION_FIELD, arg
+ .get("COMMAND", 0).equalsIgnoreCase("show"));
+ classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(PORTION_METHOD)), PORTION_METHOD,
+ arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ } else {
+ classDiagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ }
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private Set<EntityPortion> getEntityPortion(String s) {
+ final String sub = StringUtils.goLowerCase(s.substring(0, 3));
+ if (sub.equals("met")) {
+ return PORTION_METHOD;
+ }
+ if (sub.equals("mem")) {
+ return PORTION_MEMBER;
+ }
+ if (sub.equals("att") || sub.equals("fie")) {
+ return PORTION_FIELD;
+ }
+ if (sub.equals("cir")) {
+ return EnumSet.<EntityPortion> of(EntityPortion.CIRCLED_CHARACTER);
+ }
+ if (sub.equals("ste")) {
+ return EnumSet.<EntityPortion> of(EntityPortion.STEREOTYPE);
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow3.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java
index 9d8fbb4..25e2a13 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow3.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowByVisibility.java
@@ -1,140 +1,141 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.EnumSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.UmlDiagram;
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-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.RegexResult;
-import net.sourceforge.plantuml.cucadiagram.EntityPortion;
-import net.sourceforge.plantuml.skin.VisibilityModifier;
-
-public class CommandHideShow3 extends SingleLineCommand2<UmlDiagram> {
-
- private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
- private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
- EntityPortion.METHOD);
- private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
-
- public CommandHideShow3() {
- super(getRegexConcat());
- }
-
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("COMMAND", "(hide|show)"), //
- new RegexLeaf("[%s]+"), //
- new RegexLeaf("VISIBILITY",
- "((?:public|private|protected|package)?(?:[,%s]+(?:public|private|protected|package))*)"), //
- new RegexLeaf("[%s]+"), //
- new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?)"), //
- new RegexLeaf("$"));
- }
-
- @Override
- protected CommandExecutionResult executeArg(UmlDiagram classDiagram, RegexResult arg) {
- if (classDiagram instanceof ClassDiagram) {
- return executeArgClass((ClassDiagram) classDiagram, arg);
- }
- // Just ignored
- return CommandExecutionResult.ok();
- }
-
-
- private CommandExecutionResult executeArgClass(ClassDiagram classDiagram, RegexResult arg) {
-
- final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
-
- final Set<VisibilityModifier> visibilities = EnumSet.<VisibilityModifier> noneOf(VisibilityModifier.class);
- final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,");
- while (st.hasMoreTokens()) {
- addVisibilities(st.nextToken(), portion, visibilities);
- }
-
- classDiagram.hideOrShow(visibilities, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
-
- return CommandExecutionResult.ok();
- }
-
- private void addVisibilities(String token, Set<EntityPortion> portion, Set<VisibilityModifier> result) {
- if (token.equals("public") && portion.contains(EntityPortion.FIELD)) {
- result.add(VisibilityModifier.PUBLIC_FIELD);
- }
- if (token.equals("public") && portion.contains(EntityPortion.METHOD)) {
- result.add(VisibilityModifier.PUBLIC_METHOD);
- }
- if (token.equals("private") && portion.contains(EntityPortion.FIELD)) {
- result.add(VisibilityModifier.PRIVATE_FIELD);
- }
- if (token.equals("private") && portion.contains(EntityPortion.METHOD)) {
- result.add(VisibilityModifier.PRIVATE_METHOD);
- }
- if (token.equals("protected") && portion.contains(EntityPortion.FIELD)) {
- result.add(VisibilityModifier.PROTECTED_FIELD);
- }
- if (token.equals("protected") && portion.contains(EntityPortion.METHOD)) {
- result.add(VisibilityModifier.PROTECTED_METHOD);
- }
- if (token.equals("package") && portion.contains(EntityPortion.FIELD)) {
- result.add(VisibilityModifier.PACKAGE_PRIVATE_FIELD);
- }
- if (token.equals("package") && portion.contains(EntityPortion.METHOD)) {
- result.add(VisibilityModifier.PACKAGE_PRIVATE_METHOD);
- }
- }
-
- private Set<EntityPortion> getEntityPortion(String s) {
- final String sub = StringUtils.goLowerCase(s.substring(0, 3));
- if (sub.equals("met")) {
- return PORTION_METHOD;
- }
- if (sub.equals("mem")) {
- return PORTION_MEMBER;
- }
- if (sub.equals("att") || sub.equals("fie")) {
- return PORTION_FIELD;
- }
- throw new IllegalArgumentException();
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+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.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram> {
+
+ private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
+ EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
+
+ public CommandHideShowByVisibility() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COMMAND", "(hide|show)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("VISIBILITY",
+ "((?:public|private|protected|package)?(?:[,%s]+(?:public|private|protected|package))*)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram classDiagram, RegexResult arg) {
+ if (classDiagram instanceof ClassDiagram) {
+ return executeArgClass((ClassDiagram) classDiagram, arg);
+ }
+ // Just ignored
+ return CommandExecutionResult.ok();
+ }
+
+
+ private CommandExecutionResult executeArgClass(ClassDiagram classDiagram, RegexResult arg) {
+
+ final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
+
+ final Set<VisibilityModifier> visibilities = EnumSet.<VisibilityModifier> noneOf(VisibilityModifier.class);
+ final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,");
+ while (st.hasMoreTokens()) {
+ addVisibilities(st.nextToken(), portion, visibilities);
+ }
+
+ classDiagram.hideOrShow(visibilities, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+
+ return CommandExecutionResult.ok();
+ }
+
+ private void addVisibilities(String token, Set<EntityPortion> portion, Set<VisibilityModifier> result) {
+ if (token.equals("public") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PUBLIC_FIELD);
+ }
+ if (token.equals("public") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PUBLIC_METHOD);
+ }
+ if (token.equals("private") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PRIVATE_FIELD);
+ }
+ if (token.equals("private") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PRIVATE_METHOD);
+ }
+ if (token.equals("protected") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PROTECTED_FIELD);
+ }
+ if (token.equals("protected") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PROTECTED_METHOD);
+ }
+ if (token.equals("package") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PACKAGE_PRIVATE_FIELD);
+ }
+ if (token.equals("package") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PACKAGE_PRIVATE_METHOD);
+ }
+ }
+
+ private Set<EntityPortion> getEntityPortion(String s) {
+ final String sub = StringUtils.goLowerCase(s.substring(0, 3));
+ if (sub.equals("met")) {
+ return PORTION_METHOD;
+ }
+ if (sub.equals("mem")) {
+ return PORTION_MEMBER;
+ }
+ if (sub.equals("att") || sub.equals("fie")) {
+ return PORTION_FIELD;
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java
index 86eebf2..3f52a8f 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java
@@ -1,79 +1,83 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-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.RegexResult;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
-import net.sourceforge.plantuml.cucadiagram.ILeaf;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-
-public class CommandHideShowSpecificClass extends SingleLineCommand2<CucaDiagram> {
-
- public CommandHideShowSpecificClass() {
- super(getRegexConcat());
- }
-
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("COMMAND", "(hide|show)"), //
- new RegexLeaf("[%s]+"), //
- new RegexLeaf("CODE", "(" + CommandCreateClass.CODE + ")"), //
- new RegexLeaf("$"));
- }
-
- @Override
- protected CommandExecutionResult executeArg(CucaDiagram diagram, RegexResult arg) {
-
- final String codeString = arg.get("CODE", 0);
- if (codeString.equals("class")) {
- diagram.hideOrShow(LeafType.CLASS, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
- } else if (codeString.equals("interface")) {
- diagram.hideOrShow(LeafType.INTERFACE, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
- } else {
- final Code code = Code.of(codeString);
- final ILeaf leaf = diagram.getEntityFactory().getLeafs().get(code);
- if (leaf == null) {
- return CommandExecutionResult.error("Class does not exist : " + code.getFullName());
- }
- diagram.hideOrShow(leaf, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
- }
- return CommandExecutionResult.ok();
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+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.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+public class CommandHideShowSpecificClass extends SingleLineCommand2<CucaDiagram> {
+
+ public CommandHideShowSpecificClass() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COMMAND", "(hide|show)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("CODE", "(" + CommandCreateClass.CODE + ")"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(CucaDiagram diagram, RegexResult arg) {
+
+ final String codeString = arg.get("CODE", 0);
+ if (codeString.equals("class")) {
+ diagram.hideOrShow(LeafType.CLASS, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ } else if (codeString.equals("interface")) {
+ diagram.hideOrShow(LeafType.INTERFACE, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ } else {
+ final Code code = Code.of(codeString);
+ IEntity hidden = diagram.getEntityFactory().getLeafs().get(code);
+ if (hidden == null) {
+ hidden = diagram.getEntityFactory().getGroups().get(code);
+ }
+ if (hidden == null) {
+ return CommandExecutionResult.error("Class/Package does not exist : " + code.getFullName());
+ }
+ diagram.hideOrShow(hidden, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java
index 8f02c8c..0fec714 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificStereotype.java
@@ -1,67 +1,68 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-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.RegexResult;
-import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
-import net.sourceforge.plantuml.cucadiagram.Stereotype;
-
-public class CommandHideShowSpecificStereotype extends SingleLineCommand2<CucaDiagram> {
-
- public CommandHideShowSpecificStereotype() {
- super(getRegexConcat());
- }
-
- static RegexConcat getRegexConcat() {
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("COMMAND", "(hide|show)"), //
- new RegexLeaf("[%s]+"), //
- new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)"), //
- new RegexLeaf("$"));
- }
-
- @Override
- protected CommandExecutionResult executeArg(CucaDiagram diagram, RegexResult arg) {
-
- final String stereotype = arg.get("STEREOTYPE", 0);
- diagram.hideOrShow(new Stereotype(stereotype), arg.get("COMMAND", 0).equalsIgnoreCase("show"));
-
- return CommandExecutionResult.ok();
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+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.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+
+public class CommandHideShowSpecificStereotype extends SingleLineCommand2<CucaDiagram> {
+
+ public CommandHideShowSpecificStereotype() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COMMAND", "(hide|show)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(CucaDiagram diagram, RegexResult arg) {
+
+ final String stereotype = arg.get("STEREOTYPE", 0);
+ diagram.hideOrShow(new Stereotype(stereotype), arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java
index 1f6e412..1944c93 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java
@@ -1,111 +1,112 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import net.sourceforge.plantuml.FileSystem;
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.cucadiagram.Link;
-import net.sourceforge.plantuml.cucadiagram.LinkDecor;
-import net.sourceforge.plantuml.cucadiagram.LinkType;
-
-public class CommandImport extends SingleLineCommand<ClassDiagram> {
-
- public CommandImport() {
- super("(?i)^import[%s]+[%g]?([^%g]+)[%g]?$");
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram classDiagram, List<String> arg) {
- final String arg0 = arg.get(0);
- try {
- final File f = FileSystem.getInstance().getFile(arg0);
-
- if (f.isFile()) {
- includeSimpleFile(classDiagram, f);
- } else if (f.isDirectory()) {
- includeDirectory(classDiagram, f);
- }
- } catch (IOException e) {
- e.printStackTrace();
- return CommandExecutionResult.error("IO error " + e);
- }
- return CommandExecutionResult.ok();
- }
-
- private void includeDirectory(ClassDiagram classDiagram, File dir) throws IOException {
- for (File f : dir.listFiles()) {
- includeSimpleFile(classDiagram, f);
- }
-
- }
-
- private void includeSimpleFile(ClassDiagram classDiagram, File f) throws IOException {
- if (StringUtils.goLowerCase(f.getName()).endsWith(".java")) {
- includeFileJava(classDiagram, f);
- }
- // if (f.getName().goLowerCase().endsWith(".sql")) {
- // includeFileSql(f);
- // }
- }
-
- private void includeFileJava(ClassDiagram classDiagram, final File f) throws IOException {
- final JavaFile javaFile = new JavaFile(f);
- for (JavaClass cl : javaFile.getJavaClasses()) {
- final Code name = Code.of(cl.getName());
- final IEntity ent1 = classDiagram.getOrCreateLeaf(name, cl.getType(), null);
-
- for (String p : cl.getParents()) {
- final IEntity ent2 = classDiagram.getOrCreateLeaf(Code.of(p), cl.getParentType(), null);
- final Link link = new Link(ent2, ent1, new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS), Display.NULL, 2);
- classDiagram.addLink(link);
- }
- }
- }
-
- // private void includeFileSql(final File f) throws IOException {
- // new SqlImporter(getSystem(), f).process();
- // }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import net.sourceforge.plantuml.FileSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+
+public class CommandImport extends SingleLineCommand<ClassDiagram> {
+
+ public CommandImport() {
+ super("(?i)^import[%s]+[%g]?([^%g]+)[%g]?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram classDiagram, List<String> arg) {
+ final String arg0 = arg.get(0);
+ try {
+ final File f = FileSystem.getInstance().getFile(arg0);
+
+ if (f.isFile()) {
+ includeSimpleFile(classDiagram, f);
+ } else if (f.isDirectory()) {
+ includeDirectory(classDiagram, f);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return CommandExecutionResult.error("IO error " + e);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private void includeDirectory(ClassDiagram classDiagram, File dir) throws IOException {
+ for (File f : dir.listFiles()) {
+ includeSimpleFile(classDiagram, f);
+ }
+
+ }
+
+ private void includeSimpleFile(ClassDiagram classDiagram, File f) throws IOException {
+ if (StringUtils.goLowerCase(f.getName()).endsWith(".java")) {
+ includeFileJava(classDiagram, f);
+ }
+ // if (f.getName().goLowerCase().endsWith(".sql")) {
+ // includeFileSql(f);
+ // }
+ }
+
+ private void includeFileJava(ClassDiagram classDiagram, final File f) throws IOException {
+ final JavaFile javaFile = new JavaFile(f);
+ for (JavaClass cl : javaFile.getJavaClasses()) {
+ final Code name = Code.of(cl.getName());
+ final IEntity ent1 = classDiagram.getOrCreateLeaf(name, cl.getType(), null);
+
+ for (String p : cl.getParents()) {
+ final IEntity ent2 = classDiagram.getOrCreateLeaf(Code.of(p), cl.getParentType(), null);
+ final Link link = new Link(ent2, ent1, new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS), Display.NULL, 2);
+ classDiagram.addLink(link);
+ }
+ }
+ }
+
+ // private void includeFileSql(final File f) throws IOException {
+ // new SqlImporter(getSystem(), f).process();
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java
index 7209ed5..6dbc8b6 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java
@@ -1,62 +1,63 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-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.RegexResult;
-
-public class CommandLayoutNewLine extends SingleLineCommand2<ClassDiagram> {
-
- public CommandLayoutNewLine() {
- super(getRegexConcat());
- }
-
- private static RegexConcat getRegexConcat() {
-
- return new RegexConcat(new RegexLeaf("^"), //
- new RegexLeaf("layout_new_line"), //
- new RegexLeaf("$"));
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
- diagram.layoutNewLine();
- return CommandExecutionResult.ok();
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+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.RegexResult;
+
+public class CommandLayoutNewLine extends SingleLineCommand2<ClassDiagram> {
+
+ public CommandLayoutNewLine() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("layout_new_line"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ diagram.layoutNewLine();
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java
index 48ccea2..6084f22 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java
@@ -1,561 +1,618 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import net.sourceforge.plantuml.Direction;
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.UmlDiagramType;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand2;
-import net.sourceforge.plantuml.command.regex.MyPattern;
-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.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.cucadiagram.ILeaf;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-import net.sourceforge.plantuml.cucadiagram.Link;
-import net.sourceforge.plantuml.cucadiagram.LinkArrow;
-import net.sourceforge.plantuml.cucadiagram.LinkDecor;
-import net.sourceforge.plantuml.cucadiagram.LinkType;
-import net.sourceforge.plantuml.graphic.HtmlColorSet;
-import net.sourceforge.plantuml.graphic.color.ColorParser;
-import net.sourceforge.plantuml.graphic.color.ColorType;
-import net.sourceforge.plantuml.graphic.color.Colors;
-import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
-
-final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
-
- public CommandLinkClass(UmlDiagramType umlDiagramType) {
- super(getRegexConcat(umlDiagramType));
- }
-
- static private RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
- return new RegexConcat(
- new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
- new RegexOr(//
- new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
- + getClassIdentifier()),
- new RegexLeaf("COUPLE1",
- "\\([%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*,[%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*\\)")),
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
- new RegexLeaf("[%s]*"), //
-
- new RegexConcat(
- //
- new RegexLeaf("ARROW_HEAD1", "([%s]+o|[#\\[<*+^]|[<\\[]\\|)?"), //
- new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
- new RegexLeaf("ARROW_STYLE1",
- "(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
- new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
- new RegexLeaf("INSIDE", "(?:(0|\\(0\\)|\\(0|0\\))(?=[-=.~]))?"), //
- new RegexLeaf("ARROW_STYLE2",
- "(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
- new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
- new RegexLeaf("ARROW_HEAD2", "(o[%s]+|[#\\]>*+^]|\\|[>\\]])?")), //
-
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"),
- new RegexLeaf("[%s]*"), //
- new RegexOr(
- new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
- + getClassIdentifier()),
- new RegexLeaf("COUPLE2",
- "\\([%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*,[%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*\\)")),
- new RegexLeaf("[%s]*"), //
- color().getRegex(), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
- new RegexLeaf("$"));
- }
-
- private static ColorParser color() {
- return ColorParser.simpleColor(ColorType.LINE);
- }
-
- private static String getClassIdentifier() {
- return "(" + getSeparator() + "?[\\p{L}0-9_$]+(?:" + getSeparator() + "[\\p{L}0-9_$]+)*|[%g][^%g]+[%g])";
- }
-
- public static String getSeparator() {
- return "(?:\\.|::|\\\\|\\\\\\\\)";
- }
-
- private static String optionalKeywords(UmlDiagramType type) {
- if (type == UmlDiagramType.CLASS) {
- return "(interface|enum|annotation|abstract[%s]+class|abstract|class|object)";
- }
- if (type == UmlDiagramType.OBJECT) {
- return "(object)";
- }
- throw new IllegalArgumentException();
- }
-
- private LeafType getTypeIfObject(String type) {
- if ("object".equalsIgnoreCase(type)) {
- return LeafType.OBJECT;
- }
- return null;
- }
-
- @Override
- protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
- Code ent1 = Code.of(arg.get("ENT1", 1));
- Code ent2 = Code.of(arg.get("ENT2", 1));
-
- if (ent1 == null) {
- return executeArgSpecial1(diagram, arg);
- }
- if (ent2 == null) {
- return executeArgSpecial2(diagram, arg);
- }
- ent1 = ent1.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
- ent2 = ent2.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
- if (diagram.isGroup(ent1) && diagram.isGroup(ent2)) {
- return executePackageLink(diagram, arg);
- }
-
- final String type1 = arg.get("ENT1", 0);
- final LeafType typeIfObject1 = getTypeIfObject(type1);
-
- final IEntity cl1 = diagram.isGroup(ent1) ? diagram.getGroup(Code.of(StringUtils
- .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1), "\""))) : diagram.getOrCreateLeaf(
- ent1, typeIfObject1, null);
-
- final String type2 = arg.get("ENT2", 0);
- LeafType typeIfObject2 = getTypeIfObject(type2);
- if (diagram.leafExist(ent2) == false && cl1.getEntityType() == LeafType.OBJECT && typeIfObject2 == null) {
- typeIfObject2 = LeafType.OBJECT;
- }
-
- final IEntity cl2 = diagram.isGroup(ent2) ? diagram.getGroup(Code.of(StringUtils
- .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1), "\""))) : diagram.getOrCreateLeaf(
- ent2, typeIfObject2, null);
-
- if (arg.get("ENT1", 0) != null) {
- final LeafType type = LeafType.getLeafType(arg.get("ENT1", 0));
- if (type != LeafType.OBJECT) {
- ((ILeaf) cl1).muteToType(type, null);
- }
- }
- if (arg.get("ENT2", 0) != null) {
- final LeafType type = LeafType.getLeafType(arg.get("ENT2", 0));
- if (type != LeafType.OBJECT) {
- ((ILeaf) cl2).muteToType(type, null);
- }
- }
- // if (arg.get("ENT1", 2) != null) {
- // cl1.setStereotype(new Stereotype(arg.get("ENT1", 2), diagram.getSkinParam().getCircledCharacterRadius(),
- // diagram.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
- // .getIHtmlColorSet()));
- // }
- // if (arg.get("ENT2", 2) != null) {
- // cl2.setStereotype(new Stereotype(arg.get("ENT2", 2), diagram.getSkinParam().getCircledCharacterRadius(),
- // diagram.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
- // .getIHtmlColorSet()));
- // }
-
- Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
-
- final LinkType linkType = getLinkType(arg);
- final Direction dir = getDirection(arg);
- final int queue;
- if (dir == Direction.LEFT || dir == Direction.RIGHT) {
- queue = 1;
- } else {
- queue = getQueueLength(arg);
- }
-
- String firstLabel = arg.get("FIRST_LABEL", 0);
- String secondLabel = arg.get("SECOND_LABEL", 0);
-
- String labelLink = null;
-
- if (arg.get("LABEL_LINK", 0) != null) {
- labelLink = arg.get("LABEL_LINK", 0);
- if (firstLabel == null && secondLabel == null) {
- final Pattern p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
- final Matcher m1 = p1.matcher(labelLink);
- if (m1.matches()) {
- firstLabel = m1.group(1);
- labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
- StringUtils.trin(m1.group(2)), "\""));
- secondLabel = m1.group(3);
- } else {
- final Pattern p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
- final Matcher m2 = p2.matcher(labelLink);
- if (m2.matches()) {
- firstLabel = m2.group(1);
- labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
- StringUtils.trin(m2.group(2)), "\""));
- secondLabel = null;
- } else {
- final Pattern p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
- final Matcher m3 = p3.matcher(labelLink);
- if (m3.matches()) {
- firstLabel = null;
- labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
- StringUtils.trin(m3.group(1)), "\""));
- secondLabel = m3.group(2);
- }
- }
- }
- }
- labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink, "\"");
- }
-
- LinkArrow linkArrow = LinkArrow.NONE;
- if ("<".equals(labelLink)) {
- linkArrow = LinkArrow.BACKWARD;
- labelLink = null;
- } else if (">".equals(labelLink)) {
- linkArrow = LinkArrow.DIRECT_NORMAL;
- labelLink = null;
- } else if (labelLink != null && labelLink.startsWith("< ")) {
- linkArrow = LinkArrow.BACKWARD;
- labelLink = StringUtils.trin(labelLink.substring(2));
- } else if (labelLink != null && labelLink.startsWith("> ")) {
- linkArrow = LinkArrow.DIRECT_NORMAL;
- labelLink = StringUtils.trin(labelLink.substring(2));
- } else if (labelLink != null && labelLink.endsWith(" >")) {
- linkArrow = LinkArrow.DIRECT_NORMAL;
- labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
- } else if (labelLink != null && labelLink.endsWith(" <")) {
- linkArrow = LinkArrow.BACKWARD;
- labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
- }
-
- Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), queue, firstLabel, secondLabel,
- diagram.getLabeldistance(), diagram.getLabelangle());
-
- if (dir == Direction.LEFT || dir == Direction.UP) {
- link = link.getInv();
- }
- link.setLinkArrow(linkArrow);
- colors = applyStyle(arg.getLazzy("ARROW_STYLE", 0), link, colors);
- link.setColors(colors);
-
- addLink(diagram, link, arg.get("HEADER", 0));
-
- return CommandExecutionResult.ok();
- }
-
- private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
- diagram.addLink(link);
- if (weight == null) {
- // final LinkType type = link.getType();
- // --|> highest
- // --*, -->, --o normal
- // ..*, ..>, ..o lowest
- // if (type.isDashed() == false) {
- // if (type.contains(LinkDecor.EXTENDS)) {
- // link.setWeight(3);
- // }
- // if (type.contains(LinkDecor.ARROW) ||
- // type.contains(LinkDecor.COMPOSITION)
- // || type.contains(LinkDecor.AGREGATION)) {
- // link.setWeight(2);
- // }
- // }
- } else {
- link.setWeight(Double.parseDouble(weight));
- }
- }
-
- private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
- final IEntity cl1 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
- arg.get("ENT1", 1), "\"")));
- final IEntity cl2 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
- arg.get("ENT2", 1), "\"")));
-
- final LinkType linkType = getLinkType(arg);
- final Direction dir = getDirection(arg);
- final int queue;
- if (dir == Direction.LEFT || dir == Direction.RIGHT) {
- queue = 1;
- } else {
- queue = getQueueLength(arg);
- }
-
- Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
-
- final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
- final String firstLabel = arg.get("FIRST_LABEL", 0);
- final String secondLabel = arg.get("SECOND_LABEL", 0);
- final Link link = new Link(cl1, cl2, linkType, labelLink, queue, firstLabel, secondLabel,
- diagram.getLabeldistance(), diagram.getLabelangle());
-
- diagram.resetPragmaLabel();
-
- colors = applyStyle(arg.getLazzy("ARROW_STYLE", 0), link, colors);
- link.setColors(colors);
-
- addLink(diagram, link, arg.get("HEADER", 0));
- return CommandExecutionResult.ok();
- }
-
- private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
- final Code clName1 = Code.of(arg.get("COUPLE1", 0));
- final Code clName2 = Code.of(arg.get("COUPLE1", 1));
- if (diagram.leafExist(clName1) == false) {
- return CommandExecutionResult.error("No class " + clName1);
- }
- if (diagram.leafExist(clName2) == false) {
- return CommandExecutionResult.error("No class " + clName2);
- }
-
- final Code ent2 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1), "\""));
- final IEntity cl2 = diagram.getOrCreateLeaf(ent2, null, null);
-
- final LinkType linkType = getLinkType(arg);
- final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
- // final int length = getQueueLength(arg);
- // final String weight = arg.get("HEADER").get(0);
-
- final boolean result = diagram.associationClass(1, clName1, clName2, cl2, linkType, label);
- if (result == false) {
- return CommandExecutionResult.error("Cannot have more than 2 assocications");
- }
-
- return CommandExecutionResult.ok();
- }
-
- private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
- final Code clName1 = Code.of(arg.get("COUPLE2", 0));
- final Code clName2 = Code.of(arg.get("COUPLE2", 1));
- if (diagram.leafExist(clName1) == false) {
- return CommandExecutionResult.error("No class " + clName1);
- }
- if (diagram.leafExist(clName2) == false) {
- return CommandExecutionResult.error("No class " + clName2);
- }
-
- final Code ent1 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1), "\""));
- final IEntity cl1 = diagram.getOrCreateLeaf(ent1, null, null);
-
- final LinkType linkType = getLinkType(arg);
- final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
- // final int length = getQueueLength(arg);
- // final String weight = arg.get("HEADER").get(0);
-
- final boolean result = diagram.associationClass(2, clName1, clName2, cl1, linkType, label);
- if (result == false) {
- return CommandExecutionResult.error("Cannot have more than 2 assocications");
- }
-
- return CommandExecutionResult.ok();
- }
-
- private LinkDecor getDecors1(String s) {
- if (s == null) {
- return LinkDecor.NONE;
- }
- s = StringUtils.trin(s);
- if ("<|".equals(s)) {
- return LinkDecor.EXTENDS;
- }
- if ("<".equals(s)) {
- return LinkDecor.ARROW;
- }
- if ("^".equals(s)) {
- return LinkDecor.EXTENDS;
- }
- if ("+".equals(s)) {
- return LinkDecor.PLUS;
- }
- if ("o".equals(s)) {
- return LinkDecor.AGREGATION;
- }
- if ("*".equals(s)) {
- return LinkDecor.COMPOSITION;
- }
- if ("#".equals(s)) {
- return LinkDecor.SQUARRE;
- }
- return LinkDecor.NONE;
- }
-
- private LinkDecor getDecors2(String s) {
- if (s == null) {
- return LinkDecor.NONE;
- }
- s = StringUtils.trin(s);
- if ("|>".equals(s)) {
- return LinkDecor.EXTENDS;
- }
- if (">".equals(s)) {
- return LinkDecor.ARROW;
- }
- if ("^".equals(s)) {
- return LinkDecor.EXTENDS;
- }
- if ("+".equals(s)) {
- return LinkDecor.PLUS;
- }
- if ("o".equals(s)) {
- return LinkDecor.AGREGATION;
- }
- if ("*".equals(s)) {
- return LinkDecor.COMPOSITION;
- }
- if ("#".equals(s)) {
- return LinkDecor.SQUARRE;
- }
- return LinkDecor.NONE;
- }
-
- private LinkType getLinkType(RegexResult arg) {
- final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
- final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
-
- LinkType result = new LinkType(decors2, decors1);
- if (arg.get("ARROW_BODY1", 0).contains(".") || arg.get("ARROW_BODY2", 0).contains(".")) {
- result = result.getDashed();
- }
- final String middle = arg.get("INSIDE", 0);
- if ("0".equals(middle)) {
- result = result.withMiddleCircle();
- } else if ("0)".equals(middle)) {
- result = result.withMiddleCircleCircled1();
- } else if ("(0".equals(middle)) {
- result = result.withMiddleCircleCircled2();
- } else if ("(0)".equals(middle)) {
- result = result.withMiddleCircleCircled();
- }
- return result;
- }
-
- private int getQueueLength(RegexResult arg) {
- String s = getFullArrow(arg);
- s = s.replaceAll("[^-.=]", "");
- return s.length();
- }
-
- private Direction getDirection(RegexResult arg) {
- final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
- final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
-
- String s = getFullArrow(arg);
- s = s.replaceAll("[^-.=\\w]", "");
- if (s.startsWith("o")) {
- s = s.substring(1);
- }
- if (s.endsWith("o")) {
- s = s.substring(0, s.length() - 1);
- }
-
- Direction result = StringUtils.getQueueDirection(s);
- if (isInversed(decors1, decors2) && s.matches(".*\\w.*")) {
- result = result.getInv();
- }
-
- return result;
- }
-
- private String getFullArrow(RegexResult arg) {
- return notNull(arg.get("ARROW_HEAD1", 0)) + notNull(arg.get("ARROW_BODY1", 0))
- + notNull(arg.get("ARROW_DIRECTION", 0)) + notNull(arg.get("ARROW_BODY2", 0))
- + notNull(arg.get("ARROW_HEAD2", 0));
- }
-
- public static String notNull(String s) {
- if (s == null) {
- return "";
- }
- return s;
- }
-
- @Deprecated
- public static Colors applyStyle(String arrowStyle, Link link) {
- return applyStyle(arrowStyle, link, null);
- }
-
- public static Colors applyStyle(String arrowStyle, Link link, Colors colors) {
- if (arrowStyle == null) {
- return colors;
- }
- final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
- while (st.hasMoreTokens()) {
- final String s = st.nextToken();
- if (s.equalsIgnoreCase("dashed")) {
- link.goDashed();
- } else if (s.equalsIgnoreCase("bold")) {
- link.goBold();
- } else if (s.equalsIgnoreCase("dotted")) {
- link.goDotted();
- } else if (s.equalsIgnoreCase("hidden")) {
- link.goHidden();
- } else if (s.equalsIgnoreCase("plain")) {
- // Do nothing
- } else if (s.equalsIgnoreCase("norank")) {
- link.goNorank();
- } else {
- link.setSpecificColor(s);
- if (colors != null) {
- colors = colors.add(ColorType.LINE, HtmlColorSet.getInstance().getColorIfValid(s));
- }
- }
- }
- return colors;
- }
-
- private boolean isInversed(LinkDecor decors1, LinkDecor decors2) {
- if (decors1 == LinkDecor.ARROW && decors2 != LinkDecor.ARROW) {
- return true;
- }
- if (decors2 == LinkDecor.AGREGATION) {
- return true;
- }
- if (decors2 == LinkDecor.COMPOSITION) {
- return true;
- }
- if (decors2 == LinkDecor.PLUS) {
- return true;
- }
- // if (decors2 == LinkDecor.EXTENDS) {
- // return true;
- // }
- return false;
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.Matcher2;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.Pattern2;
+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.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkArrow;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.color.ColorParser;
+import net.sourceforge.plantuml.graphic.color.ColorType;
+import net.sourceforge.plantuml.graphic.color.Colors;
+import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
+
+final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
+
+ private static final String SINGLE = "[.\\\\]{0,2}[\\p{L}0-9_]+(?:[.\\\\]{1,2}[\\p{L}0-9_]+)*";
+ private static final String COUPLE = "\\([%s]*(" + SINGLE + ")[%s]*,[%s]*(" + SINGLE + ")[%s]*\\)";
+
+ public CommandLinkClass(UmlDiagramType umlDiagramType) {
+ super(getRegexConcat(umlDiagramType));
+ }
+
+ static private RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
+ return new RegexConcat(
+ new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
+ new RegexOr( //
+ new RegexLeaf("ENT1", getClassIdentifier()),//
+ new RegexLeaf("COUPLE1", COUPLE)),
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+
+ new RegexConcat(
+ //
+ new RegexLeaf("ARROW_HEAD1", "([%s]+[ox]|[)#\\[<*+^}]|[<\\[]\\||\\}o|\\}\\||\\|o|\\|\\|)?"), //
+ new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
+ new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
+ new RegexLeaf("INSIDE", "(?:(0|\\(0\\)|\\(0|0\\))(?=[-=.~]))?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
+ new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
+ new RegexLeaf("ARROW_HEAD2", "([ox][%s]+|[(#\\]>*+^\\{]|\\|[>\\]]|o\\{|\\|\\{|o\\||\\|\\|)?")), //
+
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), new RegexLeaf("[%s]*"), //
+ new RegexOr( //
+ new RegexLeaf("ENT2", getClassIdentifier()), //
+ new RegexLeaf("COUPLE2", COUPLE)), //
+ new RegexLeaf("[%s]*"), //
+ color().getRegex(), //
+ new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static ColorParser color() {
+ return ColorParser.simpleColor(ColorType.LINE);
+ }
+
+ private static String getClassIdentifier() {
+ return "(" + getSeparator() + "?[\\p{L}0-9_$]+(?:" + getSeparator() + "[\\p{L}0-9_$]+)*|[%g][^%g]+[%g])";
+ }
+
+ public static String getSeparator() {
+ return "(?:\\.|::|\\\\|\\\\\\\\)";
+ }
+
+ // private static String optionalKeywords(UmlDiagramType type) {
+ // if (type == UmlDiagramType.CLASS) {
+ // return "(interface|enum|annotation|abstract[%s]+class|abstract|class|object|entity)";
+ // }
+ // if (type == UmlDiagramType.OBJECT) {
+ // return "(object)";
+ // }
+ // throw new IllegalArgumentException();
+ // }
+ //
+ // private LeafType getTypeIfObject(String type) {
+ // if ("object".equalsIgnoreCase(type)) {
+ // return LeafType.OBJECT;
+ // }
+ // return null;
+ // }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+
+ Code ent1 = Code.of(arg.get("ENT1", 0));
+ Code ent2 = Code.of(arg.get("ENT2", 0));
+
+ if (ent1 == null) {
+ return executeArgSpecial1(diagram, arg);
+ }
+ if (ent2 == null) {
+ return executeArgSpecial2(diagram, arg);
+ }
+ ent1 = ent1.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
+ ent2 = ent2.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
+ if (isGroupButNotTheCurrentGroup(diagram, ent1) && isGroupButNotTheCurrentGroup(diagram, ent2)) {
+ return executePackageLink(diagram, arg);
+ }
+
+ String port1 = null;
+ String port2 = null;
+
+ if (removeMemberPart(diagram, ent1) != null) {
+ port1 = ent1.getPortMember();
+ ent1 = removeMemberPart(diagram, ent1);
+ }
+ if (removeMemberPart(diagram, ent2) != null) {
+ port2 = ent2.getPortMember();
+ ent2 = removeMemberPart(diagram, ent2);
+ }
+
+ final IEntity cl1 = isGroupButNotTheCurrentGroup(diagram, ent1) ? diagram.getGroup(Code.of(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""))) : diagram.getOrCreateLeaf(
+ ent1, null, null);
+
+ final IEntity cl2 = isGroupButNotTheCurrentGroup(diagram, ent2) ? diagram.getGroup(Code.of(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""))) : diagram.getOrCreateLeaf(
+ ent2, null, null);
+
+ Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
+
+ final LinkType linkType = getLinkType(arg);
+ final Direction dir = getDirection(arg);
+ final int queue;
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ queue = 1;
+ } else {
+ queue = getQueueLength(arg);
+ }
+
+ String firstLabel = arg.get("FIRST_LABEL", 0);
+ String secondLabel = arg.get("SECOND_LABEL", 0);
+
+ String labelLink = null;
+
+ if (arg.get("LABEL_LINK", 0) != null) {
+ labelLink = arg.get("LABEL_LINK", 0);
+ if (firstLabel == null && secondLabel == null) {
+ final Pattern2 p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
+ final Matcher2 m1 = p1.matcher(labelLink);
+ if (m1.matches()) {
+ firstLabel = m1.group(1);
+ labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
+ StringUtils.trin(m1.group(2)), "\""));
+ secondLabel = m1.group(3);
+ } else {
+ final Pattern2 p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
+ final Matcher2 m2 = p2.matcher(labelLink);
+ if (m2.matches()) {
+ firstLabel = m2.group(1);
+ labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
+ StringUtils.trin(m2.group(2)), "\""));
+ secondLabel = null;
+ } else {
+ final Pattern2 p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
+ final Matcher2 m3 = p3.matcher(labelLink);
+ if (m3.matches()) {
+ firstLabel = null;
+ labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
+ StringUtils.trin(m3.group(1)), "\""));
+ secondLabel = m3.group(2);
+ }
+ }
+ }
+ }
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink, "\"");
+ }
+
+ LinkArrow linkArrow = LinkArrow.NONE;
+ if ("<".equals(labelLink)) {
+ linkArrow = LinkArrow.BACKWARD;
+ labelLink = null;
+ } else if (">".equals(labelLink)) {
+ linkArrow = LinkArrow.DIRECT_NORMAL;
+ labelLink = null;
+ } else if (labelLink != null && labelLink.startsWith("< ")) {
+ linkArrow = LinkArrow.BACKWARD;
+ labelLink = StringUtils.trin(labelLink.substring(2));
+ } else if (labelLink != null && labelLink.startsWith("> ")) {
+ linkArrow = LinkArrow.DIRECT_NORMAL;
+ labelLink = StringUtils.trin(labelLink.substring(2));
+ } else if (labelLink != null && labelLink.endsWith(" >")) {
+ linkArrow = LinkArrow.DIRECT_NORMAL;
+ labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
+ } else if (labelLink != null && labelLink.endsWith(" <")) {
+ linkArrow = LinkArrow.BACKWARD;
+ labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
+ }
+
+ Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), queue, firstLabel, secondLabel,
+ diagram.getLabeldistance(), diagram.getLabelangle());
+ if (arg.get("URL", 0) != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(arg.get("URL", 0));
+ link.setUrl(url);
+ }
+ link.setPortMembers(port1, port2);
+
+ if (dir == Direction.LEFT || dir == Direction.UP) {
+ link = link.getInv();
+ }
+ link.setLinkArrow(linkArrow);
+ colors = applyStyle(arg.getLazzy("ARROW_STYLE", 0), link, colors);
+ link.setColors(colors);
+
+ addLink(diagram, link, arg.get("HEADER", 0));
+
+ return CommandExecutionResult.ok();
+ }
+
+ private boolean isGroupButNotTheCurrentGroup(AbstractClassOrObjectDiagram diagram, Code code) {
+ if (diagram.getCurrentGroup().getCode().equals(code)) {
+ return false;
+ }
+ return diagram.isGroup(code);
+ }
+
+ private Code removeMemberPart(AbstractClassOrObjectDiagram diagram, Code code) {
+ if (diagram.leafExist(code)) {
+ return null;
+ }
+ final Code before = code.removeMemberPart();
+ if (before == null) {
+ return null;
+ }
+ if (diagram.leafExist(before) == false) {
+ return null;
+ }
+ return before;
+ }
+
+ // private CommandExecutionResult executeLinkFields(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ // System.err.println("field1=" + arg.get("ENT1", 1));
+ // System.err.println("field2=" + arg.get("ENT2", 1));
+ // return CommandExecutionResult.error("not working yet");
+ // }
+
+ private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
+ diagram.addLink(link);
+ if (weight == null) {
+ // final LinkType type = link.getType();
+ // --|> highest
+ // --*, -->, --o normal
+ // ..*, ..>, ..o lowest
+ // if (type.isDashed() == false) {
+ // if (type.contains(LinkDecor.EXTENDS)) {
+ // link.setWeight(3);
+ // }
+ // if (type.contains(LinkDecor.ARROW) ||
+ // type.contains(LinkDecor.COMPOSITION)
+ // || type.contains(LinkDecor.AGREGATION)) {
+ // link.setWeight(2);
+ // }
+ // }
+ } else {
+ link.setWeight(Double.parseDouble(weight));
+ }
+ }
+
+ private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ final IEntity cl1 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
+ arg.get("ENT1", 0), "\"")));
+ final IEntity cl2 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
+ arg.get("ENT2", 0), "\"")));
+
+ final LinkType linkType = getLinkType(arg);
+ final Direction dir = getDirection(arg);
+ final int queue;
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ queue = 1;
+ } else {
+ queue = getQueueLength(arg);
+ }
+
+ Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
+
+ final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
+ final String firstLabel = arg.get("FIRST_LABEL", 0);
+ final String secondLabel = arg.get("SECOND_LABEL", 0);
+ final Link link = new Link(cl1, cl2, linkType, labelLink, queue, firstLabel, secondLabel,
+ diagram.getLabeldistance(), diagram.getLabelangle());
+
+ diagram.resetPragmaLabel();
+
+ colors = applyStyle(arg.getLazzy("ARROW_STYLE", 0), link, colors);
+ link.setColors(colors);
+
+ addLink(diagram, link, arg.get("HEADER", 0));
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ final Code clName1 = Code.of(arg.get("COUPLE1", 0));
+ final Code clName2 = Code.of(arg.get("COUPLE1", 1));
+ if (diagram.leafExist(clName1) == false) {
+ return CommandExecutionResult.error("No class " + clName1);
+ }
+ if (diagram.leafExist(clName2) == false) {
+ return CommandExecutionResult.error("No class " + clName2);
+ }
+
+ final Code ent2 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""));
+ final IEntity cl2 = diagram.getOrCreateLeaf(ent2, null, null);
+
+ final LinkType linkType = getLinkType(arg);
+ final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
+ // final int length = getQueueLength(arg);
+ // final String weight = arg.get("HEADER").get(0);
+
+ final boolean result = diagram.associationClass(1, clName1, clName2, cl2, linkType, label);
+ if (result == false) {
+ return CommandExecutionResult.error("Cannot have more than 2 assocications");
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ final Code clName1 = Code.of(arg.get("COUPLE2", 0));
+ final Code clName2 = Code.of(arg.get("COUPLE2", 1));
+ if (diagram.leafExist(clName1) == false) {
+ return CommandExecutionResult.error("No class " + clName1);
+ }
+ if (diagram.leafExist(clName2) == false) {
+ return CommandExecutionResult.error("No class " + clName2);
+ }
+
+ final Code ent1 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""));
+ final IEntity cl1 = diagram.getOrCreateLeaf(ent1, null, null);
+
+ final LinkType linkType = getLinkType(arg);
+ final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
+ // final int length = getQueueLength(arg);
+ // final String weight = arg.get("HEADER").get(0);
+
+ final boolean result = diagram.associationClass(2, clName1, clName2, cl1, linkType, label);
+ if (result == false) {
+ return CommandExecutionResult.error("Cannot have more than 2 assocications");
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+ private LinkDecor getDecors1(String s) {
+ if (s == null) {
+ return LinkDecor.NONE;
+ }
+ s = StringUtils.trin(s);
+ if ("<|".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if ("}".equals(s)) {
+ return LinkDecor.CROWFOOT;
+ }
+ if ("}o".equals(s)) {
+ return LinkDecor.CIRCLE_CROWFOOT;
+ }
+ if ("}|".equals(s)) {
+ return LinkDecor.LINE_CROWFOOT;
+ }
+ if ("|o".equals(s)) {
+ return LinkDecor.CIRCLE_LINE;
+ }
+ if ("||".equals(s)) {
+ return LinkDecor.DOUBLE_LINE;
+ }
+ if ("<".equals(s)) {
+ return LinkDecor.ARROW;
+ }
+ if ("^".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if ("+".equals(s)) {
+ return LinkDecor.PLUS;
+ }
+ if ("o".equals(s)) {
+ return LinkDecor.AGREGATION;
+ }
+ if ("x".equals(s)) {
+ return LinkDecor.NOT_NAVIGABLE;
+ }
+ if ("*".equals(s)) {
+ return LinkDecor.COMPOSITION;
+ }
+ if ("#".equals(s)) {
+ return LinkDecor.SQUARE;
+ }
+ if (")".equals(s)) {
+ return LinkDecor.PARENTHESIS;
+ }
+ return LinkDecor.NONE;
+ }
+
+ private LinkDecor getDecors2(String s) {
+ if (s == null) {
+ return LinkDecor.NONE;
+ }
+ s = StringUtils.trin(s);
+ if ("|>".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if (">".equals(s)) {
+ return LinkDecor.ARROW;
+ }
+ if ("{".equals(s)) {
+ return LinkDecor.CROWFOOT;
+ }
+ if ("o{".equals(s)) {
+ return LinkDecor.CIRCLE_CROWFOOT;
+ }
+ if ("|{".equals(s)) {
+ return LinkDecor.LINE_CROWFOOT;
+ }
+ if ("o|".equals(s)) {
+ return LinkDecor.CIRCLE_LINE;
+ }
+ if ("||".equals(s)) {
+ return LinkDecor.DOUBLE_LINE;
+ }
+ if ("^".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if ("+".equals(s)) {
+ return LinkDecor.PLUS;
+ }
+ if ("o".equals(s)) {
+ return LinkDecor.AGREGATION;
+ }
+ if ("x".equals(s)) {
+ return LinkDecor.NOT_NAVIGABLE;
+ }
+ if ("*".equals(s)) {
+ return LinkDecor.COMPOSITION;
+ }
+ if ("#".equals(s)) {
+ return LinkDecor.SQUARE;
+ }
+ if ("(".equals(s)) {
+ return LinkDecor.PARENTHESIS;
+ }
+ return LinkDecor.NONE;
+ }
+
+ private LinkType getLinkType(RegexResult arg) {
+ final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
+ final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
+
+ LinkType result = new LinkType(decors2, decors1);
+ if (arg.get("ARROW_BODY1", 0).contains(".") || arg.get("ARROW_BODY2", 0).contains(".")) {
+ result = result.getDashed();
+ }
+ final String middle = arg.get("INSIDE", 0);
+ if ("0".equals(middle)) {
+ result = result.withMiddleCircle();
+ } else if ("0)".equals(middle)) {
+ result = result.withMiddleCircleCircled1();
+ } else if ("(0".equals(middle)) {
+ result = result.withMiddleCircleCircled2();
+ } else if ("(0)".equals(middle)) {
+ result = result.withMiddleCircleCircled();
+ }
+ return result;
+ }
+
+ private int getQueueLength(RegexResult arg) {
+ String s = getFullArrow(arg);
+ s = s.replaceAll("[^-.=]", "");
+ return s.length();
+ }
+
+ private Direction getDirection(RegexResult arg) {
+ final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
+ final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
+
+ String s = getFullArrow(arg);
+ s = s.replaceAll("[^-.=\\w]", "");
+ if (s.startsWith("o")) {
+ s = s.substring(1);
+ }
+ if (s.endsWith("o")) {
+ s = s.substring(0, s.length() - 1);
+ }
+
+ Direction result = StringUtils.getQueueDirection(s);
+ if (isInversed(decors1, decors2) && s.matches(".*\\w.*")) {
+ result = result.getInv();
+ }
+
+ return result;
+ }
+
+ private String getFullArrow(RegexResult arg) {
+ return notNull(arg.get("ARROW_HEAD1", 0)) + notNull(arg.get("ARROW_BODY1", 0))
+ + notNull(arg.get("ARROW_DIRECTION", 0)) + notNull(arg.get("ARROW_BODY2", 0))
+ + notNull(arg.get("ARROW_HEAD2", 0));
+ }
+
+ public static String notNull(String s) {
+ if (s == null) {
+ return "";
+ }
+ return s;
+ }
+
+ @Deprecated
+ public static Colors applyStyle(String arrowStyle, Link link) {
+ return applyStyle(arrowStyle, link, null);
+ }
+
+ public static Colors applyStyle(String arrowStyle, Link link, Colors colors) {
+ if (arrowStyle == null) {
+ return colors;
+ }
+ final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
+ while (st.hasMoreTokens()) {
+ final String s = st.nextToken();
+ if (s.equalsIgnoreCase("dashed")) {
+ link.goDashed();
+ } else if (s.equalsIgnoreCase("bold")) {
+ link.goBold();
+ } else if (s.equalsIgnoreCase("dotted")) {
+ link.goDotted();
+ } else if (s.equalsIgnoreCase("hidden")) {
+ link.goHidden();
+ } else if (s.equalsIgnoreCase("plain")) {
+ // Do nothing
+ } else if (s.equalsIgnoreCase("norank")) {
+ link.goNorank();
+ } else {
+ link.setSpecificColor(s);
+ if (colors != null) {
+ colors = colors.add(ColorType.LINE, HtmlColorSet.getInstance().getColorIfValid(s));
+ }
+ }
+ }
+ return colors;
+ }
+
+ private boolean isInversed(LinkDecor decors1, LinkDecor decors2) {
+ if (decors1 == LinkDecor.ARROW && decors2 != LinkDecor.ARROW) {
+ return true;
+ }
+ if (decors2 == LinkDecor.AGREGATION) {
+ return true;
+ }
+ if (decors2 == LinkDecor.COMPOSITION) {
+ return true;
+ }
+ if (decors2 == LinkDecor.PLUS) {
+ return true;
+ }
+ // if (decors2 == LinkDecor.EXTENDS) {
+ // return true;
+ // }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java
index 25192ac..5e701ca 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java
@@ -1,228 +1,228 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.UmlDiagramType;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand2;
-import net.sourceforge.plantuml.command.regex.MyPattern;
-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.Code;
-import net.sourceforge.plantuml.cucadiagram.Display;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-import net.sourceforge.plantuml.cucadiagram.Link;
-import net.sourceforge.plantuml.cucadiagram.LinkDecor;
-import net.sourceforge.plantuml.cucadiagram.LinkType;
-import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
-import net.sourceforge.plantuml.utils.UniqueSequence;
-
-final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
-
- public CommandLinkLollipop(UmlDiagramType umlDiagramType) {
- super(getRegexConcat(umlDiagramType));
- }
-
- static RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
- return new RegexConcat(new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
- new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
- + "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
- new RegexLeaf("[%s]*"), //
- new RegexOr(new RegexLeaf("LOL_THEN_ENT", "\\(\\)([-=.]+)"), //
- new RegexLeaf("ENT_THEN_LOL", "([-=.]+)\\(\\)")), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
- + "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
- new RegexLeaf("[%s]*"), //
- new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
- new RegexLeaf("$"));
- }
-
- private static String optionalKeywords(UmlDiagramType type) {
- if (type == UmlDiagramType.CLASS) {
- return "(interface|enum|annotation|abstract[%s]+class|abstract|class)";
- }
- if (type == UmlDiagramType.OBJECT) {
- return "(object)";
- }
- throw new IllegalArgumentException();
- }
-
- @Override
- protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
-
- final Code ent1 = Code.of(arg.get("ENT1", 1));
- final Code ent2 = Code.of(arg.get("ENT2", 1));
-
- final IEntity cl1;
- final IEntity cl2;
- final IEntity normalEntity;
-
- final String suffix = "lol" + UniqueSequence.getValue();
- if (arg.get("LOL_THEN_ENT", 0) == null) {
- assert arg.get("ENT_THEN_LOL", 0) != null;
- cl1 = diagram.getOrCreateLeaf(ent1, null, null);
- cl2 = diagram.createLeaf(cl1.getCode().addSuffix(suffix), Display.getWithNewlines(ent2), LeafType.LOLLIPOP,
- null);
- normalEntity = cl1;
- } else {
- cl2 = diagram.getOrCreateLeaf(ent2, null, null);
- cl1 = diagram.createLeaf(cl2.getCode().addSuffix(suffix), Display.getWithNewlines(ent1), LeafType.LOLLIPOP,
- null);
- normalEntity = cl2;
- }
-
- final LinkType linkType = getLinkType(arg);
- final String queue = getQueue(arg);
-
- int length = queue.length();
- if (length == 1 && diagram.getNbOfHozizontalLollipop(normalEntity) > 1) {
- length++;
- }
-
- String firstLabel = arg.get("FIRST_LABEL", 0);
- String secondLabel = arg.get("SECOND_LABEL", 0);
-
- String labelLink = null;
-
- if (arg.get("LABEL_LINK", 0) != null) {
- labelLink = arg.get("LABEL_LINK", 0);
- if (firstLabel == null && secondLabel == null) {
- final Pattern p1 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)\"([^\"]+)\"$");
- final Matcher m1 = p1.matcher(labelLink);
- if (m1.matches()) {
- firstLabel = m1.group(1);
- labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils
- .trin(m1.group(2))));
- secondLabel = m1.group(3);
- } else {
- final Pattern p2 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)$");
- final Matcher m2 = p2.matcher(labelLink);
- if (m2.matches()) {
- firstLabel = m2.group(1);
- labelLink = StringUtils.trin(StringUtils
- .eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m2.group(2))));
- secondLabel = null;
- } else {
- final Pattern p3 = MyPattern.cmpile("^([^\"]+)\"([^\"]+)\"$");
- final Matcher m3 = p3.matcher(labelLink);
- if (m3.matches()) {
- firstLabel = null;
- labelLink = StringUtils.trin(StringUtils
- .eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m3.group(1))));
- secondLabel = m3.group(2);
- }
- }
- }
- }
- labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
- } /*
- * else if (arg.get("LABEL_LINK_XT").get(0) != null || arg.get("LABEL_LINK_XT").get(1) != null ||
- * arg.get("LABEL_LINK_XT").get(2) != null) { labelLink = arg.get("LABEL_LINK_XT").get(1); firstLabel =
- * merge(firstLabel, arg.get("LABEL_LINK_XT").get(0)); secondLabel = merge(arg.get("LABEL_LINK_XT").get(2),
- * secondLabel); }
- */
-
- final Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), length, firstLabel,
- secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
- diagram.resetPragmaLabel();
- addLink(diagram, link, arg.get("HEADER", 0));
-
- return CommandExecutionResult.ok();
- }
-
- // private String merge(String a, String b) {
- // if (a == null && b == null) {
- // return null;
- // }
- // if (a == null && b != null) {
- // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
- // }
- // if (b == null && a != null) {
- // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a);
- // }
- // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a) +
- // "\\n"
- // + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
- // }
-
- private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
- diagram.addLink(link);
- if (weight == null) {
- // final LinkType type = link.getType();
- // --|> highest
- // --*, -->, --o normal
- // ..*, ..>, ..o lowest
- // if (type.isDashed() == false) {
- // if (type.contains(LinkDecor.EXTENDS)) {
- // link.setWeight(3);
- // }
- // if (type.contains(LinkDecor.ARROW) ||
- // type.contains(LinkDecor.COMPOSITION)
- // || type.contains(LinkDecor.AGREGATION)) {
- // link.setWeight(2);
- // }
- // }
- } else {
- link.setWeight(Double.parseDouble(weight));
- }
- }
-
- private LinkType getLinkType(RegexResult arg) {
- return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
- }
-
- private String getQueue(RegexResult arg) {
- if (arg.get("LOL_THEN_ENT", 0) != null) {
- return StringUtils.trin(arg.get("LOL_THEN_ENT", 0));
- }
- if (arg.get("ENT_THEN_LOL", 0) != null) {
- return StringUtils.trin(arg.get("ENT_THEN_LOL", 0));
- }
- throw new IllegalArgumentException();
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.Matcher2;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.Pattern2;
+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.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
+
+ public CommandLinkLollipop(UmlDiagramType umlDiagramType) {
+ super(getRegexConcat(umlDiagramType));
+ }
+
+ static RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
+ return new RegexConcat(new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
+ new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ + "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(new RegexLeaf("LOL_THEN_ENT", "\\(\\)([-=.]+)"), //
+ new RegexLeaf("ENT_THEN_LOL", "([-=.]+)\\(\\)")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ + "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static String optionalKeywords(UmlDiagramType type) {
+ if (type == UmlDiagramType.CLASS) {
+ return "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity)";
+ }
+ if (type == UmlDiagramType.OBJECT) {
+ return "(object)";
+ }
+ throw new IllegalArgumentException();
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+
+ final Code ent1 = Code.of(arg.get("ENT1", 1));
+ final Code ent2 = Code.of(arg.get("ENT2", 1));
+
+ final IEntity cl1;
+ final IEntity cl2;
+ final IEntity normalEntity;
+
+ final String suffix = "lol" + UniqueSequence.getValue();
+ if (arg.get("LOL_THEN_ENT", 0) == null) {
+ assert arg.get("ENT_THEN_LOL", 0) != null;
+ cl1 = diagram.getOrCreateLeaf(ent1, null, null);
+ cl2 = diagram.createLeaf(cl1.getCode().addSuffix(suffix), Display.getWithNewlines(ent2), LeafType.LOLLIPOP,
+ null);
+ normalEntity = cl1;
+ } else {
+ cl2 = diagram.getOrCreateLeaf(ent2, null, null);
+ cl1 = diagram.createLeaf(cl2.getCode().addSuffix(suffix), Display.getWithNewlines(ent1), LeafType.LOLLIPOP,
+ null);
+ normalEntity = cl2;
+ }
+
+ final LinkType linkType = getLinkType(arg);
+ final String queue = getQueue(arg);
+
+ int length = queue.length();
+ if (length == 1 && diagram.getNbOfHozizontalLollipop(normalEntity) > 1) {
+ length++;
+ }
+
+ String firstLabel = arg.get("FIRST_LABEL", 0);
+ String secondLabel = arg.get("SECOND_LABEL", 0);
+
+ String labelLink = null;
+
+ if (arg.get("LABEL_LINK", 0) != null) {
+ labelLink = arg.get("LABEL_LINK", 0);
+ if (firstLabel == null && secondLabel == null) {
+ final Pattern2 p1 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)\"([^\"]+)\"$");
+ final Matcher2 m1 = p1.matcher(labelLink);
+ if (m1.matches()) {
+ firstLabel = m1.group(1);
+ labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils
+ .trin(m1.group(2))));
+ secondLabel = m1.group(3);
+ } else {
+ final Pattern2 p2 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)$");
+ final Matcher2 m2 = p2.matcher(labelLink);
+ if (m2.matches()) {
+ firstLabel = m2.group(1);
+ labelLink = StringUtils.trin(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m2.group(2))));
+ secondLabel = null;
+ } else {
+ final Pattern2 p3 = MyPattern.cmpile("^([^\"]+)\"([^\"]+)\"$");
+ final Matcher2 m3 = p3.matcher(labelLink);
+ if (m3.matches()) {
+ firstLabel = null;
+ labelLink = StringUtils.trin(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m3.group(1))));
+ secondLabel = m3.group(2);
+ }
+ }
+ }
+ }
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
+ } /*
+ * else if (arg.get("LABEL_LINK_XT").get(0) != null || arg.get("LABEL_LINK_XT").get(1) != null ||
+ * arg.get("LABEL_LINK_XT").get(2) != null) { labelLink = arg.get("LABEL_LINK_XT").get(1); firstLabel =
+ * merge(firstLabel, arg.get("LABEL_LINK_XT").get(0)); secondLabel = merge(arg.get("LABEL_LINK_XT").get(2),
+ * secondLabel); }
+ */
+
+ final Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), length, firstLabel,
+ secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
+ diagram.resetPragmaLabel();
+ addLink(diagram, link, arg.get("HEADER", 0));
+
+ return CommandExecutionResult.ok();
+ }
+
+ // private String merge(String a, String b) {
+ // if (a == null && b == null) {
+ // return null;
+ // }
+ // if (a == null && b != null) {
+ // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
+ // }
+ // if (b == null && a != null) {
+ // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a);
+ // }
+ // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a) +
+ // BackSlash.VV1
+ // + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
+ // }
+
+ private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
+ diagram.addLink(link);
+ if (weight == null) {
+ // final LinkType type = link.getType();
+ // --|> highest
+ // --*, -->, --o normal
+ // ..*, ..>, ..o lowest
+ // if (type.isDashed() == false) {
+ // if (type.contains(LinkDecor.EXTENDS)) {
+ // link.setWeight(3);
+ // }
+ // if (type.contains(LinkDecor.ARROW) ||
+ // type.contains(LinkDecor.COMPOSITION)
+ // || type.contains(LinkDecor.AGREGATION)) {
+ // link.setWeight(2);
+ // }
+ // }
+ } else {
+ link.setWeight(Double.parseDouble(weight));
+ }
+ }
+
+ private LinkType getLinkType(RegexResult arg) {
+ return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
+ }
+
+ private String getQueue(RegexResult arg) {
+ if (arg.get("LOL_THEN_ENT", 0) != null) {
+ return StringUtils.trin(arg.get("LOL_THEN_ENT", 0));
+ }
+ if (arg.get("ENT_THEN_LOL", 0) != null) {
+ return StringUtils.trin(arg.get("ENT_THEN_LOL", 0));
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java
index 8a4db0f..58d8a50 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java
@@ -1,59 +1,60 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.List;
-
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
-
-public class CommandNamespaceSeparator extends SingleLineCommand<ClassDiagram> {
-
- public CommandNamespaceSeparator() {
- super("(?i)^set[%s]namespaceseparator[%s](\\S+)$");
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
- final String s = arg.get(0);
- if ("none".equalsIgnoreCase(s)) {
- diagram.setNamespaceSeparator(null);
- } else {
- diagram.setNamespaceSeparator(s);
- }
- return CommandExecutionResult.ok();
- }
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+
+public class CommandNamespaceSeparator extends SingleLineCommand<ClassDiagram> {
+
+ public CommandNamespaceSeparator() {
+ super("(?i)^set[%s]namespaceseparator[%s](\\S+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
+ final String s = arg.get(0);
+ if ("none".equalsIgnoreCase(s)) {
+ diagram.setNamespaceSeparator(null);
+ } else {
+ diagram.setNamespaceSeparator(s);
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java
index a094a2b..40f0b37 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java
@@ -1,63 +1,64 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.List;
-
-import net.sourceforge.plantuml.FontParam;
-import net.sourceforge.plantuml.classdiagram.ClassDiagram;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-import net.sourceforge.plantuml.cucadiagram.Stereotype;
-
-public class CommandStereotype extends SingleLineCommand<ClassDiagram> {
-
- public CommandStereotype() {
- super("(?i)^([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)$");
- }
-
- @Override
- protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
- final Code code = Code.of(arg.get(0));
- final String stereotype = arg.get(1);
- final IEntity entity = diagram.getOrCreateLeaf(code, null, null);
- entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
- .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getIHtmlColorSet()));
- return CommandExecutionResult.ok();
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+
+public class CommandStereotype extends SingleLineCommand<ClassDiagram> {
+
+ public CommandStereotype() {
+ super("(?i)^([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
+ final Code code = Code.of(arg.get(0));
+ final String stereotype = arg.get(1);
+ final IEntity entity = diagram.getOrCreateLeaf(code, null, null);
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam().getIHtmlColorSet()));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java
index 3c5e186..3fa22d7 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java
@@ -1,73 +1,74 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.List;
-
-import net.sourceforge.plantuml.Url;
-import net.sourceforge.plantuml.UrlBuilder;
-import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
-import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
-import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
-import net.sourceforge.plantuml.cucadiagram.Code;
-import net.sourceforge.plantuml.cucadiagram.IEntity;
-
-public class CommandUrl extends SingleLineCommand<AbstractEntityDiagram> {
-
- public CommandUrl() {
- super("(?i)^url[%s]*(?:of|for)?[%s]+([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]+(?:is)?[%s]*(" + UrlBuilder.getRegexp() + ")$");
- }
-
- @Override
- protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, List<String> arg) {
- final Code code = Code.of(arg.get(0));
- final String urlString = arg.get(1);
- final IEntity entity;
- if (diagram.leafExist(code)) {
- entity = diagram.getOrCreateLeaf(code, null, null);
- } else if (diagram.isGroup(code)) {
- entity = diagram.getGroup(code);
- } else {
- return CommandExecutionResult.error(code + " does not exist");
- }
- // final IEntity entity = diagram.getOrCreateLeaf(code, null);
- final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
- final Url url = urlBuilder.getUrl(urlString);
- entity.addUrl(url);
- return CommandExecutionResult.ok();
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandUrl extends SingleLineCommand<AbstractEntityDiagram> {
+
+ public CommandUrl() {
+ super("(?i)^url[%s]*(?:of|for)?[%s]+([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]+(?:is)?[%s]*(" + UrlBuilder.getRegexp() + ")$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, List<String> arg) {
+ final Code code = Code.of(arg.get(0));
+ final String urlString = arg.get(1);
+ final IEntity entity;
+ if (diagram.leafExist(code)) {
+ entity = diagram.getOrCreateLeaf(code, null, null);
+ } else if (diagram.isGroup(code)) {
+ entity = diagram.getGroup(code);
+ } else {
+ return CommandExecutionResult.error(code + " does not exist");
+ }
+ // final IEntity entity = diagram.getOrCreateLeaf(code, null);
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java b/src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java
index d73eb05..2c0ccc1 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java
@@ -1,56 +1,57 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-
-public class GenericRegexProducer {
-
- public final static String PATTERN = "[^\\<\\>]" + getGenericRegex(4);
-
- // \<[^\<\>]([^\<\>]|\<\>)*\>
- static final private String part1 = "(?:[^\\<\\>]|\\<";
- static final private String part2 = "\\>)*";
-
- static String getGenericRegex(int level) {
- if (level < 0) {
- throw new IllegalArgumentException();
- }
- if (level == 0) {
- return part1 + part2;
- }
- return part1 + getGenericRegex(level - 1) + part2;
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+
+public class GenericRegexProducer {
+
+ public final static String PATTERN = "[^\\<\\>/]" + getGenericRegex(4);
+
+ // \<[^\<\>]([^\<\>]|\<\>)*\>
+ static final private String part1 = "(?:[^\\<\\>/]|\\<";
+ static final private String part2 = "\\>)*";
+
+ static String getGenericRegex(int level) {
+ if (level < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (level == 0) {
+ return part1 + part2;
+ }
+ return part1 + getGenericRegex(level - 1) + part2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java b/src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java
index cf051d6..562f1d7 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java
@@ -1,87 +1,88 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-
-class JavaClass {
-
- private final String name;
- private final String javaPackage;
- private final List<String> parents = new ArrayList<String>();
- private final LeafType type;
- private final LeafType parentType;
-
- public JavaClass(String javaPackage, String name, String p, LeafType type, LeafType parentType) {
- this.name = name;
- this.javaPackage = javaPackage;
- if (p == null) {
- p = "";
- }
- final StringTokenizer st = new StringTokenizer(StringUtils.trin(p), ",");
- while (st.hasMoreTokens()) {
- this.parents.add(StringUtils.trin(st.nextToken()).replaceAll("\\<.*", ""));
- }
- this.type = type;
- this.parentType = parentType;
- }
-
- public final String getName() {
- return name;
- }
-
- public final LeafType getType() {
- return type;
- }
-
- public final List<String> getParents() {
- return Collections.unmodifiableList(parents);
- }
-
- public final LeafType getParentType() {
- return parentType;
- }
-
- public final String getJavaPackage() {
- return javaPackage;
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+class JavaClass {
+
+ private final String name;
+ private final String javaPackage;
+ private final List<String> parents = new ArrayList<String>();
+ private final LeafType type;
+ private final LeafType parentType;
+
+ public JavaClass(String javaPackage, String name, String p, LeafType type, LeafType parentType) {
+ this.name = name;
+ this.javaPackage = javaPackage;
+ if (p == null) {
+ p = "";
+ }
+ final StringTokenizer st = new StringTokenizer(StringUtils.trin(p), ",");
+ while (st.hasMoreTokens()) {
+ this.parents.add(StringUtils.trin(st.nextToken()).replaceAll("\\<.*", ""));
+ }
+ this.type = type;
+ this.parentType = parentType;
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ public final LeafType getType() {
+ return type;
+ }
+
+ public final List<String> getParents() {
+ return Collections.unmodifiableList(parents);
+ }
+
+ public final LeafType getParentType() {
+ return parentType;
+ }
+
+ public final String getJavaPackage() {
+ return javaPackage;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java b/src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java
index c4d21c5..61d617b 100644
--- a/src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java
+++ b/src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java
@@ -1,111 +1,112 @@
-/* ========================================================================
- * PlantUML : a free UML diagram generator
- * ========================================================================
- *
- * (C) Copyright 2009-2017, Arnaud Roques
- *
- * Project Info: http://plantuml.com
- *
- * This file is part of PlantUML.
- *
- * Licensed under The MIT License (Massachusetts Institute of Technology License)
- *
- * See http://opensource.org/licenses/MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
- * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Original Author: Arnaud Roques
- */
-package net.sourceforge.plantuml.classdiagram.command;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import net.sourceforge.plantuml.StringUtils;
-import net.sourceforge.plantuml.command.regex.MyPattern;
-import net.sourceforge.plantuml.cucadiagram.LeafType;
-
-class JavaFile {
-
- private static final Pattern classDefinition = MyPattern
- .cmpile("^(?:public[%s]+|abstract[%s]+|final[%s]+)*(class|interface|enum|annotation)[%s]+(\\w+)(?:.*\\b(extends|implements)[%s]+([\\w%s,]+))?");
-
- private static final Pattern packageDefinition = MyPattern.cmpile("^package[%s]+([\\w+.]+)[%s]*;");
-
- private final List<JavaClass> all = new ArrayList<JavaClass>();
-
- public JavaFile(File f) throws IOException {
- BufferedReader br = null;
- try {
- br = new BufferedReader(new FileReader(f));
- initFromReader(br);
- } finally {
- if (br != null) {
- br.close();
- }
- }
- }
-
- private void initFromReader(BufferedReader br) throws IOException {
- String javaPackage = null;
- String s;
- while ((s = br.readLine()) != null) {
- s = StringUtils.trin(s);
- final Matcher matchPackage = packageDefinition.matcher(s);
- if (matchPackage.find()) {
- javaPackage = matchPackage.group(1);
- } else {
- final Matcher matchClassDefinition = classDefinition.matcher(s);
- if (matchClassDefinition.find()) {
- final String n = matchClassDefinition.group(2);
- final String p = matchClassDefinition.group(4);
- final LeafType type = LeafType.valueOf(StringUtils.goUpperCase(matchClassDefinition.group(1)));
- final LeafType parentType = getParentType(type, matchClassDefinition.group(3));
- all.add(new JavaClass(javaPackage, n, p, type, parentType));
- }
- }
- }
- }
-
- static LeafType getParentType(LeafType type, String extendsOrImplements) {
- if (extendsOrImplements == null) {
- return null;
- }
- if (type == LeafType.CLASS) {
- if (extendsOrImplements.equals("extends")) {
- return LeafType.CLASS;
- }
- return LeafType.INTERFACE;
- }
- return LeafType.INTERFACE;
- }
-
- public List<JavaClass> getJavaClasses() {
- return Collections.unmodifiableList(all);
-
- }
-
-}
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2017, Arnaud Roques
+ *
+ * Project Info: http://plantuml.com
+ *
+ * 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
+ *
+ * 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.classdiagram.command;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.Matcher2;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.Pattern2;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+class JavaFile {
+
+ private static final Pattern2 classDefinition = MyPattern
+ .cmpile("^(?:public[%s]+|abstract[%s]+|final[%s]+)*(class|interface|enum|annotation)[%s]+(\\w+)(?:.*\\b(extends|implements)[%s]+([\\w%s,]+))?");
+
+ private static final Pattern2 packageDefinition = MyPattern.cmpile("^package[%s]+([\\w+.]+)[%s]*;");
+
+ private final List<JavaClass> all = new ArrayList<JavaClass>();
+
+ public JavaFile(File f) throws IOException {
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(f));
+ initFromReader(br);
+ } finally {
+ if (br != null) {
+ br.close();
+ }
+ }
+ }
+
+ private void initFromReader(BufferedReader br) throws IOException {
+ String javaPackage = null;
+ String s;
+ while ((s = br.readLine()) != null) {
+ s = StringUtils.trin(s);
+ final Matcher2 matchPackage = packageDefinition.matcher(s);
+ if (matchPackage.find()) {
+ javaPackage = matchPackage.group(1);
+ } else {
+ final Matcher2 matchClassDefinition = classDefinition.matcher(s);
+ if (matchClassDefinition.find()) {
+ final String n = matchClassDefinition.group(2);
+ final String p = matchClassDefinition.group(4);
+ final LeafType type = LeafType.valueOf(StringUtils.goUpperCase(matchClassDefinition.group(1)));
+ final LeafType parentType = getParentType(type, matchClassDefinition.group(3));
+ all.add(new JavaClass(javaPackage, n, p, type, parentType));
+ }
+ }
+ }
+ }
+
+ static LeafType getParentType(LeafType type, String extendsOrImplements) {
+ if (extendsOrImplements == null) {
+ return null;
+ }
+ if (type == LeafType.CLASS) {
+ if (extendsOrImplements.equals("extends")) {
+ return LeafType.CLASS;
+ }
+ return LeafType.INTERFACE;
+ }
+ return LeafType.INTERFACE;
+ }
+
+ public List<JavaClass> getJavaClasses() {
+ return Collections.unmodifiableList(all);
+
+ }
+
+}