1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +00:00

version 1.2018.13

This commit is contained in:
Arnaud Roques 2018-11-26 19:46:50 +01:00
parent 03e61673a7
commit 3736d048b3
30 changed files with 2384 additions and 0 deletions

View File

@ -0,0 +1,52 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* 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 Smetana.
* Smetana is a partial translation of Graphviz/Dot sources from C to Java.
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* This translation is distributed under the same Licence as the original C program:
*
*************************************************************************
* Copyright (c) 2011 AT&T Intellectual Property
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************
*
* THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
* LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
*
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
*
* You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package h;
import smetana.core.__ptr__;
public interface ST_Node_t___or_object_t extends __ptr__ {
}

View File

@ -0,0 +1,90 @@
/* ========================================================================
* 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;
public class QString {
private final String data;
private final long mask;
public QString(String data) {
this.data = data;
this.mask = getMask(data);
}
@Override
public String toString() {
return data;
}
public boolean containsQ(QString other) {
if ((this.mask & other.mask) != other.mask) {
return false;
}
return this.data.contains(other.data);
}
static long getMask(String s) {
long result = 0;
for (int i = 0; i < s.length(); i++) {
result |= getMask(s.charAt(i));
}
return result;
}
static long getMask(char c) {
if (c >= '0' && c <= '9') {
final int n = c - '0';
return 1L << n;
}
if (c >= 'a' && c <= 'z') {
final int n = c - 'a' + 10;
return 1L << n;
}
if (c >= 'A' && c <= 'Z') {
final int n = c - 'A' + 10 + 26;
return 1L << n;
}
if (c == '_') {
return 1L << (10 + 26 + 26);
}
if (c == '(') {
return 1L << 63;
}
return 0;
}
}

View File

@ -0,0 +1,136 @@
/* ========================================================================
* 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.ant;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileList;
import org.apache.tools.ant.types.FileSet;
public class CheckZipTask extends Task {
private String zipfile = null;
private List<FileSet> filesets = new ArrayList<FileSet>();
private List<FileList> filelists = new ArrayList<FileList>();
/**
* Add a set of files to touch
*/
public void addFileset(FileSet set) {
filesets.add(set);
}
/**
* Add a filelist to touch
*/
public void addFilelist(FileList list) {
filelists.add(list);
}
// The method executing the task
@Override
public void execute() throws BuildException {
myLog("Check " + zipfile);
try {
loadZipFile(new File(zipfile));
for (FileList fileList : filelists) {
manageFileList(fileList);
}
} catch (IOException e) {
e.printStackTrace();
throw new BuildException(e.toString());
}
}
private void manageFileList(FileList fileList) {
boolean error = false;
final String[] srcFiles = fileList.getFiles(getProject());
for (String s : srcFiles) {
if (isPresentInFile(s) == false) {
myLog("Missing " + s);
error = true;
}
}
if (error) {
throw new BuildException("Some entries are missing in the zipfile");
}
}
private boolean isPresentInFile(String s) {
return entries.contains(s);
}
private final List<String> entries = new ArrayList<String>();
private void loadZipFile(File file) throws IOException {
this.entries.clear();
final PrintWriter pw = new PrintWriter("tmp.txt");
final ZipInputStream zis = new ZipInputStream(new FileInputStream(file));
ZipEntry ze = zis.getNextEntry();
while (ze != null) {
final String fileName = ze.getName();
this.entries.add(fileName);
if (fileName.endsWith("/") == false) {
pw.println("<file name=\"" + fileName + "\" />");
}
ze = zis.getNextEntry();
}
pw.close();
zis.close();
}
private synchronized void myLog(String s) {
this.log(s);
}
public void setZipfile(String s) {
this.zipfile = s;
}
}

View File

@ -0,0 +1,55 @@
/* ========================================================================
* 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.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
public class CommandMainframe extends SingleLineCommand<UmlDiagram> {
public CommandMainframe() {
super("(?i)^mainframe(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
}
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
final Display label = Display.getWithNewlines(arg.get(0));
diagram.setMainFrame(label);
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,61 @@
/* ========================================================================
* 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.nwdiag;
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 CommandComment extends SingleLineCommand2<NwDiagram> {
public CommandComment() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("[%s]*//.*"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,65 @@
/* ========================================================================
* 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.nwdiag;
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 CommandElement extends SingleLineCommand2<NwDiagram> {
public CommandElement() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("NAME", "([\\p{L}0-9_]+)"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("DEFINITION", "(\\[(.*)\\])?"), //
new RegexLeaf(";?"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
return diagram.addElement(arg.get("NAME", 0), arg.get("DEFINITION", 1));
}
}

View File

@ -0,0 +1,63 @@
/* ========================================================================
* 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.nwdiag;
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 CommandEndSomething extends SingleLineCommand2<NwDiagram> {
public CommandEndSomething() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("\\}"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
return diagram.endSomething();
}
}

View File

@ -0,0 +1,67 @@
/* ========================================================================
* 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.nwdiag;
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 CommandGroup extends SingleLineCommand2<NwDiagram> {
public CommandGroup() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("group"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("NAME", "([\\p{L}0-9_]+)?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("\\{"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
return diagram.openGroup(arg.get("NAME", 0));
}
}

View File

@ -0,0 +1,67 @@
/* ========================================================================
* 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.nwdiag;
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 CommandLink extends SingleLineCommand2<NwDiagram> {
public CommandLink() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("NAME1", "[\\p{L}0-9_]+"), //
new RegexLeaf("[%s]*--[%s]*"), //
new RegexLeaf("NAME2", "[\\p{L}0-9_]+"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf(";?"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
return diagram.link();
}
}

View File

@ -0,0 +1,66 @@
/* ========================================================================
* 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.nwdiag;
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 CommandNetwork extends SingleLineCommand2<NwDiagram> {
public CommandNetwork() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("network"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("NAME", "([\\p{L}0-9_]+)?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("\\{"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
return diagram.openNetwork(arg.get("NAME", 0));
}
}

View File

@ -0,0 +1,64 @@
/* ========================================================================
* 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.nwdiag;
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 CommandNwDiagInit extends SingleLineCommand2<NwDiagram> {
public CommandNwDiagInit() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("TYPE", "nwdiag"), //
new RegexLeaf("[%s]+"), //
new RegexLeaf("\\{"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
diagram.init();
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,68 @@
/* ========================================================================
* 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.nwdiag;
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 CommandProperty extends SingleLineCommand2<NwDiagram> {
public CommandProperty() {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("NAME", "(address|color)"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("="), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("VALUE", "\"(.*)\""), //
new RegexLeaf("[%s]*"), //
new RegexLeaf(";?"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(NwDiagram diagram, RegexResult arg) {
return diagram.setProperty(arg.get("NAME", 0), arg.get("VALUE", 0));
}
}

View File

@ -0,0 +1,120 @@
/* ========================================================================
* 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.nwdiag;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.ugraphic.UFont;
public class DiagElement {
private USymbol shape = USymbol.RECTANGLE;
private final String name;
private String description;
private final Network mainNetwork;
@Override
public String toString() {
return name;
}
public DiagElement(String name, Network network) {
this.description = name;
this.mainNetwork = network;
this.name = name;
}
private TextBlock toTextBlock(String s) {
if (s == null) {
return null;
}
if (s.length() == 0) {
return TextBlockUtils.empty(0, 0);
}
s = s.replace(", ", "\\n");
return Display.getWithNewlines(s).create(getFontConfiguration(), HorizontalAlignment.LEFT,
new SpriteContainerEmpty());
}
private FontConfiguration getFontConfiguration() {
final UFont font = UFont.serif(11);
return new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLACK, false);
}
public LinkedElement asTextBlock(final String adress1, final String adress2) {
final TextBlock ad1 = toTextBlock(adress1);
final TextBlock ad2 = toTextBlock(adress2);
final SymbolContext symbolContext = new SymbolContext(ColorParam.activityBackground.getDefaultValue(),
ColorParam.activityBorder.getDefaultValue()).withShadow(true);
final TextBlock desc = toTextBlock(description);
final TextBlock box = shape
.asSmall(TextBlockUtils.empty(0, 0), desc, TextBlockUtils.empty(0, 0), symbolContext);
return new LinkedElement(ad1, box, ad2, mainNetwork, this);
}
public String getDescription() {
return description;
}
public final Network getMainNetwork() {
return mainNetwork;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public final void setShape(String shapeName) {
if ("database".equalsIgnoreCase(shapeName)) {
this.shape = USymbol.DATABASE;
}
if ("node".equalsIgnoreCase(shapeName)) {
this.shape = USymbol.NODE;
}
}
}

View File

@ -0,0 +1,82 @@
/* ========================================================================
* 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.nwdiag;
import java.util.HashSet;
import java.util.Set;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class DiagGroup {
private final String name;
private final Network network;
private final Set<String> elements = new HashSet<String>();
private HtmlColor color;
@Override
public String toString() {
return name + " " + network + " " + elements;
}
public DiagGroup(String name, Network network) {
this.name = name;
this.network = network;
}
public final String getName() {
return name;
}
public void addElement(String name) {
this.elements.add(name);
}
public boolean matches(LinkedElement tested) {
if (network != null && network != tested.getNetwork()) {
return false;
}
return elements.contains(tested.getElement().getName());
}
public final HtmlColor getColor() {
return color;
}
public final void setColor(HtmlColor color) {
this.color = color;
}
}

View File

@ -0,0 +1,136 @@
/* ========================================================================
* 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.nwdiag;
import java.util.Collection;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class GridTextBlockDecorated extends GridTextBlockSimple {
public static final HtmlColorSetSimple colors = new HtmlColorSetSimple();
public static final int NETWORK_THIN = 5;
private final Collection<DiagGroup> groups;
public GridTextBlockDecorated(int lines, int cols, Collection<DiagGroup> groups) {
super(lines, cols);
this.groups = groups;
}
@Override
public void drawGrid(UGraphic ug) {
for (DiagGroup group : groups) {
drawGroups(ug, group);
}
drawNetworkTube(ug);
}
private void drawGroups(UGraphic ug, DiagGroup group) {
final StringBounder stringBounder = ug.getStringBounder();
MinMax size = null;
double y = 0;
for (int i = 0; i < data.length; i++) {
final double lineHeight = lineHeight(stringBounder, i);
double x = 0;
for (int j = 0; j < data[i].length; j++) {
final double colWidth = colWidth(stringBounder, j);
final LinkedElement element = data[i][j];
if (element != null && group.matches(element)) {
final MinMax minMax = element.getMinMax(stringBounder, colWidth, lineHeight).translate(
new UTranslate(x, y));
size = size == null ? minMax : size.addMinMax(minMax);
}
x += colWidth;
}
y += lineHeight;
}
if (size != null) {
HtmlColor color = group.getColor();
if (color == null) {
color = colors.getColorIfValid("#AAA");
}
size.draw(ug, color);
}
}
private void drawNetworkTube(final UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
double y = 0;
for (int i = 0; i < data.length; i++) {
final Network network = getNetwork(i);
double x = 0;
double xmin = -1;
double xmax = 0;
for (int j = 0; j < data[i].length; j++) {
final boolean hline = isPresent(i, j) || isPresent(i - 1, j);
if (hline && xmin < 0) {
xmin = x;
}
x += colWidth(stringBounder, j);
if (hline) {
xmax = x;
}
}
final URectangle rect = new URectangle(xmax - xmin, NETWORK_THIN);
rect.setDeltaShadow(1.0);
UGraphic ug2 = ug.apply(new UTranslate(xmin, y));
if (network != null && network.getColor() != null) {
ug2 = ug2.apply(new UChangeBackColor(network.getColor()));
}
ug2.draw(rect);
y += lineHeight(stringBounder, i);
}
}
private Network getNetwork(int i) {
for (int j = 0; j < data[i].length; j++) {
if (isPresent(i, j)) {
return data[i][j].getNetwork();
}
}
return null;
}
}

View File

@ -0,0 +1,131 @@
/* ========================================================================
* 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.nwdiag;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class GridTextBlockSimple implements TextBlock {
protected final LinkedElement data[][];
public GridTextBlockSimple(int lines, int cols) {
this.data = new LinkedElement[lines][cols];
}
protected boolean isPresent(int i, int j) {
if (i == -1) {
return false;
}
return data[i][j] != null;
}
public void drawGrid(UGraphic ug) {
}
public void drawU(UGraphic ug) {
drawGrid(ug);
final StringBounder stringBounder = ug.getStringBounder();
double y = 0;
for (int i = 0; i < data.length; i++) {
final double lineHeight = lineHeight(stringBounder, i);
double x = 0;
for (int j = 0; j < data[i].length; j++) {
final double colWidth = colWidth(stringBounder, j);
if (data[i][j] != null) {
data[i][j].drawMe(ug.apply(new UTranslate(x, y)), colWidth, lineHeight);
}
x += colWidth;
}
y += lineHeight;
}
}
protected double colWidth(StringBounder stringBounder, final int j) {
double width = 0;
for (int i = 0; i < data.length; i++) {
if (data[i][j] != null) {
width = Math.max(width, data[i][j].naturalDimension(stringBounder).getWidth());
}
}
return width;
}
public double lineHeight(StringBounder stringBounder, final int i) {
double height = 0;
for (int j = 0; j < data[i].length; j++) {
if (data[i][j] != null) {
height = Math.max(height, data[i][j].naturalDimension(stringBounder).getHeight());
}
}
return height;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
if (data.length == 0) {
return new Dimension2DDouble(0, 0);
}
double height = 0;
for (int i = 0; i < data.length; i++) {
height += lineHeight(stringBounder, i);
}
double width = 0;
for (int j = 0; j < data[0].length; j++) {
width += colWidth(stringBounder, j);
}
return new Dimension2DDouble(width, height);
}
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) {
throw new UnsupportedOperationException("member=" + member + " " + getClass().toString());
}
public MinMax getMinMax(StringBounder stringBounder) {
throw new UnsupportedOperationException(getClass().toString());
}
public void add(int i, int j, LinkedElement value) {
data[i][j] = value;
}
}

View File

@ -0,0 +1,136 @@
/* ========================================================================
* 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.nwdiag;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.utils.MathUtils;
public class LinkedElement {
private final TextBlock ad1;
private final TextBlock box;
private final TextBlock ad2;
private final Network network;
private final DiagElement element;
public LinkedElement(TextBlock ad1, TextBlock box, TextBlock ad2, Network network, DiagElement element) {
this.ad1 = ad1;
this.box = box;
this.ad2 = ad2;
this.network = network;
this.element = element;
}
private final double marginAd = 10;
private final double marginBox = 15;
public MinMax getMinMax(StringBounder stringBounder, double width, double height) {
final double xMiddle = width / 2;
final double yMiddle = height / 2;
final Dimension2D dimBox = box.calculateDimension(stringBounder);
final double x1 = xMiddle - dimBox.getWidth() / 2;
final double y1 = yMiddle - dimBox.getHeight() / 2;
final double x2 = xMiddle + dimBox.getWidth() / 2;
final double y2 = yMiddle + dimBox.getHeight() / 2;
return MinMax.getEmpty(false).addPoint(x1 - 5, y1 - 5).addPoint(x2 + 5, y2 + 5);
}
public void drawMe(UGraphic ug, double width, double height) {
final double xMiddle = width / 2;
final double yMiddle = height / 2;
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimBox = box.calculateDimension(stringBounder);
final double y1 = yMiddle - dimBox.getHeight() / 2;
final double y2 = yMiddle + dimBox.getHeight() / 2;
drawCenter(ug, box, xMiddle, yMiddle);
final HtmlColor color = ColorParam.activityBorder.getDefaultValue();
ug = ug.apply(new UChangeColor(color));
drawHLine(ug, xMiddle, GridTextBlockDecorated.NETWORK_THIN, y1);
if (ad2 != null) {
drawHLine(ug, xMiddle, y2, height);
}
drawCenter(ug, ad1, xMiddle, (GridTextBlockDecorated.NETWORK_THIN + y1) / 2);
if (ad2 != null) {
drawCenter(ug, ad2, xMiddle, (y2 + height - GridTextBlockDecorated.NETWORK_THIN) / 2);
}
}
private void drawCenter(UGraphic ug, TextBlock block, double x, double y) {
final Dimension2D dim = block.calculateDimension(ug.getStringBounder());
block.drawU(ug.apply(new UTranslate(x - dim.getWidth() / 2, y - dim.getHeight() / 2)));
}
private void drawHLine(UGraphic ug, double x, double y1, double y2) {
final ULine line = new ULine(0, y2 - y1);
ug.apply(new UTranslate(x, y1)).draw(line);
}
public Dimension2D naturalDimension(StringBounder stringBounder) {
final Dimension2D dim1 = ad1.calculateDimension(stringBounder);
final Dimension2D dimBox = box.calculateDimension(stringBounder);
final Dimension2D dim2 = ad2 == null ? new Dimension2DDouble(0, 0) : ad2.calculateDimension(stringBounder);
final double width = MathUtils.max(dim1.getWidth() + 2 * marginAd, dimBox.getWidth() + 2 * marginBox,
dim2.getWidth() + 2 * marginAd);
final double height = dim1.getHeight() + 2 * marginAd + dimBox.getHeight() + 2 * marginBox + dim2.getHeight()
+ 2 * marginAd;
return new Dimension2DDouble(width, height);
}
public final Network getNetwork() {
return network;
}
public final DiagElement getElement() {
return element;
}
}

View File

@ -0,0 +1,103 @@
/* ========================================================================
* 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.nwdiag;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class Network {
private final String name;
private final Map<DiagElement, String> localElements = new LinkedHashMap<DiagElement, String>();
private HtmlColor color;
private String ownAdress;
@Override
public String toString() {
return name;
}
public Network(String name) {
this.name = name;
}
public String getAdress(DiagElement element) {
return localElements.get(element);
}
public void addElement(DiagElement element, Map<String, String> props) {
String address = props.get("address");
if (address == null) {
address = "";
}
if (address.length() == 0 && localElements.containsKey(element)) {
return;
}
localElements.put(element, address);
}
public boolean constainsLocally(String name) {
for (DiagElement element : localElements.keySet()) {
if (element.getName().equals(name)) {
return true;
}
}
return false;
}
public final String getOwnAdress() {
return ownAdress;
}
public final void setOwnAdress(String ownAdress) {
this.ownAdress = ownAdress;
}
public final String getName() {
return name;
}
public final HtmlColor getColor() {
return color;
}
public final void setColor(HtmlColor color) {
this.color = color;
}
}

View File

@ -0,0 +1,291 @@
/* ========================================================================
* 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.nwdiag;
import java.awt.geom.Dimension2D;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UEmpty;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class NwDiagram extends UmlDiagram {
private boolean initDone;
private final Map<String, DiagElement> elements = new LinkedHashMap<String, DiagElement>();
private final List<Network> networks = new ArrayList<Network>();
private final List<DiagGroup> groups = new ArrayList<DiagGroup>();
private DiagGroup currentGroup = null;
public DiagramDescription getDescription() {
return new DiagramDescription("(Nwdiag)");
}
@Override
public UmlDiagramType getUmlDiagramType() {
return UmlDiagramType.NWDIAG;
}
public void init() {
initDone = true;
}
private Network currentNetwork() {
if (networks.size() == 0) {
return null;
}
return networks.get(networks.size() - 1);
}
public CommandExecutionResult openGroup(String name) {
if (initDone == false) {
return error();
}
currentGroup = new DiagGroup(name, currentNetwork());
groups.add(currentGroup);
return CommandExecutionResult.ok();
}
public CommandExecutionResult openNetwork(String name) {
if (initDone == false) {
return error();
}
final Network network = new Network(name);
networks.add(network);
return CommandExecutionResult.ok();
}
public CommandExecutionResult endSomething() {
if (initDone == false) {
return error();
}
this.currentGroup = null;
return CommandExecutionResult.ok();
}
public CommandExecutionResult addElement(String name, String definition) {
if (initDone == false) {
return error();
}
if (currentGroup != null) {
currentGroup.addElement(name);
}
if (currentNetwork() != null) {
DiagElement element = elements.get(name);
if (element == null) {
element = new DiagElement(name, currentNetwork());
elements.put(name, element);
}
final Map<String, String> props = toSet(definition);
final String description = props.get("description");
if (description != null) {
element.setDescription(description);
}
final String shape = props.get("shape");
if (shape != null) {
element.setShape(shape);
}
currentNetwork().addElement(element, props);
}
return CommandExecutionResult.ok();
}
private CommandExecutionResult error() {
return CommandExecutionResult.error("");
}
private Map<String, String> toSet(String definition) {
final Map<String, String> result = new HashMap<String, String>();
if (definition == null) {
return result;
}
final Pattern p = Pattern.compile("\\s*(\\w+)\\s*=\\s*(\"([^\"]*)\"|[^\\s,]+)");
final Matcher m = p.matcher(definition);
while (m.find()) {
final String name = m.group(1);
final String value = m.group(3) == null ? m.group(2) : m.group(3);
result.put(name, value);
}
return result;
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
final Scale scale = getScale();
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), dpiFactor, null, "", "", 0, 0,
null, false);
final UDrawable result = getUDrawable();
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, 0, os);
}
private UDrawable getUDrawable() {
return new UDrawable() {
public void drawU(UGraphic ug) {
drawMe(ug);
}
};
}
private TextBlock toTextBlock(String name, String s) {
if (s != null) {
name += "\\n" + s;
}
return Display.getWithNewlines(name).create(getFontConfiguration(), HorizontalAlignment.RIGHT,
new SpriteContainerEmpty());
}
private FontConfiguration getFontConfiguration() {
final UFont font = UFont.serif(11);
return new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLACK, false);
}
private void drawMe(UGraphic ug) {
final double margin = 5;
ug = ug.apply(new UTranslate(margin, margin));
final StringBounder stringBounder = ug.getStringBounder();
final GridTextBlockDecorated grid = new GridTextBlockDecorated(networks.size(), elements.size(), groups);
for (int i = 0; i < networks.size(); i++) {
final Network current = networks.get(i);
final Network next = i + 1 < networks.size() ? networks.get(i + 1) : null;
int j = 0;
for (Map.Entry<String, DiagElement> ent : elements.entrySet()) {
final DiagElement element = ent.getValue();
if (element.getMainNetwork() == current && current.constainsLocally(ent.getKey())) {
final String ad1 = current.getAdress(element);
final String ad2 = next == null ? null : next.getAdress(element);
grid.add(i, j, element.asTextBlock(ad1, ad2));
}
j++;
}
}
double deltaX = 0;
double deltaY = 0;
for (int i = 0; i < networks.size(); i++) {
final Network current = networks.get(i);
final String address = current.getOwnAdress();
final TextBlock desc = toTextBlock(current.getName(), address);
final Dimension2D dim = desc.calculateDimension(stringBounder);
if (i == 0) {
deltaY = (dim.getHeight() - GridTextBlockDecorated.NETWORK_THIN) / 2;
}
deltaX = Math.max(deltaX, dim.getWidth());
}
double y = 0;
for (int i = 0; i < networks.size(); i++) {
final Network current = networks.get(i);
final String address = current.getOwnAdress();
final TextBlock desc = toTextBlock(current.getName(), address);
final Dimension2D dim = desc.calculateDimension(stringBounder);
desc.drawU(ug.apply(new UTranslate(deltaX - dim.getWidth(), y)));
y += grid.lineHeight(stringBounder, i);
}
deltaX += 5;
grid.drawU(ug.apply(new UChangeColor(ColorParam.activityBorder.getDefaultValue()))
.apply(new UChangeBackColor(ColorParam.activityBackground.getDefaultValue()))
.apply(new UTranslate(deltaX, deltaY)));
final Dimension2D dimGrid = grid.calculateDimension(stringBounder);
ug.apply(new UTranslate(dimGrid.getWidth() + deltaX + margin, dimGrid.getHeight() + deltaY + margin)).draw(
new UEmpty(1, 1));
}
public CommandExecutionResult setProperty(String property, String value) {
if (initDone == false) {
return error();
}
if ("address".equalsIgnoreCase(property) && currentNetwork() != null) {
currentNetwork().setOwnAdress(value);
}
if ("color".equalsIgnoreCase(property)) {
final HtmlColor color = GridTextBlockDecorated.colors.getColorIfValid(value);
if (currentGroup != null) {
currentGroup.setColor(color);
} else if (currentNetwork() != null) {
currentNetwork().setColor(color);
}
}
return CommandExecutionResult.ok();
}
public CommandExecutionResult link() {
if (initDone == false) {
return error();
}
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,67 @@
/* ========================================================================
* 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.nwdiag;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
public class NwDiagramFactory extends UmlDiagramFactory {
@Override
public NwDiagram createEmptyDiagram() {
return new NwDiagram();
}
@Override
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
addCommonCommands(cmds);
cmds.add(new CommandNwDiagInit());
cmds.add(new CommandComment());
cmds.add(new CommandElement());
cmds.add(new CommandGroup());
cmds.add(new CommandNetwork());
cmds.add(new CommandLink());
cmds.add(new CommandProperty());
cmds.add(new CommandEndSomething());
return cmds;
}
}

View File

@ -0,0 +1,58 @@
/* ========================================================================
* 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.preproc;
public class DefinesGet {
private final Defines defines;
public DefinesGet(Defines defines) {
this.defines = defines;
}
public final Defines get() {
return defines;
}
public void saveState() {
this.defines.saveState1();
}
public void restoreState() {
this.defines.restoreState1();
}
}

View File

@ -0,0 +1,49 @@
/* ========================================================================
* 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.preproc;
import net.sourceforge.plantuml.CharSequence2;
public class ReadLineEmpty implements ReadLine {
public void close() {
}
public CharSequence2 readLine() {
return null;
}
}

View File

@ -0,0 +1,49 @@
/* ========================================================================
* 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
* Modified by: Nicolas Jouanin
*
*
*/
package net.sourceforge.plantuml.preproc2;
public enum PreprocessorIncludeStrategy {
ONCE, MANY;
public static PreprocessorIncludeStrategy fromString(String group) {
if ("once".equalsIgnoreCase(group)) {
return ONCE;
}
return MANY;
}
}

View File

@ -0,0 +1,44 @@
/* ========================================================================
* 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.project3;
public interface Moment {
public Instant getStart();
public Instant getEnd();
}

View File

@ -0,0 +1,56 @@
/* ========================================================================
* 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.project3;
public class MomentImpl implements Moment {
private final Instant start;
private final Instant end;
public MomentImpl(Instant start, Instant end) {
this.start = start;
this.end = end;
}
public Instant getStart() {
return start;
}
public Instant getEnd() {
return end;
}
}

View File

@ -0,0 +1,54 @@
/* ========================================================================
* 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.version;
public enum LicenseType {
NONE, NAMED, DISTRIBUTOR, UNKNOWN;
public static LicenseType fromInt(int type) {
if (type == -1) {
return NONE;
}
if (type == 0) {
return NAMED;
}
if (type == 2) {
return DISTRIBUTOR;
}
return UNKNOWN;
}
}

View File

@ -0,0 +1,154 @@
/* ========================================================================
* 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.version;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.ArrayList;
import java.util.List;
import java.util.prefs.BackingStoreException;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SignatureUtils;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class PSystemKeycheck extends AbstractPSystem {
final private String key;
final private String sig;
public PSystemKeycheck(String sig, String key) {
this.sig = sig;
this.key = key;
}
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) {
try {
drawInternal(ug);
} catch (Exception e) {
e.printStackTrace();
}
}
});
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
public DiagramDescription getDescription() {
return new DiagramDescription("(Key)");
}
private void drawInternal(UGraphic ug) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
final List<String> strings = header();
try {
final LicenseInfo info = LicenseInfo.retrieveNamed(sig, key, false);
strings.add("<u>Provided license information</u>:");
License.addLicenseInfo(strings, info);
strings.add(" ");
} catch (Exception e) {
e.printStackTrace();
strings.add("<i>Error:</i> " + e);
}
final TextBlock disp = GraphicStrings.createBlackOnWhite(strings);
disp.drawU(ug);
}
private ArrayList<String> header() {
final ArrayList<String> strings = new ArrayList<String>();
strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")");
strings.add("(" + License.getCurrent() + " source distribution)");
if (OptionFlags.ALLOW_INCLUDE) {
strings.add("Loaded from " + Version.getJarPath());
}
strings.add(" ");
return strings;
}
private void drawFlash(UGraphic ug, LicenseInfo info) throws IOException {
final List<String> strings = header();
strings.add("To get your <i>Professional Edition License</i>,");
strings.add("please send this qrcode to <b>plantuml@gmail.com</b> :");
TextBlock disp = GraphicStrings.createBlackOnWhite(strings);
disp.drawU(ug);
ug = ug.apply(new UTranslate(0, disp.calculateDimension(ug.getStringBounder()).getHeight()));
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage im = utils.exportFlashcode(
Version.versionString() + "\n" + SignatureUtils.toHexString(Magic.signature()), Color.BLACK,
Color.WHITE);
if (im != null) {
final UImage flash = new UImage(im).scaleNearestNeighbor(4);
ug.draw(flash);
ug = ug.apply(new UTranslate(0, flash.getHeight()));
}
if (info.isNone() == false) {
strings.clear();
strings.add("<u>Installed license</u>:");
License.addLicenseInfo(strings, info);
strings.add(" ");
disp = GraphicStrings.createBlackOnWhite(strings);
disp.drawU(ug);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB