1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-05 01:50:49 +00:00

version 8022

This commit is contained in:
Arnaud Roques 2015-04-07 20:18:37 +02:00
parent 1104e10b37
commit b6ea839fa1
1360 changed files with 12919 additions and 8217 deletions

View File

@ -20,11 +20,27 @@
<target name="compile">
<delete dir="build" />
<mkdir dir="build" />
<javac target="1.5" srcdir="src" destdir="build" />
<javac target="1.6" srcdir="src" destdir="build" />
<copy file="src/net/sourceforge/plantuml/version/logo.png"
todir="build/net/sourceforge/plantuml/version" />
<copy file="src/net/sourceforge/plantuml/version/favicon.png"
todir="build/net/sourceforge/plantuml/version" />
<copy todir="build/net/sourceforge/plantuml/version">
<fileset dir="src/net/sourceforge/plantuml/version">
<include name="*.png" />
</fileset>
</copy>
<copy todir="build/net/sourceforge/plantuml/openiconic/data">
<fileset dir="src/net/sourceforge/plantuml/openiconic/data">
<include name="*.txt" />
<include name="*.svg" />
</fileset>
</copy>
<copy todir="build/net/sourceforge/plantuml/fun">
<fileset dir="src/net/sourceforge/plantuml/fun">
<include name="*.png" />
</fileset>
</copy>
</target>
<target name="dist" depends="compile">

22
pom.xml
View File

@ -30,12 +30,13 @@
Script Author: Julien Eluard
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>7989-SNAPSHOT</version>
<version>8022-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>
@ -93,6 +94,18 @@
</developer>
</developers>
<profiles>
<profile>
<id>doclint-java8-disable</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<javadoc.opts>-Xdoclint:none</javadoc.opts>
</properties>
</profile>
</profiles>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<resources>
@ -101,6 +114,8 @@
<includes>
<include>net/sourceforge/plantuml/version/logo.png</include>
<include>net/sourceforge/plantuml/version/favicon.png</include>
<include>net/sourceforge/plantuml/openiconic/data/*.svg</include>
<include>net/sourceforge/plantuml/fun/*.png</include>
</includes>
</resource>
</resources>
@ -133,6 +148,9 @@
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>${javadoc.opts}</additionalparam>
</configuration>
</execution>
</executions>
</plugin>

View File

@ -21,8 +21,9 @@ package jcckit.util;
import java.awt.Color;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.HtmlColorSet;
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
/**
@ -300,9 +301,10 @@ public class ConfigParameters {
}
}
static private IHtmlColorSet colors = new HtmlColorSetSimple();
private Color decodeInternal(String value) {
if (HtmlColorUtils.getColorIfValid(value)!=null) {
return new ColorMapperIdentity().getMappedColor(HtmlColorUtils.getColorIfValid(value));
if (colors.getColorIfValid(value)!=null) {
return new ColorMapperIdentity().getMappedColor(colors.getColorIfValid(value));
}
return Color.decode(value);
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11351 $
* Revision $Revision: 14028 $
*
*/
package net.sourceforge.plantuml;
@ -54,7 +54,7 @@ public abstract class AbstractPSystem implements Diagram {
final StringBuilder toAppend = new StringBuilder();
toAppend.append("PlantUML version ");
toAppend.append(Version.versionString());
toAppend.append("(" + new Date(Version.compileTime()) + ")\n");
toAppend.append("(" + Version.compileTimeString() + ")\n");
toAppend.append("(" + License.getCurrent() + " source distribution)\n");
final Properties p = System.getProperties();
toAppend.append(p.getProperty("java.runtime.name"));
@ -89,7 +89,7 @@ public abstract class AbstractPSystem implements Diagram {
public Display getTitle() {
if (source == null) {
return Display.emptyList();
return Display.empty();
}
return source.getTitle();
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -39,23 +39,23 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.core.Diagram;
public class BlockUml {
private final List<? extends CharSequence> data;
private final int startLine;
private Diagram system;
// private static final Pattern patternFilename =
// Pattern.compile("^@start\\S+\\s+\"?(.*?)\"?$");
private static final Pattern patternFilename = Pattern
.compile("^@start[^\\s{}\"]+[\\s{][\\s\"]*([^\"]*?)[\\s}\"]*$");
private static final Pattern patternFilename = MyPattern.cmpile("^@start[^%s{}%g]+[%s{][%s%g]*([^%g]*?)[%s}%g]*$");
BlockUml(String... strings) {
this(Arrays.asList(strings));
this(Arrays.asList(strings), 0);
}
public BlockUml(List<? extends CharSequence> strings) {
public BlockUml(List<? extends CharSequence> strings, int startLine) {
this.startLine = startLine;
final String s0 = strings.get(0).toString().trim();
if (s0.startsWith("@start") == false) {
throw new IllegalArgumentException();
@ -72,7 +72,11 @@ public class BlockUml {
if (ok == false) {
return null;
}
final String result = m.group(1);
String result = m.group(1);
final int x = result.indexOf(',');
if (x != -1) {
result = result.substring(0, x);
}
for (int i = 0; i < result.length(); i++) {
final char c = result.charAt(i);
if ("<>|".indexOf(c) != -1) {
@ -82,19 +86,15 @@ public class BlockUml {
return result;
}
private Diagram getSystem() {
public Diagram getDiagram() {
if (system == null) {
createSystem();
system = new PSystemBuilder().createPSystem(data);
}
return system;
}
public Diagram getDiagram() {
return getSystem();
}
private void createSystem() {
system = new PSystemBuilder().createPSystem(data);
public final int getStartLine() {
return startLine;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -46,16 +46,20 @@ import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.Preprocessor;
import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.UncommentReadLine;
import net.sourceforge.plantuml.utils.StartUtils;
final public class BlockUmlBuilder {
private final List<BlockUml> blocks = new ArrayList<BlockUml>();
private final Set<File> usedFiles = new HashSet<File>();
private final UncommentReadLine reader2;
public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader reader, File newCurrentDir) throws IOException {
public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader reader, File newCurrentDir)
throws IOException {
Preprocessor includer = null;
try {
includer = new Preprocessor(new UncommentReadLine(new ReadLineReader(reader)), charset, defines, usedFiles, newCurrentDir);
reader2 = new UncommentReadLine(new ReadLineReader(reader));
includer = new Preprocessor(reader2, charset, defines, usedFiles, newCurrentDir);
init(includer, config);
} finally {
if (includer != null) {
@ -67,17 +71,36 @@ final public class BlockUmlBuilder {
private void init(Preprocessor includer, List<String> config) throws IOException {
String s = null;
List<String> current = null;
boolean paused = false;
int startLine = 0;
while ((s = includer.readLine()) != null) {
if (StartUtils.isArobaseStartDiagram(s)) {
current = new ArrayList<String>();
paused = false;
startLine = includer.getLineNumber();
}
if (current != null) {
if (StartUtils.isArobasePauseDiagram(s)) {
paused = true;
reader2.setPaused(true);
}
if (current != null && paused == false) {
current.add(s);
} else if (paused) {
final String append = StartUtils.getPossibleAppend(s);
if (append != null) {
current.add(append);
}
}
if (StartUtils.isArobaseUnpauseDiagram(s)) {
paused = false;
reader2.setPaused(false);
}
if (StartUtils.isArobaseEndDiagram(s) && current != null) {
current.addAll(1, config);
blocks.add(new BlockUml(current));
blocks.add(new BlockUml(current, startLine));
current = null;
reader2.setPaused(false);
}
}
}
@ -91,11 +114,9 @@ final public class BlockUmlBuilder {
}
/*
* private List<String> getStrings(Reader reader) throws IOException {
* final List<String> result = new ArrayList<String>(); Preprocessor
* includer = null; try { includer = new Preprocessor(reader, defines);
* String s = null; while ((s = includer.readLine()) != null) {
* result.add(s); } } finally { if (includer != null) { includer.close(); } }
* return Collections.unmodifiableList(result); }
* private List<String> getStrings(Reader reader) throws IOException { final List<String> result = new
* ArrayList<String>(); Preprocessor includer = null; try { includer = new Preprocessor(reader, defines); String s =
* null; while ((s = includer.readLine()) != null) { result.add(s); } } finally { if (includer != null) {
* includer.close(); } } return Collections.unmodifiableList(result); }
*/
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,100 +28,142 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11149 $
* Revision $Revision: 13975 $
*
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
public enum ColorParam {
background,
background(HtmlColorUtils.WHITE),
hyperlink(HtmlColorUtils.BLUE),
activityBackground,
activityBorder,
activityStart,
activityEnd,
activityBar,
activityArrow,
usecaseActorBackground,
usecaseActorBorder,
usecaseBorder,
usecaseBackground,
usecaseArrow,
objectBackground,
objectBorder,
objectArrow,
activityBackground(HtmlColorUtils.MY_YELLOW),
activityBorder(HtmlColorUtils.MY_RED),
activityStart(HtmlColorUtils.BLACK),
activityEnd(HtmlColorUtils.BLACK),
activityBar(HtmlColorUtils.BLACK),
activityArrow(HtmlColorUtils.MY_RED),
classBackground,
classBorder,
stereotypeCBackground,
stereotypeABackground,
stereotypeIBackground,
stereotypeEBackground,
classArrow,
usecaseBorder(HtmlColorUtils.MY_RED),
usecaseBackground(HtmlColorUtils.MY_YELLOW),
usecaseArrow(HtmlColorUtils.MY_RED),
objectBackground(HtmlColorUtils.MY_YELLOW),
objectBorder(HtmlColorUtils.MY_RED),
objectArrow(HtmlColorUtils.MY_RED),
packageBackground,
packageBorder,
classBackground(HtmlColorUtils.MY_YELLOW),
classBorder(HtmlColorUtils.MY_RED),
stereotypeCBackground(HtmlColorUtils.COL_ADD1B2),
stereotypeABackground(HtmlColorUtils.COL_A9DCDF),
stereotypeIBackground(HtmlColorUtils.COL_B4A7E5),
stereotypeEBackground(HtmlColorUtils.COL_EB937F),
classArrow(HtmlColorUtils.MY_RED),
packageBackground(HtmlColorUtils.MY_YELLOW),
packageBorder(HtmlColorUtils.BLACK),
partitionBackground,
partitionBorder,
partitionBackground(HtmlColorUtils.MY_YELLOW),
partitionBorder(HtmlColorUtils.BLACK),
componentBackground,
componentBorder,
componentInterfaceBackground,
componentInterfaceBorder,
componentBackground(HtmlColorUtils.MY_YELLOW),
componentBorder(HtmlColorUtils.MY_RED),
interfaceBackground(HtmlColorUtils.MY_YELLOW),
interfaceBorder(HtmlColorUtils.MY_RED),
// componentArrow,
stateBackground,
stateBorder,
stateArrow,
stateStart,
stateEnd,
stateBackground(HtmlColorUtils.MY_YELLOW),
stateBorder(HtmlColorUtils.MY_RED),
stateArrow(HtmlColorUtils.MY_RED),
stateStart(HtmlColorUtils.BLACK),
stateEnd(HtmlColorUtils.BLACK),
noteBackground(true),
noteBorder,
noteBackground(HtmlColorUtils.COL_FBFB77, true),
noteBorder(HtmlColorUtils.MY_RED),
legendBackground(true),
legendBorder,
legendBackground(HtmlColorUtils.COL_DDDDDD, true),
legendBorder(HtmlColorUtils.BLACK),
sequenceActorBackground(true),
sequenceActorBorder,
sequenceGroupBorder,
sequenceGroupBackground(true),
sequenceReferenceBorder,
sequenceReferenceHeaderBackground(true),
sequenceReferenceBackground(true),
sequenceDividerBackground(true),
sequenceLifeLineBackground(true),
sequenceLifeLineBorder,
sequenceParticipantBackground(true),
sequenceParticipantBorder,
sequenceArrow,
sequenceBoxBorder,
sequenceBoxBackground(true),
actorBackground(HtmlColorUtils.MY_YELLOW, true),
actorBorder(HtmlColorUtils.MY_RED),
participantBackground(HtmlColorUtils.MY_YELLOW, true),
participantBorder(HtmlColorUtils.MY_RED),
sequenceGroupBorder(HtmlColorUtils.BLACK),
sequenceGroupBackground(HtmlColorUtils.COL_EEEEEE, true),
sequenceReferenceBorder(HtmlColorUtils.BLACK),
sequenceReferenceHeaderBackground(HtmlColorUtils.COL_EEEEEE, true),
sequenceReferenceBackground(HtmlColorUtils.WHITE, true),
sequenceDividerBackground(HtmlColorUtils.COL_EEEEEE, true),
sequenceLifeLineBackground(HtmlColorUtils.WHITE, true),
sequenceLifeLineBorder(HtmlColorUtils.MY_RED),
sequenceArrow(HtmlColorUtils.MY_RED),
sequenceBoxBorder(HtmlColorUtils.MY_RED),
sequenceBoxBackground(HtmlColorUtils.COL_DDDDDD, true),
iconPrivate,
iconPrivateBackground,
iconPackage,
iconPackageBackground,
iconProtected,
iconProtectedBackground,
iconPublic,
iconPublicBackground;
artifactBackground(HtmlColorUtils.MY_YELLOW),
artifactBorder(HtmlColorUtils.MY_RED),
cloudBackground(HtmlColorUtils.MY_YELLOW),
cloudBorder(HtmlColorUtils.MY_RED),
databaseBackground(HtmlColorUtils.MY_YELLOW),
databaseBorder(HtmlColorUtils.MY_RED),
folderBackground(HtmlColorUtils.MY_YELLOW),
folderBorder(HtmlColorUtils.MY_RED),
frameBackground(HtmlColorUtils.MY_YELLOW),
frameBorder(HtmlColorUtils.MY_RED),
nodeBackground(HtmlColorUtils.MY_YELLOW),
nodeBorder(HtmlColorUtils.MY_RED),
rectangleBackground(HtmlColorUtils.MY_YELLOW),
rectangleBorder(HtmlColorUtils.MY_RED),
agentBackground(HtmlColorUtils.MY_YELLOW),
agentBorder(HtmlColorUtils.MY_RED),
storageBackground(HtmlColorUtils.MY_YELLOW),
storageBorder(HtmlColorUtils.MY_RED),
boundaryBackground(HtmlColorUtils.MY_YELLOW),
boundaryBorder(HtmlColorUtils.MY_RED),
controlBackground(HtmlColorUtils.MY_YELLOW),
controlBorder(HtmlColorUtils.MY_RED),
entityBackground(HtmlColorUtils.MY_YELLOW),
entityBorder(HtmlColorUtils.MY_RED),
iconPrivate(HtmlColorUtils.COL_C82930),
iconPrivateBackground(HtmlColorUtils.COL_F24D5C),
iconPackage(HtmlColorUtils.COL_1963A0),
iconPackageBackground(HtmlColorUtils.COL_4177AF),
iconProtected(HtmlColorUtils.COL_B38D22),
iconProtectedBackground(HtmlColorUtils.COL_FFFF44),
iconPublic(HtmlColorUtils.COL_038048),
iconPublicBackground(HtmlColorUtils.COL_84BE84);
private final boolean isBackground;
private final HtmlColor defaultValue;
private ColorParam(HtmlColor defaultValue) {
this(defaultValue, false);
}
private ColorParam() {
this(false);
this(null, false);
}
private ColorParam(boolean isBackground) {
this(null, isBackground);
}
private ColorParam(HtmlColor defaultValue, boolean isBackground) {
this.isBackground = isBackground;
this.defaultValue = defaultValue;
}
protected boolean isBackground() {
return isBackground;
}
public final HtmlColor getDefaultValue() {
return defaultValue;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,13 +28,15 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11564 $
* Revision $Revision: 15096 $
*
*/
package net.sourceforge.plantuml;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.utils.MathUtils;
public class Dimension2DDouble extends Dimension2D {
final private double width;
@ -70,6 +72,9 @@ public class Dimension2DDouble extends Dimension2D {
}
public static Dimension2D delta(Dimension2D dim, double deltaWidth, double deltaHeight) {
if (deltaHeight == 0 && deltaWidth == 0) {
return dim;
}
return new Dimension2DDouble(dim.getWidth() + deltaWidth, dim.getHeight() + deltaHeight);
}
@ -96,7 +101,7 @@ public class Dimension2DDouble extends Dimension2D {
final double height = top1.getHeight() + top2.getHeight() + bottom.getHeight();
return new Dimension2DDouble(width, height);
}
public static Dimension2D max(Dimension2D dim1, Dimension2D dim2) {
return atLeast(dim1, dim2.getWidth(), dim2.getHeight());
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 9786 $
* Revision $Revision: 12866 $
*
*/
package net.sourceforge.plantuml;
@ -82,7 +82,7 @@ public class DirWatcher {
files.add(f);
for (GeneratedImage g : sourceFileReader.getGeneratedImages()) {
result.add(g);
if (OptionFlags.getInstance().isFailOnError() && g.isError()) {
if (option.isFailfastOrFailfast2() && g.lineErrorRaw() != -1) {
error = true;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -92,4 +92,28 @@ public enum Direction {
}
throw new IllegalArgumentException();
}
public static Direction fromVector(Point2D p1, Point2D p2) {
final double x1 = p1.getX();
final double y1 = p1.getY();
final double x2 = p2.getX();
final double y2 = p2.getY();
if (x1 == x2 && y1 == y2) {
return null;
}
if (x1 == x2) {
if (y2 > y1) {
return Direction.DOWN;
}
return Direction.UP;
}
if (y1 == y2) {
if (x2 > x1) {
return Direction.RIGHT;
}
return Direction.LEFT;
}
throw new IllegalArgumentException("Not a H or V line!");
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 10103 $
* Revision $Revision: 12235 $
*
*/
package net.sourceforge.plantuml;

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -42,7 +42,7 @@ import java.io.File;
*
*/
public enum FileFormat {
PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, PDF, MJPEG, HTML, HTML5, VDX;
PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, PDF, MJPEG, ANIMATED_GIF, HTML, HTML5, VDX, LATEX, BASE64;
/**
* Returns the file format to be used for that format.
@ -53,10 +53,16 @@ public enum FileFormat {
if (name().startsWith("XMI")) {
return ".xmi";
}
if (this == MJPEG) {
return ".avi";
}
if (this == ANIMATED_GIF) {
return ".gif";
}
if (this == EPS_TEXT) {
return EPS.getFileSuffix();
}
return "." + name().toLowerCase();
return "." + StringUtils.goLowerCase(name());
}
/**

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -47,13 +47,15 @@ import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5;
import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz;
import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
import net.sourceforge.plantuml.StringUtils;
/**
* A FileFormat with some parameters.
@ -67,9 +69,10 @@ public class FileFormatOption {
private final FileFormat fileFormat;
private final AffineTransform affineTransform;
private final boolean withMetadata;
private final boolean useRedForError;
public FileFormatOption(FileFormat fileFormat) {
this(fileFormat, null, true);
this(fileFormat, null, true, false);
}
public final boolean isWithMetadata() {
@ -77,17 +80,18 @@ public class FileFormatOption {
}
public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
this(fileFormat, null, false);
this(fileFormat, null, false, false);
}
public FileFormatOption(FileFormat fileFormat, AffineTransform at) {
this(fileFormat, at, true);
}
public FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata) {
private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError) {
this.fileFormat = fileFormat;
this.affineTransform = at;
this.withMetadata = withMetadata;
this.useRedForError = useRedForError;
}
public FileFormatOption withUseRedForError() {
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true);
}
@Override
@ -114,7 +118,7 @@ public class FileFormatOption {
* @param rotation
* @return
*/
public UGraphic createUGraphic(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
public UGraphic2 createUGraphic(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
HtmlColor mybackcolor, boolean rotation) {
switch (fileFormat) {
case PNG:
@ -129,16 +133,18 @@ public class FileFormatOption {
return new UGraphicHtml5(colorMapper);
case VDX:
return new UGraphicVdx(colorMapper);
case LATEX:
return new UGraphicTikz(colorMapper);
default:
throw new UnsupportedOperationException(fileFormat.toString());
}
}
public UGraphic createUGraphic(final Dimension2D dim) {
public UGraphic2 createUGraphic(final Dimension2D dim) {
return createUGraphic(new ColorMapperIdentity(), 1.0, dim, null, false);
}
private UGraphic createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor,
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor,
boolean rotation) {
Color backColor = Color.WHITE;
if (mybackcolor instanceof HtmlColorSimple) {
@ -156,7 +162,7 @@ public class FileFormatOption {
}
private UGraphic createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
HtmlColor mybackcolor, boolean rotation) {
Color backColor = Color.WHITE;
if (mybackcolor instanceof HtmlColorSimple) {
@ -189,4 +195,8 @@ public class FileFormatOption {
return ug;
}
public final boolean isUseRedForError() {
return useRedForError;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 9786 $
* Revision $Revision: 14586 $
*
*/
package net.sourceforge.plantuml;
@ -40,6 +40,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
public class FileGroup {
private final List<File> result = new ArrayList<File>();
@ -47,7 +49,7 @@ public class FileGroup {
private final List<String> excluded;
private final Option option;
private final static Pattern predirPath = Pattern.compile("^([^*?]*[/\\\\])?(.*)$");
private final static Pattern predirPath = MyPattern.cmpile("^([^*?]*[/\\\\])?(.*)$");
public FileGroup(String pattern, List<String> excluded, Option option) {
this.pattern = pattern;
@ -121,7 +123,7 @@ public class FileGroup {
return f.getPath().replace('\\', '/');
}
private final static Pattern noStarInDirectory = Pattern.compile("^(?:([^*?]*)[/\\\\])?([^/\\\\]*)$");
private final static Pattern noStarInDirectory = MyPattern.cmpile("^(?:([^*?]*)[/\\\\])?([^/\\\\]*)$");
private void initWithSimpleStar() {
assert pattern.indexOf("**") == -1;
@ -160,7 +162,7 @@ public class FileGroup {
return Collections.unmodifiableList(result);
}
static String toRegexp(String pattern) {
public static String toRegexp(String pattern) {
pattern = pattern.replace("\\", "/");
pattern = pattern.replace(".", "\\.");
pattern = pattern.replace("?", "[^/]");

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 9786 $
* Revision $Revision: 14056 $
*
*/
package net.sourceforge.plantuml;
@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class FileSystem {
private final static FileSystem singleton = new FileSystem();

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -43,6 +43,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicInteger;
// Used by the Eclipse Plugin, so do not change package location.
public class FileUtils {
private static AtomicInteger counter;

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11985 $
* Revision $Revision: 15799 $
*
*/
package net.sourceforge.plantuml;
@ -41,26 +41,36 @@ interface FontParamConstant {
}
public enum FontParam {
ACTIVITY(14, Font.PLAIN), //
// ACTIVITY_ARROW(13, Font.PLAIN), //
ACTIVITY(12, Font.PLAIN), //
ACTIVITY_DIAMOND(11, Font.PLAIN), //
ACTIVITY_ARROW(11, Font.PLAIN), //
GENERIC_ARROW(13, Font.PLAIN), //
ACTIVITY2(12, Font.PLAIN), //
ACTIVITY_ARROW2(11, Font.PLAIN), //
CIRCLED_CHARACTER(17, Font.BOLD, FontParamConstant.COLOR, "Monospaced"), //
// OBJECT_ARROW(10, Font.PLAIN), //
OBJECT_ATTRIBUTE(10, Font.PLAIN), //
OBJECT(12, Font.PLAIN), //
OBJECT_STEREOTYPE(12, Font.ITALIC), //
// CLASS_ARROW(10, Font.PLAIN), //
CLASS_ATTRIBUTE(10, Font.PLAIN), //
CLASS(12, Font.PLAIN), //
CLASS_STEREOTYPE(12, Font.ITALIC), //
COMPONENT(14, Font.PLAIN), //
INTERFACE(14, Font.PLAIN), //
INTERFACE_STEREOTYPE(14, Font.ITALIC), //
COMPONENT_STEREOTYPE(14, Font.ITALIC), //
// COMPONENT_ARROW(13, Font.PLAIN), //
NOTE(13, Font.PLAIN), //
PACKAGE(14, Font.PLAIN), //
SEQUENCE_ACTOR(13, Font.PLAIN), //
ACTOR(14, Font.PLAIN), //
ARTIFACT(14, Font.PLAIN), //
CLOUD(14, Font.PLAIN), //
FOLDER(14, Font.PLAIN), //
FRAME(14, Font.PLAIN), //
STORAGE(14, Font.PLAIN), //
BOUNDARY(14, Font.PLAIN), //
CONTROL(14, Font.PLAIN), //
ENTITY(14, Font.PLAIN), //
AGENT(14, Font.PLAIN), //
RECTANGLE(14, Font.PLAIN), //
NODE(14, Font.PLAIN), //
DATABASE(14, Font.PLAIN), //
SEQUENCE_ARROW(13, Font.PLAIN), //
SEQUENCE_BOX(13, Font.BOLD), //
SEQUENCE_DIVIDER(13, Font.BOLD), //
@ -68,10 +78,9 @@ public enum FontParam {
SEQUENCE_DELAY(11, Font.PLAIN), //
SEQUENCE_GROUP(11, Font.BOLD), //
SEQUENCE_GROUP_HEADER(13, Font.BOLD), //
SEQUENCE_PARTICIPANT(13, Font.PLAIN), //
SEQUENCE_TITLE(13, Font.BOLD), //
PARTICIPANT(14, Font.PLAIN), //
SEQUENCE_TITLE(14, Font.BOLD), //
STATE(14, Font.PLAIN), //
// STATE_ARROW(13, Font.PLAIN), //
STATE_ATTRIBUTE(12, Font.PLAIN), //
LEGEND(14, Font.PLAIN), //
TITLE(18, Font.PLAIN), //
@ -79,9 +88,20 @@ public enum FontParam {
HEADER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), //
USECASE(14, Font.PLAIN), //
USECASE_STEREOTYPE(14, Font.ITALIC), //
USECASE_ACTOR(14, Font.PLAIN), //
USECASE_ACTOR_STEREOTYPE(14, Font.ITALIC); //
// USECASE_ARROW(13, Font.PLAIN, FontParamConstant.COLOR, FontParamConstant.FAMILY);
ARTIFACT_STEREOTYPE(14, Font.ITALIC), //
CLOUD_STEREOTYPE(14, Font.ITALIC), //
STORAGE_STEREOTYPE(14, Font.ITALIC), //
BOUNDARY_STEREOTYPE(14, Font.ITALIC), //
CONTROL_STEREOTYPE(14, Font.ITALIC), //
ENTITY_STEREOTYPE(14, Font.ITALIC), //
AGENT_STEREOTYPE(14, Font.ITALIC), //
RECTANGLE_STEREOTYPE(14, Font.ITALIC), //
NODE_STEREOTYPE(14, Font.ITALIC), //
FOLDER_STEREOTYPE(14, Font.ITALIC), //
FRAME_STEREOTYPE(14, Font.ITALIC), //
DATABASE_STEREOTYPE(14, Font.ITALIC), //
ACTOR_STEREOTYPE(14, Font.ITALIC), //
SEQUENCE_STEREOTYPE(14, Font.ITALIC); //
private final int defaultSize;
private final int fontStyle;
@ -106,8 +126,11 @@ public enum FontParam {
return defaultSize;
}
public final int getDefaultFontStyle(ISkinParam skinParam) {
if (this == PACKAGE) {
public final int getDefaultFontStyle(ISkinParam skinParam, boolean inPackageTitle) {
if (this == STATE) {
return fontStyle;
}
if (inPackageTitle || this == PACKAGE) {
return Font.BOLD;
}
return fontStyle;

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 10298 $
* Revision $Revision: 12869 $
*
*/
package net.sourceforge.plantuml;
@ -41,10 +41,10 @@ public class GeneratedImage implements Comparable<GeneratedImage> {
private final File pngFile;
private final String description;
private final Diagram system;
private final BlockUml blockUml;
public GeneratedImage(File pngFile, String description, Diagram system) {
this.system = system;
public GeneratedImage(File pngFile, String description, BlockUml blockUml) {
this.blockUml = blockUml;
this.pngFile = pngFile;
this.description = description;
}
@ -57,8 +57,12 @@ public class GeneratedImage implements Comparable<GeneratedImage> {
return description;
}
public boolean isError() {
return system instanceof PSystemError;
public int lineErrorRaw() {
final Diagram system = blockUml.getDiagram();
if (system instanceof PSystemError) {
return ((PSystemError) system).getHigherErrorPosition() + blockUml.getStartLine();
}
return -1;
}
@Override

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -33,32 +33,39 @@
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UStroke;
public interface ISkinParam extends SpriteContainer {
public interface ISkinParam extends ISkinSimple {
public HtmlColor getHyperlinkColor();
public boolean useUnderlineForHyperlink();
public HtmlColor getBackgroundColor();
public String getValue(String key);
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable);
public HtmlColor getHtmlColor(ColorParam param, String stereotype, boolean clickable);
public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype);
public HtmlColor getFontHtmlColor(FontParam param, String stereotype);
public UStroke getThickness(LineParam param, Stereotype stereotype);
public UStroke getThickness(LineParam param);
public UFont getFont(FontParam fontParam, String stereotype);
public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle);
public HorizontalAlignment getHorizontalAlignment(AlignParam param);
public HorizontalAlignment getDefaultTextAlignment();
public int getCircledCharacterRadius();
public int classAttributeIconSize();
@ -79,7 +86,7 @@ public interface ISkinParam extends SpriteContainer {
public boolean stereotypePositionTop();
public boolean useSwimlanes();
public boolean useSwimlanes(UmlDiagramType type);
public double getNodesep();
@ -94,9 +101,21 @@ public interface ISkinParam extends SpriteContainer {
public boolean forceSequenceParticipantUnderlined();
public ConditionStyle getConditionStyle();
public double minClassWidth();
public boolean sameClassWidth();
public Rankdir getRankdir();
public boolean useOctagonForActivity(Stereotype stereotype);
public IHtmlColorSet getIHtmlColorSet();
public int groupInheritance();
public boolean useGuillemet();
public boolean handwritten();
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -38,12 +38,10 @@ import java.util.List;
public interface ISourceFileReader {
public List<GeneratedImage> getGeneratedImages() throws IOException, InterruptedException;
public List<String> getEncodedUrl() throws IOException, InterruptedException;
public boolean hasError() throws IOException, InterruptedException;
public List<GeneratedImage> getGeneratedImages() throws IOException;
public List<String> getEncodedUrl() throws IOException;
public boolean hasError();
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -41,7 +41,9 @@ public enum LineParam {
// sequenceGroupBorder(0.1),
// sequenceReferenceBorder(0.1),
sequenceLifeLineBorder,
sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder;
sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder,
classBorder, objectBorder,
packageBorder;
// sequenceBoxBorder(0.1);
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,11 +28,12 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 9786 $
* Revision $Revision: 14532 $
*
*/
package net.sourceforge.plantuml;
public abstract class Log {
private static final long start = System.currentTimeMillis();
@ -52,14 +53,37 @@ public abstract class Log {
private static String format(String s) {
final long delta = System.currentTimeMillis() - start;
// final HealthCheck healthCheck = Performance.getHealthCheck();
// final long cpu = healthCheck.jvmCpuTime() / 1000L / 1000L;
// final long dot = healthCheck.dotTime().getSum();
final long freeMemory = Runtime.getRuntime().freeMemory();
final long maxMemory = Runtime.getRuntime().maxMemory();
final long totalMemory = Runtime.getRuntime().totalMemory();
final long usedMemory = totalMemory - freeMemory;
final int threadActiveCount = Thread.activeCount();
final StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append(delta / 1000L);
sb.append(".");
sb.append(String.format("%03d", delta % 1000L));
// if (cpu != -1) {
// sb.append(" - ");
// sb.append(cpu / 1000L);
// sb.append(".");
// sb.append(String.format("%03d", cpu % 1000L));
// }
// sb.append(" - ");
// sb.append(dot / 1000L);
// sb.append(".");
// sb.append(String.format("%03d", dot % 1000L));
// sb.append("(");
// sb.append(healthCheck.dotTime().getNb());
// sb.append(")");
sb.append(" - ");
final long total = (Runtime.getRuntime().totalMemory()) / 1024 / 1024;
final long free = (Runtime.getRuntime().freeMemory()) / 1024 / 1024;
final long total = totalMemory / 1024 / 1024;
final long free = freeMemory / 1024 / 1024;
sb.append(total);
sb.append(" Mo) ");
sb.append(free);
@ -70,16 +94,16 @@ public abstract class Log {
}
public static void println(Object s) {
if (header == null) {
if (header2.get() == null) {
System.err.println("L = " + s);
} else {
System.err.println(header + " " + s);
System.err.println(header2.get() + " " + s);
}
}
private static String header;
private static final ThreadLocal<String> header2 = new ThreadLocal<String>();
public static void header(String s) {
header = s;
header2.set(s);
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -49,7 +49,7 @@ public class NewpagedDiagram extends AbstractPSystem {
private final List<Diagram> diagrams = new ArrayList<Diagram>();
private NewpagedDiagram(Diagram diag1, Diagram diag2) {
public NewpagedDiagram(AbstractPSystem diag1, AbstractPSystem diag2) {
if (diag1 instanceof NewpagedDiagram) {
throw new IllegalArgumentException();
}
@ -60,18 +60,33 @@ public class NewpagedDiagram extends AbstractPSystem {
this.diagrams.add(diag2);
}
public static NewpagedDiagram newpage(AbstractPSystem diagram, AbstractPSystem empty) {
if (diagram instanceof NewpagedDiagram) {
final NewpagedDiagram other = (NewpagedDiagram) diagram;
other.diagrams.add(empty);
return other;
}
return new NewpagedDiagram(diagram, empty);
@Override
public String toString() {
return super.toString() + " SIZE=" + diagrams.size() + " " + diagrams;
}
public CommandExecutionResult executeCommand(Command cmd, List<String> lines) {
final int nb = diagrams.size();
return cmd.execute(diagrams.get(nb - 1), lines);
final CommandExecutionResult tmp = cmd.execute(diagrams.get(nb - 1), lines);
if (tmp.getNewDiagram() instanceof NewpagedDiagram) {
final NewpagedDiagram new1 = (NewpagedDiagram) tmp.getNewDiagram();
// System.err.println("this=" + this);
// System.err.println("new1=" + new1);
if (new1.size() != 2) {
throw new IllegalStateException();
}
if (new1.diagrams.get(0) != this.diagrams.get(nb - 1)) {
throw new IllegalStateException();
}
this.diagrams.add(new1.diagrams.get(1));
return tmp.withDiagram(this);
}
return tmp;
}
private int size() {
return diagrams.size();
}
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
@ -108,4 +123,12 @@ public class NewpagedDiagram extends AbstractPSystem {
return sb.toString();
}
@Override
public void makeDiagramReady() {
super.makeDiagramReady();
for (Diagram diagram : diagrams) {
((AbstractPSystem) diagram).makeDiagramReady();
}
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 12022 $
* Revision $Revision: 14727 $
*
*/
package net.sourceforge.plantuml;
@ -38,6 +38,7 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@ -45,6 +46,7 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.preproc.Defines;
public class Option {
@ -58,6 +60,8 @@ public class Option {
private boolean pipe = false;
private boolean syntax = false;
private boolean checkOnly = false;
private boolean failfast = false;
private boolean failfast2 = false;
private boolean pattern = false;
private boolean duration = false;
private int nbThreads = 0;
@ -109,6 +113,10 @@ public class Option {
setFileFormat(FileFormat.PNG);
} else if (s.equalsIgnoreCase("-vdx") || s.equalsIgnoreCase("-tvdx")) {
setFileFormat(FileFormat.VDX);
} else if (s.equalsIgnoreCase("-latex") || s.equalsIgnoreCase("-tlatex")) {
setFileFormat(FileFormat.LATEX);
} else if (s.equalsIgnoreCase("-base64") || s.equalsIgnoreCase("-tbase64")) {
setFileFormat(FileFormat.BASE64);
} else if (s.equalsIgnoreCase("-pdf") || s.equalsIgnoreCase("-tpdf")) {
setFileFormat(FileFormat.PDF);
} else if (s.equalsIgnoreCase("-overwrite")) {
@ -160,9 +168,12 @@ public class Option {
} else if (nb.matches("\\d+")) {
this.nbThreads = Integer.parseInt(nb);
}
} else if (s.equalsIgnoreCase("-failfast")) {
this.failfast = true;
} else if (s.equalsIgnoreCase("-failfast2")) {
this.failfast2 = true;
} else if (s.equalsIgnoreCase("-checkonly")) {
this.checkOnly = true;
OptionFlags.getInstance().setFailOnError(true);
} else if (s.equalsIgnoreCase("-config")) {
i++;
if (i == arg.length) {
@ -227,11 +238,9 @@ public class Option {
OptionFlags.getInstance().setEncodesprite(true);
} else if (s.equalsIgnoreCase("-nosuggestengine")) {
OptionFlags.getInstance().setUseSuggestEngine(false);
} else if (s.equalsIgnoreCase("-failonerror")) {
OptionFlags.getInstance().setFailOnError(true);
} else if (s.equalsIgnoreCase("-printfonts")) {
OptionFlags.getInstance().setPrintFonts(true);
} else if (s.toLowerCase().startsWith("-ftp")) {
} else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
final int x = s.indexOf(':');
if (x == -1) {
this.ftpPort = 4242;
@ -267,7 +276,7 @@ public class Option {
}
private void manageDefine(String s) {
final Pattern p = Pattern.compile("^(\\w+)(?:=(.*))?$");
final Pattern p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
final Matcher m = p.matcher(s);
if (m.find()) {
define(m.group(1), m.group(2));
@ -275,7 +284,7 @@ public class Option {
}
private void manageSkinParam(String s) {
final Pattern p = Pattern.compile("^(\\w+)(?:=(.*))?$");
final Pattern p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
final Matcher m = p.matcher(s);
if (m.find()) {
skinParam(m.group(1), m.group(2));
@ -308,7 +317,7 @@ public class Option {
public Defines getDefaultDefines() {
final Defines result = new Defines();
for (Map.Entry<String, String> ent : defines.entrySet()) {
result.define(ent.getKey(), ent.getValue());
result.define(ent.getKey(), Arrays.asList(ent.getValue()));
}
return result;
@ -383,6 +392,22 @@ public class Option {
this.checkOnly = checkOnly;
}
public final boolean isFailfastOrFailfast2() {
return failfast || failfast2;
}
public final boolean isFailfast2() {
return failfast2;
}
public final void setFailfast(boolean failfast) {
this.failfast = failfast;
}
public final void setFailfast2(boolean failfast2) {
this.failfast2 = failfast2;
}
public final File getOutputFile() {
return outputFile;
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11833 $
* Revision $Revision: 15087 $
*
*/
package net.sourceforge.plantuml;
@ -45,14 +45,18 @@ import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
public class OptionFlags {
// static public final boolean PBBACK = false;
static public boolean GRAPHVIZCACHE = false;
// static public boolean GRAPHVIZCACHE = false;
static public final boolean TRACE_DOT = false;
static public final boolean HORIZONTAL_LINE_BETWEEN_DIFFERENT_PACKAGE_ALLOWED = false;
static public boolean ALLOW_INCLUDE = true;
static public final boolean USE_HECTOR = false;
static public final boolean USE_CREOLE = true;
static public boolean ADD_NICE_FOR_DOT = false;
static public final boolean STRICT_SELFMESSAGE_POSITION = true;
static public final boolean FORCE_TEOZ = false;
static public final boolean USE_INTERFACE_EYE1 = false;
static public final boolean USE_INTERFACE_EYE2 = false;
static public final boolean SWI2 = false;
void reset() {
reset(false);
@ -70,7 +74,7 @@ public class OptionFlags {
checkDotError = false;
printFonts = false;
useSuggestEngine = true;
failOnError = false;
// failOnError = false;
encodesprite = false;
// PIC_LINE = false;
}
@ -92,7 +96,7 @@ public class OptionFlags {
private boolean checkDotError;
private boolean printFonts;
private boolean useSuggestEngine;
private boolean failOnError;
// private boolean failOnError;
private boolean encodesprite;
private boolean overwrite;
private File logData;
@ -259,13 +263,13 @@ public class OptionFlags {
this.useSuggestEngine = useSuggestEngine;
}
public final boolean isFailOnError() {
return failOnError;
}
public final void setFailOnError(boolean failOnError) {
this.failOnError = failOnError;
}
// public final boolean isFailOnError() {
// return failOnError;
// }
//
// public final void setFailOnError(boolean failOnError) {
// this.failOnError = failOnError;
// }
public final boolean isEncodesprite() {
return encodesprite;
@ -282,5 +286,5 @@ public class OptionFlags {
public final void setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11786 $
* Revision $Revision: 14028 $
*
*/
package net.sourceforge.plantuml;
@ -72,6 +72,8 @@ public class OptionPrint {
System.out.println(" -tpng\t\tTo generate images using PNG format (default)");
System.out.println(" -tsvg\t\tTo generate images using SVG format");
System.out.println(" -teps\t\tTo generate images using EPS format");
System.out.println(" -tpdf\t\tTo generate images using PDF format");
System.out.println(" -tvdx\t\tTo generate images using VDX format");
System.out.println(" -txmi\t\tTo generate XMI file for class diagram");
System.out.println(" -thtml\t\tTo generate HTML files for class diagram");
System.out.println(" -ttxt\t\tTo generate images with ASCII art");
@ -79,6 +81,7 @@ public class OptionPrint {
System.out.println(" -o[utput] \"dir\"\tTo generate images in the specified directory");
System.out.println(" -DVAR1=value\tTo set a preprocessing variable as if '!define VAR1 value' were used");
System.out.println(" -Sparam1=value\tTo set a skin parameter as if 'skinparam param1 value' were used");
System.out.println(" -r[ecurse]\t\trecurse through directories");
System.out.println(" -config \"file\"\tTo read the provided config file before each diagram");
System.out.println(" -charset xxx\tTo use a specific charset (default is " + charset + ")");
System.out.println(" -e[x]clude pattern\tTo exclude files that match the provided pattern");
@ -94,19 +97,22 @@ public class OptionPrint {
System.out.println(" -testdot\t\tTo test the installation of graphviz");
System.out.println(" -graphvizdot \"exe\"\tTo specify dot executable");
System.out.println(" -p[ipe]\t\tTo use stdin for PlantUML source and stdout for PNG/SVG/EPS generation");
System.out.println(" -computeurl\t\tTo compute the encoded URL of a PlantUML source file");
System.out.println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image");
System.out.println(" -computeurl|-encodeurl\tTo compute the encoded URL of a PlantUML source file");
System.out.println(" -decodeurl\t\tTo retrieve the PlantUML source from an encoded URL");
System.out.println(" -syntax\t\tTo report any syntax error from standard input without generating images");
System.out.println(" -language\t\tTo print the list of PlantUML keywords");
System.out.println(" -nosuggestengine\tTo disable the suggest engine when errors in diagrams");
System.out.println(" -checkonly\t\tTo check the syntax of files without generating images");
System.out.println(" -failonerror\tTo stop processing if syntax error in diagram occurs");
System.out.println(" -failfast\t\tTo stop processing as soon as a syntax error in diagram occurs");
System.out.println(" -failfast2\t\tTo do a first syntax check before processing files, to fail even faster");
System.out.println(" -pattern\t\tTo print the list of Regular Expression used by PlantUML");
System.out.println(" -duration\t\tTo print the duration of complete diagrams processing");
System.out.println(" -nbthread N\t\tTo use (N) threads for processing");
System.out.println(" -nbthread auto\tTo use " + Option.defaultNbThreads() + " threads for processing");
System.out.println(" -author[s]\t\tTo print information about PlantUML authors");
System.out.println(" -overwrite\t\tTo all to overwrite read only files");
System.out.println(" -overwrite\t\tTo allow to overwrite read only files");
System.out.println(" -printfonts\t\tTo print fonts available on your system");
System.out.println();
System.out.println("If needed, you can setup the environment variable GRAPHVIZ_DOT.");
exit();
@ -128,7 +134,7 @@ public class OptionPrint {
public static void printVersion() throws InterruptedException {
System.out
.println("PlantUML version " + Version.versionString() + " (" + new Date(Version.compileTime()) + ")");
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println("(" + License.getCurrent() + " source distribution)");
final Properties p = System.getProperties();
System.out.println(p.getProperty("java.runtime.name"));
@ -144,7 +150,7 @@ public class OptionPrint {
public static void checkVersion() throws InterruptedException {
System.out
.println("PlantUML version " + Version.versionString() + " (" + new Date(Version.compileTime()) + ")");
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println();
final int lastversion = PSystemVersion.extractDownloadableVersion(null, null);
if (lastversion == -1) {
@ -170,13 +176,15 @@ public class OptionPrint {
public static void printAbout() throws InterruptedException {
// Duplicate in PSystemVersion
System.out
.println("PlantUML version " + Version.versionString() + " (" + new Date(Version.compileTime()) + ")");
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println();
System.out.println("Original idea: Arnaud Roques");
System.out.println("Word Macro: Alain Bertucat & Matthieu Sabatier");
System.out.println("Word Add-in: Adriaan van den Brand");
System.out.println("Eclipse Plugin: Claude Durif & Anne Pecoil");
System.out.println("Servlet & XWiki: Maxime Sinclair");
System.out.println("Site design: Raphael Cotisson");
System.out.println("Logo: Benjamin Croizet");
System.out.println();
System.out.println("http://plantuml.sourceforge.net");
exit();

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -47,11 +47,13 @@ import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.creole.PSystemCreoleFactory;
import net.sourceforge.plantuml.cute.PSystemCuteFactory;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
import net.sourceforge.plantuml.directdot.PSystemDotFactory;
import net.sourceforge.plantuml.ditaa.PSystemDitaaFactory;
import net.sourceforge.plantuml.donors.PSystemDonorsFactory;
import net.sourceforge.plantuml.eggs.PSystemAppleTwoFactory;
import net.sourceforge.plantuml.eggs.PSystemCharlieFactory;
import net.sourceforge.plantuml.eggs.PSystemEggFactory;
import net.sourceforge.plantuml.eggs.PSystemLostFactory;
import net.sourceforge.plantuml.eggs.PSystemPathFactory;
@ -59,8 +61,11 @@ import net.sourceforge.plantuml.eggs.PSystemRIPFactory;
import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory;
import net.sourceforge.plantuml.font.PSystemListFontsFactory;
import net.sourceforge.plantuml.jcckit.PSystemJcckitFactory;
import net.sourceforge.plantuml.jungle.PSystemTreeFactory;
import net.sourceforge.plantuml.logo.PSystemLogoFactory;
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory;
import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory;
import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
import net.sourceforge.plantuml.postit.PostIdDiagramFactory;
import net.sourceforge.plantuml.printskin.PrintSkinFactory;
@ -76,6 +81,8 @@ import net.sourceforge.plantuml.version.PSystemVersionFactory;
public class PSystemBuilder {
public static final long startTime = System.currentTimeMillis();
final public Diagram createPSystem(final List<? extends CharSequence> strings) {
final List<PSystemFactory> factories = getAllFactories();
@ -97,9 +104,9 @@ public class PSystemBuilder {
}
final PSystemError err = merge(errors);
// if (OptionFlags.getInstance().isQuiet() == false) {
// err.print(System.err);
// }
// if (OptionFlags.getInstance().isQuiet() == false) {
// err.print(System.err);
// }
return err;
}
@ -120,6 +127,8 @@ public class PSystemBuilder {
factories.add(new PSystemVersionFactory());
factories.add(new PSystemDonorsFactory());
factories.add(new PSystemListFontsFactory());
factories.add(new PSystemOpenIconicFactory());
factories.add(new PSystemListOpenIconicFactory());
factories.add(new PSystemSaltFactory(DiagramType.SALT));
factories.add(new PSystemSaltFactory(DiagramType.UML));
factories.add(new PSystemDotFactory(DiagramType.DOT));
@ -140,11 +149,14 @@ public class PSystemBuilder {
factories.add(new PSystemLostFactory());
factories.add(new PSystemPathFactory());
factories.add(new PSystemOregonFactory());
factories.add(new PSystemCharlieFactory());
if (License.getCurrent() == License.GPL) {
factories.add(new PSystemXearthFactory());
}
factories.add(new PSystemProjectFactory2());
factories.add(new FlowDiagramFactory());
factories.add(new PSystemTreeFactory(DiagramType.JUNGLE));
factories.add(new PSystemCuteFactory(DiagramType.CUTE));
return factories;
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 12053 $
* Revision $Revision: 15848 $
*/
package net.sourceforge.plantuml;
@ -41,16 +41,33 @@ import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.asciiart.UmlCharArea;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
public class PSystemError extends AbstractPSystem {
private final List<String> htmlStrings = new ArrayList<String>();
private final List<String> plainStrings = new ArrayList<String>();
private String getSuggestColor(boolean useRed) {
if (useRed) {
return "black";
}
return "white";
}
private String getRed(boolean useRed) {
if (useRed) {
return "#CD0A0A";
}
return "red";
}
private final int higherErrorPosition;
private final List<ErrorUml> printedErrors;
@ -72,7 +89,6 @@ public class PSystemError extends AbstractPSystem {
higherErrorPosition = higherErrorPositionSyntax;
printedErrors = getErrorsAt(higherErrorPositionSyntax, ErrorUmlType.SYNTAX_ERROR, all);
}
appendSource(higherErrorPosition);
}
@ -81,55 +97,118 @@ public class PSystemError extends AbstractPSystem {
}
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
final GraphicStrings result = new GraphicStrings(htmlStrings);
return result.exportDiagram(os, getMetadata(), fileFormat);
if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
final UGraphicTxt ugt = new UGraphicTxt();
final UmlCharArea area = ugt.getCharArea();
area.drawStringsLR(getTextStrings(), 0, 0);
area.print(new PrintStream(os));
return new ImageDataSimple(1, 1);
}
final boolean useRed = fileFormat.isUseRedForError();
final GraphicStrings result = GraphicStrings.createDefault(getHtmlStrings(useRed), useRed);
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false);
imageBuilder.addUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
}
private void appendSource(int position) {
private List<String> getTextStrings() {
final List<String> result = new ArrayList<String>();
final int limit = 4;
int start;
final int skip = position - limit + 1;
final int skip = higherErrorPosition - limit + 1;
if (skip <= 0) {
start = 0;
} else {
if (skip == 1) {
htmlStrings.add("... (skipping 1 line) ...");
plainStrings.add("... (skipping 1 line) ...");
result.add("... (skipping 1 line) ...");
} else {
htmlStrings.add("... (skipping " + skip + " lines) ...");
plainStrings.add("... (skipping " + skip + " lines) ...");
result.add("... (skipping " + skip + " lines) ...");
}
start = position - limit + 1;
start = higherErrorPosition - limit + 1;
}
for (int i = start; i < position; i++) {
htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
plainStrings.add(getSource().getLine(i));
for (int i = start; i < higherErrorPosition; i++) {
result.add(getSource().getLine(i));
}
final String errorLine = getSource().getLine(higherErrorPosition);
final String err = StringUtils.hideComparatorCharacters(errorLine);
if (StringUtils.isNotEmpty(err)) {
result.add(err);
}
final String errorLine = getSource().getLine(position);
htmlStrings.add("<w:red>" + StringUtils.hideComparatorCharacters(errorLine) + "</w>");
plainStrings.add(StringUtils.hideComparatorCharacters(errorLine));
final StringBuilder underscore = new StringBuilder();
for (int i = 0; i < errorLine.length(); i++) {
underscore.append("^");
}
plainStrings.add(underscore.toString());
result.add(underscore.toString());
final Collection<String> textErrors = new LinkedHashSet<String>();
for (ErrorUml er : printedErrors) {
textErrors.add(er.getError());
}
for (String er : textErrors) {
htmlStrings.add(" <color:red>" + er);
plainStrings.add(" " + er);
result.add(" " + er);
}
boolean first = true;
for (String s : getSuggest()) {
if (first) {
htmlStrings.add(" <color:white><i>" + s);
result.add(" " + s);
} else {
htmlStrings.add("<color:white>" + StringUtils.hideComparatorCharacters(s));
result.add(s);
}
first = false;
}
return result;
}
private List<String> getHtmlStrings(boolean useRed) {
final List<String> htmlStrings = new ArrayList<String>();
final int limit = 4;
int start;
final int skip = higherErrorPosition - limit + 1;
if (skip <= 0) {
start = 0;
} else {
if (skip == 1) {
htmlStrings.add("... (skipping 1 line) ...");
} else {
htmlStrings.add("... (skipping " + skip + " lines) ...");
}
start = higherErrorPosition - limit + 1;
}
for (int i = start; i < higherErrorPosition; i++) {
htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
}
final String errorLine = getSource().getLine(higherErrorPosition);
final String err = StringUtils.hideComparatorCharacters(errorLine);
if (StringUtils.isNotEmpty(err)) {
htmlStrings.add("<w:" + getRed(useRed) + ">" + err + "</w>");
}
// final StringBuilder underscore = new StringBuilder();
// for (int i = 0; i < errorLine.length(); i++) {
// underscore.append("^");
// }
final Collection<String> textErrors = new LinkedHashSet<String>();
for (ErrorUml er : printedErrors) {
textErrors.add(er.getError());
}
for (String er : textErrors) {
htmlStrings.add(" <color:" + getRed(useRed) + ">" + er + "</color>");
}
boolean first = true;
for (String s : getSuggest()) {
if (first) {
htmlStrings.add(" <color:" + getSuggestColor(useRed) + "><i>" + s + "</i></color>");
} else {
htmlStrings.add("<color:" + getSuggestColor(useRed) + ">" + StringUtils.hideComparatorCharacters(s)
+ "</color>");
}
first = false;
}
return htmlStrings;
}
public List<String> getSuggest() {
@ -190,14 +269,6 @@ public class PSystemError extends AbstractPSystem {
return new DiagramDescriptionImpl("(Error)", getClass());
}
private void print(PrintStream ps) {
synchronized (ps) {
for (String s : plainStrings) {
ps.println(StringUtils.showComparatorCharacters(s));
}
}
}
public final int getHigherErrorPosition() {
return higherErrorPosition;
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -150,7 +150,7 @@ public class PSystemUtils {
os.close();
}
}
if (system.hasUrl() && cmap != null && cmap.containsCMapData()) {
if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap);
}
return Arrays.asList(suggestedFile);
@ -173,7 +173,7 @@ public class PSystemUtils {
} finally {
fos.close();
}
if (system.hasUrl() && cmap != null && cmap.containsCMapData()) {
if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap);
}
Log.info("File size : " + f.length());
@ -207,7 +207,7 @@ public class PSystemUtils {
}
List<File> result = Arrays.asList(suggestedFile);
if (system.hasUrl() && cmap != null && cmap.containsCMapData()) {
if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap);
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -33,10 +33,10 @@
*/
package net.sourceforge.plantuml;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.StringUtils;
public class Pragma {
@ -61,7 +61,13 @@ public class Pragma {
return values.get(name);
}
protected Set<Map.Entry<String, String>> entrySet() {
return Collections.unmodifiableSet(values.entrySet());
public boolean horizontalLineBetweenDifferentPackageAllowed() {
return isDefine("horizontallinebetweendifferentpackageallowed");
}
public boolean useTeozLayout() {
final String teoz = getValue("teoz");
return "true".equalsIgnoreCase(teoz) || "on".equalsIgnoreCase(teoz);
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 12023 $
* Revision $Revision: 14871 $
*
*/
package net.sourceforge.plantuml;
@ -85,7 +85,7 @@ public class Run {
Log.info("Forcing -Djava.awt.headless=true");
System.setProperty("java.awt.headless", "true");
Log.info("java.awt.headless set as true");
}
if (OptionFlags.getInstance().isPrintFonts()) {
printFonts();
@ -106,18 +106,39 @@ public class Run {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
}
new MainWindow2(option);
final List<String> list = option.getResult();
File dir = null;
if (list.size() == 1) {
final File f = new File(list.get(0));
if (f.exists() && f.isDirectory()) {
dir = f;
}
}
new MainWindow2(option, dir);
} else if (option.isPipe() || option.isSyntax()) {
managePipe(option);
forceQuit = true;
} else if (option.isFailfast2()) {
final long start2 = System.currentTimeMillis();
option.setCheckOnly(true);
error = manageAllFiles(option);
option.setCheckOnly(false);
if (option.isDuration()) {
final double duration = (System.currentTimeMillis() - start2) / 1000.0;
Log.error("Check Duration = " + duration + " seconds");
}
if (error == false) {
error = manageAllFiles(option);
}
forceQuit = true;
} else {
error = manageAllFiles(option);
forceQuit = true;
}
if (option.isDuration()) {
final long duration = System.currentTimeMillis() - start;
Log.error("Duration = " + (duration / 1000L) + " seconds");
final double duration = (System.currentTimeMillis() - start) / 1000.0;
Log.error("Duration = " + duration + " seconds");
}
if (error) {
@ -141,7 +162,7 @@ public class Run {
if (result.get(0).startsWith("4")) {
level = SpriteGrayLevel.GRAY_4;
}
compressed = result.get(0).toLowerCase().endsWith("z");
compressed = StringUtils.goLowerCase(result.get(0)).endsWith("z");
f = new File(result.get(1));
} else {
f = new File(result.get(0));
@ -176,7 +197,7 @@ public class Run {
private static void goFtp(Option option) throws IOException {
final int ftpPort = option.getFtpPort();
System.err.println("ftpPort=" + ftpPort);
final FtpServer ftpServer = new FtpServer(ftpPort);
final FtpServer ftpServer = new FtpServer(ftpPort, option.getFileFormat());
ftpServer.go();
}
@ -281,6 +302,7 @@ public class Run {
&& OptionFlags.getInstance().isMetadata() == false) {
return multithread(option);
}
boolean errorGlobal = false;
for (String s : option.getResult()) {
if (option.isDecodeurl()) {
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
@ -293,6 +315,9 @@ public class Run {
try {
final boolean error = manageFileInternal(f, option);
if (error) {
errorGlobal = true;
}
if (error && option.isFailfastOrFailfast2()) {
return true;
}
} catch (IOException e) {
@ -301,7 +326,7 @@ public class Run {
}
}
}
return false;
return errorGlobal;
}
private static boolean multithread(final Option option) throws InterruptedException {
@ -313,7 +338,7 @@ public class Run {
for (final File f : group.getFiles()) {
executor.submit(new Runnable() {
public void run() {
if (errors.get()) {
if (errors.get() && option.isFailfastOrFailfast2()) {
return;
}
try {
@ -359,21 +384,27 @@ public class Run {
System.out.println(s);
}
return false;
} else if (option.isCheckOnly()) {
return sourceFileReader.hasError();
}
if (option.isCheckOnly()) {
final boolean hasError = sourceFileReader.hasError();
final List<GeneratedImage> result = sourceFileReader.getGeneratedImages();
hasErrors(f, result);
return hasError;
}
final List<GeneratedImage> result = sourceFileReader.getGeneratedImages();
if (OptionFlags.getInstance().isFailOnError()) {
for (GeneratedImage i : result) {
if (i.isError()) {
Log.error("Error in file: " + f.getCanonicalPath());
}
if (i.isError() && OptionFlags.getInstance().isFailOnError()) {
return true;
}
return hasErrors(f, result);
}
private static boolean hasErrors(File f, final List<GeneratedImage> list) throws IOException {
boolean result = false;
for (GeneratedImage i : list) {
final int lineError = i.lineErrorRaw();
if (lineError != -1) {
Log.error("Error line " + lineError + " in file: " + f.getCanonicalPath());
result = true;
}
}
return false;
return result;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 9786 $
* Revision $Revision: 12235 $
*
*/
package net.sourceforge.plantuml;

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 10298 $
* Revision $Revision: 12235 $
*
*/
package net.sourceforge.plantuml;

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11707 $
* Revision $Revision: 15850 $
*
*/
package net.sourceforge.plantuml;
@ -44,11 +44,16 @@ import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
@ -61,33 +66,47 @@ import net.sourceforge.plantuml.ugraphic.UStroke;
public class SkinParam implements ISkinParam {
private final Map<String, String> params = new HashMap<String, String>();
private Rankdir rankdir = Rankdir.TOP_TO_BOTTOM;
public void setParam(String key, String value) {
params.put(cleanForKey(key), value.trim());
}
private static final String stereoPatternString = "\\<\\<(.*?)\\>\\>";
private static final Pattern stereoPattern = Pattern.compile(stereoPatternString);
private static final Pattern stereoPattern = MyPattern.cmpile(stereoPatternString);
private final UmlDiagramType type;
// public SkinParam() {
//
// }
public SkinParam(UmlDiagramType type) {
this.type = type;
if (type == null) {
setParam("shadowing", "false");
}
public static SkinParam noShadowing() {
final SkinParam result = new SkinParam();
result.setParam("shadowing", "false");
return result;
}
// public SkinParam(String type) {
// if (type == null) {
// setParam("shadowing", "false");
// }
// }
static String cleanForKey(String key) {
key = key.toLowerCase().trim();
key = StringUtils.goLowerCase(key).trim();
key = key.replaceAll("_|\\.|\\s", "");
key = key.replaceAll("partition", "package");
key = key.replaceAll("activityarrow", "genericarrow");
key = key.replaceAll("objectarrow", "genericarrow");
key = key.replaceAll("classarrow", "genericarrow");
key = key.replaceAll("componentarrow", "genericarrow");
key = key.replaceAll("statearrow", "genericarrow");
key = key.replaceAll("usecasearrow", "genericarrow");
key = replaceSmart(key, "partition", "package");
key = replaceSmart(key, "sequenceparticipant", "participant");
key = replaceSmart(key, "sequenceactor", "actor");
if (key.contains("arrow")) {
key = key.replaceAll("activityarrow|objectarrow|classarrow|componentarrow|statearrow|usecasearrow",
"genericarrow");
}
// // key = key.replaceAll("activityarrow", "genericarrow");
// // key = key.replaceAll("objectarrow", "genericarrow");
// // key = key.replaceAll("classarrow", "genericarrow");
// // key = key.replaceAll("componentarrow", "genericarrow");
// // key = key.replaceAll("statearrow", "genericarrow");
// // key = key.replaceAll("usecasearrow", "genericarrow");
final Matcher m = stereoPattern.matcher(key);
if (m.find()) {
final String s = m.group(1);
@ -97,6 +116,21 @@ public class SkinParam implements ISkinParam {
return key;
}
private static String replaceSmart(String s, String src, String target) {
if (s.contains(src) == false) {
return s;
}
return s.replaceAll(src, target);
}
public HtmlColor getHyperlinkColor() {
final HtmlColor result = getHtmlColor(ColorParam.hyperlink, null, false);
if (result == null) {
return HtmlColorUtils.BLUE;
}
return result;
}
public HtmlColor getBackgroundColor() {
final HtmlColor result = getHtmlColor(ColorParam.background, null, false);
if (result == null) {
@ -117,19 +151,19 @@ public class SkinParam implements ISkinParam {
if (c == '_') {
upper = true;
} else {
sb.append(upper ? Character.toUpperCase(c) : Character.toLowerCase(c));
sb.append(upper ? StringUtils.goUpperCase(c) : StringUtils.goLowerCase(c));
upper = false;
}
}
return sb.toString();
}
public HtmlColor getHtmlColor(ColorParam param, String stereotype, boolean clickable) {
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "color" + stereotype);
if (value2 != null && HtmlColorUtils.getColorIfValid(value2) != null) {
return HtmlColorUtils.getColorIfValid(value2);
final String value2 = getValue(param.name() + "color" + stereotype.getLabel(false));
if (value2 != null && getIHtmlColorSet().getColorIfValid(value2) != null) {
return getIHtmlColorSet().getColorIfValid(value2);
}
}
final String value = getValue(getParamName(param, clickable));
@ -137,7 +171,7 @@ public class SkinParam implements ISkinParam {
if (value == null) {
return null;
}
return HtmlColorUtils.getColorIfValid(value, acceptTransparent);
return getIHtmlColorSet().getColorIfValid(value, acceptTransparent);
}
private String getParamName(ColorParam param, boolean clickable) {
@ -150,16 +184,16 @@ public class SkinParam implements ISkinParam {
return n + "color";
}
private void checkStereotype(String stereotype) {
if (stereotype.startsWith("<<") == false || stereotype.endsWith(">>") == false) {
throw new IllegalArgumentException();
}
private void checkStereotype(Stereotype stereotype) {
// if (stereotype.startsWith("<<") == false || stereotype.endsWith(">>") == false) {
// throw new IllegalArgumentException();
// }
}
private int getFontSize(FontParam param, String stereotype) {
private int getFontSize(FontParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "fontsize" + stereotype);
final String value2 = getValue(param.name() + "fontsize" + stereotype.getLabel(false));
if (value2 != null && value2.matches("\\d+")) {
return Integer.parseInt(value2);
}
@ -174,10 +208,10 @@ public class SkinParam implements ISkinParam {
return Integer.parseInt(value);
}
private String getFontFamily(FontParam param, String stereotype) {
private String getFontFamily(FontParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "fontname" + stereotype);
final String value2 = getValue(param.name() + "fontname" + stereotype.getLabel(false));
if (value2 != null) {
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value2);
}
@ -196,29 +230,29 @@ public class SkinParam implements ISkinParam {
return param.getDefaultFamily();
}
public HtmlColor getFontHtmlColor(FontParam param, String stereotype) {
public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype) {
String value = null;
if (stereotype != null) {
checkStereotype(stereotype);
value = getValue(param.name() + "fontcolor" + stereotype);
value = getValue(param.name() + "fontcolor" + stereotype.getLabel(false));
}
if (value == null || HtmlColorUtils.getColorIfValid(value) == null) {
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
value = getValue(param.name() + "fontcolor");
}
if (value == null || HtmlColorUtils.getColorIfValid(value) == null) {
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
value = getValue("defaultfontcolor");
}
if (value == null || HtmlColorUtils.getColorIfValid(value) == null) {
if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
value = param.getDefaultColor();
}
return HtmlColorUtils.getColorIfValid(value);
return getIHtmlColorSet().getColorIfValid(value);
}
private int getFontStyle(FontParam param, String stereotype) {
private int getFontStyle(FontParam param, Stereotype stereotype, boolean inPackageTitle) {
String value = null;
if (stereotype != null) {
checkStereotype(stereotype);
value = getValue(param.name() + "fontstyle" + stereotype);
value = getValue(param.name() + "fontstyle" + stereotype.getLabel(false));
}
if (value == null) {
value = getValue(param.name() + "fontstyle");
@ -227,25 +261,26 @@ public class SkinParam implements ISkinParam {
value = getValue("defaultfontstyle");
}
if (value == null) {
return param.getDefaultFontStyle(this);
return param.getDefaultFontStyle(this, inPackageTitle);
}
int result = Font.PLAIN;
if (value.toLowerCase().contains("bold")) {
if (StringUtils.goLowerCase(value).contains("bold")) {
result = result | Font.BOLD;
}
if (value.toLowerCase().contains("italic")) {
if (StringUtils.goLowerCase(value).contains("italic")) {
result = result | Font.ITALIC;
}
return result;
}
public UFont getFont(FontParam fontParam, String stereotype) {
public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle) {
if (stereotype != null) {
checkStereotype(stereotype);
}
final String fontFamily = getFontFamily(fontParam, stereotype);
final int fontStyle = getFontStyle(fontParam, stereotype);
return new UFont(fontFamily, fontStyle, getFontSize(fontParam, stereotype));
final int fontStyle = getFontStyle(fontParam, stereotype, inPackageTitle);
final int fontSize = getFontSize(fontParam, stereotype);
return new UFont(fontFamily, fontStyle, fontSize);
}
public int getCircledCharacterRadius() {
@ -292,11 +327,15 @@ public class SkinParam implements ISkinParam {
final String h = capitalize(p.name());
result.add(h + "Color");
}
for (LineParam p : EnumSet.allOf(LineParam.class)) {
final String h = capitalize(p.name());
result.add(h + "Thickness");
}
return Collections.unmodifiableSet(result);
}
private static String capitalize(String name) {
return name.substring(0, 1).toUpperCase() + name.substring(1);
return StringUtils.goUpperCase(name.substring(0, 1)) + name.substring(1);
}
public int getDpi() {
@ -354,6 +393,15 @@ public class SkinParam implements ISkinParam {
return result;
}
public HorizontalAlignment getDefaultTextAlignment() {
final String value = getValue("defaulttextalignment");
final HorizontalAlignment result = HorizontalAlignment.fromString(value);
if (result == null) {
return HorizontalAlignment.CENTER;
}
return result;
}
private String getArg(String value, int i) {
if (value == null) {
return null;
@ -373,13 +421,16 @@ public class SkinParam implements ISkinParam {
}
public boolean shadowing() {
if (strictUmlStyle()) {
return false;
}
final String value = getValue("shadowing");
if ("false".equalsIgnoreCase(value)) {
return false;
}
if ("true".equalsIgnoreCase(value)) {
return true;
}
if (strictUmlStyle()) {
return false;
}
return true;
}
@ -418,7 +469,7 @@ public class SkinParam implements ISkinParam {
return true;
}
public boolean useSwimlanes() {
public boolean useSwimlanes(UmlDiagramType type) {
if (type != UmlDiagramType.ACTIVITY) {
return false;
}
@ -455,7 +506,14 @@ public class SkinParam implements ISkinParam {
return 0;
}
public UStroke getThickness(LineParam param) {
public UStroke getThickness(LineParam param, Stereotype stereotype) {
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue(param.name() + "thickness" + stereotype.getLabel(false));
if (value2 != null && value2.matches("[\\d.]+")) {
return new UStroke(Double.parseDouble(value2));
}
}
final String value = getValue(param.name() + "thickness");
if (value != null && value.matches("[\\d.]+")) {
return new UStroke(Double.parseDouble(value));
@ -508,4 +566,80 @@ public class SkinParam implements ISkinParam {
return "true".equals(getValue("sameclasswidth"));
}
public final Rankdir getRankdir() {
return rankdir;
}
public final void setRankdir(Rankdir rankdir) {
this.rankdir = rankdir;
}
public boolean useOctagonForActivity(Stereotype stereotype) {
String value = getValue("activityshape");
if (stereotype != null) {
checkStereotype(stereotype);
final String value2 = getValue("activityshape" + stereotype.getLabel(false));
if (value2 != null) {
value = value2;
}
}
if ("roundedbox".equalsIgnoreCase(value)) {
return false;
}
if ("octagon".equalsIgnoreCase(value)) {
return true;
}
return false;
}
private final IHtmlColorSet htmlColorSet = new HtmlColorSetSimple();
public IHtmlColorSet getIHtmlColorSet() {
return htmlColorSet;
}
public boolean useUnderlineForHyperlink() {
final String value = getValue("hyperlinkunderline");
if ("false".equalsIgnoreCase(value)) {
return false;
}
return true;
}
public double getPadding() {
final String value = getValue("padding");
if (value != null && value.matches("\\d+(\\.\\d+)?")) {
return Double.parseDouble(value);
}
return 0;
}
public int groupInheritance() {
final String value = getValue("groupinheritance");
int result = Integer.MAX_VALUE;
if (value != null && value.matches("\\d+")) {
result = Integer.parseInt(value);
}
if (result <= 1) {
result = Integer.MAX_VALUE;
}
return result;
}
public boolean useGuillemet() {
final String value = getValue("guillemet");
if ("false".equalsIgnoreCase(value)) {
return false;
}
return true;
}
public boolean handwritten() {
final String value = getValue("handwritten");
if ("true".equalsIgnoreCase(value)) {
return true;
}
return false;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -33,6 +33,7 @@
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class SkinParamBackcolored extends SkinParamDelegator {
@ -68,12 +69,16 @@ public class SkinParamBackcolored extends SkinParamDelegator {
return super.getBackgroundColor();
}
public HtmlColor getHtmlColor(ColorParam param, String stereotype, boolean clickable) {
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
if (param.isBackground() && backColorElement != null) {
return backColorElement;
}
if (forceClickage) {
clickable = true;
final HtmlColor c1 = super.getHtmlColor(param, stereotype, true);
if (c1 != null) {
return c1;
}
// clickable = true;
}
return super.getHtmlColor(param, stereotype, clickable);
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -33,6 +33,7 @@
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class SkinParamBackcoloredReference extends SkinParamDelegator {
@ -47,7 +48,7 @@ public class SkinParamBackcoloredReference extends SkinParamDelegator {
this.sequenceReferenceHeaderBackground = sequenceReferenceHeaderBackground;
}
public HtmlColor getHtmlColor(ColorParam param, String stereotype, boolean clickable) {
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
if (param == ColorParam.sequenceReferenceHeaderBackground && sequenceReferenceHeaderBackground != null) {
return sequenceReferenceHeaderBackground;
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -33,10 +33,13 @@
*/
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.IHtmlColorSet;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
@ -52,6 +55,10 @@ public class SkinParamDelegator implements ISkinParam {
this.skinParam = skinParam;
}
public HtmlColor getHyperlinkColor() {
return skinParam.getHyperlinkColor();
}
public HtmlColor getBackgroundColor() {
return skinParam.getBackgroundColor();
}
@ -60,15 +67,15 @@ public class SkinParamDelegator implements ISkinParam {
return skinParam.getCircledCharacterRadius();
}
public UFont getFont(FontParam fontParam, String stereotype) {
return skinParam.getFont(fontParam, stereotype);
public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle) {
return skinParam.getFont(fontParam, stereotype, false);
}
public HtmlColor getFontHtmlColor(FontParam param, String stereotype) {
public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype) {
return skinParam.getFontHtmlColor(param, stereotype);
}
public HtmlColor getHtmlColor(ColorParam param, String stereotype, boolean clickable) {
public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
return skinParam.getHtmlColor(param, stereotype, clickable);
}
@ -120,8 +127,8 @@ public class SkinParamDelegator implements ISkinParam {
return skinParam.stereotypePositionTop();
}
public boolean useSwimlanes() {
return skinParam.useSwimlanes();
public boolean useSwimlanes(UmlDiagramType type) {
return skinParam.useSwimlanes(type);
}
public double getNodesep() {
@ -136,8 +143,8 @@ public class SkinParamDelegator implements ISkinParam {
return skinParam.getRoundCorner();
}
public UStroke getThickness(LineParam param) {
return skinParam.getThickness(param);
public UStroke getThickness(LineParam param, Stereotype stereotype) {
return skinParam.getThickness(param, stereotype);
}
public double maxMessageSize() {
@ -164,4 +171,41 @@ public class SkinParamDelegator implements ISkinParam {
return skinParam.sameClassWidth();
}
public Rankdir getRankdir() {
return skinParam.getRankdir();
}
public boolean useOctagonForActivity(Stereotype stereotype) {
return skinParam.useOctagonForActivity(stereotype);
}
public IHtmlColorSet getIHtmlColorSet() {
return skinParam.getIHtmlColorSet();
}
public boolean useUnderlineForHyperlink() {
return skinParam.useUnderlineForHyperlink();
}
public HorizontalAlignment getDefaultTextAlignment() {
return skinParam.getDefaultTextAlignment();
}
public double getPadding() {
return skinParam.getPadding();
}
public int groupInheritance() {
return skinParam.groupInheritance();
}
public boolean useGuillemet() {
return skinParam.useGuillemet();
}
public boolean handwritten() {
return skinParam.handwritten();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -39,22 +39,19 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UFont;
public class SkinParamUtils {
private static final Rose rose = new Rose();
public static UFont getFont(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
final String s = stereo == null ? null : stereo.getLabel();
return skinParam.getFont(fontParam, s);
return skinParam.getFont(fontParam, stereo, false);
}
public static HtmlColor getFontColor(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
final String s = stereo == null ? null : stereo.getLabel();
return skinParam.getFontHtmlColor(fontParam, s);
return skinParam.getFontHtmlColor(fontParam, stereo);
}
public static HtmlColor getColor(ISkinParam skinParam, ColorParam colorParam, Stereotype stereo) {
final String s = stereo == null ? null : stereo.getLabel();
return rose.getHtmlColor(skinParam, colorParam, s);
return rose.getHtmlColor(skinParam, colorParam, stereo);
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -101,7 +101,7 @@ public class SourceFileReader implements ISourceFileReader {
.getParentFile());
}
public boolean hasError() throws IOException, InterruptedException {
public boolean hasError() {
for (final BlockUml b : builder.getBlockUmls()) {
if (b.getDiagram() instanceof PSystemError) {
return true;
@ -142,7 +142,7 @@ public class SourceFileReader implements ISourceFileReader {
ps.close();
}
}
final GeneratedImage generatedImage = new GeneratedImage(f, desc, system);
final GeneratedImage generatedImage = new GeneratedImage(f, desc, blockUml);
result.add(generatedImage);
}
@ -153,7 +153,7 @@ public class SourceFileReader implements ISourceFileReader {
return Collections.unmodifiableList(result);
}
public List<String> getEncodedUrl() throws IOException, InterruptedException {
public List<String> getEncodedUrl() throws IOException {
final List<String> result = new ArrayList<String>();
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
for (BlockUml blockUml : builder.getBlockUmls()) {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -58,8 +58,8 @@ public class SourceFileReader2 implements ISourceFileReader {
private final BlockUmlBuilder builder;
private FileFormatOption fileFormatOption;
public SourceFileReader2(Defines defines, final File file, File outputFile, List<String> config,
String charset, FileFormatOption fileFormatOption) throws IOException {
public SourceFileReader2(Defines defines, final File file, File outputFile, List<String> config, String charset,
FileFormatOption fileFormatOption) throws IOException {
this.file = file;
this.fileFormatOption = fileFormatOption;
this.outputFile = outputFile;
@ -68,10 +68,11 @@ public class SourceFileReader2 implements ISourceFileReader {
}
FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile().getParentFile());
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
.getParentFile());
}
public boolean hasError() throws IOException, InterruptedException {
public boolean hasError() {
for (final BlockUml b : builder.getBlockUmls()) {
if (b.getDiagram() instanceof PSystemError) {
return true;
@ -80,7 +81,7 @@ public class SourceFileReader2 implements ISourceFileReader {
return false;
}
public List<GeneratedImage> getGeneratedImages() throws IOException, InterruptedException {
public List<GeneratedImage> getGeneratedImages() throws IOException {
Log.info("Reading file: " + file);
final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
@ -93,7 +94,7 @@ public class SourceFileReader2 implements ISourceFileReader {
for (File f : PSystemUtils.exportDiagrams(system, suggested, fileFormatOption)) {
final String desc = "[" + file.getName() + "] " + system.getDescription();
final GeneratedImage generatedImage = new GeneratedImage(f, desc, system);
final GeneratedImage generatedImage = new GeneratedImage(f, desc, blockUml);
result.add(generatedImage);
}
@ -104,7 +105,7 @@ public class SourceFileReader2 implements ISourceFileReader {
return Collections.unmodifiableList(result);
}
public List<String> getEncodedUrl() throws IOException, InterruptedException {
public List<String> getEncodedUrl() throws IOException {
final List<String> result = new ArrayList<String>();
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
for (BlockUml blockUml : builder.getBlockUmls()) {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -49,6 +49,8 @@ import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class SourceStringReader {
@ -67,16 +69,19 @@ public class SourceStringReader {
}
public SourceStringReader(Defines defines, String source, String charset, List<String> config) {
try {
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
null);
this.blocks = builder.getBlockUmls();
} catch (IOException e) {
Log.error("error " + e);
throw new IllegalStateException(e);
// WARNING GLOBAL LOCK HERE
synchronized (SourceStringReader.class) {
try {
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
null);
this.blocks = builder.getBlockUmls();
} catch (IOException e) {
Log.error("error " + e);
throw new IllegalStateException(e);
}
}
}
public String generateImage(OutputStream os) throws IOException {
return generateImage(os, 0);
}
@ -98,15 +103,14 @@ public class SourceStringReader {
public String generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) throws IOException {
if (blocks.size() == 0) {
final GraphicStrings error = new GraphicStrings(Arrays.asList("No @startuml found"));
error.writeImage(os, fileFormatOption, null);
noStartumlFound(os, fileFormatOption);
return null;
}
for (BlockUml b : blocks) {
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
if (numImage < nbInSystem) {
//final CMapData cmap = new CMapData();
// final CMapData cmap = new CMapData();
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
if (imageData.containsCMapData()) {
return system.getDescription().getDescription() + "\n" + imageData.getCMapData("plantuml");
@ -120,6 +124,14 @@ public class SourceStringReader {
}
private void noStartumlFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
final GraphicStrings error = GraphicStrings.createDefault(Arrays.asList("No @startuml found"),
fileFormatOption.isUseRedForError());
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null,
null, 0, 0, null, false);
imageBuilder.addUDrawable(error);
imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
}
public DiagramDescription generateDiagramDescription(OutputStream os) throws IOException {
return generateDiagramDescription(os, 0);
@ -132,7 +144,8 @@ public class SourceStringReader {
return result;
}
public DiagramDescription generateDiagramDescription(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
public DiagramDescription generateDiagramDescription(OutputStream os, FileFormatOption fileFormatOption)
throws IOException {
return generateDiagramDescription(os, 0, fileFormatOption);
}
@ -140,11 +153,10 @@ public class SourceStringReader {
return generateDiagramDescription(os, numImage, new FileFormatOption(FileFormat.PNG));
}
public DiagramDescription generateDiagramDescription(OutputStream os, int numImage, FileFormatOption fileFormatOption)
throws IOException {
public DiagramDescription generateDiagramDescription(OutputStream os, int numImage,
FileFormatOption fileFormatOption) throws IOException {
if (blocks.size() == 0) {
final GraphicStrings error = new GraphicStrings(Arrays.asList("No @startuml found"));
error.writeImage(os, fileFormatOption, null);
noStartumlFound(os, fileFormatOption);
return null;
}
for (BlockUml b : blocks) {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -39,4 +39,6 @@ public interface SpriteContainer {
public Sprite getSprite(String name);
public boolean useGuillemet();
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -35,10 +35,22 @@ package net.sourceforge.plantuml;
import net.sourceforge.plantuml.ugraphic.Sprite;
public class SpriteContainerEmpty implements SpriteContainer {
public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple {
public Sprite getSprite(String name) {
return null;
}
public String getValue(String key) {
return null;
}
public double getPadding() {
return 0;
}
public boolean useGuillemet() {
return false;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11949 $
* Revision $Revision: 13958 $
*
*/
package net.sourceforge.plantuml;
@ -41,9 +41,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -52,6 +54,7 @@ import net.sourceforge.plantuml.preproc.ReadLineReader;
import net.sourceforge.plantuml.preproc.UncommentReadLine;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
// Do not move
public class StringUtils {
public static String getPlateformDependentAbsolutePath(File file) {
@ -59,7 +62,7 @@ public class StringUtils {
}
public static List<String> getWithNewlines2(Code s) {
return getWithNewlines2(s.getCode());
return getWithNewlines2(s.getFullName());
}
public static List<String> getWithNewlines2(String s) {
@ -176,6 +179,22 @@ public class StringUtils {
public static String capitalize(String s) {
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
}
public static String goUpperCase(String s) {
return s.toUpperCase(Locale.ENGLISH);
}
public static char goUpperCase(char c) {
return goUpperCase("" + c).charAt(0);
}
public static String goLowerCase(String s) {
return s.toLowerCase(Locale.ENGLISH);
}
public static char goLowerCase(char c) {
return goLowerCase("" + c).charAt(0);
}
public static String manageArrowForCuca(String s) {
final Direction dir = getArrowDirection(s);
@ -255,22 +274,31 @@ public class StringUtils {
// return Code.of(eventuallyRemoveStartingAndEndingDoubleQuote(s.getCode()));
// }
public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s) {
if (s.startsWith("\"") && s.endsWith("\"")) {
public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s, String format) {
if (format.contains("\"") && s.length() > 1 && isDoubleQuote(s.charAt(0))
&& isDoubleQuote(s.charAt(s.length() - 1))) {
return s.substring(1, s.length() - 1);
}
if (s.startsWith("(") && s.endsWith(")")) {
if (format.contains("(") && s.startsWith("(") && s.endsWith(")")) {
return s.substring(1, s.length() - 1);
}
if (s.startsWith("[") && s.endsWith("]")) {
if (format.contains("[") && s.startsWith("[") && s.endsWith("]")) {
return s.substring(1, s.length() - 1);
}
if (s.startsWith(":") && s.endsWith(":")) {
if (format.contains(":") && s.startsWith(":") && s.endsWith(":")) {
return s.substring(1, s.length() - 1);
}
return s;
}
public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s) {
return eventuallyRemoveStartingAndEndingDoubleQuote(s, "\"([:");
}
private static boolean isDoubleQuote(char c) {
return c == '\"' || c == '\u201c' || c == '\u201d' || c == '\u00ab' || c == '\u00bb';
}
public static boolean isCJK(char c) {
final Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
Log.println("block=" + block);
@ -412,11 +440,11 @@ public class StringUtils {
public static List<String> splitComma(String s) {
s = s.trim();
if (s.matches("([\\p{L}0-9_.]+|\"[^\"]+\")(\\s*,\\s*([\\p{L}0-9_.]+|\"[^\"]+\"))*") == false) {
throw new IllegalArgumentException();
}
// if (s.matches("([\\p{L}0-9_.]+|[%g][^%g]+[%g])(\\s*,\\s*([\\p{L}0-9_.]+|[%g][^%g]+[%g]))*") == false) {
// throw new IllegalArgumentException();
// }
final List<String> result = new ArrayList<String>();
final Pattern p = Pattern.compile("([\\p{L}0-9_.]+|\"[^\"]+\")");
final Pattern p = MyPattern.cmpile("([\\p{L}0-9_.]+|[%g][^%g]+[%g])");
final Matcher m = p.matcher(s);
while (m.find()) {
result.add(eventuallyRemoveStartingAndEndingDoubleQuote(m.group(0)));
@ -426,7 +454,7 @@ public class StringUtils {
public static String getAsHtml(Color color) {
if (color == null) {
throw new IllegalArgumentException();
return null;
}
return getAsHtml(color.getRGB());
}
@ -452,52 +480,6 @@ public class StringUtils {
return uid1 + String.format("%04d", uid2);
}
public static Display manageEmbededDiagrams(final Display strings) {
Display result = new Display();
final Iterator<CharSequence> it = strings.iterator();
while (it.hasNext()) {
CharSequence s = it.next();
if (s.equals("{{")) {
Display other = new Display();
other = other.add("@startuml");
while (it.hasNext()) {
final CharSequence s2 = it.next();
if (s2.equals("}}")) {
break;
}
other = other.add(s2);
}
other = other.add("@enduml");
s = new EmbededDiagram(other);
}
result = result.add(s);
}
return result;
}
public static List<CharSequence> manageEmbededDiagrams2(final List<String> strings) {
final List<CharSequence> result = new ArrayList<CharSequence>();
final Iterator<String> it = strings.iterator();
while (it.hasNext()) {
CharSequence s = it.next();
if (s.equals("{{")) {
final List<String> other = new ArrayList<String>();
other.add("@startuml");
while (it.hasNext()) {
final String s2 = it.next();
if (s2.equals("}}")) {
break;
}
other.add(s2);
}
other.add("@enduml");
s = new EmbededDiagram(new Display(other));
}
result.add(s);
}
return result;
}
public static boolean isMethod(String s) {
return s.contains("(") || s.contains(")");
}
@ -508,4 +490,9 @@ public class StringUtils {
return Collections.unmodifiableList(result);
}
public static boolean endsWithBackslash(final String s) {
return s.endsWith("\\") && s.endsWith("\\\\") == false;
}
// http://docs.oracle.com/javase/tutorial/i18n/format/dateFormat.html
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 11873 $
* Revision $Revision: 15848 $
*
*/
package net.sourceforge.plantuml;
@ -50,24 +50,38 @@ import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.script.ScriptException;
import net.sourceforge.plantuml.anim.Animation;
import net.sourceforge.plantuml.anim.AnimationDecoder;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.fun.IconLoader;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.QuoteUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
import net.sourceforge.plantuml.pdf.PdfConverter;
import net.sourceforge.plantuml.svek.EmptySvgException;
import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.Sprite;
import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.version.Version;
public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
@ -82,13 +96,15 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
private Display footer;
private Display legend = null;
private HorizontalAlignment legendAlignment = HorizontalAlignment.CENTER;
private VerticalAlignment legendVerticalAlignment = VerticalAlignment.BOTTOM;
private HorizontalAlignment headerAlignment = HorizontalAlignment.RIGHT;
private HorizontalAlignment footerAlignment = HorizontalAlignment.CENTER;
private final Pragma pragma = new Pragma();
private Scale scale;
private Animation animation;
private final SkinParam skinParam = new SkinParam(getUmlDiagramType());
private final SkinParam skinParam = new SkinParam();
final public void setTitle(Display strings) {
this.title = strings;
@ -119,7 +135,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
}
public void setParam(String key, String value) {
skinParam.setParam(key.toLowerCase(), value);
skinParam.setParam(StringUtils.goLowerCase(key), value);
}
public final Display getHeader() {
@ -168,6 +184,20 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
return scale;
}
final public void setAnimation(List<String> animationData) {
try {
final AnimationDecoder animationDecoder = new AnimationDecoder(animationData);
this.animation = Animation.create(animationDecoder.decode());
} catch (ScriptException e) {
e.printStackTrace();
}
}
final public Animation getAnimation() {
return animation;
}
public final double getDpiFactor(FileFormatOption fileFormatOption) {
if (getSkinParam().getDpi() == 96) {
return 1.0;
@ -190,36 +220,12 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
final public ImageData exportDiagram(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
List<BufferedImage> flashcodes = null;
try {
if ("split".equalsIgnoreCase(getSkinParam().getValue("flashcode"))
&& fileFormatOption.getFileFormat() == FileFormat.PNG) {
final String s = getSource().getPlainString();
flashcodes = getFlashCodeUtils().exportSplitCompress(s);
} else if ("compress".equalsIgnoreCase(getSkinParam().getValue("flashcode"))
&& fileFormatOption.getFileFormat() == FileFormat.PNG) {
final String s = getSource().getPlainString();
flashcodes = getFlashCodeUtils().exportFlashcodeCompress(s);
} else if (getSkinParam().getValue("flashcode") != null
&& fileFormatOption.getFileFormat() == FileFormat.PNG) {
final String s = getSource().getPlainString();
flashcodes = getFlashCodeUtils().exportFlashcodeSimple(s);
}
} catch (IOException e) {
Log.error("Cannot generate flashcode");
e.printStackTrace();
flashcodes = null;
}
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
return exportDiagramInternalPdf(os, index, flashcodes);
}
if (fileFormatOption.getFileFormat() == FileFormat.MJPEG) {
// exportDiagramInternalMjpeg(os);
// return;*
throw new UnsupportedOperationException();
return exportDiagramInternalPdf(os, index);
}
try {
final ImageData imageData = exportDiagramInternal(os, index, fileFormatOption, flashcodes);
final ImageData imageData = exportDiagramInternal(os, index, fileFormatOption);
this.lastInfo = new Dimension2DDouble(imageData.getWidth(), imageData.getHeight());
return imageData;
} catch (UnparsableGraphvizException e) {
@ -236,6 +242,61 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat,
String graphvizVersion, String svg) throws IOException {
final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
final List<String> strings = getFailureText(exception, graphvizVersion);
final String flash = getFlashData();
for (StackTraceElement ste : exception.getStackTrace()) {
strings.add(" " + ste.toString());
}
if (exception.getCause() != null) {
final Throwable cause = exception.getCause();
strings.add(" ");
strings.add("Caused by " + cause.toString());
for (StackTraceElement ste : cause.getStackTrace()) {
strings.add(" " + ste.toString());
}
}
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, getSkinParam().handwritten());
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage im = utils.exportFlashcode(flash);
if (im != null) {
GraphvizCrash.addDecodeHint(strings);
}
final GraphicStrings graphicStrings = new GraphicStrings(strings, font, HtmlColorUtils.BLACK,
HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON, IconLoader.getRandom(),
GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);
if (im == null) {
imageBuilder.addUDrawable(graphicStrings);
} else {
imageBuilder.addUDrawable(new UDrawable() {
public void drawU(UGraphic ug) {
graphicStrings.drawU(ug);
final double height = graphicStrings.calculateDimension(ug.getStringBounder()).getHeight();
ug = ug.apply(new UTranslate(0, height));
ug.draw(new UImage(im));
}
});
}
imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
}
private String getFlashData() {
// for (Map.Entry<Object, Object> ent : System.getProperties().entrySet()) {
// System.err.println("p1=" + ent.getKey() + " " + ent.getValue());
// }
final StringBuilder result = new StringBuilder();
final UmlSource source = getSource();
result.append(source.getPlainString());
return result.toString();
}
private List<String> getFailureText(Throwable exception, String graphvizVersion) {
final List<String> strings = new ArrayList<String>();
strings.add("An error has occured : " + exception);
final String quote = QuoteUtils.getSomeQuote();
@ -250,6 +311,8 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
strings.add("GraphViz version used : " + graphvizVersion);
}
strings.add(" ");
GraphvizCrash.addProperties(strings);
strings.add(" ");
strings.add("This may be caused by :");
strings.add(" - a bug in PlantUML");
strings.add(" - a problem in GraphViz");
@ -258,17 +321,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
strings.add("You can try to turn arround this issue by simplifing your diagram.");
strings.add(" ");
strings.add(exception.toString());
for (StackTraceElement ste : exception.getStackTrace()) {
strings.add(" " + ste.toString());
}
final GraphicStrings graphicStrings = new GraphicStrings(strings, font, HtmlColorUtils.BLACK,
HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON);
graphicStrings.writeImage(os, fileFormat, svg);
}
private FlashCodeUtils getFlashCodeUtils() {
return FlashCodeFactory.getFlashCodeUtils();
return strings;
}
private void exportDiagramInternalMjpeg(OutputStream os) throws IOException {
@ -293,8 +346,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
private Dimension2D lastInfo;
private ImageData exportDiagramInternalPdf(OutputStream os, int index, List<BufferedImage> flashcodes)
throws IOException {
private ImageData exportDiagramInternalPdf(OutputStream os, int index) throws IOException {
final File svg = FileUtils.createTempFile("pdf", ".svf");
final File pdfFile = FileUtils.createTempFile("pdf", ".pdf");
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(svg));
@ -305,8 +357,8 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
return result;
}
protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption,
List<BufferedImage> flashcodes) throws IOException;
protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException;
final protected void exportCmap(File suggestedFile, final ImageData cmapdata) throws FileNotFoundException {
final String name = changeName(suggestedFile.getAbsolutePath());
@ -365,8 +417,13 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
return legendAlignment;
}
public final void setLegend(Display legend, HorizontalAlignment horizontalAlignment) {
public final VerticalAlignment getLegendVerticalAlignment() {
return legendVerticalAlignment;
}
public final void setLegend(Display legend, HorizontalAlignment horizontalAlignment, VerticalAlignment valignment) {
this.legend = legend;
this.legendAlignment = horizontalAlignment;
this.legendVerticalAlignment = valignment;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 9786 $
* Revision $Revision: 12235 $
*
*/
package net.sourceforge.plantuml;

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -35,6 +35,8 @@ package net.sourceforge.plantuml;
import java.util.Comparator;
import net.sourceforge.plantuml.cucadiagram.dot.DotMaker2;
public class Url implements EnsureVisible {
private final String url;
@ -81,6 +83,9 @@ public class Url implements EnsureVisible {
}
public String getCoords(double scale) {
if (DotMaker2.isJunit() && visible.getCoords(1.0).contains("0,0,0,0")) {
throw new IllegalStateException();
}
return visible.getCoords(scale);
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -36,13 +36,15 @@ package net.sourceforge.plantuml;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.regex.MyPattern;
public class UrlBuilder {
public static enum ModeUrl {
STRICT, AT_START, ANYWHERE
STRICT, AT_START, ANYWHERE, AT_END
}
private static final String URL_PATTERN = "\\[\\[(\"[^\"]+\"|[^{} \\]\\[]*)(?: *\\{([^{}]+)\\})?(?: *([^\\]\\[]+))?\\]\\]";
private static final String URL_PATTERN = "\\[\\[([%g][^%g]+[%g]|[^{}%s\\]\\[]*)(?:[%s]*\\{([^{}]+)\\})?(?:[%s]*([^\\]\\[]+))?\\]\\]";
private final String topurl;
private ModeUrl mode;
@ -55,11 +57,13 @@ public class UrlBuilder {
public Url getUrl(String s) {
final Pattern p;
if (mode == ModeUrl.STRICT) {
p = Pattern.compile("(?i)^" + URL_PATTERN + "$");
p = MyPattern.cmpile("(?i)^" + URL_PATTERN + "$");
} else if (mode == ModeUrl.AT_START) {
p = Pattern.compile("(?i)^" + URL_PATTERN + ".*");
p = MyPattern.cmpile("(?i)^" + URL_PATTERN + ".*");
} else if (mode == ModeUrl.AT_END) {
p = MyPattern.cmpile("(?i).*" + URL_PATTERN + "$");
} else if (mode == ModeUrl.ANYWHERE) {
p = Pattern.compile("(?i).*" + URL_PATTERN + ".*");
p = MyPattern.cmpile("(?i).*" + URL_PATTERN + ".*");
} else {
throw new IllegalStateException();
}
@ -82,7 +86,7 @@ public class UrlBuilder {
}
public static String purgeUrl(final String label) {
final Pattern p = Pattern.compile("(?: )*" + URL_PATTERN + "(?: )*");
final Pattern p = MyPattern.cmpile("[%s]*" + URL_PATTERN + "[%s]*");
final Matcher m = p.matcher(label);
if (m.find() == false) {
throw new IllegalStateException();

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -41,6 +41,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.PSystemBasicFactory;
import net.sourceforge.plantuml.command.regex.MyPattern;
import com.ctreber.acearth.plugins.markers.Marker;
@ -60,7 +61,7 @@ public class PSystemXearthFactory extends PSystemBasicFactory<PSystemXearth> {
}
private void extractDimension(String startLine) {
final Pattern p = Pattern.compile("\\((\\d+),(\\d+)\\)");
final Pattern p = MyPattern.cmpile("\\((\\d+),(\\d+)\\)");
final Matcher m = p.matcher(startLine);
final boolean ok = m.find();
if (ok) {
@ -82,7 +83,7 @@ public class PSystemXearthFactory extends PSystemBasicFactory<PSystemXearth> {
if (line.startsWith("#") || line.startsWith("'")) {
return system;
}
final Pattern p = Pattern.compile("(\\w+)\\s*=\\s*(.*)");
final Pattern p = MyPattern.cmpile("(\\w+)[%s]*=[%s]*(.*)");
final Matcher m = p.matcher(line);
if (m.find()) {
config.put(m.group(1), m.group(2));

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 12053 $
* Revision $Revision: 14721 $
*
*/
package net.sourceforge.plantuml.activitydiagram;
@ -38,7 +38,6 @@ import java.util.List;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.UniqueSequence;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.cucadiagram.Code;
@ -48,6 +47,8 @@ import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.utils.UniqueSequence;
public class ActivityDiagram extends CucaDiagram {
@ -55,8 +56,8 @@ public class ActivityDiagram extends CucaDiagram {
private IEntity lastEntityBrancheConsulted;
private ConditionalContext currentContext;
public ILeaf getOrCreateLeaf(Code code, LeafType type) {
return getOrCreateLeafDefault(code, type);
public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
return getOrCreateLeafDefault(code, type, symbol);
}
private String getAutoBranch() {
@ -66,13 +67,13 @@ public class ActivityDiagram extends CucaDiagram {
public IEntity getOrCreate(Code code, Display display, LeafType type) {
final IEntity result;
if (leafExist(code)) {
result = getOrCreateLeafDefault(code, type);
result = getOrCreateLeafDefault(code, type, null);
if (result.getEntityType() != type) {
// throw new IllegalArgumentException("Already known: " + code + " " + result.getType() + " " + type);
return null;
}
} else {
result = createLeaf(code, display, type);
result = createLeaf(code, display, type, null);
}
updateLasts(result);
return result;
@ -80,7 +81,7 @@ public class ActivityDiagram extends CucaDiagram {
public void startIf(Code optionalCode) {
final IEntity br = createLeaf(optionalCode == null ? Code.of(getAutoBranch()) : optionalCode,
Display.asList(""), LeafType.BRANCH);
Display.create(""), LeafType.BRANCH, null);
currentContext = new ConditionalContext(currentContext, br, Direction.DOWN);
}
@ -92,8 +93,9 @@ public class ActivityDiagram extends CucaDiagram {
return (ILeaf) getOrCreate(Code.of("start"), Display.getWithNewlines("start"), LeafType.CIRCLE_START);
}
public ILeaf getEnd() {
return (ILeaf) getOrCreate(Code.of("end"), Display.getWithNewlines("end"), LeafType.CIRCLE_END);
public ILeaf getEnd(String suppId) {
final Code code = suppId == null ? Code.of("end") : Code.of("end$" + suppId);
return (ILeaf) getOrCreate(code, Display.getWithNewlines("end"), LeafType.CIRCLE_END);
}
private void updateLasts(final IEntity result) {
@ -107,14 +109,14 @@ public class ActivityDiagram extends CucaDiagram {
}
@Override
public ILeaf createLeaf(Code code, Display display, LeafType type) {
final ILeaf result = super.createLeaf(code, display, type);
public ILeaf createLeaf(Code code, Display display, LeafType type, USymbol symbol) {
final ILeaf result = super.createLeaf(code, display, type, symbol);
updateLasts(result);
return result;
}
public IEntity createNote(Code code, Display display) {
return super.createLeaf(code, display, LeafType.NOTE);
return super.createLeaf(code, display, LeafType.NOTE, null);
}
final protected List<String> getDotStrings() {
@ -123,7 +125,7 @@ public class ActivityDiagram extends CucaDiagram {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(" + getLeafs().size() + " activities)", getClass());
return new DiagramDescriptionImpl("(" + getLeafssize() + " activities)", getClass());
}
public IEntity getLastEntityConsulted() {
@ -151,7 +153,7 @@ public class ActivityDiagram extends CucaDiagram {
public IEntity createInnerActivity() {
// Log.println("createInnerActivity A");
final Code code = Code.of("##" + UniqueSequence.getValue());
final IEntity g = getOrCreateGroup(code, Display.getWithNewlines(code), null, GroupType.INNER_ACTIVITY,
final IEntity g = getOrCreateGroup(code, Display.getWithNewlines(code), GroupType.INNER_ACTIVITY,
getCurrentGroup());
// g.setRankdir(Rankdir.LEFT_TO_RIGHT);
lastEntityConsulted = null;
@ -172,8 +174,7 @@ public class ActivityDiagram extends CucaDiagram {
if (getCurrentGroup().getGroupType() != GroupType.INNER_ACTIVITY) {
throw new IllegalStateException("type=" + getCurrentGroup().getGroupType());
}
getOrCreateGroup(code, Display.getWithNewlines("code"), null, GroupType.CONCURRENT_ACTIVITY,
getCurrentGroup());
getOrCreateGroup(code, Display.getWithNewlines("code"), GroupType.CONCURRENT_ACTIVITY, getCurrentGroup());
lastEntityConsulted = null;
lastEntityBrancheConsulted = null;
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -40,10 +40,11 @@ import net.sourceforge.plantuml.activitydiagram.command.CommandElse;
import net.sourceforge.plantuml.activitydiagram.command.CommandEndPartition;
import net.sourceforge.plantuml.activitydiagram.command.CommandEndif;
import net.sourceforge.plantuml.activitydiagram.command.CommandIf;
import net.sourceforge.plantuml.activitydiagram.command.CommandLinkActivity2;
import net.sourceforge.plantuml.activitydiagram.command.CommandLinkActivity;
import net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2;
import net.sourceforge.plantuml.activitydiagram.command.CommandPartition;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandFootboxIgnored;
import net.sourceforge.plantuml.command.CommandRankDir;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
import net.sourceforge.plantuml.command.note.FactoryNoteActivityCommand;
@ -59,6 +60,7 @@ public class ActivityDiagramFactory extends UmlDiagramFactory {
@Override
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
cmds.add(new CommandFootboxIgnored());
addCommonCommands(cmds);
cmds.add(new CommandRankDir());
@ -78,7 +80,7 @@ public class ActivityDiagramFactory extends UmlDiagramFactory {
cmds.add(new CommandElse());
cmds.add(new CommandEndif());
cmds.add(new CommandLinkActivity2());
cmds.add(new CommandLinkActivity());
// addCommand(new CommandInnerConcurrent(system));
return cmds;

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 10778 $
* Revision $Revision: 12235 $
*
*/
package net.sourceforge.plantuml.activitydiagram.command;
@ -43,7 +43,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
public class CommandEndPartition extends SingleLineCommand<ActivityDiagram> {
public CommandEndPartition() {
super("(?i)^(end ?partition|\\})$");
super("(?i)^(end[%s]?partition|\\})$");
}
@Override

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -42,7 +42,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand;
public class CommandEndif extends SingleLineCommand<ActivityDiagram> {
public CommandEndif() {
super("(?i)^end ?if$");
super("(?i)^end[%s]?if$");
}
@Override

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -62,16 +62,16 @@ public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
new RegexOr("FIRST", //
new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
new RegexLeaf("BAR", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), //
new RegexLeaf("QUOTED", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("\\s*"), //
new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexOr(//
new RegexLeaf("IF1", "if\\s*\"([^\"]*)\"\\s*(?:as\\s+([\\p{L}0-9_.]+)\\s+)?"), //
new RegexLeaf("IF2", "if\\s+(.+?)\\s*")), //
new RegexLeaf("IF1", "if[%s]*[%g]([^%g]*)[%g][%s]*(?:as[%s]+([\\p{L}0-9_.]+)[%s]+)?"), //
new RegexLeaf("IF2", "if[%s]+(.+?)[%s]*")), //
new RegexLeaf("(?:then)?$"));
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -34,11 +34,11 @@
package net.sourceforge.plantuml.activitydiagram.command;
import net.sourceforge.plantuml.Direction;
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.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
@ -57,6 +57,7 @@ import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.StringUtils;
public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
@ -64,91 +65,106 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
super(getRegexConcat());
}
static RegexConcat getRegexConcat() {
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexOptional(//
new RegexOr("FIRST", //
new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
new RegexLeaf("BAR", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), //
new RegexLeaf("QUOTED", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("\\s*"), //
new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("BACKCOLOR", "(#\\w+[-\\\\|/]?\\w+)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BACKCOLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("ARROW", "([-=.]+(?:\\*|left|right|up|down|le?|ri?|up?|do?)?[-=.]*\\>)"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
new RegexLeaf("ARROW_STYLE1",
"(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
new RegexLeaf("ARROW_STYLE2",
"(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexOr("FIRST2", //
new RegexLeaf("STAR2", "(\\(\\*(top)?\\))"), //
new RegexLeaf("STAR2", "(\\(\\*(top|\\d+)?\\))"), //
new RegexLeaf("OPENBRACKET2", "(\\{)"), //
new RegexLeaf("CODE2", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
new RegexLeaf("BAR2", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), //
new RegexLeaf("QUOTED2", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9][\\p{L}0-9_.]*))?"), //
new RegexLeaf("BAR2", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED2", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?"), //
new RegexLeaf("QUOTED_INVISIBLE2", "(\\w.*?)")), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("PARTITION2", "(?:in\\s+(\"[^\"]+\"|\\S+))?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("BACKCOLOR2", "(#\\w+[-\\\\|/]?\\w+)?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("PARTITION2", "(?:in[%s]+([%g][^%g]+[%g]|\\S+))?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BACKCOLOR2", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, RegexResult arg2) {
final IEntity entity1 = getEntity(diagram, arg2, true);
protected CommandExecutionResult executeArg(ActivityDiagram diagram, RegexResult arg) {
final IEntity entity1 = getEntity(diagram, arg, true);
if (entity1 == null) {
return CommandExecutionResult.error("No such activity");
}
if (arg2.get("STEREOTYPE", 0) != null) {
entity1.setStereotype(new Stereotype(arg2.get("STEREOTYPE", 0)));
if (arg.get("STEREOTYPE", 0) != null) {
entity1.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0)));
}
if (arg2.get("BACKCOLOR", 0) != null) {
entity1.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(arg2.get("BACKCOLOR", 0)));
if (arg.get("BACKCOLOR", 0) != null) {
entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("BACKCOLOR", 0)));
}
final IEntity entity2 = getEntity(diagram, arg2, false);
final IEntity entity2 = getEntity(diagram, arg, false);
if (entity2 == null) {
return CommandExecutionResult.error("No such activity");
}
if (arg2.get("BACKCOLOR2", 0) != null) {
entity2.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(arg2.get("BACKCOLOR2", 0)));
if (arg.get("BACKCOLOR2", 0) != null) {
entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("BACKCOLOR2", 0)));
}
if (arg2.get("STEREOTYPE2", 0) != null) {
entity2.setStereotype(new Stereotype(arg2.get("STEREOTYPE2", 0)));
if (arg.get("STEREOTYPE2", 0) != null) {
entity2.setStereotype(new Stereotype(arg.get("STEREOTYPE2", 0)));
}
final Display linkLabel = Display.getWithNewlines(arg2.get("BRACKET", 0));
final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0));
final String arrow = StringUtils.manageArrowForCuca(arg2.get("ARROW", 0));
final String arrowBody1 = CommandLinkClass.notNull(arg.get("ARROW_BODY1", 0));
final String arrowBody2 = CommandLinkClass.notNull(arg.get("ARROW_BODY2", 0));
final String arrowDirection = CommandLinkClass.notNull(arg.get("ARROW_DIRECTION", 0));
final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
int lenght = arrow.length() - 1;
if (arg2.get("ARROW", 0).contains("*")) {
if (arrowDirection.contains("*")) {
lenght = 2;
}
LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
if (arg2.get("ARROW", 0).contains(".")) {
if ((arrowBody1 + arrowBody2).contains(".")) {
type = type.getDotted();
}
Link link = new Link(entity1, entity2, type, linkLabel, lenght);
if (arg2.get("ARROW", 0).contains("*")) {
if (arrowDirection.contains("*")) {
link.setConstraint(false);
}
final Direction direction = StringUtils.getArrowDirection(arg2.get("ARROW", 0));
final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
if (direction == Direction.LEFT || direction == Direction.UP) {
link = link.getInv();
}
if (arg2.get("URL", 0) != null) {
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url urlLink = urlBuilder.getUrl(arg2.get("URL", 0));
final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
link.setUrl(urlLink);
}
CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
diagram.addLink(link);
return CommandExecutionResult.ok();
@ -163,13 +179,14 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
return system.createInnerActivity();
}
if (arg.get("STAR" + suf, 0) != null) {
final String suppId = arg.get("STAR" + suf, 1);
if (start) {
if (arg.get("STAR" + suf, 1) != null) {
if (suppId != null) {
system.getStart().setTop(true);
}
return system.getStart();
}
return system.getEnd();
return system.getEnd(suppId);
}
String partition = arg.get("PARTITION" + suf, 0);
if (partition != null) {
@ -178,11 +195,11 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final Code code = Code.of(arg.get("CODE" + suf, 0));
if (code != null) {
if (partition != null) {
system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), null,
GroupType.PACKAGE, system.getRootGroup());
system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
system.getRootGroup());
}
final IEntity result = system.getOrCreate(code, Display.getWithNewlines(code),
getTypeIfExisting(system, code));
CommandLinkActivity.getTypeIfExisting(system, code));
if (partition != null) {
system.endGroup();
}
@ -196,11 +213,11 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
if (quoted.get(0) != null) {
final Code quotedCode = Code.of(quoted.get(1) == null ? quoted.get(0) : quoted.get(1));
if (partition != null) {
system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), null,
GroupType.PACKAGE, system.getRootGroup());
system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
system.getRootGroup());
}
final IEntity result = system.getOrCreate(quotedCode, Display.getWithNewlines(quoted.get(0)),
getTypeIfExisting(system, quotedCode));
CommandLinkActivity.getTypeIfExisting(system, quotedCode));
if (partition != null) {
system.endGroup();
}
@ -209,8 +226,8 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
final Code quotedInvisible = Code.of(arg.get("QUOTED_INVISIBLE" + suf, 0));
if (quotedInvisible != null) {
if (partition != null) {
system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), null,
GroupType.PACKAGE, system.getRootGroup());
system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
system.getRootGroup());
}
final IEntity result = system.getOrCreate(quotedInvisible, Display.getWithNewlines(quotedInvisible),
LeafType.ACTIVITY);
@ -229,7 +246,7 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
static LeafType getTypeIfExisting(ActivityDiagram system, Code code) {
if (system.leafExist(code)) {
final IEntity ent = system.getLeafs().get(code);
final IEntity ent = system.getLeafsget(code);
if (ent.getEntityType() == LeafType.BRANCH) {
return LeafType.BRANCH;
}
@ -237,17 +254,4 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
return LeafType.ACTIVITY;
}
static LeafType getTypeFromString(String type, final LeafType circle) {
if (type == null) {
return LeafType.ACTIVITY;
}
if (type.equals("*")) {
return circle;
}
if (type.startsWith("=")) {
return LeafType.SYNCHRO_BAR;
}
throw new IllegalArgumentException();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -34,10 +34,8 @@
package net.sourceforge.plantuml.activitydiagram.command;
import java.util.List;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -45,6 +43,7 @@ import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines2;
import net.sourceforge.plantuml.command.MultilinesStrategy;
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.RegexOptional;
@ -59,7 +58,7 @@ 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.HtmlColorUtils;
import net.sourceforge.plantuml.StringUtils;
public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram> {
@ -69,7 +68,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
@Override
public String getPatternEnd() {
return "(?i)^\\s*([^\"]*)\"(?:\\s+as\\s+([\\p{L}0-9][\\p{L}0-9_.]*))?\\s*(\\<\\<.*\\>\\>)?\\s*(?:in\\s+(\"[^\"]+\"|\\S+))?\\s*(#\\w+)?$";
return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$";
}
static RegexConcat getRegexConcat() {
@ -78,20 +77,20 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
new RegexOr("FIRST", //
new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
new RegexLeaf("BAR", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), //
new RegexLeaf("QUOTED", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("\\s*"), //
new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("ARROW", "([-=.]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[-=.]*\\>)"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("DESC", "\"([^\"]*?)"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("DESC", "[%g]([^%g]*?)"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("$"));
}
@ -105,7 +104,8 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
}
if (line0.get("BACKCOLOR", 0) != null) {
entity1.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(line0.get("BACKCOLOR", 0)));
entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(line0.get("BACKCOLOR", 0)));
}
final StringBuilder sb = new StringBuilder();
@ -133,7 +133,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
}
}
final List<String> lineLast = StringUtils.getSplit(Pattern.compile(getPatternEnd()),
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
lines.get(lines.size() - 1));
if (StringUtils.isNotEmpty(lineLast.get(0))) {
if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
@ -151,10 +151,10 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
}
if (partition != null) {
diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), null,
GroupType.PACKAGE, null);
diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
null);
}
final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY);
final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
if (partition != null) {
diagram.endGroup();
}
@ -166,7 +166,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
entity2.setStereotype(new Stereotype(lineLast.get(2)));
}
if (lineLast.get(4) != null) {
entity2.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(lineLast.get(4)));
entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(lineLast.get(4)));
}
if (entity1 == null || entity2 == null) {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -34,10 +34,8 @@
package net.sourceforge.plantuml.activitydiagram.command;
import java.util.List;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
@ -46,6 +44,7 @@ import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines2;
import net.sourceforge.plantuml.command.MultilinesStrategy;
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.RegexOptional;
@ -60,7 +59,9 @@ 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.HtmlColorSet;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.StringUtils;
public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram> {
@ -70,7 +71,7 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
@Override
public String getPatternEnd() {
return "(?i)^\\s*([^\"]*)\"(?:\\s+as\\s+([\\p{L}0-9][\\p{L}0-9_.]*))?\\s*(\\<\\<.*\\>\\>)?\\s*(?:in\\s+(\"[^\"]+\"|\\S+))?\\s*(#\\w+)?$";
return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$";
}
static RegexConcat getRegexConcat() {
@ -79,13 +80,13 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
new RegexOr("FIRST", //
new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
new RegexLeaf("BAR", "(?:==+)\\s*([\\p{L}0-9_.]+)\\s*(?:==+)"), //
new RegexLeaf("QUOTED", "\"([^\"]+)\"(?:\\s+as\\s+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("\\s*"), //
new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
@ -96,13 +97,11 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
"(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
// new RegexLeaf("ARROW", "([-=.]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[-=.]*\\>)"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("DESC", "\"([^\"]*?)"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("DESC", "[%g]([^%g]*?)"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("$"));
}
@ -116,7 +115,8 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
}
if (line0.get("BACKCOLOR", 0) != null) {
entity1.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(line0.get("BACKCOLOR", 0)));
entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(line0.get("BACKCOLOR", 0)));
}
final StringBuilder sb = new StringBuilder();
@ -144,7 +144,7 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
}
}
final List<String> lineLast = StringUtils.getSplit(Pattern.compile(getPatternEnd()),
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
lines.get(lines.size() - 1));
if (StringUtils.isNotEmpty(lineLast.get(0))) {
if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
@ -162,10 +162,10 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
}
if (partition != null) {
diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), null, GroupType.PACKAGE,
diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
null);
}
final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY);
final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
if (partition != null) {
diagram.endGroup();
}
@ -177,7 +177,7 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
entity2.setStereotype(new Stereotype(lineLast.get(2)));
}
if (lineLast.get(4) != null) {
entity2.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(lineLast.get(4)));
entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(lineLast.get(4)));
}
if (entity1 == null || entity2 == null) {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -28,14 +28,13 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 10778 $
* Revision $Revision: 14661 $
*
*/
package net.sourceforge.plantuml.activitydiagram.command;
import java.util.List;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
@ -44,23 +43,24 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.HtmlColorSet;
import net.sourceforge.plantuml.StringUtils;
public class CommandPartition extends SingleLineCommand<ActivityDiagram> {
public CommandPartition() {
super("(?i)^partition\\s+(\"[^\"]+\"|\\S+)\\s*(#[0-9a-fA-F]{6}|#?\\w+)?\\s*\\{?$");
super("(?i)^partition[%s]+([%g][^%g]+[%g]|\\S+)[%s]*(#[0-9a-fA-F]{6}|#?\\w+)?[%s]*\\{?$");
}
@Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)));
final IGroup currentPackage = diagram.getCurrentGroup();
final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(code), null, GroupType.PACKAGE,
final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(code), GroupType.PACKAGE,
currentPackage);
final String color = arg.get(1);
if (color != null) {
p.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(color));
p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
}
return CommandExecutionResult.ok();
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -38,9 +38,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.CMapData;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption;
@ -51,14 +49,14 @@ import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlanes;
import net.sourceforge.plantuml.api.ImageDataComplex;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -68,10 +66,10 @@ import net.sourceforge.plantuml.graphic.TextBlockRecentred;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.DecorateEntityImage;
import net.sourceforge.plantuml.svek.DecorateTextBlock;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
public class ActivityDiagram3 extends UmlDiagram {
@ -113,12 +111,30 @@ public class ActivityDiagram3 extends UmlDiagram {
return swinlanes.nextLinkRenderer();
}
public void addActivity(Display activity, HtmlColor color, BoxStyle style) {
public void addActivity(Display activity, HtmlColor color, BoxStyle style, Url url) {
manageSwimlaneStrategy();
current()
.add(new InstructionSimple(activity, color, nextLinkRenderer(), swinlanes.getCurrentSwimlane(), style));
final InstructionSimple ins = new InstructionSimple(activity, color, nextLinkRenderer(),
swinlanes.getCurrentSwimlane(), style, url);
current().add(ins);
setNextLinkRendererInternal(null);
manageHasUrl(activity);
if (url != null) {
hasUrl = true;
}
}
public CommandExecutionResult addGoto(String name) {
final InstructionGoto ins = new InstructionGoto(swinlanes.getCurrentSwimlane(), name);
current().add(ins);
setNextLinkRendererInternal(null);
return CommandExecutionResult.ok();
}
public CommandExecutionResult addLabel(String name) {
final InstructionLabel ins = new InstructionLabel(swinlanes.getCurrentSwimlane(), name);
current().add(ins);
setNextLinkRendererInternal(null);
return CommandExecutionResult.ok();
}
public void start() {
@ -128,7 +144,7 @@ public class ActivityDiagram3 extends UmlDiagram {
public void stop() {
manageSwimlaneStrategy();
current().add(new InstructionStop(swinlanes.getCurrentSwimlane()));
current().add(new InstructionStop(swinlanes.getCurrentSwimlane(), nextLinkRenderer()));
}
public DiagramDescription getDescription() {
@ -140,12 +156,25 @@ public class ActivityDiagram3 extends UmlDiagram {
return UmlDiagramType.ACTIVITY;
}
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption,
List<BufferedImage> flashcodes) throws IOException {
private TextBlock addLegend(TextBlock original) {
final Display legend = getLegend();
if (legend == null) {
return original;
}
final TextBlock text = EntityImageLegend.create(legend, getSkinParam());
return DecorateEntityImage.add(original, text, getLegendAlignment(), getLegendVerticalAlignment());
}
@Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
// BUG42
// COMPRESSION
// TextBlock result = swinlanes;
TextBlock result = new TextBlockCompressed(swinlanes);
result = new TextBlockRecentred(result);
result = addLegend(result);
result = addTitle(result);
result = addHeaderAndFooter(result);
final ISkinParam skinParam = getSkinParam();
@ -153,20 +182,13 @@ public class ActivityDiagram3 extends UmlDiagram {
final double margin = 10;
final double dpiFactor = getDpiFactor(fileFormatOption, Dimension2DDouble.delta(dim, 2 * margin, 0));
final UGraphic ug = TextBlockUtils.getPrinted(result, fileFormatOption, skinParam.getColorMapper(), dpiFactor,
getSkinParam().getBackgroundColor(), margin);
final ImageBuilder imageBuilder = new ImageBuilder(skinParam.getColorMapper(), dpiFactor, getSkinParam()
.getBackgroundColor(), fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(),
margin, margin, getAnimation(), getSkinParam().handwritten());
imageBuilder.addUDrawable(result);
ug.writeImage(os, fileFormatOption.isWithMetadata() ? getMetadata() : null, getDpi(fileFormatOption));
return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
if (ug instanceof UGraphicG2d) {
final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered();
if (urls.size() > 0) {
final CMapData cmap = CMapData.cmapString(urls, dpiFactor);
return new ImageDataComplex(dim, cmap, getWarningOrError());
}
}
return new ImageDataSimple(dim);
}
private final double getDpiFactor(FileFormatOption fileFormatOption, final Dimension2D dim) {
@ -186,7 +208,8 @@ public class ActivityDiagram3 extends UmlDiagram {
return original;
}
final TextBlock text = TextBlockUtils.create(title, new FontConfiguration(getFont(FontParam.TITLE),
getFontColor(FontParam.TITLE, null)), HorizontalAlignment.CENTER, getSkinParam());
getFontColor(FontParam.TITLE, null), getSkinParam().getHyperlinkColor(), getSkinParam()
.useUnderlineForHyperlink()), HorizontalAlignment.CENTER, getSkinParam());
return new DecorateTextBlock(original, text, HorizontalAlignment.CENTER);
}
@ -198,26 +221,29 @@ public class ActivityDiagram3 extends UmlDiagram {
return original;
}
final TextBlock textFooter = footer == null ? null : TextBlockUtils.create(footer, new FontConfiguration(
getFont(FontParam.FOOTER), getFontColor(FontParam.FOOTER, null)), getFooterAlignment(), getSkinParam());
getFont(FontParam.FOOTER), getFontColor(FontParam.FOOTER, null), getSkinParam().getHyperlinkColor(),
getSkinParam().useUnderlineForHyperlink()), getFooterAlignment(), getSkinParam());
final TextBlock textHeader = header == null ? null : TextBlockUtils.create(header, new FontConfiguration(
getFont(FontParam.HEADER), getFontColor(FontParam.HEADER, null)), getHeaderAlignment(), getSkinParam());
getFont(FontParam.HEADER), getFontColor(FontParam.HEADER, null), getSkinParam().getHyperlinkColor(),
getSkinParam().useUnderlineForHyperlink()), getHeaderAlignment(), getSkinParam());
return new DecorateTextBlock(original, textHeader, getHeaderAlignment(), textFooter, getFooterAlignment());
}
private final UFont getFont(FontParam fontParam) {
final ISkinParam skinParam = getSkinParam();
return skinParam.getFont(fontParam, null);
return skinParam.getFont(fontParam, null, false);
}
private final HtmlColor getFontColor(FontParam fontParam, String stereo) {
private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereotype2) {
final ISkinParam skinParam = getSkinParam();
return skinParam.getFontHtmlColor(fontParam, stereo);
return skinParam.getFontHtmlColor(fontParam, stereotype2);
}
public void fork() {
final InstructionFork instructionFork = new InstructionFork(current());
final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer());
current().add(instructionFork);
setNextLinkRendererInternal(null);
setCurrent(instructionFork);
}
@ -238,14 +264,16 @@ public class ActivityDiagram3 extends UmlDiagram {
}
public void split() {
final InstructionSplit instructionSplit = new InstructionSplit(current());
final InstructionSplit instructionSplit = new InstructionSplit(current(), nextLinkRenderer());
setNextLinkRendererInternal(null);
current().add(instructionSplit);
setCurrent(instructionSplit);
}
public CommandExecutionResult splitAgain() {
if (current() instanceof InstructionSplit) {
((InstructionSplit) current()).splitAgain();
((InstructionSplit) current()).splitAgain(nextLinkRenderer());
setNextLinkRendererInternal(null);
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Cannot find split");
@ -253,23 +281,26 @@ public class ActivityDiagram3 extends UmlDiagram {
public CommandExecutionResult endSplit() {
if (current() instanceof InstructionSplit) {
((InstructionSplit) current()).endSplit(nextLinkRenderer());
setNextLinkRendererInternal(null);
setCurrent(((InstructionSplit) current()).getParent());
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Cannot find split");
}
public void startIf(Display test, Display whenThen) {
public void startIf(Display test, Display whenThen, HtmlColor color) {
manageSwimlaneStrategy();
final InstructionIf1 instructionIf = new InstructionIf1(swinlanes.getCurrentSwimlane(), current(), test,
whenThen, nextLinkRenderer());
final InstructionIf instructionIf = new InstructionIf(swinlanes.getCurrentSwimlane(), current(), test,
whenThen, nextLinkRenderer(), color, getSkinParam());
current().add(instructionIf);
setNextLinkRendererInternal(null);
setCurrent(instructionIf);
}
public CommandExecutionResult elseIf(Display test, Display whenThen) {
if (current() instanceof InstructionIf1) {
((InstructionIf1) current()).elseIf(test, whenThen, nextLinkRenderer());
public CommandExecutionResult elseIf(Display test, Display whenThen, HtmlColor color) {
if (current() instanceof InstructionIf) {
((InstructionIf) current()).elseIf(test, whenThen, nextLinkRenderer(), color);
setNextLinkRendererInternal(null);
return CommandExecutionResult.ok();
}
@ -277,8 +308,11 @@ public class ActivityDiagram3 extends UmlDiagram {
}
public CommandExecutionResult else2(Display whenElse) {
if (current() instanceof InstructionIf1) {
((InstructionIf1) current()).swithToElse(whenElse, nextLinkRenderer());
if (current() instanceof InstructionIf) {
final boolean result = ((InstructionIf) current()).swithToElse2(whenElse, nextLinkRenderer());
if (result == false) {
return CommandExecutionResult.error("Cannot find if");
}
setNextLinkRendererInternal(null);
return CommandExecutionResult.ok();
}
@ -286,29 +320,33 @@ public class ActivityDiagram3 extends UmlDiagram {
}
public CommandExecutionResult endif() {
if (current() instanceof InstructionIf1) {
((InstructionIf1) current()).endif(nextLinkRenderer());
if (current() instanceof InstructionIf) {
((InstructionIf) current()).endif(nextLinkRenderer());
setNextLinkRendererInternal(null);
setCurrent(((InstructionIf1) current()).getParent());
setCurrent(((InstructionIf) current()).getParent());
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Cannot find if");
}
public void startRepeat() {
public void startRepeat(HtmlColor color) {
manageSwimlaneStrategy();
final InstructionRepeat instructionRepeat = new InstructionRepeat(swinlanes.getCurrentSwimlane(), current(),
nextLinkRenderer());
nextLinkRenderer(), color);
current().add(instructionRepeat);
setCurrent(instructionRepeat);
setNextLinkRendererInternal(null);
}
public CommandExecutionResult repeatWhile(Display label) {
public CommandExecutionResult repeatWhile(Display label, Display yes, Display out, Display linkLabel,
HtmlColor linkColor) {
manageSwimlaneStrategy();
if (current() instanceof InstructionRepeat) {
final InstructionRepeat instructionRepeat = (InstructionRepeat) current();
instructionRepeat.setTest(label, nextLinkRenderer());
final LinkRendering back = new LinkRendering(linkColor);
back.setDisplay(linkLabel);
instructionRepeat.setTest(label, yes, out, nextLinkRenderer(), back);
setCurrent(instructionRepeat.getParent());
this.setNextLinkRendererInternal(null);
return CommandExecutionResult.ok();
@ -317,10 +355,10 @@ public class ActivityDiagram3 extends UmlDiagram {
}
public void doWhile(Display test, Display yes) {
public void doWhile(Display test, Display yes, HtmlColor color) {
manageSwimlaneStrategy();
final InstructionWhile instructionWhile = new InstructionWhile(swinlanes.getCurrentSwimlane(), current(), test,
nextLinkRenderer(), yes);
nextLinkRenderer(), yes, color, getSkinParam());
current().add(instructionWhile);
setCurrent(instructionWhile);
}
@ -342,9 +380,9 @@ public class ActivityDiagram3 extends UmlDiagram {
return CommandExecutionResult.ok();
}
public void startGroup(Display name) {
public void startGroup(Display name, HtmlColor backColor, HtmlColor titleColor) {
manageSwimlaneStrategy();
final InstructionGroup instructionGroup = new InstructionGroup(current(), name);
final InstructionGroup instructionGroup = new InstructionGroup(current(), name, backColor, titleColor);
current().add(instructionGroup);
setCurrent(instructionGroup);
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -44,19 +44,24 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandArrowLong3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandElse3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandElseIf2;
import net.sourceforge.plantuml.activitydiagram3.command.CommandElseLegacy1;
import net.sourceforge.plantuml.activitydiagram3.command.CommandEndPartition3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandEndif3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandFork3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandForkAgain3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandForkEnd3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandGoto;
import net.sourceforge.plantuml.activitydiagram3.command.CommandGroup3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandGroupEnd3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandIf2;
import net.sourceforge.plantuml.activitydiagram3.command.CommandIf2Multilines;
import net.sourceforge.plantuml.activitydiagram3.command.CommandIf4;
import net.sourceforge.plantuml.activitydiagram3.command.CommandIfLegacy1;
import net.sourceforge.plantuml.activitydiagram3.command.CommandKill3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandLabel;
import net.sourceforge.plantuml.activitydiagram3.command.CommandLink3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandNote3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandNoteLong3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandPartition3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandRepeat3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandRepeatWhile3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandSplit3;
@ -70,6 +75,7 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane2;
import net.sourceforge.plantuml.activitydiagram3.command.CommandWhile3;
import net.sourceforge.plantuml.activitydiagram3.command.CommandWhileEnd3;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandFootboxIgnored;
import net.sourceforge.plantuml.command.UmlDiagramFactory;
public class ActivityDiagramFactory3 extends UmlDiagramFactory {
@ -78,15 +84,21 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
cmds.add(new CommandFootboxIgnored());
addCommonCommands(cmds);
cmds.add(new CommandSwimlane());
cmds.add(new CommandSwimlane2());
cmds.add(new CommandPartition3());
cmds.add(new CommandEndPartition3());
cmds.add(new CommandGroup3());
cmds.add(new CommandGroupEnd3());
cmds.add(new CommandArrow3());
cmds.add(new CommandArrowLong3());
cmds.add(new CommandActivity3());
cmds.add(new CommandIf4());
cmds.add(new CommandIf2());
cmds.add(new CommandIf2Multilines());
cmds.add(new CommandIfLegacy1());
cmds.add(new CommandElseIf2());
cmds.add(new CommandElse3());
@ -102,8 +114,8 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
cmds.add(new CommandSplit3());
cmds.add(new CommandSplitAgain3());
cmds.add(new CommandSplitEnd3());
cmds.add(new CommandGroup3());
cmds.add(new CommandGroupEnd3());
// cmds.add(new CommandGroup3());
// cmds.add(new CommandGroupEnd3());
cmds.add(new CommandStart3());
cmds.add(new CommandStop3());
cmds.add(new CommandStopLegacy1());
@ -115,6 +127,10 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
cmds.add(new CommandActivityLong3());
cmds.add(new CommandActivityLegacy1());
cmds.add(new CommandLabel());
cmds.add(new CommandGoto());
return cmds;
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -47,15 +47,21 @@ public class Branch {
private final InstructionList list;
private final Display labelTest;
private final Display labelPositive;
private final HtmlColor color;
private LinkRendering inlinkRendering;
private Ftile ftile;
public Branch(Swimlane swimlane, Display labelPositive, Display labelTest) {
public boolean isOnlySingleStop() {
return list.isOnlySingleStop();
}
public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color) {
this.list = new InstructionList(swimlane);
this.labelTest = labelTest;
this.labelPositive = labelPositive;
this.color = color;
}
public void add(Instruction ins) {
@ -83,6 +89,10 @@ public class Branch {
}
public final Display getLabelPositive() {
final LinkRendering in = ftile.getInLinkRendering();
if (in != null && in.getDisplay() != null) {
return in.getDisplay();
}
return labelPositive;
}
@ -101,4 +111,13 @@ public class Branch {
public boolean shadowing() {
return ftile.shadowing();
}
public final HtmlColor getColor() {
return color;
}
public boolean isEmpty() {
return list.isEmpty();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -47,9 +47,11 @@ public class InstructionFork implements Instruction {
private final List<InstructionList> forks = new ArrayList<InstructionList>();
private final Instruction parent;
private final LinkRendering inlinkRendering;
public InstructionFork(Instruction parent) {
public InstructionFork(Instruction parent, LinkRendering inlinkRendering) {
this.parent = parent;
this.inlinkRendering = inlinkRendering;
this.forks.add(new InstructionList());
}
@ -67,7 +69,7 @@ public class InstructionFork implements Instruction {
for (InstructionList list : forks) {
all.add(list.createFtile(factory));
}
return factory.createFork(all);
return factory.createFork(getSwimlaneIn(), all);
}
public Instruction getParent() {
@ -83,7 +85,7 @@ public class InstructionFork implements Instruction {
}
public LinkRendering getInLinkRendering() {
return null;
return inlinkRendering;
}
public void addNote(Display note, NotePosition position) {
@ -95,7 +97,8 @@ public class InstructionFork implements Instruction {
}
public Swimlane getSwimlaneIn() {
return parent.getSwimlaneOut();
// return parent.getSwimlaneOut();
return forks.get(0).getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -39,33 +39,38 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
public class InstructionGroup implements Instruction {
private final InstructionList list = new InstructionList();
private final Instruction parent;
private final HtmlColor backColor;
private final HtmlColor titleColor;
private final Display test;
private Display headerNote;
public InstructionGroup(Instruction parent, Display test) {
public InstructionGroup(Instruction parent, Display test, HtmlColor backColor, HtmlColor titleColor) {
this.parent = parent;
this.test = test;
this.backColor = backColor;
this.titleColor = titleColor;
}
public void add(Instruction ins) {
list.add(ins);
}
public Ftile createFtile(FtileFactory factory) {
return factory.createGroup(list.createFtile(factory), test);
return factory.createGroup(list.createFtile(factory), test, backColor, titleColor, headerNote);
}
public Instruction getParent() {
return parent;
}
final public boolean kill() {
return list.kill();
}
@ -75,9 +80,13 @@ public class InstructionGroup implements Instruction {
}
public void addNote(Display note, NotePosition position) {
if (list.isEmpty()) {
this.headerNote = note;
return;
}
list.addNote(note, position);
}
public Set<Swimlane> getSwimlanes() {
return list.getSwimlanes();
}
@ -86,11 +95,8 @@ public class InstructionGroup implements Instruction {
return list.getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
return list.getSwimlaneOut();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -42,7 +42,6 @@ import java.util.Set;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
@ -50,21 +49,30 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition;
public class InstructionList implements Instruction {
private final List<Instruction> all = new ArrayList<Instruction>();
private boolean killed = false;
private final Swimlane defaultSwimlane;
public boolean isOnlySingleStop() {
if (all.size() == 1) {
final Instruction last = getLast();
return last instanceof InstructionStop;
}
return false;
}
public InstructionList() {
this(null);
}
public boolean isEmpty() {
return all.isEmpty();
}
public InstructionList(Swimlane defaultSwimlane) {
this.defaultSwimlane = defaultSwimlane;
}
public void add(Instruction ins) {
if (killed == false) {
all.add(ins);
}
all.add(ins);
}
public Ftile createFtile(FtileFactory factory) {
@ -82,17 +90,21 @@ public class InstructionList implements Instruction {
} else {
result = factory.assembly(result, cur);
}
}
if (killed) {
result = new FtileKilled(result);
if (outlinkRendering != null) {
result = factory.decorateOut(result, outlinkRendering);
}
// if (killed) {
// result = new FtileKilled(result);
// }
return result;
}
final public boolean kill() {
this.killed = true;
return true;
if (all.size() == 0) {
return false;
}
return getLast().kill();
}
public LinkRendering getInLinkRendering() {
@ -113,16 +125,21 @@ public class InstructionList implements Instruction {
public Set<Swimlane> getSwimlanes() {
return getSwimlanes2(all);
}
public Swimlane getSwimlaneIn() {
if (getSwimlanes().size() == 0) {
return null;
}
return all.get(0).getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
if (getSwimlanes().size() == 0) {
return null;
}
return getLast().getSwimlaneOut();
}
public static Set<Swimlane> getSwimlanes2(List<? extends Instruction> list) {
final Set<Swimlane> result = new HashSet<Swimlane>();
for (Instruction ins : list) {
@ -131,4 +148,10 @@ public class InstructionList implements Instruction {
return Collections.unmodifiableSet(result);
}
private LinkRendering outlinkRendering;
public void setOutRendering(LinkRendering outlinkRendering) {
this.outlinkRendering = outlinkRendering;
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -39,6 +39,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
public class InstructionRepeat implements Instruction {
@ -47,14 +48,19 @@ public class InstructionRepeat implements Instruction {
private final Instruction parent;
private final LinkRendering nextLinkRenderer;
private final Swimlane swimlane;
private final HtmlColor color;
private Display test;
private Display yes;
private Display out;
private LinkRendering endRepeatLinkRendering;
private LinkRendering backRepeatLinkRendering;
public InstructionRepeat(Swimlane swimlane, Instruction parent, LinkRendering nextLinkRenderer) {
public InstructionRepeat(Swimlane swimlane, Instruction parent, LinkRendering nextLinkRenderer, HtmlColor color) {
this.parent = parent;
this.swimlane = swimlane;
this.nextLinkRenderer = nextLinkRenderer;
this.color = color;
}
public void add(Instruction ins) {
@ -62,16 +68,20 @@ public class InstructionRepeat implements Instruction {
}
public Ftile createFtile(FtileFactory factory) {
return factory.repeat(swimlane, factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering), test);
return factory.repeat(swimlane, factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering),
test, yes, out, color, backRepeatLinkRendering);
}
public Instruction getParent() {
return parent;
}
public void setTest(Display test, LinkRendering linkRenderer) {
public void setTest(Display test, Display yes, Display out, LinkRendering endRepeatLinkRendering, LinkRendering backRepeatLinkRendering) {
this.test = test;
this.endRepeatLinkRendering = linkRenderer;
this.yes = yes;
this.out = out;
this.endRepeatLinkRendering = endRepeatLinkRendering;
this.backRepeatLinkRendering = backRepeatLinkRendering;
}
final public boolean kill() {
@ -85,7 +95,7 @@ public class InstructionRepeat implements Instruction {
public void addNote(Display note, NotePosition position) {
repeatList.addNote(note, position);
}
public Set<Swimlane> getSwimlanes() {
return repeatList.getSwimlanes();
}
@ -98,5 +108,4 @@ public class InstructionRepeat implements Instruction {
return repeatList.getSwimlaneOut();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -33,9 +33,11 @@
*/
package net.sourceforge.plantuml.activitydiagram3;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -43,27 +45,37 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition;
public class InstructionSimple extends MonoSwimable implements Instruction {
private boolean killed = false;
private final Display label;
private final HtmlColor color;
private final LinkRendering inlinkRendering;
private Display note;
private NotePosition notePosition;
private final BoxStyle style;
private final Url url;
public InstructionSimple(Display label, HtmlColor color, LinkRendering inlinkRendering, Swimlane swimlane, BoxStyle style) {
public InstructionSimple(Display label, HtmlColor color, LinkRendering inlinkRendering, Swimlane swimlane,
BoxStyle style, Url url) {
super(swimlane);
this.url = url;
this.style = style;
this.label = label;
this.color = color;
this.inlinkRendering = inlinkRendering;
}
public Ftile createFtile(FtileFactory factory) {
final Ftile result = factory.activity(label, color, getSwimlaneIn(), style);
if (note == null) {
return result;
Ftile result = factory.activity(label, color, getSwimlaneIn(), style);
if (url != null) {
result = factory.addUrl(result, url);
}
return factory.addNote(result, note, notePosition);
if (note != null) {
result = factory.addNote(result, note, notePosition);
}
if (killed) {
return new FtileKilled(result);
}
return result;
}
public void add(Instruction other) {
@ -71,7 +83,8 @@ public class InstructionSimple extends MonoSwimable implements Instruction {
}
final public boolean kill() {
return false;
this.killed = true;
return true;
}
public LinkRendering getInLinkRendering() {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -47,16 +47,18 @@ public class InstructionSplit implements Instruction {
private final List<InstructionList> splits = new ArrayList<InstructionList>();
private final Instruction parent;
private final LinkRendering inlinkRendering;
public InstructionSplit(Instruction parent) {
public InstructionSplit(Instruction parent, LinkRendering inlinkRendering) {
this.parent = parent;
this.splits.add(new InstructionList());
this.inlinkRendering = inlinkRendering;
}
private InstructionList getLast() {
return splits.get(splits.size() - 1);
}
public void add(Instruction ins) {
getLast().add(ins);
}
@ -73,8 +75,19 @@ public class InstructionSplit implements Instruction {
return parent;
}
public void splitAgain() {
this.splits.add(new InstructionList());
public void splitAgain(LinkRendering inlinkRendering) {
if (inlinkRendering != null) {
getLast().setOutRendering(inlinkRendering);
}
final InstructionList list = new InstructionList();
this.splits.add(list);
}
public void endSplit(LinkRendering inlinkRendering) {
if (inlinkRendering != null) {
getLast().setOutRendering(inlinkRendering);
}
}
final public boolean kill() {
@ -82,7 +95,7 @@ public class InstructionSplit implements Instruction {
}
public LinkRendering getInLinkRendering() {
return null;
return inlinkRendering;
}
public void addNote(Display note, NotePosition position) {

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -40,9 +40,12 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
public class InstructionStop extends MonoSwimable implements Instruction {
public InstructionStop(Swimlane swimlane) {
private final LinkRendering inlinkRendering;
public InstructionStop(Swimlane swimlane, LinkRendering inlinkRendering) {
super(swimlane);
this.inlinkRendering = inlinkRendering;
}
public Ftile createFtile(FtileFactory factory) {
@ -52,18 +55,17 @@ public class InstructionStop extends MonoSwimable implements Instruction {
public void add(Instruction other) {
throw new UnsupportedOperationException();
}
final public boolean kill() {
return false;
}
public LinkRendering getInLinkRendering() {
return null;
return inlinkRendering;
}
public void addNote(Display note, NotePosition position) {
throw new UnsupportedOperationException();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -35,10 +35,13 @@ package net.sourceforge.plantuml.activitydiagram3;
import java.util.Set;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
public class InstructionWhile implements Instruction {
@ -46,6 +49,7 @@ public class InstructionWhile implements Instruction {
private final InstructionList repeatList = new InstructionList();
private final Instruction parent;
private final LinkRendering nextLinkRenderer;
private final HtmlColor color;
private final Display test;
private final Display yes;
@ -53,22 +57,32 @@ public class InstructionWhile implements Instruction {
private LinkRendering endInlinkRendering;
private LinkRendering afterEndwhile;
private final Swimlane swimlane;
private final ISkinParam skinParam;
public InstructionWhile(Swimlane swimlane, Instruction parent, Display test, LinkRendering nextLinkRenderer, Display yes) {
public InstructionWhile(Swimlane swimlane, Instruction parent, Display test, LinkRendering nextLinkRenderer,
Display yes, HtmlColor color, ISkinParam skinParam) {
this.parent = parent;
this.test = test;
this.nextLinkRenderer = nextLinkRenderer;
this.yes = yes;
this.swimlane = swimlane;
this.color = color;
this.skinParam = skinParam;
}
public void add(Instruction ins) {
repeatList.add(ins);
}
private Display note;
private NotePosition position;
public Ftile createFtile(FtileFactory factory) {
Ftile tmp = factory.decorateOut(repeatList.createFtile(factory), endInlinkRendering);
tmp = factory.createWhile(swimlane, tmp, test, yes, out, afterEndwhile);
tmp = factory.createWhile(swimlane, tmp, test, yes, out, afterEndwhile, color);
if (note != null) {
tmp = new FtileWithNoteOpale(tmp, note, position, skinParam, false);
}
// tmp = factory.decorateOut(tmp, afterEndwhile);
return tmp;
}
@ -95,9 +109,14 @@ public class InstructionWhile implements Instruction {
}
public void addNote(Display note, NotePosition position) {
repeatList.addNote(note, position);
if (repeatList.isEmpty()) {
this.note = note;
this.position = position;
} else {
repeatList.addNote(note, position);
}
}
public Set<Swimlane> getSwimlanes() {
return repeatList.getSwimlanes();
}
@ -110,6 +129,4 @@ public class InstructionWhile implements Instruction {
return getSwimlaneIn();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -59,7 +59,7 @@ public class LinkRendering {
@Override
public String toString() {
return super.toString() + " " + color;
return super.toString() + " " + display + " " + color;
}
public static HtmlColor getColor(LinkRendering inLinkRendering, HtmlColor defaultColor) {
@ -76,4 +76,11 @@ public class LinkRendering {
return col;
}
public static Display getDisplay(LinkRendering linkRendering) {
if (linkRendering == null) {
return null;
}
return linkRendering.getDisplay();
}
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -33,6 +33,9 @@
*/
package net.sourceforge.plantuml.activitydiagram3.command;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -46,10 +49,7 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils;
public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
// public static final String ENDING_GROUP = "([/;|<>}\\]])";
// public static final String ENDING_GROUP =
// "(;|(?<![/|<>}\\]])(?:[/<}\\]])|(?<!\\</?\\w{1,5})(?<!\\<img[^>]{1,999})(?:\\>)|(?<!\\|.{1,999})(?:\\|))";
public static final String ENDING_GROUP = "(;|(?<![/|<>}\\]])(?:[/<}\\]])|(?<!\\</?\\w{1,5})(?<!\\<img[^>]{1,999})(?<!\\<\\$\\w{1,999})(?:\\>)|(?<!\\|.{1,999})(?:\\|))";
public static final String ENDING_GROUP = "(;|(?<![/|<>}\\]])(?:[/<}\\]])|(?<!\\</?\\w{1,5})(?<!\\<img[^>]{1,999})(?<!\\<\\$\\w{1,999})(?<!\\>)(?:\\>)|(?<!\\|.{1,999})(?:\\|))";
public CommandActivity3() {
super(getRegexConcat());
@ -57,8 +57,9 @@ public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("COLOR", "(?::?(" + HtmlColorUtils.COLOR_REGEXP + "))?"), //
new RegexLeaf(":"), //
new RegexLeaf("COLOR", "(?:(#\\w+[-\\\\|/]?\\w+):)?"), //
new RegexLeaf("LABEL", "(.*)"), //
new RegexLeaf("STYLE", ENDING_GROUP), //
new RegexLeaf("$"));
@ -66,9 +67,18 @@ public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
final HtmlColor color = HtmlColorUtils.getColorIfValid(arg.get("COLOR", 0));
final Url url;
if (arg.get("URL", 0) == null) {
url = null;
} else {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
url = urlBuilder.getUrl(arg.get("URL", 0));
}
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0));
diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), color, style);
diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), color, style, url);
return CommandExecutionResult.ok();
}

View File

@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, Arnaud Roques
* (C) Copyright 2009-2014, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
@ -57,7 +57,7 @@ public class CommandActivityLegacy1 extends SingleLineCommand2<ActivityDiagram3>
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), null, BoxStyle.PLAIN);
diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), null, BoxStyle.PLAIN, null);
return CommandExecutionResult.ok();
}

Some files were not shown because too many files have changed in this diff Show More