1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 10:59:01 +00:00

Version 6210

This commit is contained in:
Arnaud Roques 2011-03-20 22:40:07 +01:00
parent 573aac6a1c
commit a53403952e
65 changed files with 2197 additions and 210 deletions

View File

@ -36,7 +36,7 @@
<groupId>net.sourceforge.plantuml</groupId> <groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId> <artifactId>plantuml</artifactId>
<version>6141-SNAPSHOT</version> <version>6210-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PlantUML</name> <name>PlantUML</name>

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6130 $ * Revision $Revision: 6187 $
* *
*/ */
package net.sourceforge.plantuml; package net.sourceforge.plantuml;
@ -57,6 +57,7 @@ public class Option {
private boolean decodeurl = false; private boolean decodeurl = false;
private boolean pipe = false; private boolean pipe = false;
private boolean syntax = false; private boolean syntax = false;
private boolean pattern = false;
private File outputDir = null; private File outputDir = null;
private final List<String> result = new ArrayList<String>(); private final List<String> result = new ArrayList<String>();
@ -147,6 +148,8 @@ public class Option {
OptionFlags.getInstance().setVerbose(true); OptionFlags.getInstance().setVerbose(true);
} else if (s.equalsIgnoreCase("-pipe") || s.equalsIgnoreCase("-p")) { } else if (s.equalsIgnoreCase("-pipe") || s.equalsIgnoreCase("-p")) {
pipe = true; pipe = true;
} else if (s.equalsIgnoreCase("-pattern")) {
pattern = true;
} else if (s.equalsIgnoreCase("-syntax")) { } else if (s.equalsIgnoreCase("-syntax")) {
syntax = true; syntax = true;
OptionFlags.getInstance().setQuiet(true); OptionFlags.getInstance().setQuiet(true);
@ -270,6 +273,10 @@ public class Option {
return syntax; return syntax;
} }
public final boolean isPattern() {
return pattern;
}
public FileFormatOption getFileFormatOption() { public FileFormatOption getFileFormatOption() {
return new FileFormatOption(getFileFormat()); return new FileFormatOption(getFileFormat());
} }

View File

@ -49,6 +49,7 @@ import net.sourceforge.plantuml.eggs.PSystemPathFactory;
import net.sourceforge.plantuml.eggs.PSystemRIPFactory; import net.sourceforge.plantuml.eggs.PSystemRIPFactory;
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory; import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
import net.sourceforge.plantuml.oregon.PSystemOregonFactory; import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
import net.sourceforge.plantuml.postit.PostIdDiagramFactory;
import net.sourceforge.plantuml.printskin.PrintSkinFactory; import net.sourceforge.plantuml.printskin.PrintSkinFactory;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
import net.sourceforge.plantuml.statediagram.StateDiagramFactory; import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
@ -71,6 +72,7 @@ public class PSystemBuilder {
factories.add(new ActivityDiagramFactory2()); factories.add(new ActivityDiagramFactory2());
factories.add(new CompositeDiagramFactory()); factories.add(new CompositeDiagramFactory());
factories.add(new ObjectDiagramFactory()); factories.add(new ObjectDiagramFactory());
factories.add(new PostIdDiagramFactory());
factories.add(new PrintSkinFactory()); factories.add(new PrintSkinFactory());
factories.add(new PSystemVersionFactory()); factories.add(new PSystemVersionFactory());
factories.add(new PSystemSudokuFactory()); factories.add(new PSystemSudokuFactory());

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5969 $ * Revision $Revision: 6188 $
* *
*/ */
package net.sourceforge.plantuml; package net.sourceforge.plantuml;
@ -39,15 +39,34 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.UIManager; import javax.swing.UIManager;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
import net.sourceforge.plantuml.activitydiagram2.ActivityDiagramFactory2;
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
import net.sourceforge.plantuml.code.Transcoder; import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil; import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory;
import net.sourceforge.plantuml.componentdiagram.ComponentDiagramFactory;
import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory;
import net.sourceforge.plantuml.eggs.PSystemEggFactory;
import net.sourceforge.plantuml.eggs.PSystemLostFactory;
import net.sourceforge.plantuml.eggs.PSystemPathFactory;
import net.sourceforge.plantuml.eggs.PSystemRIPFactory;
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
import net.sourceforge.plantuml.png.MetadataTag; import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.printskin.PrintSkinFactory;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory;
import net.sourceforge.plantuml.swing.MainWindow; import net.sourceforge.plantuml.swing.MainWindow;
import net.sourceforge.plantuml.usecasediagram.UsecaseDiagramFactory;
import net.sourceforge.plantuml.version.PSystemVersionFactory;
public class Run { public class Run {
@ -56,7 +75,9 @@ public class Run {
if (OptionFlags.getInstance().isVerbose()) { if (OptionFlags.getInstance().isVerbose()) {
Log.info("GraphicsEnvironment.isHeadless() " + GraphicsEnvironment.isHeadless()); Log.info("GraphicsEnvironment.isHeadless() " + GraphicsEnvironment.isHeadless());
} }
if (OptionFlags.getInstance().isGui()) { if (option.isPattern()) {
managePattern();
} else if (OptionFlags.getInstance().isGui()) {
try { try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) { } catch (Exception e) {
@ -69,6 +90,24 @@ public class Run {
} }
} }
private static void managePattern() {
printPattern(new SequenceDiagramFactory());
printPattern(new ClassDiagramFactory());
printPattern(new ActivityDiagramFactory());
printPattern(new UsecaseDiagramFactory());
printPattern(new ComponentDiagramFactory());
printPattern(new StateDiagramFactory());
printPattern(new ObjectDiagramFactory());
}
private static void printPattern(AbstractUmlSystemCommandFactory factory) {
System.out.println();
System.out.println(factory.getClass().getSimpleName().replaceAll("Factory", ""));
for (String s : factory.getDescription()) {
System.out.println(s);
}
}
private static void managePipe(Option option) throws IOException { private static void managePipe(Option option) throws IOException {
final String charset = option.getCharset(); final String charset = option.getCharset();
final BufferedReader br; final BufferedReader br;
@ -127,8 +166,8 @@ public class Run {
System.out.println(new MetadataTag(f, "plantuml").getData()); System.out.println(new MetadataTag(f, "plantuml").getData());
System.out.println("------------------------"); System.out.println("------------------------");
} else { } else {
final SourceFileReader sourceFileReader = new SourceFileReader(option.getDefaultDefines(), f, option final SourceFileReader sourceFileReader = new SourceFileReader(option.getDefaultDefines(), f,
.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption()); option.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption());
if (option.isComputeurl()) { if (option.isComputeurl()) {
final List<String> urls = sourceFileReader.getEncodedUrl(); final List<String> urls = sourceFileReader.getEncodedUrl();
for (String s : urls) { for (String s : urls) {

View File

@ -100,10 +100,10 @@ public class ActivityDiagram2 extends CucaDiagram {
afterAdd(act); afterAdd(act);
} }
private void afterAdd(final Entity act) { private void afterAdd(final IEntity act) {
for (IEntity last : this.waitings) { for (IEntity last : this.waitings) {
System.err.println("last=" + last); // System.err.println("last=" + last);
System.err.println("act=" + act); // System.err.println("act=" + act);
this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), futureLabel, futureLength)); this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), futureLabel, futureLength));
futureLabel = null; futureLabel = null;
} }
@ -117,15 +117,14 @@ public class ActivityDiagram2 extends CucaDiagram {
this.waitings.add(act); this.waitings.add(act);
this.futureLength = 2; this.futureLength = 2;
} }
public IEntity getLastEntityConsulted() { public IEntity getLastEntityConsulted() {
if (waitings.size()==1) { if (waitings.size() == 1) {
return waitings.iterator().next(); return waitings.iterator().next();
} }
return null; return null;
} }
private String getAutoCode() { private String getAutoCode() {
return "ac" + UniqueSequence.getValue(); return "ac" + UniqueSequence.getValue();
} }
@ -142,7 +141,8 @@ public class ActivityDiagram2 extends CucaDiagram {
currentContext = new ConditionalContext2(currentContext, br, Direction.DOWN, when); currentContext = new ConditionalContext2(currentContext, br, Direction.DOWN, when);
for (IEntity last : this.waitings) { for (IEntity last : this.waitings) {
if (test == null) { if (test == null) {
// this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), test, futureLength)); // this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW,
// LinkDecor.NONE), test, futureLength));
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} else { } else {
this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), this.futureLabel, this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), this.futureLabel,
@ -162,14 +162,14 @@ public class ActivityDiagram2 extends CucaDiagram {
public void endif() { public void endif() {
final boolean hasElse = currentContext.isHasElse(); final boolean hasElse = currentContext.isHasElse();
System.err.println("CALL endif hasElse " + hasElse); // System.err.println("CALL endif hasElse " + hasElse);
this.waitings.addAll(currentContext.getPendings()); this.waitings.addAll(currentContext.getPendings());
currentContext = currentContext.getParent(); currentContext = currentContext.getParent();
if (currentContext == null) { // if (currentContext == null) {
System.err.println("after endif " + currentContext); // System.err.println("after endif " + currentContext);
} else { // } else {
System.err.println("after endif " + currentContext.getPendings()); // System.err.println("after endif " + currentContext.getPendings());
} // }
} }
public void else2(String when) { public void else2(String when) {
@ -196,7 +196,7 @@ public class ActivityDiagram2 extends CucaDiagram {
private final Collection<PendingLink> pendingLinks = new ArrayList<PendingLink>(); private final Collection<PendingLink> pendingLinks = new ArrayList<PendingLink>();
public void callGoto(String gotoLabel) { public void callGoto(String gotoLabel) {
System.err.println("CALL goto " + gotoLabel); // System.err.println("CALL goto " + gotoLabel);
final IEntity dest = labels.get(gotoLabel); final IEntity dest = labels.get(gotoLabel);
for (IEntity last : this.waitings) { for (IEntity last : this.waitings) {
if (dest == null) { if (dest == null) {
@ -206,14 +206,17 @@ public class ActivityDiagram2 extends CucaDiagram {
this.futureLength)); this.futureLength));
} }
} }
System.err.println("Avant fin goto, waitings=" + waitings); // System.err.println("Avant fin goto, waitings=" + waitings);
this.waitings.clear(); this.waitings.clear();
// currentContext.clearPendingsButFirst(); // currentContext.clearPendingsButFirst();
} }
public void end() { public void end() {
// TODO Auto-generated method stub if (waitings.size() == 0) {
throw new IllegalStateException();
}
final IEntity act = getOrCreateEntity("end", EntityType.CIRCLE_END);
afterAdd(act);
} }
} }

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.activitydiagram2.command.CommandIf2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandLabel2; import net.sourceforge.plantuml.activitydiagram2.command.CommandLabel2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandMultilinesNoteActivity2; import net.sourceforge.plantuml.activitydiagram2.command.CommandMultilinesNoteActivity2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandNewActivity2; import net.sourceforge.plantuml.activitydiagram2.command.CommandNewActivity2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandNewMultilinesActivity2;
import net.sourceforge.plantuml.activitydiagram2.command.CommandStart2; import net.sourceforge.plantuml.activitydiagram2.command.CommandStart2;
import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory; import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory;
@ -83,6 +84,7 @@ public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory {
// addCommand(new CommandElse(system)); // addCommand(new CommandElse(system));
// addCommand(new CommandEndif(system)); // addCommand(new CommandEndif(system));
// addCommand(new CommandInnerConcurrent(system)); // addCommand(new CommandInnerConcurrent(system));
addCommand(new CommandNewMultilinesActivity2(system));
} }
} }

View File

@ -0,0 +1,64 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5751 $
*
*/
package net.sourceforge.plantuml.activitydiagram2.command;
import java.util.List;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines;
public class CommandNewMultilinesActivity2 extends CommandMultilines<ActivityDiagram2> {
public CommandNewMultilinesActivity2(final ActivityDiagram2 system) {
super(system, "(?i)^[\"<].*$", "(?i)^.*[\">]$");
}
public final CommandExecutionResult execute(List<String> lines) {
if (getSystem().entities().size() == 0) {
return CommandExecutionResult.error("Missing start keyword");
}
if (getSystem().isReachable() == false) {
return CommandExecutionResult.error("Unreachable statement");
}
String s = StringUtils.getMergedLines(lines);
s = s.substring(1, s.length() - 2);
getSystem().newActivity(s);
return CommandExecutionResult.ok();
}
}

View File

@ -28,12 +28,14 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6095 $ * Revision $Revision: 6192 $
* *
*/ */
package net.sourceforge.plantuml.classdiagram; package net.sourceforge.plantuml.classdiagram;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
@ -43,16 +45,24 @@ public abstract class AbstractEntityDiagram extends CucaDiagram {
abstract public IEntity getOrCreateClass(String code); abstract public IEntity getOrCreateClass(String code);
protected List<String> getDotStrings() { final protected List<String> getDotStrings() {
// return Arrays.asList("nodesep=.5;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];", // return Arrays.asList("nodesep=.5;", "ranksep=0.8;", "edge
// "node [fontsize=11,height=.35,width=.55];"); // [fontsize=11,labelfontsize=11];",
return Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];", // "node [fontsize=11,height=.35,width=.55];");
"node [fontsize=11,height=.35,width=.55];");
final List<String> def = Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];",
"node [fontsize=11,height=.35,width=.55];");
if (getPragma().isDefine("graphattributes")==false) {
return def;
}
final String attribute = getPragma().getValue("graphattributes");
final List<String> result = new ArrayList<String>(def);
result.add(attribute);
return Collections.unmodifiableList(result);
} }
final public String getDescription() { final public String getDescription() {
return "(" + entities().size() + " entities)"; return "(" + entities().size() + " entities)";
} }
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5895 $ * Revision $Revision: 6167 $
* *
*/ */
package net.sourceforge.plantuml.classdiagram; package net.sourceforge.plantuml.classdiagram;
@ -146,4 +146,5 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
return UmlDiagramType.CLASS; return UmlDiagramType.CLASS;
} }
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5613 $ * Revision $Revision: 6169 $
* *
*/ */
package net.sourceforge.plantuml.classdiagram; package net.sourceforge.plantuml.classdiagram;
@ -38,6 +38,7 @@ import net.sourceforge.plantuml.classdiagram.command.CommandCreateEntityClass2;
import net.sourceforge.plantuml.classdiagram.command.CommandCreateEntityClassMultilines2; import net.sourceforge.plantuml.classdiagram.command.CommandCreateEntityClassMultilines2;
import net.sourceforge.plantuml.classdiagram.command.CommandEndNamespace; import net.sourceforge.plantuml.classdiagram.command.CommandEndNamespace;
import net.sourceforge.plantuml.classdiagram.command.CommandHideShow; import net.sourceforge.plantuml.classdiagram.command.CommandHideShow;
import net.sourceforge.plantuml.classdiagram.command.CommandHideShow3;
import net.sourceforge.plantuml.classdiagram.command.CommandImport; import net.sourceforge.plantuml.classdiagram.command.CommandImport;
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass2; import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass2;
import net.sourceforge.plantuml.classdiagram.command.CommandLinkLollipop; import net.sourceforge.plantuml.classdiagram.command.CommandLinkLollipop;
@ -93,6 +94,7 @@ public class ClassDiagramFactory extends AbstractUmlSystemCommandFactory {
// addCommand(new CommandCreateEntityClassMultilines(system)); // addCommand(new CommandCreateEntityClassMultilines(system));
addCommand(new CommandCreateEntityClassMultilines2(system)); addCommand(new CommandCreateEntityClassMultilines2(system));
addCommand(new CommandHideShow3(system));
addCommand(new CommandHideShow(system)); addCommand(new CommandHideShow(system));
} }

View File

@ -34,19 +34,22 @@
package net.sourceforge.plantuml.classdiagram.command; package net.sourceforge.plantuml.classdiagram.command;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.Map;
import java.util.Set; import java.util.Set;
import net.sourceforge.plantuml.classdiagram.ClassDiagram; import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand; import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
import net.sourceforge.plantuml.cucadiagram.EntityGender; import net.sourceforge.plantuml.cucadiagram.EntityGender;
import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils; import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils;
import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.EntityType; import net.sourceforge.plantuml.cucadiagram.EntityType;
import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IEntity;
public class CommandHideShow extends SingleLineCommand<ClassDiagram> { public class CommandHideShow extends SingleLineCommand2<ClassDiagram> {
private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD); private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD, private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
@ -54,9 +57,18 @@ public class CommandHideShow extends SingleLineCommand<ClassDiagram> {
private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD); private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
public CommandHideShow(ClassDiagram classDiagram) { public CommandHideShow(ClassDiagram classDiagram) {
super( super(classDiagram, getRegexConcat());
classDiagram, }
"(?i)^(hide|show)\\s+(?:(class|interface|enum|abstract|[\\p{L}0-9_.]+|\"[^\"]+\"|\\<\\<.*\\>\\>)\\s+)*?(?:(empty)\\s+)?(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)$");
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("COMMAND", "(hide|show)"), //
new RegexLeaf("\\s+"), //
new RegexLeaf("GENDER",
"(?:(class|interface|enum|abstract|[\\p{L}0-9_.]+|\"[^\"]+\"|\\<\\<.*\\>\\>)\\s+)*?"), //
new RegexLeaf("EMPTY", "(?:(empty)\\s+)?"), //
new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)"), //
new RegexLeaf("$"));
} }
private final EntityGender emptyByGender(Set<EntityPortion> portion) { private final EntityGender emptyByGender(Set<EntityPortion> portion) {
@ -73,35 +85,38 @@ public class CommandHideShow extends SingleLineCommand<ClassDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(List<String> arg) { protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get(3));
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION").get(0));
EntityGender gender = null; EntityGender gender = null;
if (arg.get(1) == null) { final String arg1 = arg.get("GENDER").get(0);
if (arg1 == null) {
gender = EntityGenderUtils.all(); gender = EntityGenderUtils.all();
} else if (arg.get(1).equalsIgnoreCase("class")) { } else if (arg1.equalsIgnoreCase("class")) {
gender = EntityGenderUtils.byEntityType(EntityType.CLASS); gender = EntityGenderUtils.byEntityType(EntityType.CLASS);
} else if (arg.get(1).equalsIgnoreCase("interface")) { } else if (arg1.equalsIgnoreCase("interface")) {
gender = EntityGenderUtils.byEntityType(EntityType.INTERFACE); gender = EntityGenderUtils.byEntityType(EntityType.INTERFACE);
} else if (arg.get(1).equalsIgnoreCase("enum")) { } else if (arg1.equalsIgnoreCase("enum")) {
gender = EntityGenderUtils.byEntityType(EntityType.ENUM); gender = EntityGenderUtils.byEntityType(EntityType.ENUM);
} else if (arg.get(1).equalsIgnoreCase("abstract")) { } else if (arg1.equalsIgnoreCase("abstract")) {
gender = EntityGenderUtils.byEntityType(EntityType.ABSTRACT_CLASS); gender = EntityGenderUtils.byEntityType(EntityType.ABSTRACT_CLASS);
} else if (arg.get(1).startsWith("<<")) { } else if (arg1.startsWith("<<")) {
gender = EntityGenderUtils.byStereotype(arg.get(1)); gender = EntityGenderUtils.byStereotype(arg1);
} else { } else {
final IEntity entity = getSystem().getOrCreateClass(arg.get(1)); final IEntity entity = getSystem().getOrCreateClass(arg1);
gender = EntityGenderUtils.byEntityAlone(entity); gender = EntityGenderUtils.byEntityAlone(entity);
} }
if (gender != null) { if (gender != null) {
final boolean empty = arg.get(2) != null; final boolean empty = arg.get("EMPTY").get(0) != null;
if (empty == true) { if (empty == true) {
gender = EntityGenderUtils.and(gender, emptyByGender(portion)); gender = EntityGenderUtils.and(gender, emptyByGender(portion));
} }
if (getSystem().getCurrentGroup() != null) { if (getSystem().getCurrentGroup() != null) {
gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(getSystem().getCurrentGroup())); gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(getSystem().getCurrentGroup()));
} }
getSystem().hideOrShow(gender, portion, arg.get(0).equalsIgnoreCase("show")); getSystem().hideOrShow(gender, portion, arg.get("COMMAND").get(0).equalsIgnoreCase("show"));
} }
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
@ -125,4 +140,5 @@ public class CommandHideShow extends SingleLineCommand<ClassDiagram> {
} }
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }

View File

@ -0,0 +1,129 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5019 $
*
*/
package net.sourceforge.plantuml.classdiagram.command;
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.skin.VisibilityModifier;
public class CommandHideShow3 extends SingleLineCommand2<ClassDiagram> {
private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
EntityPortion.METHOD);
private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
public CommandHideShow3(ClassDiagram classDiagram) {
super(classDiagram, getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("COMMAND", "(hide|show)"), //
new RegexLeaf("\\s+"), //
new RegexLeaf("VISIBILITY",
"((?:public|private|protected|package)?(?:[,\\s]+(?:public|private|protected|package))*)"), //
new RegexLeaf("\\s+"), //
new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?)"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION").get(0));
final Set<VisibilityModifier> visibilities = EnumSet.<VisibilityModifier> noneOf(VisibilityModifier.class);
final StringTokenizer st = new StringTokenizer(arg.get("VISIBILITY").get(0).toLowerCase(), " ,");
while (st.hasMoreTokens()) {
addVisibilities(st.nextToken(), portion, visibilities);
}
getSystem().hideOrShow(visibilities, arg.get("COMMAND").get(0).equalsIgnoreCase("show"));
return CommandExecutionResult.ok();
}
private void addVisibilities(String token, Set<EntityPortion> portion, Set<VisibilityModifier> result) {
if (token.equals("public") && portion.contains(EntityPortion.FIELD)) {
result.add(VisibilityModifier.PUBLIC_FIELD);
}
if (token.equals("public") && portion.contains(EntityPortion.METHOD)) {
result.add(VisibilityModifier.PUBLIC_METHOD);
}
if (token.equals("private") && portion.contains(EntityPortion.FIELD)) {
result.add(VisibilityModifier.PRIVATE_FIELD);
}
if (token.equals("private") && portion.contains(EntityPortion.METHOD)) {
result.add(VisibilityModifier.PRIVATE_METHOD);
}
if (token.equals("protected") && portion.contains(EntityPortion.FIELD)) {
result.add(VisibilityModifier.PROTECTED_FIELD);
}
if (token.equals("protected") && portion.contains(EntityPortion.METHOD)) {
result.add(VisibilityModifier.PROTECTED_METHOD);
}
if (token.equals("package") && portion.contains(EntityPortion.FIELD)) {
result.add(VisibilityModifier.PACKAGE_PRIVATE_FIELD);
}
if (token.equals("package") && portion.contains(EntityPortion.METHOD)) {
result.add(VisibilityModifier.PACKAGE_PRIVATE_METHOD);
}
}
private Set<EntityPortion> getEntityPortion(String s) {
final String sub = s.substring(0, 3).toLowerCase();
if (sub.equals("met")) {
return PORTION_METHOD;
}
if (sub.equals("mem")) {
return PORTION_MEMBER;
}
if (sub.equals("att") || sub.equals("fie")) {
return PORTION_FIELD;
}
throw new IllegalArgumentException();
}
}

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 3827 $ * Revision $Revision: 6170 $
* *
*/ */
package net.sourceforge.plantuml.code; package net.sourceforge.plantuml.code;
@ -55,7 +55,9 @@ public class AsciiEncoder implements URLEncoder {
} }
public byte[] decode(String s) { public byte[] decode(String s) {
assert s.length() % 4 == 0 : "Cannot decode " + s; if (s.length() % 4 != 0) {
throw new IllegalArgumentException("Cannot decode " + s);
}
final byte data[] = new byte[(s.length() * 3 + 3) / 4]; final byte data[] = new byte[(s.length() * 3 + 3) / 4];
int pos = 0; int pos = 0;
for (int i = 0; i < s.length(); i += 4) { for (int i = 0; i < s.length(); i += 4) {

View File

@ -28,12 +28,14 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6097 $ * Revision $Revision: 6191 $
* *
*/ */
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
@ -82,6 +84,7 @@ public abstract class AbstractUmlSystemCommandFactory implements PSystemCommandF
final protected void addCommonCommands(UmlDiagram system) { final protected void addCommonCommands(UmlDiagram system) {
addCommand(new CommandNope(system)); addCommand(new CommandNope(system));
addCommand(new CommandMultilinesComment(system));
addCommand(new CommandPragma(system)); addCommand(new CommandPragma(system));
addCommand(new CommandTitle(system)); addCommand(new CommandTitle(system));
addCommand(new CommandMultilinesTitle(system)); addCommand(new CommandMultilinesTitle(system));
@ -107,4 +110,13 @@ public abstract class AbstractUmlSystemCommandFactory implements PSystemCommandF
cmds.add(cmd); cmds.add(cmd);
} }
final public List<String> getDescription() {
final List<String> result = new ArrayList<String>();
for (Command cmd : cmds) {
result.addAll(Arrays.asList(cmd.getDescription()));
}
return Collections.unmodifiableList(result);
}
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 4762 $ * Revision $Revision: 6184 $
* *
*/ */
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
@ -44,5 +44,7 @@ public interface Command {
boolean isDeprecated(List<String> lines); boolean isDeprecated(List<String> lines);
String getHelpMessageForDeprecated(List<String> lines); String getHelpMessageForDeprecated(List<String> lines);
String[] getDescription();
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5749 $ * Revision $Revision: 6186 $
* *
*/ */
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
@ -57,6 +57,10 @@ public abstract class CommandMultilines<S extends PSystem> implements Command {
this.starting = Pattern.compile(patternStart); this.starting = Pattern.compile(patternStart);
this.ending = Pattern.compile(patternEnd); this.ending = Pattern.compile(patternEnd);
} }
public String[] getDescription() {
return new String[] { "START: " + starting.pattern(), "END: " + ending.pattern() };
}
final public CommandControl isValid(List<String> lines) { final public CommandControl isValid(List<String> lines) {
if (isCommandForbidden()) { if (isCommandForbidden()) {

View File

@ -58,6 +58,10 @@ public abstract class CommandMultilines2<S extends PSystem> implements Command {
this.starting = patternStart; this.starting = patternStart;
this.ending = Pattern.compile(patternEnd); this.ending = Pattern.compile(patternEnd);
} }
public String[] getDescription() {
return new String[] { "START: "+starting.getPattern(), "END: "+ending.pattern() };
}
final public CommandControl isValid(List<String> lines) { final public CommandControl isValid(List<String> lines) {
if (isCommandForbidden()) { if (isCommandForbidden()) {

View File

@ -56,6 +56,10 @@ public abstract class CommandMultilinesBracket<S extends PSystem> implements Com
protected boolean isCommandForbidden() { protected boolean isCommandForbidden() {
return false; return false;
} }
public String[] getDescription() {
return new String[] { "BRACKET: " + starting.pattern() };
}
protected void actionIfCommandValid() { protected void actionIfCommandValid() {
} }

View File

@ -0,0 +1,51 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5957 $
*
*/
package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
public class CommandMultilinesComment extends CommandMultilines<UmlDiagram> {
public CommandMultilinesComment(final UmlDiagram diagram) {
super(diagram, "(?i)^\\s*/'.*$", "(?i)^.*'/\\s*$");
}
public CommandExecutionResult execute(List<String> lines) {
System.err.println(lines);
return CommandExecutionResult.ok();
}
}

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5983 $ * Revision $Revision: 6209 $
* *
*/ */
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
@ -36,6 +36,7 @@ package net.sourceforge.plantuml.command;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UniqueSequence;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.cucadiagram.Group; import net.sourceforge.plantuml.cucadiagram.Group;
import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.GroupType;
@ -45,7 +46,8 @@ public class CommandPackage extends SingleLineCommand<AbstractEntityDiagram> {
public CommandPackage(AbstractEntityDiagram diagram) { public CommandPackage(AbstractEntityDiagram diagram) {
super(diagram, super(diagram,
"(?i)^package\\s+(\"[^\"]+\"|\\S+)(?:\\s+as\\s+([\\p{L}0-9_.]+))?\\s*(#[0-9a-fA-F]{6}|#?\\w+)?\\s*\\{?$"); "(?i)^package\\s+(\"[^\"]+\"|[^#\\s{}]*)(?:\\s+as\\s+([\\p{L}0-9_.]+))?\\s*(#[0-9a-fA-F]{6}|#?\\w+)?\\s*\\{?$");
// "(?i)^package\\s+(\"[^\"]+\"|\\S+)(?:\\s+as\\s+([\\p{L}0-9_.]+))?\\s*(#[0-9a-fA-F]{6}|#?\\w+)?\\s*\\{?$");
} }
@Override @Override
@ -53,16 +55,22 @@ public class CommandPackage extends SingleLineCommand<AbstractEntityDiagram> {
final String code; final String code;
final String display; final String display;
if (arg.get(1) == null) { if (arg.get(1) == null) {
code = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)); if (StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)).length() == 0) {
display = code; code = "##" + UniqueSequence.getValue();
display = null;
} else {
code = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
display = code;
}
} else { } else {
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)); display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
code = arg.get(1); code = arg.get(1);
} }
final Group currentPackage = getSystem().getCurrentGroup(); final Group currentPackage = getSystem().getCurrentGroup();
// if (getSystem().entityExist(code)) { // if (getSystem().entityExist(code)) {
// return CommandExecutionResult.error("Package cannot have the same name as an existing class"); // return CommandExecutionResult.error("Package cannot have the same
// } // name as an existing class");
// }
final Group p = getSystem().getOrCreateGroup(code, display, null, GroupType.PACKAGE, currentPackage); final Group p = getSystem().getOrCreateGroup(code, display, null, GroupType.PACKAGE, currentPackage);
p.setBold(true); p.setBold(true);
final String color = arg.get(2); final String color = arg.get(2);

View File

@ -75,4 +75,8 @@ public class ProtectedCommand implements Command {
return cmd.isValid(lines); return cmd.isValid(lines);
} }
public String[] getDescription() {
return cmd.getDescription();
}
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5041 $ * Revision $Revision: 6186 $
* *
*/ */
package net.sourceforge.plantuml.command; package net.sourceforge.plantuml.command;
@ -67,6 +67,10 @@ public abstract class SingleLineCommand<S extends PSystem> implements Command {
this.system = system; this.system = system;
this.pattern = Pattern.compile(pattern); this.pattern = Pattern.compile(pattern);
} }
public String[] getDescription() {
return new String[]{pattern.pattern()};
}
final protected S getSystem() { final protected S getSystem() {
return system; return system;

View File

@ -63,6 +63,10 @@ public abstract class SingleLineCommand2<S extends PSystem> implements Command {
final protected S getSystem() { final protected S getSystem() {
return system; return system;
} }
public String[] getDescription() {
return new String[] { pattern.getPattern() };
}
final public CommandControl isValid(List<String> lines) { final public CommandControl isValid(List<String> lines) {
if (lines.size() != 1) { if (lines.size() != 1) {

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6062 $ * Revision $Revision: 6199 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
@ -40,6 +40,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -58,6 +59,8 @@ import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramFileMaker;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramFileMakerBeta; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramFileMakerBeta;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramPngMaker3; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramPngMaker3;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker; import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower { public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower {
@ -105,7 +108,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
if (display == null) { if (display == null) {
display = code; display = code;
} }
final Entity entity = new Entity(code, display, type, group); final Entity entity = new Entity(code, display, type, group, getHides());
entities.put(code, entity); entities.put(code, entity);
nbLinks.put(entity, 0); nbLinks.put(entity, 0);
return entity; return entity;
@ -166,9 +169,9 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
protected final Group getOrCreateGroupInternal(String code, String display, String namespace, GroupType type, protected final Group getOrCreateGroupInternal(String code, String display, String namespace, GroupType type,
Group parent) { Group parent) {
// if (entityExist(code)) { // if (entityExist(code)) {
// throw new IllegalArgumentException("code=" + code); // throw new IllegalArgumentException("code=" + code);
// } // }
Group g = groups.get(code); Group g = groups.get(code);
if (g == null) { if (g == null) {
g = new Group(code, display, namespace, type, parent); g = new Group(code, display, namespace, type, parent);
@ -176,7 +179,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
Entity entityGroup = entities.get(code); Entity entityGroup = entities.get(code);
if (entityGroup == null) { if (entityGroup == null) {
entityGroup = new Entity("$$" + code, code, EntityType.GROUP, g); entityGroup = new Entity("$$" + code, code, EntityType.GROUP, g, getHides());
} else { } else {
entityGroup.muteToCluster(g); entityGroup.muteToCluster(g);
} }
@ -272,7 +275,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
final public List<File> createFiles(File suggestedFile, FileFormatOption fileFormatOption) throws IOException, final public List<File> createFiles(File suggestedFile, FileFormatOption fileFormatOption) throws IOException,
InterruptedException { InterruptedException {
final FileFormat fileFormat = fileFormatOption.getFileFormat(); final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) { if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) {
@ -480,7 +483,16 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
} }
} }
public void hideOrShow(Set<VisibilityModifier> visibilities, boolean show) {
if (show) {
hides.removeAll(visibilities);
} else {
hides.addAll(visibilities);
}
}
private final List<HideOrShow> hideOrShows = new ArrayList<HideOrShow>(); private final List<HideOrShow> hideOrShows = new ArrayList<HideOrShow>();
private final Set<VisibilityModifier> hides = new HashSet<VisibilityModifier>();
static class HideOrShow { static class HideOrShow {
private final EntityGender gender; private final EntityGender gender;
@ -498,5 +510,19 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
public int getNbImages() { public int getNbImages() {
return this.horizontalPages * this.verticalPages; return this.horizontalPages * this.verticalPages;
} }
public final Set<VisibilityModifier> getHides() {
return Collections.unmodifiableSet(hides);
}
private GraphvizLayoutStrategy strategy = GraphvizLayoutStrategy.DOT;
public void setStrategy(GraphvizLayoutStrategy strategy) {
this.strategy = strategy;
}
public GraphvizLayoutStrategy getStrategy() {
return strategy;
}
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6121 $ * Revision $Revision: 6169 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
@ -38,10 +38,12 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.UniqueSequence; import net.sourceforge.plantuml.UniqueSequence;
import net.sourceforge.plantuml.cucadiagram.dot.DrawFile; import net.sourceforge.plantuml.cucadiagram.dot.DrawFile;
import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.skin.VisibilityModifier;
public class Entity implements IEntity { public class Entity implements IEntity {
@ -53,14 +55,15 @@ public class Entity implements IEntity {
private Stereotype stereotype; private Stereotype stereotype;
private final List<Member> fields2 = new ArrayList<Member>(); private final List<Member> fields = new ArrayList<Member>();
private final List<Member> methods2 = new ArrayList<Member>(); private final List<Member> methods = new ArrayList<Member>();
private final Set<VisibilityModifier> hides;
private Group container; private Group container;
private DrawFile imageFile; private DrawFile imageFile;
private String url; private String url;
private boolean top; private boolean top;
public final boolean isTop() { public final boolean isTop() {
@ -71,17 +74,19 @@ public class Entity implements IEntity {
this.top = top; this.top = top;
} }
public Entity(String code, String display, EntityType type, Group entityPackage) { public Entity(String code, String display, EntityType type, Group entityPackage, Set<VisibilityModifier> hides) {
this("cl" + UniqueSequence.getValue(), code, display, type, entityPackage); this("cl" + UniqueSequence.getValue(), code, display, type, entityPackage, hides);
} }
public Entity(String uid, String code, String display, EntityType type, Group entityPackage) { public Entity(String uid, String code, String display, EntityType type, Group entityPackage,
Set<VisibilityModifier> hides) {
if (code == null || code.length() == 0) { if (code == null || code.length() == 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (display == null /* || display.length() == 0 */) { if (display == null /* || display.length() == 0 */) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.hides = hides;
this.uid = uid; this.uid = uid;
this.type = type; this.type = type;
this.code = code; this.code = code;
@ -105,30 +110,48 @@ public class Entity implements IEntity {
public void addFieldOrMethod(String s) { public void addFieldOrMethod(String s) {
if (isMethod(s)) { if (isMethod(s)) {
methods2.add(new Member(s, true)); methods.add(new Member(s, true));
} else { } else {
addField(s); addField(s);
} }
} }
public void addField(String s) { public void addField(String s) {
fields2.add(new Member(s, false)); fields.add(new Member(s, false));
} }
public void addField(Member s) { public void addField(Member s) {
fields2.add(s); fields.add(s);
} }
private boolean isMethod(String s) { private boolean isMethod(String s) {
return s.contains("(") || s.contains(")"); return s.contains("(") || s.contains(")");
} }
public List<Member> methods2() { public List<Member> getMethodsToDisplay() {
return Collections.unmodifiableList(methods2); if (hides==null || hides.size() == 0) {
return Collections.unmodifiableList(methods);
}
final List<Member> result = new ArrayList<Member>();
for (Member m : methods) {
if (hides.contains(m.getVisibilityModifier()) == false) {
result.add(m);
}
}
return Collections.unmodifiableList(result);
} }
public List<Member> fields2() { public List<Member> getFieldsToDisplay() {
return Collections.unmodifiableList(fields2); if (hides==null || hides.size() == 0) {
return Collections.unmodifiableList(fields);
}
final List<Member> result = new ArrayList<Member>();
for (Member m : fields) {
if (hides.contains(m.getVisibilityModifier()) == false) {
result.add(m);
}
}
return Collections.unmodifiableList(result);
} }
public EntityType getType() { public EntityType getType() {

View File

@ -99,7 +99,7 @@ public class EntityGenderUtils {
static public EntityGender emptyMethods() { static public EntityGender emptyMethods() {
return new EntityGender() { return new EntityGender() {
public boolean contains(IEntity test) { public boolean contains(IEntity test) {
return test.methods2().size()==0; return test.getMethodsToDisplay().size()==0;
} }
}; };
} }
@ -107,7 +107,7 @@ public class EntityGenderUtils {
static public EntityGender emptyFields() { static public EntityGender emptyFields() {
return new EntityGender() { return new EntityGender() {
public boolean contains(IEntity test) { public boolean contains(IEntity test) {
return test.fields2().size()==0; return test.getFieldsToDisplay().size()==0;
} }
}; };
} }
@ -115,7 +115,7 @@ public class EntityGenderUtils {
static public EntityGender emptyMembers() { static public EntityGender emptyMembers() {
return new EntityGender() { return new EntityGender() {
public boolean contains(IEntity test) { public boolean contains(IEntity test) {
return test.methods2().size()==0 && test.fields2().size()==0; return test.getMethodsToDisplay().size()==0 && test.getFieldsToDisplay().size()==0;
} }
}; };
} }

View File

@ -47,8 +47,8 @@ public abstract class EntityUtils {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
return new IEntity() { return new IEntity() {
public List<Member> fields2() { public List<Member> getFieldsToDisplay() {
return ent.fields2(); return ent.getFieldsToDisplay();
} }
public String getDisplay() { public String getDisplay() {
@ -79,8 +79,8 @@ public abstract class EntityUtils {
return ent.getUrl(); return ent.getUrl();
} }
public List<Member> methods2() { public List<Member> getMethodsToDisplay() {
return ent.methods2(); return ent.getMethodsToDisplay();
} }
public DrawFile getImageFile() { public DrawFile getImageFile() {

View File

@ -52,13 +52,13 @@ public interface IEntity extends Imaged, SpecificBackcolorable {
public String getUrl(); public String getUrl();
public List<Member> fields2(); public List<Member> getFieldsToDisplay();
public Stereotype getStereotype(); public Stereotype getStereotype();
public void setStereotype(Stereotype stereotype); public void setStereotype(Stereotype stereotype);
public List<Member> methods2(); public List<Member> getMethodsToDisplay();
public String getCode(); public String getCode();

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6009 $ * Revision $Revision: 6152 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram; package net.sourceforge.plantuml.cucadiagram;
@ -42,6 +42,7 @@ import net.sourceforge.plantuml.UniqueSequence;
import net.sourceforge.plantuml.cucadiagram.dot.DrawFile; import net.sourceforge.plantuml.cucadiagram.dot.DrawFile;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.HorizontalAlignement;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
@ -66,12 +67,19 @@ public class Link implements Imaged {
private final String labeldistance; private final String labeldistance;
private final String labelangle; private final String labelangle;
private HtmlColor specificColor;
public Link(IEntity cl1, IEntity cl2, LinkType type, String label, int length) { public Link(IEntity cl1, IEntity cl2, LinkType type, String label, int length) {
this(cl1, cl2, type, label, length, null, null, null, null); this(cl1, cl2, type, label, length, null, null, null, null, null);
} }
public Link(IEntity cl1, IEntity cl2, LinkType type, String label, int length, String qualifier1, public Link(IEntity cl1, IEntity cl2, LinkType type, String label, int length, String qualifier1,
String qualifier2, String labeldistance, String labelangle) { String qualifier2, String labeldistance, String labelangle) {
this(cl1, cl2, type, label, length, qualifier1, qualifier2, labeldistance, labelangle, null);
}
public Link(IEntity cl1, IEntity cl2, LinkType type, String label, int length, String qualifier1,
String qualifier2, String labeldistance, String labelangle, HtmlColor specificColor) {
if (length < 1) { if (length < 1) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -87,10 +95,27 @@ public class Link implements Imaged {
this.qualifier2 = qualifier2; this.qualifier2 = qualifier2;
this.labeldistance = labeldistance; this.labeldistance = labeldistance;
this.labelangle = labelangle; this.labelangle = labelangle;
this.specificColor = specificColor;
} }
public Link getInv() { public Link getInv() {
return new Link(cl2, cl1, type.getInv(), label, length, qualifier2, qualifier1, labeldistance, labelangle); return new Link(cl2, cl1, type.getInv(), label, length, qualifier2, qualifier1, labeldistance, labelangle,
specificColor);
}
public Link getDashed() {
return new Link(cl1, cl2, type.getDashed(), label, length, qualifier1, qualifier2, labeldistance, labelangle,
specificColor);
}
public Link getDotted() {
return new Link(cl1, cl2, type.getDotted(), label, length, qualifier1, qualifier2, labeldistance, labelangle,
specificColor);
}
public Link getBold() {
return new Link(cl1, cl2, type.getBold(), label, length, qualifier1, qualifier2, labeldistance, labelangle,
specificColor);
} }
public String getLabeldistance() { public String getLabeldistance() {
@ -281,4 +306,12 @@ public class Link implements Imaged {
return 0; return 0;
} }
public HtmlColor getSpecificColor() {
return specificColor;
}
public void setSpecificColor(String s) {
this.specificColor = HtmlColor.getColorIfValid(s);
}
} }

View File

@ -35,6 +35,6 @@ package net.sourceforge.plantuml.cucadiagram;
public enum LinkStyle { public enum LinkStyle {
NORMAL, DASHED, INTERFACE_PROVIDER, INTERFACE_USER; NORMAL, DASHED, INTERFACE_PROVIDER, INTERFACE_USER, DOTTED, BOLD;
} }

View File

@ -73,10 +73,26 @@ public class LinkType {
return style == LinkStyle.DASHED; return style == LinkStyle.DASHED;
} }
public boolean isDotted() {
return style == LinkStyle.DOTTED;
}
public boolean isBold() {
return style == LinkStyle.BOLD;
}
public LinkType getDashed() { public LinkType getDashed() {
return new LinkType(decor1, LinkStyle.DASHED, decor2); return new LinkType(decor1, LinkStyle.DASHED, decor2);
} }
public LinkType getDotted() {
return new LinkType(decor1, LinkStyle.DOTTED, decor2);
}
public LinkType getBold() {
return new LinkType(decor1, LinkStyle.BOLD, decor2);
}
public LinkType getInterfaceProvider() { public LinkType getInterfaceProvider() {
return new LinkType(decor1, LinkStyle.INTERFACE_PROVIDER, decor2); return new LinkType(decor1, LinkStyle.INTERFACE_PROVIDER, decor2);
} }
@ -114,6 +130,12 @@ public class LinkType {
if (style == LinkStyle.DASHED) { if (style == LinkStyle.DASHED) {
sb.append(",style=dashed"); sb.append(",style=dashed");
} }
if (style == LinkStyle.DOTTED) {
sb.append(",style=dotted,");
}
if (style == LinkStyle.BOLD) {
sb.append(",style=bold,");
}
return sb.toString(); return sb.toString();
} }

View File

@ -41,11 +41,6 @@ public class Member {
private final boolean staticModifier; private final boolean staticModifier;
private final boolean abstractModifier; private final boolean abstractModifier;
private boolean privateModifier;
private boolean protectedModifier;
private boolean publicModifier;
private boolean packagePrivateModifier;
private final VisibilityModifier visibilityModifier; private final VisibilityModifier visibilityModifier;
public Member(String display, boolean isMethod) { public Member(String display, boolean isMethod) {
@ -55,30 +50,15 @@ public class Member {
final String displayClean = display.replaceAll("(?i)\\{(static|classifier|abstract)\\}", "").trim(); final String displayClean = display.replaceAll("(?i)\\{(static|classifier|abstract)\\}", "").trim();
if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) { if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
updateVisibility(display.charAt(0));
visibilityModifier = VisibilityModifier.getVisibilityModifier(display.charAt(0), isMethod == false); visibilityModifier = VisibilityModifier.getVisibilityModifier(display.charAt(0), isMethod == false);
this.display = displayClean.substring(1).trim(); this.display = displayClean.substring(1).trim();
} else { } else {
this.display = displayClean; this.display = displayClean;
visibilityModifier = null; visibilityModifier = null;
} }
// assert VisibilityModifier.isVisibilityCharacter(this.display.charAt(0)) == false; // assert
// VisibilityModifier.isVisibilityCharacter(this.display.charAt(0)) ==
} // false;
private void updateVisibility(char c) {
if (c == '-') {
this.privateModifier = true;
}
if (c == '#') {
this.protectedModifier = true;
}
if (c == '+') {
this.publicModifier = true;
}
if (c == '~') {
this.packagePrivateModifier = true;
}
} }
@ -130,23 +110,27 @@ public class Member {
} }
public final boolean isVisibilityModified() { public final boolean isVisibilityModified() {
return privateModifier || publicModifier || protectedModifier || packagePrivateModifier; return visibilityModifier != null;
} }
public final boolean isPrivate() { public final boolean isPrivate() {
return privateModifier; return visibilityModifier == VisibilityModifier.PRIVATE_FIELD
|| visibilityModifier == VisibilityModifier.PRIVATE_METHOD;
} }
public final boolean isProtected() { public final boolean isProtected() {
return protectedModifier; return visibilityModifier == VisibilityModifier.PROTECTED_FIELD
|| visibilityModifier == VisibilityModifier.PROTECTED_METHOD;
} }
public final boolean isPublic() { public final boolean isPublic() {
return publicModifier; return visibilityModifier == VisibilityModifier.PUBLIC_FIELD
|| visibilityModifier == VisibilityModifier.PUBLIC_METHOD;
} }
public final boolean isPackagePrivate() { public final boolean isPackagePrivate() {
return packagePrivateModifier; return visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_FIELD
|| visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_METHOD;
} }
public final VisibilityModifier getVisibilityModifier() { public final VisibilityModifier getVisibilityModifier() {

View File

@ -0,0 +1,184 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6104 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.graphic.GraphicStrings;
class AbstractGraphviz2 implements Graphviz {
private final OS os;
private final GraphvizLayoutStrategy strategy;
private final String dotString;
private final String[] type;
AbstractGraphviz2(OS os, GraphvizLayoutStrategy strategy, String dotString, String... type) {
if (type == null) {
throw new IllegalArgumentException();
}
this.os = os;
this.strategy = strategy;
this.dotString = dotString;
this.type = type;
}
final public void createPng(OutputStream os) throws IOException, InterruptedException {
if (dotString == null) {
throw new IllegalArgumentException();
}
if (illegalDotExe()) {
createPngNoGraphviz(os, new FileFormatOption(FileFormat.valueOf(type[0].toUpperCase())));
return;
}
final String cmd = getCommandLine();
ProcessRunner p = null;
try {
Log.info("Starting Graphviz process " + cmd);
Log.info("DotString size: " + dotString.length());
p = new ProcessRunner(cmd);
p.run(dotString.getBytes(), os);
Log.info("Ending process ok");
} catch (Throwable e) {
e.printStackTrace();
Log.error("Error: " + e);
Log.error("The command was " + cmd);
Log.error("");
Log.error("Try java -jar plantuml.jar -testdot to figure out the issue");
Log.error("");
} finally {
Log.info("Ending Graphviz process");
}
if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getError().length() > 0) {
Log.error("GraphViz error stream : " + p.getError());
if (OptionFlags.getInstance().isCheckDotError()) {
throw new IllegalStateException("Dot error " + p.getError());
}
}
if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getOut().length() > 0) {
Log.error("GraphViz out stream : " + p.getOut());
if (OptionFlags.getInstance().isCheckDotError()) {
throw new IllegalStateException("Dot out " + p.getOut());
}
}
}
private String getCommandLine() {
final StringBuilder sb = new StringBuilder();
sb.append(os.getCommand(strategy));
appendImageType(sb);
return sb.toString();
}
public String dotVersion() throws IOException, InterruptedException {
final String cmd = os.getCommand(strategy)+" -V";
return executeCmd(cmd);
}
public File getDotExe() {
return os.getExecutable(strategy);
}
private boolean illegalDotExe() {
final File exe = getDotExe();
return exe == null || exe.isFile() == false || exe.canRead() == false;
}
private String executeCmd(final String cmd) throws IOException, InterruptedException {
final ProcessRunner p = new ProcessRunner(cmd);
p.run(null, null);
final StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(p.getOut())) {
sb.append(p.getOut());
}
if (StringUtils.isNotEmpty(p.getError())) {
if (sb.length() > 0) {
sb.append(' ');
}
sb.append(p.getError());
}
return sb.toString().replace('\n', ' ').trim();
}
final private void createPngNoGraphviz(OutputStream os, FileFormatOption format) throws IOException {
final List<String> msg = new ArrayList<String>();
final File exe = getDotExe();
msg.add("Dot Executable: " + exe);
if (exe != null) {
if (exe.exists() == false) {
msg.add("File does not exist");
} else if (exe.isDirectory()) {
msg.add("It should be an executable, not a directory");
} else if (exe.isFile() == false) {
msg.add("Not a valid file");
} else if (exe.canRead() == false) {
msg.add("File cannot be read");
}
}
msg.add("Cannot find Graphviz. You should try");
msg.add(" ");
msg.add("@startuml");
msg.add("testdot");
msg.add("@enduml");
msg.add(" ");
msg.add(" or ");
msg.add(" ");
msg.add("java -jar plantuml.jar -testdot");
final GraphicStrings errorResult = new GraphicStrings(msg);
errorResult.writeImage(os, format);
}
private final void appendImageType(final StringBuilder sb) {
for (String t : type) {
sb.append(" -T" + t + " ");
}
}
}

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6130 $ * Revision $Revision: 6197 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram.dot; package net.sourceforge.plantuml.cucadiagram.dot;
@ -57,6 +57,8 @@ import java.util.regex.Pattern;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.EmptyImageBuilder;
@ -966,8 +968,9 @@ public final class CucaDiagramFileMaker {
dotData.setVisibilityModifierPresent(true); dotData.setVisibilityModifierPresent(true);
} }
} }
return new DotMaker(dotData, dotStrings, fileFormat); return diagram.getStrategy().getGraphvizMaker(dotData, dotStrings, fileFormat);
// return new DotMaker(dotData, dotStrings, fileFormat);
} }
private void populateImages(double dpiFactor, int dpi) throws IOException { private void populateImages(double dpiFactor, int dpi) throws IOException {

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5789 $ * Revision $Revision: 6169 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram.dot; package net.sourceforge.plantuml.cucadiagram.dot;
@ -83,11 +83,11 @@ public final class CucaDiagramSimplifier {
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
final Entity proxy = new Entity("#" + g.getCode(), g.getDisplay(), type, g.getParent()); final Entity proxy = new Entity("#" + g.getCode(), g.getDisplay(), type, g.getParent(), diagram.getHides());
if (type == EntityType.STATE) { if (type == EntityType.STATE) {
manageBackColorForState(diagram, g, proxy); manageBackColorForState(diagram, g, proxy);
} }
for (Member field : g.getEntityCluster().fields2()) { for (Member field : g.getEntityCluster().getFieldsToDisplay()) {
proxy.addField(field); proxy.addField(field);
} }
computeImageGroup(g, proxy, dotStrings); computeImageGroup(g, proxy, dotStrings);

View File

@ -126,14 +126,14 @@ public final class CucaDiagramTxtMaker {
int y = 2; int y = 2;
ug.getCharArea().drawHLine('-', y, 1, w - 1); ug.getCharArea().drawHLine('-', y, 1, w - 1);
y++; y++;
for (Member att : ent.fields2()) { for (Member att : ent.getFieldsToDisplay()) {
final List<String> disp = StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()); final List<String> disp = StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar());
ug.getCharArea().drawStringsLR(disp, 1, y); ug.getCharArea().drawStringsLR(disp, 1, y);
y += StringUtils.getHeight(disp); y += StringUtils.getHeight(disp);
} }
ug.getCharArea().drawHLine('-', y, 1, w - 1); ug.getCharArea().drawHLine('-', y, 1, w - 1);
y++; y++;
for (Member att : ent.methods2()) { for (Member att : ent.getMethodsToDisplay()) {
final List<String> disp = StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()); final List<String> disp = StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar());
ug.getCharArea().drawStringsLR(disp, 1, y); ug.getCharArea().drawStringsLR(disp, 1, y);
y += StringUtils.getHeight(disp); y += StringUtils.getHeight(disp);
@ -151,10 +151,10 @@ public final class CucaDiagramTxtMaker {
private int getHeight(Entity entity) { private int getHeight(Entity entity) {
int result = StringUtils.getHeight(StringUtils.getWithNewlines(entity.getDisplay())); int result = StringUtils.getHeight(StringUtils.getWithNewlines(entity.getDisplay()));
for (Member att : entity.methods2()) { for (Member att : entity.getMethodsToDisplay()) {
result += StringUtils.getHeight(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar())); result += StringUtils.getHeight(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()));
} }
for (Member att : entity.fields2()) { for (Member att : entity.getFieldsToDisplay()) {
result += StringUtils.getHeight(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar())); result += StringUtils.getHeight(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()));
} }
return result + 4; return result + 4;
@ -162,13 +162,13 @@ public final class CucaDiagramTxtMaker {
private int getWidth(Entity entity) { private int getWidth(Entity entity) {
int result = StringUtils.getWidth(StringUtils.getWithNewlines(entity.getDisplay())); int result = StringUtils.getWidth(StringUtils.getWithNewlines(entity.getDisplay()));
for (Member att : entity.methods2()) { for (Member att : entity.getMethodsToDisplay()) {
final int w = StringUtils.getWidth(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar())); final int w = StringUtils.getWidth(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()));
if (w > result) { if (w > result) {
result = w; result = w;
} }
} }
for (Member att : entity.fields2()) { for (Member att : entity.getFieldsToDisplay()) {
final int w = StringUtils.getWidth(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar())); final int w = StringUtils.getWidth(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()));
if (w > result) { if (w > result) {
result = w; result = w;

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6141 $ * Revision $Revision: 6195 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram.dot; package net.sourceforge.plantuml.cucadiagram.dot;
@ -148,7 +148,6 @@ final public class DotMaker implements GraphvizMaker {
} }
private void initPrintWriter(StringBuilder sb) { private void initPrintWriter(StringBuilder sb) {
Log.info("Entities = " + data.getEntities().size()); Log.info("Entities = " + data.getEntities().size());
@ -195,7 +194,7 @@ final public class DotMaker implements GraphvizMaker {
for (Group g : data.getGroupHierarchy().getChildrenGroups(parent)) { for (Group g : data.getGroupHierarchy().getChildrenGroups(parent)) {
if (data.isEmpty(g) && g.getType() == GroupType.PACKAGE) { if (data.isEmpty(g) && g.getType() == GroupType.PACKAGE) {
final IEntity folder = new Entity(g.getUid(), g.getCode(), g.getDisplay(), EntityType.EMPTY_PACKAGE, final IEntity folder = new Entity(g.getUid(), g.getCode(), g.getDisplay(), EntityType.EMPTY_PACKAGE,
null); null, null);
printEntity(sb, folder); printEntity(sb, folder);
} else { } else {
printGroup(sb, g); printGroup(sb, g);
@ -346,9 +345,9 @@ final public class DotMaker implements GraphvizMaker {
if (g.getDisplay() != null) { if (g.getDisplay() != null) {
final StringBuilder label = new StringBuilder(manageHtmlIB(g.getDisplay(), getFontParamForGroup(), null)); final StringBuilder label = new StringBuilder(manageHtmlIB(g.getDisplay(), getFontParamForGroup(), null));
if (g.getEntityCluster().fields2().size() > 0) { if (g.getEntityCluster().getFieldsToDisplay().size() > 0) {
label.append("<BR ALIGN=\"LEFT\"/>"); label.append("<BR ALIGN=\"LEFT\"/>");
for (Member att : g.getEntityCluster().fields2()) { for (Member att : g.getEntityCluster().getFieldsToDisplay()) {
label.append(manageHtmlIB(" " + att.getDisplayWithVisibilityChar() + " ", label.append(manageHtmlIB(" " + att.getDisplayWithVisibilityChar() + " ",
FontParam.STATE_ATTRIBUTE, null)); FontParam.STATE_ATTRIBUTE, null));
label.append("<BR ALIGN=\"LEFT\"/>"); label.append("<BR ALIGN=\"LEFT\"/>");
@ -512,7 +511,7 @@ final public class DotMaker implements GraphvizMaker {
} }
private void printLink(StringBuilder sb, Link link) throws IOException { private void printLink(StringBuilder sb, Link link) throws IOException {
final StringBuilder decoration = getLinkDecoration(); final StringBuilder decoration = getLinkDecoration(link);
if (link.getWeight() > 1) { if (link.getWeight() > 1) {
decoration.append("weight=" + link.getWeight() + ","); decoration.append("weight=" + link.getWeight() + ",");
@ -611,8 +610,14 @@ final public class DotMaker implements GraphvizMaker {
return g.getUid() + "_" + link.getUid(); return g.getUid() + "_" + link.getUid();
} }
private StringBuilder getLinkDecoration() { private StringBuilder getLinkDecoration(Link link) {
final StringBuilder decoration = new StringBuilder("[color=" + getColorString(getArrowColorParam(), null) + ","); final StringBuilder decoration = new StringBuilder("[color=");
if (link.getSpecificColor() == null) {
decoration.append(getColorString(getArrowColorParam(), null));
} else {
decoration.append("\"" + link.getSpecificColor().getAsHtml() + "\"");
}
decoration.append(",");
decoration.append("fontcolor=" + getFontColorString(getArrowFontParam(), null) + ","); decoration.append("fontcolor=" + getFontColorString(getArrowFontParam(), null) + ",");
decoration.append("fontsize=\"" + data.getSkinParam().getFontSize(getArrowFontParam(), null) + "\","); decoration.append("fontsize=\"" + data.getSkinParam().getFontSize(getArrowFontParam(), null) + "\",");
@ -838,7 +843,7 @@ final public class DotMaker implements GraphvizMaker {
sb.append(entity.getUid() + " [margin=0,pad=0," + label + ",shape=none,image=\"" + absolutePath + "\"];"); sb.append(entity.getUid() + " [margin=0,pad=0," + label + ",shape=none,image=\"" + absolutePath + "\"];");
} else if (type == EntityType.ACTIVITY) { } else if (type == EntityType.ACTIVITY) {
String shape = "octagon"; String shape = "octagon";
if (data.getSkinParam().useOctagonForActivity()==false || entity.getImageFile() != null) { if (data.getSkinParam().useOctagonForActivity() == false || entity.getImageFile() != null) {
shape = "rect"; shape = "rect";
} }
sb.append(entity.getUid() + " [fontcolor=" + getFontColorString(FontParam.ACTIVITY, stereo) + ",fillcolor=" sb.append(entity.getUid() + " [fontcolor=" + getFontColorString(FontParam.ACTIVITY, stereo) + ",fillcolor="
@ -908,7 +913,7 @@ final public class DotMaker implements GraphvizMaker {
} else { } else {
throw new IllegalStateException(type.toString() + " " + data.getUmlDiagramType()); throw new IllegalStateException(type.toString() + " " + data.getUmlDiagramType());
} }
if (entity.isTop()) { if (entity.isTop()) {
rankMin.add(entity.getUid()); rankMin.add(entity.getUid());
} }
@ -1020,9 +1025,9 @@ final public class DotMaker implements GraphvizMaker {
sb.append("<TR><TD>" + manageHtmlIB(entity.getDisplay(), FontParam.STATE, stereotype) + "</TD></TR>"); sb.append("<TR><TD>" + manageHtmlIB(entity.getDisplay(), FontParam.STATE, stereotype) + "</TD></TR>");
sb.append("</TABLE>"); sb.append("</TABLE>");
if (entity.fields2().size() > 0) { if (entity.getFieldsToDisplay().size() > 0) {
sb.append("|"); sb.append("|");
for (Member att : entity.fields2()) { for (Member att : entity.getFieldsToDisplay()) {
sb.append(manageHtmlIB(att.getDisplayWithVisibilityChar(), FontParam.STATE_ATTRIBUTE, stereotype)); sb.append(manageHtmlIB(att.getDisplayWithVisibilityChar(), FontParam.STATE_ATTRIBUTE, stereotype));
sb.append("<BR ALIGN=\"LEFT\"/>"); sb.append("<BR ALIGN=\"LEFT\"/>");
} }
@ -1046,7 +1051,7 @@ final public class DotMaker implements GraphvizMaker {
sb.append("</TABLE>"); sb.append("</TABLE>");
} }
if (entity.fields2().size() == 0 && cFile == null) { if (entity.getFieldsToDisplay().size() == 0 && cFile == null) {
sb.append("|"); sb.append("|");
} }
@ -1252,9 +1257,9 @@ final public class DotMaker implements GraphvizMaker {
// if (fileFormat == FileFormat.EPS) { // if (fileFormat == FileFormat.EPS) {
// sb.append(addFieldsEps(entity.fields2(), true)); // sb.append(addFieldsEps(entity.fields2(), true));
// } else { // } else {
final boolean hasStatic = hasStatic(entity.fields2()); final boolean hasStatic = hasStatic(entity.getFieldsToDisplay());
sb.append("<TR ALIGN=\"LEFT\"><TD " + getWitdh55() + " ALIGN=\"LEFT\">"); sb.append("<TR ALIGN=\"LEFT\"><TD " + getWitdh55() + " ALIGN=\"LEFT\">");
for (Member att : entity.fields2()) { for (Member att : entity.getFieldsToDisplay()) {
sb.append(manageHtmlIBspecial(att, FontParam.CLASS_ATTRIBUTE, hasStatic, getColorString( sb.append(manageHtmlIBspecial(att, FontParam.CLASS_ATTRIBUTE, hasStatic, getColorString(
ColorParam.classBackground, stereo), true)); ColorParam.classBackground, stereo), true));
sb.append("<BR ALIGN=\"LEFT\"/>"); sb.append("<BR ALIGN=\"LEFT\"/>");
@ -1266,9 +1271,9 @@ final public class DotMaker implements GraphvizMaker {
// if (fileFormat == FileFormat.EPS) { // if (fileFormat == FileFormat.EPS) {
// sb.append(addFieldsEps(entity.methods2(), true)); // sb.append(addFieldsEps(entity.methods2(), true));
// } else { // } else {
final boolean hasStatic = hasStatic(entity.methods2()); final boolean hasStatic = hasStatic(entity.getMethodsToDisplay());
sb.append("<TR ALIGN=\"LEFT\"><TD ALIGN=\"LEFT\">"); sb.append("<TR ALIGN=\"LEFT\"><TD ALIGN=\"LEFT\">");
for (Member att : entity.methods2()) { for (Member att : entity.getMethodsToDisplay()) {
sb.append(manageHtmlIBspecial(att, FontParam.CLASS_ATTRIBUTE, hasStatic, getColorString( sb.append(manageHtmlIBspecial(att, FontParam.CLASS_ATTRIBUTE, hasStatic, getColorString(
ColorParam.classBackground, stereo), true)); ColorParam.classBackground, stereo), true));
sb.append("<BR ALIGN=\"LEFT\"/>"); sb.append("<BR ALIGN=\"LEFT\"/>");
@ -1365,14 +1370,14 @@ final public class DotMaker implements GraphvizMaker {
if (showFields) { if (showFields) {
sb.append("<TR><TD " + getWitdh55() + ">"); sb.append("<TR><TD " + getWitdh55() + ">");
if (entity.fields2().size() > 0) { if (entity.getFieldsToDisplay().size() > 0) {
buildTableVisibility(entity, true, sb, springField); buildTableVisibility(entity, true, sb, springField);
} }
sb.append("</TD></TR>"); sb.append("</TD></TR>");
} }
if (showMethods) { if (showMethods) {
sb.append("<TR><TD>"); sb.append("<TR><TD>");
if (entity.methods2().size() > 0) { if (entity.getMethodsToDisplay().size() > 0) {
buildTableVisibility(entity, false, sb, springMethod); buildTableVisibility(entity, false, sb, springMethod);
} }
sb.append("</TD></TR>"); sb.append("</TD></TR>");
@ -1400,9 +1405,9 @@ final public class DotMaker implements GraphvizMaker {
throws IOException { throws IOException {
sb.append("<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">"); sb.append("<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">");
final boolean hasStatic = hasStatic(entity.methods2()); final boolean hasStatic = hasStatic(entity.getMethodsToDisplay());
final boolean dpiNormal = data.getDpi() == 96; final boolean dpiNormal = data.getDpi() == 96;
for (Member att : isField ? entity.fields2() : entity.methods2()) { for (Member att : isField ? entity.getFieldsToDisplay() : entity.getMethodsToDisplay()) {
sb.append("<TR>"); sb.append("<TR>");
if (dpiNormal) { if (dpiNormal) {
sb.append("<TD WIDTH=\"10\">"); sb.append("<TD WIDTH=\"10\">");
@ -1454,7 +1459,7 @@ final public class DotMaker implements GraphvizMaker {
private int getLongestMethods(IEntity entity) { private int getLongestMethods(IEntity entity) {
int result = 0; int result = 0;
for (Member att : entity.methods2()) { for (Member att : entity.getMethodsToDisplay()) {
final int size = att.getDisplayWithVisibilityChar().length(); final int size = att.getDisplayWithVisibilityChar().length();
if (size > result) { if (size > result) {
result = size; result = size;
@ -1466,7 +1471,7 @@ final public class DotMaker implements GraphvizMaker {
private int getLongestField(IEntity entity) { private int getLongestField(IEntity entity) {
int result = 0; int result = 0;
for (Member att : entity.fields2()) { for (Member att : entity.getFieldsToDisplay()) {
final int size = att.getDisplayWithVisibilityChar().length(); final int size = att.getDisplayWithVisibilityChar().length();
if (size > result) { if (size > result) {
result = size; result = size;
@ -1501,7 +1506,7 @@ final public class DotMaker implements GraphvizMaker {
sb.append("</TD></TR>"); sb.append("</TD></TR>");
sb.append("<TR><TD " + getWitdh55() + ">"); sb.append("<TR><TD " + getWitdh55() + ">");
if (entity.fields2().size() == 0) { if (entity.getFieldsToDisplay().size() == 0) {
sb.append(manageHtmlIB(" ", FontParam.OBJECT_ATTRIBUTE, stereo)); sb.append(manageHtmlIB(" ", FontParam.OBJECT_ATTRIBUTE, stereo));
} else { } else {
buildTableVisibility(entity, true, sb, springField); buildTableVisibility(entity, true, sb, springField);
@ -1532,10 +1537,10 @@ final public class DotMaker implements GraphvizMaker {
sb.append("</TD></TR>"); sb.append("</TD></TR>");
sb.append("<TR ALIGN=\"LEFT\"><TD " + getWitdh55() + " ALIGN=\"LEFT\">"); sb.append("<TR ALIGN=\"LEFT\"><TD " + getWitdh55() + " ALIGN=\"LEFT\">");
if (entity.fields2().size() == 0) { if (entity.getFieldsToDisplay().size() == 0) {
sb.append(manageHtmlIB(" ", FontParam.OBJECT_ATTRIBUTE, stereo)); sb.append(manageHtmlIB(" ", FontParam.OBJECT_ATTRIBUTE, stereo));
} else { } else {
for (Member att : entity.fields2()) { for (Member att : entity.getFieldsToDisplay()) {
sb.append(manageHtmlIB(att.getDisplayWithVisibilityChar(), FontParam.OBJECT_ATTRIBUTE, stereo)); sb.append(manageHtmlIB(att.getDisplayWithVisibilityChar(), FontParam.OBJECT_ATTRIBUTE, stereo));
sb.append("<BR ALIGN=\"LEFT\"/>"); sb.append("<BR ALIGN=\"LEFT\"/>");
} }

View File

@ -0,0 +1,135 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6104 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.graphic.GraphicStrings;
abstract class Executable {
private final File dotExe;
static boolean isWindows() {
return File.separatorChar == '\\';
}
Executable(String dotString, String... type) {
if (type == null) {
throw new IllegalArgumentException();
}
this.dotExe = searchDotExe();
}
private File searchDotExe() {
if (OptionFlags.getInstance().getDotExecutable() == null) {
final String getenv = GraphvizUtils.getenvGraphvizDot();
if (getenv == null) {
return specificDotExe();
}
return new File(getenv);
}
return new File(OptionFlags.getInstance().getDotExecutable());
}
abstract protected File specificDotExe();
final public String dotVersion() throws IOException, InterruptedException {
final String cmd = getCommandLineVersion();
return executeCmd(cmd);
}
private String executeCmd(final String cmd) throws IOException, InterruptedException {
final ProcessRunner p = new ProcessRunner(cmd);
p.run(null, null);
final StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(p.getOut())) {
sb.append(p.getOut());
}
if (StringUtils.isNotEmpty(p.getError())) {
if (sb.length() > 0) {
sb.append(' ');
}
sb.append(p.getError());
}
return sb.toString().replace('\n', ' ').trim();
}
final private void createPngNoGraphviz(OutputStream os, FileFormatOption format) throws IOException {
final List<String> msg = new ArrayList<String>();
msg.add("Dot Executable: " + dotExe);
if (dotExe != null) {
if (dotExe.exists() == false) {
msg.add("File does not exist");
} else if (dotExe.isDirectory()) {
msg.add("It should be an executable, not a directory");
} else if (dotExe.isFile() == false) {
msg.add("Not a valid file");
} else if (dotExe.canRead() == false) {
msg.add("File cannot be read");
}
}
msg.add("Cannot find Graphviz. You should try");
msg.add(" ");
msg.add("@startuml");
msg.add("testdot");
msg.add("@enduml");
msg.add(" ");
msg.add(" or ");
msg.add(" ");
msg.add("java -jar plantuml.jar -testdot");
final GraphicStrings errorResult = new GraphicStrings(msg);
errorResult.writeImage(os, format);
}
abstract String getCommandLine();
abstract String getCommandLineVersion();
public final File getDotExe() {
return dotExe;
}
}

View File

@ -0,0 +1,73 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 3977 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
import java.util.List;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.OptionFlags;
public enum GraphvizLayoutStrategy {
DOT, NEATO;
public GraphvizMaker getGraphvizMaker(DotData data,
List<String> dotStrings, FileFormat fileFormat) {
if (this == DOT) {
return new DotMaker(data, dotStrings, fileFormat);
}
throw new UnsupportedOperationException(this.toString());
}
public File getSystemForcedExecutable() {
if (this == DOT) {
return getSystemForcedDot();
}
throw new UnsupportedOperationException(this.toString());
}
private File getSystemForcedDot() {
if (OptionFlags.getInstance().getDotExecutable() == null) {
final String getenv = GraphvizUtils.getenvGraphvizDot();
if (getenv == null) {
return null;
}
return new File(getenv);
}
return new File(OptionFlags.getInstance().getDotExecutable());
}
}

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6007 $ * Revision $Revision: 6200 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram.dot; package net.sourceforge.plantuml.cucadiagram.dot;
@ -51,6 +51,7 @@ public class GraphvizUtils {
return File.separatorChar == '\\'; return File.separatorChar == '\\';
} }
@Deprecated
public static Graphviz create(String dotString, String... type) { public static Graphviz create(String dotString, String... type) {
if (isWindows()) { if (isWindows()) {
return new GraphvizWindows(dotString, type); return new GraphvizWindows(dotString, type);
@ -58,6 +59,10 @@ public class GraphvizUtils {
return new GraphvizLinux(dotString, type); return new GraphvizLinux(dotString, type);
} }
public static Graphviz create2(GraphvizLayoutStrategy strategy, String dotString, String... type) {
return new AbstractGraphviz2(getOS(), strategy, dotString, type);
}
static public File getDotExe() { static public File getDotExe() {
return create(null, "png").getDotExe(); return create(null, "png").getDotExe();
} }
@ -161,5 +166,12 @@ public class GraphvizUtils {
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
} }
public static OS getOS() {
if (isWindows()) {
return new OSWindows();
}
return new OSLinux();
}
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5872 $ * Revision $Revision: 6197 $
* *
*/ */
package net.sourceforge.plantuml.cucadiagram.dot; package net.sourceforge.plantuml.cucadiagram.dot;
@ -47,6 +47,8 @@ import java.util.Map;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileUtils; import net.sourceforge.plantuml.FileUtils;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
@ -214,7 +216,8 @@ public final class GroupPngMaker {
// dotData.putAllStaticImages(staticImages); // dotData.putAllStaticImages(staticImages);
// dotData.putAllImagesLink(imagesLink); // dotData.putAllImagesLink(imagesLink);
return new DotMaker(dotData, dotStrings, fileFormat); // return new DotMaker(dotData, dotStrings, fileFormat);
return diagram.getStrategy().getGraphvizMaker(dotData, dotStrings, fileFormat);
} }
private List<Link> getPureInnerLinks() { private List<Link> getPureInnerLinks() {

View File

@ -0,0 +1,50 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6104 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
abstract class OS {
static boolean isWindows() {
return File.separatorChar == '\\';
}
abstract String getFileName(GraphvizLayoutStrategy strategy);
abstract File getExecutable(GraphvizLayoutStrategy strategy);
public abstract String getCommand(GraphvizLayoutStrategy strategy);
}

View File

@ -0,0 +1,66 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6104 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
class OSLinux extends OS {
@Override
File getExecutable(GraphvizLayoutStrategy strategy) {
File result = strategy.getSystemForcedExecutable();
if (result != null) {
return result;
}
final String fileName = getFileName(strategy);
final File usrLocalBin = new File("/usr/local/bin/" + fileName);
if (usrLocalBin.exists()) {
return usrLocalBin;
}
final File usrBin = new File("/usr/bin/" + fileName);
return usrBin;
}
@Override
String getFileName(GraphvizLayoutStrategy strategy) {
return strategy.name().toLowerCase();
}
@Override
public String getCommand(GraphvizLayoutStrategy strategy) {
return getExecutable(strategy).getAbsolutePath();
}
}

View File

@ -0,0 +1,94 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6104 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class OSWindows extends OS {
@Override
File getExecutable(GraphvizLayoutStrategy strategy) {
File result = strategy.getSystemForcedExecutable();
if (result != null) {
return result;
}
result = searchInDir(new File("c:/Program Files"), strategy);
if (result != null) {
return result;
}
result = searchInDir(new File("c:/Program Files (x86)"), strategy);
return result;
}
private File searchInDir(final File programFile, GraphvizLayoutStrategy strategy) {
if (programFile.exists() == false || programFile.isDirectory() == false) {
return null;
}
final List<File> dots = new ArrayList<File>();
for (File f : programFile.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory() && pathname.getName().startsWith("Graphviz");
}
})) {
final File result = new File(new File(f, "bin"), getFileName(strategy));
if (result.exists() && result.canRead()) {
dots.add(result.getAbsoluteFile());
}
}
return higherVersion(dots);
}
static File higherVersion(List<File> dots) {
if (dots.size() == 0) {
return null;
}
Collections.sort(dots, Collections.reverseOrder());
return dots.get(0);
}
@Override
String getFileName(GraphvizLayoutStrategy strategy) {
return strategy.name().toLowerCase() + ".exe";
}
@Override
public String getCommand(GraphvizLayoutStrategy strategy) {
return "\"" + getExecutable(strategy).getAbsolutePath() + "\"";
}
}

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6009 $ * Revision $Revision: 6168 $
* *
*/ */
package net.sourceforge.plantuml.graph; package net.sourceforge.plantuml.graph;
@ -63,8 +63,8 @@ class EntityImageClass extends AbstractEntityImage {
super(entity); super(entity);
this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration(
getFont14(), Color.BLACK), HorizontalAlignement.CENTER); getFont14(), Color.BLACK), HorizontalAlignement.CENTER);
this.methods = new MethodsOrFieldsArea(entity.methods2(), getFont14()); this.methods = new MethodsOrFieldsArea(entity.getMethodsToDisplay(), getFont14());
this.fields = new MethodsOrFieldsArea(entity.fields2(), getFont14()); this.fields = new MethodsOrFieldsArea(entity.getFieldsToDisplay(), getFont14());
circledCharacter = getCircledCharacter(entity); circledCharacter = getCircledCharacter(entity);

View File

@ -82,8 +82,8 @@ public class EntityImageClass2 extends AbstractEntityImage2 {
getFont(FontParam.CLASS_STEREOTYPE), getFontColor(FontParam.CLASS_STEREOTYPE)), getFont(FontParam.CLASS_STEREOTYPE), getFontColor(FontParam.CLASS_STEREOTYPE)),
HorizontalAlignement.CENTER); HorizontalAlignement.CENTER);
} }
this.methods = new MethodsOrFieldsArea2(entity.methods2(), FontParam.CLASS_ATTRIBUTE, skinParam); this.methods = new MethodsOrFieldsArea2(entity.getMethodsToDisplay(), FontParam.CLASS_ATTRIBUTE, skinParam);
this.fields = new MethodsOrFieldsArea2(entity.fields2(), FontParam.CLASS_ATTRIBUTE, skinParam); this.fields = new MethodsOrFieldsArea2(entity.getFieldsToDisplay(), FontParam.CLASS_ATTRIBUTE, skinParam);
circledCharacter = getCircledCharacter(entity); circledCharacter = getCircledCharacter(entity);
} }

View File

@ -0,0 +1,112 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4167 $
*
*/
package net.sourceforge.plantuml.postit;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class Area implements Elastic {
private final String title;
private final char id;
private Dimension2D minimunDimension;
private final List<PostIt> postIts = new ArrayList<PostIt>();
public Area(char id, String title) {
this.id = id;
this.title = title;
}
public char getId() {
return id;
}
public String getTitle() {
return title;
}
public Dimension2D getMinimunDimension() {
return minimunDimension;
}
public void setMinimunDimension(Dimension2D minimunDimension) {
this.minimunDimension = minimunDimension;
}
public Dimension2D getDimension() {
throw new UnsupportedOperationException();
}
public double heightWhenWidthIs(double width, StringBounder stringBounder) {
final AreaLayoutFixedWidth layout = new AreaLayoutFixedWidth();
final Map<PostIt, Point2D> pos = layout.getPositions(postIts, stringBounder);
double max = 10;
for (Map.Entry<PostIt, Point2D> ent : pos.entrySet()) {
final double y = ent.getKey().getDimension(stringBounder).getHeight() + ent.getValue().getY();
max = Math.max(max, y);
}
return max + 10;
}
public double widthWhenHeightIs(double height, StringBounder stringBounder) {
throw new UnsupportedOperationException();
}
public void add(PostIt postIt) {
postIts.add(postIt);
}
public void drawU(UGraphic ug) {
final AreaLayout layout = new AreaLayoutFixedWidth();
final Map<PostIt, Point2D> pos = layout.getPositions(postIts, ug.getStringBounder());
final double tx = ug.getTranslateX();
final double ty = ug.getTranslateY();
for (Map.Entry<PostIt, Point2D> ent : pos.entrySet()) {
ug.translate(ent.getValue().getX(), ent.getValue().getY());
ent.getKey().drawU(ug);
ug.setTranslate(tx, ty);
}
}
}

View File

@ -0,0 +1,46 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4167 $
*
*/
package net.sourceforge.plantuml.postit;
import java.awt.geom.Point2D;
import java.util.Collection;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
public interface AreaLayout {
Map<PostIt, Point2D> getPositions(Collection<PostIt> all, StringBounder stringBounder);
}

View File

@ -0,0 +1,61 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4167 $
*
*/
package net.sourceforge.plantuml.postit;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
public class AreaLayoutFixedWidth implements AreaLayout {
public Map<PostIt, Point2D> getPositions(Collection<PostIt> all, StringBounder stringBounder) {
double x = 0;
double y = 0;
final Map<PostIt, Point2D> result = new LinkedHashMap<PostIt, Point2D>();
for (PostIt p : all) {
result.put(p, new Point2D.Double(x, y));
final Dimension2D dim = p.getDimension(stringBounder);
x += dim.getWidth() + 10;
}
return Collections.unmodifiableMap(result);
}
}

View File

@ -0,0 +1,67 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 5424 $
*
*/
package net.sourceforge.plantuml.postit;
import java.util.Map;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
public class CommandCreatePostIt extends SingleLineCommand2<PostItDiagram> {
public CommandCreatePostIt(PostItDiagram diagram) {
super(diagram, getRegexConcat());
}
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("post[- ]?it\\s+"), //
new RegexLeaf("ID", "([-\\p{L}0-9_./]+)"), //
new RegexLeaf("\\s+"), //
new RegexLeaf("TEXT", ":?(.*)?$"));
}
@Override
protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) {
final String id = arg.get("ID").get(0);
final String text = arg.get("TEXT").get(0);
getSystem().createPostIt(id, StringUtils.getWithNewlines(text));
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,55 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4762 $
*
*/
package net.sourceforge.plantuml.postit;
import java.util.List;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
public class CommandWidth extends SingleLineCommand<PostItDiagram> {
public CommandWidth(PostItDiagram system) {
super(system, "(?i)^width\\s+(\\d+)$");
}
@Override
protected CommandExecutionResult executeArg(List<String> arg) {
final int width = Integer.parseInt(arg.get(0));
getSystem().setWidth(width);
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,44 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4167 $
*
*/
package net.sourceforge.plantuml.postit;
import net.sourceforge.plantuml.graphic.StringBounder;
public interface Elastic {
double widthWhenHeightIs(double height, StringBounder stringBounder);
double heightWhenWidthIs(double width, StringBounder stringBounder);
}

View File

@ -0,0 +1,55 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6137 $
*
*/
package net.sourceforge.plantuml.postit;
import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory;
public class PostIdDiagramFactory extends AbstractUmlSystemCommandFactory {
private PostItDiagram system;
@Override
protected void initCommands() {
system = new PostItDiagram();
addCommonCommands(system);
addCommand(new CommandCreatePostIt(system));
addCommand(new CommandWidth(system));
}
public PostItDiagram getSystem() {
return system;
}
}

View File

@ -0,0 +1,114 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4167 $
*
*/
package net.sourceforge.plantuml.postit;
import java.awt.Color;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.SimpleContext2D;
import net.sourceforge.plantuml.skin.rose.ComponentRoseNote;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class PostIt {
private final String id;
private final List<String> text;
private Dimension2D minimunDimension;
public PostIt(String id, List<String> text) {
this.id = id;
this.text = text;
}
public String getId() {
return id;
}
public List<String> getText() {
return Collections.unmodifiableList(text);
}
public Dimension2D getMinimunDimension() {
return minimunDimension;
}
public void setMinimunDimension(Dimension2D minimunDimension) {
this.minimunDimension = minimunDimension;
}
public Dimension2D getDimension(StringBounder stringBounder) {
double width = getComponent().getPreferredWidth(stringBounder);
double height = getComponent().getPreferredHeight(stringBounder);
if (minimunDimension != null && width < minimunDimension.getWidth()) {
width = minimunDimension.getWidth();
}
if (minimunDimension != null && height < minimunDimension.getHeight()) {
height = minimunDimension.getHeight();
}
return new Dimension2DDouble(width, height);
}
public void drawU(UGraphic ug) {
final Component note = getComponent();
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimensionToUse = getDimension(stringBounder);
note.drawU(ug, dimensionToUse, new SimpleContext2D(false));
}
private Component getComponent() {
final Color noteBackgroundColor = HtmlColor.getColorIfValid("#FBFB77").getColor();
final Color borderColor = HtmlColor.getColorIfValid("#A80036").getColor();
final SkinParam param = new SkinParam();
final Font fontNote = param.getFont(FontParam.NOTE, null);
final ComponentRoseNote note = new ComponentRoseNote(noteBackgroundColor, borderColor, Color.BLACK, fontNote,
text);
return note;
}
}

View File

@ -0,0 +1,147 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 4167 $
*
*/
package net.sourceforge.plantuml.postit;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.png.PngIO;
import net.sourceforge.plantuml.sequencediagram.graphic.SequenceDiagramFileMaker;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
public class PostItDiagram extends UmlDiagram {
private final Area defaultArea = new Area('\0', null);
private final Map<String, PostIt> postIts = new HashMap<String, PostIt>();
@Override
public UmlDiagramType getUmlDiagramType() {
throw new UnsupportedOperationException();
}
public void createFile(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException {
final UGraphic ug = createImage(fileFormatOption);
drawU(ug);
if (ug instanceof UGraphicG2d) {
final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
PngIO.write(im, os, this.getMetadata(), this.getDpi(fileFormatOption));
} else if (ug instanceof UGraphicSvg) {
final UGraphicSvg svg = (UGraphicSvg) ug;
svg.createXml(os);
} else if (ug instanceof UGraphicEps) {
final UGraphicEps eps = (UGraphicEps) ug;
os.write(eps.getEPSCode().getBytes());
}
}
public List<File> createFiles(File suggestedFile, FileFormatOption fileFormatOption) throws IOException,
InterruptedException {
OutputStream os = null;
try {
os = new FileOutputStream(suggestedFile);
createFile(os, 0, fileFormatOption);
} finally {
if (os != null) {
os.close();
}
}
return Arrays.asList(suggestedFile);
}
public String getDescription() {
return "Board of post-it";
}
public Area getDefaultArea() {
return defaultArea;
}
public Area createArea(char id) {
throw new UnsupportedOperationException();
}
public PostIt createPostIt(String id, List<String> text) {
if (postIts.containsKey(id)) {
throw new IllegalArgumentException();
}
final PostIt postIt = new PostIt(id, text);
postIts.put(id, postIt);
getDefaultArea().add(postIt);
return postIt;
}
void drawU(UGraphic ug) {
getDefaultArea().drawU(ug);
}
private UGraphic createImage(FileFormatOption fileFormatOption) {
final Color backColor = this.getSkinParam().getBackgroundColor().getColor();
final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.PNG) {
final double height = getDefaultArea().heightWhenWidthIs(width,
SequenceDiagramFileMaker.getDummystringbounder());
final EmptyImageBuilder builder = new EmptyImageBuilder(width, height, backColor);
final Graphics2D graphics2D = builder.getGraphics2D();
final double dpiFactor = this.getDpiFactor(fileFormatOption);
return new UGraphicG2d(graphics2D, builder.getBufferedImage(), dpiFactor);
}
throw new UnsupportedOperationException();
}
private int width = 800;
public void setWidth(int width) {
this.width = width;
}
}

View File

@ -0,0 +1,76 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 3835 $
*
*/
package net.sourceforge.plantuml.preproc;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class StartumlExtractReader implements ReadLine {
private final ReadLine raw;
public StartumlExtractReader(File f, int num) throws FileNotFoundException {
if (num < 0) {
throw new IllegalArgumentException();
}
raw = getReadLine(f);
}
static public boolean containsStartuml(File f) throws IOException {
ReadLine r = null;
try {
r = getReadLine(f);
} finally {
if (r != null) {
r.close();
}
}
return false;
}
private static ReadLine getReadLine(File f) throws FileNotFoundException {
return new UncommentReadLine(new ReadLineReader(new FileReader(f)));
}
public String readLine() throws IOException {
return raw.readLine();
}
public void close() throws IOException {
raw.close();
}
}

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 5251 $ * Revision $Revision: 6198 $
* *
*/ */
package net.sourceforge.plantuml.sequencediagram.graphic; package net.sourceforge.plantuml.sequencediagram.graphic;
@ -133,7 +133,7 @@ class ConstraintSet {
} }
} }
private void pushToLeftParticipantBox(double deltaX, Pushable firstToChange) { public void pushToLeftParticipantBox(double deltaX, Pushable firstToChange, boolean including) {
if (deltaX <= 0) { if (deltaX <= 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -145,6 +145,9 @@ class ConstraintSet {
for (Pushable box : participantList) { for (Pushable box : participantList) {
if (box.equals(firstToChange)) { if (box.equals(firstToChange)) {
founded = true; founded = true;
if (including==false) {
continue;
}
} }
if (founded) { if (founded) {
box.pushToLeft(deltaX); box.pushToLeft(deltaX);
@ -153,7 +156,7 @@ class ConstraintSet {
} }
public void pushToLeft(double delta) { public void pushToLeft(double delta) {
pushToLeftParticipantBox(delta, firstBorder); pushToLeftParticipantBox(delta, firstBorder, true);
} }
private void ensureSpaceAfter(StringBounder stringBounder, Pushable p1, Pushable p2, double space) { private void ensureSpaceAfter(StringBounder stringBounder, Pushable p1, Pushable p2, double space) {
@ -167,7 +170,7 @@ class ConstraintSet {
assert p1.getCenterX(stringBounder) < p2.getCenterX(stringBounder); assert p1.getCenterX(stringBounder) < p2.getCenterX(stringBounder);
final double existingSpace = p2.getCenterX(stringBounder) - p1.getCenterX(stringBounder); final double existingSpace = p2.getCenterX(stringBounder) - p1.getCenterX(stringBounder);
if (existingSpace < space) { if (existingSpace < space) {
pushToLeftParticipantBox(space - existingSpace, p2); pushToLeftParticipantBox(space - existingSpace, p2, true);
} }
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6113 $ * Revision $Revision: 6198 $
* *
*/ */
package net.sourceforge.plantuml.sequencediagram.graphic; package net.sourceforge.plantuml.sequencediagram.graphic;
@ -141,7 +141,7 @@ class DrawableSet {
return height + heightEnglober; return height + heightEnglober;
} }
public List<ParticipantEngloberContexted> getExistingParticipantEnglober2() { public List<ParticipantEngloberContexted> getExistingParticipantEnglober() {
final List<ParticipantEngloberContexted> result = new ArrayList<ParticipantEngloberContexted>(); final List<ParticipantEngloberContexted> result = new ArrayList<ParticipantEngloberContexted>();
ParticipantEngloberContexted pending = null; ParticipantEngloberContexted pending = null;
for (Map.Entry<Participant, ParticipantEnglober> ent : participantEnglobers2.entrySet()) { for (Map.Entry<Participant, ParticipantEnglober> ent : participantEnglobers2.entrySet()) {
@ -163,7 +163,7 @@ class DrawableSet {
public double getOffsetForEnglobers(StringBounder stringBounder) { public double getOffsetForEnglobers(StringBounder stringBounder) {
double result = 0; double result = 0;
for (ParticipantEngloberContexted englober : getExistingParticipantEnglober2()) { for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
final Component comp = skin.createComponent(ComponentType.ENGLOBER, skinParam, englober final Component comp = skin.createComponent(ComponentType.ENGLOBER, skinParam, englober
.getParticipantEnglober().getTitle()); .getParticipantEnglober().getTitle());
final double height = comp.getPreferredHeight(stringBounder); final double height = comp.getPreferredHeight(stringBounder);
@ -178,7 +178,7 @@ class DrawableSet {
static private final int MARGIN_FOR_ENGLOBERS1 = 2; static private final int MARGIN_FOR_ENGLOBERS1 = 2;
public double getTailHeight(StringBounder stringBounder, boolean showTail) { public double getTailHeight(StringBounder stringBounder, boolean showTail) {
final double marginForEnglobers = getExistingParticipantEnglober2().size() > 0 ? MARGIN_FOR_ENGLOBERS : 0; final double marginForEnglobers = getExistingParticipantEnglober().size() > 0 ? MARGIN_FOR_ENGLOBERS : 0;
if (showTail == false) { if (showTail == false) {
return 1 + marginForEnglobers; return 1 + marginForEnglobers;
@ -315,7 +315,7 @@ class DrawableSet {
} }
private void drawEnglobers(UGraphic ug, double height, Context2D context) { private void drawEnglobers(UGraphic ug, double height, Context2D context) {
for (ParticipantEngloberContexted englober : getExistingParticipantEnglober2()) { for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
double x1 = getX1(englober); double x1 = getX1(englober);
final double x2 = getX2(ug.getStringBounder(), englober); final double x2 = getX2(ug.getStringBounder(), englober);
@ -325,9 +325,9 @@ class DrawableSet {
final double preferedWidth = getEngloberPreferedWidth(ug.getStringBounder(), final double preferedWidth = getEngloberPreferedWidth(ug.getStringBounder(),
englober.getParticipantEnglober()); englober.getParticipantEnglober());
if (preferedWidth > width) { if (preferedWidth > width) {
if (englober.getFirst2() == englober.getLast2()) { //if (englober.getFirst2() == englober.getLast2()) {
x1 -= (preferedWidth - width) / 2; x1 -= (preferedWidth - width) / 2;
} //}
final Dimension2DDouble dim = new Dimension2DDouble(preferedWidth, height); final Dimension2DDouble dim = new Dimension2DDouble(preferedWidth, height);
ug.translate(x1, 1); ug.translate(x1, 1);
comp.drawU(ug, dim, context); comp.drawU(ug, dim, context);
@ -351,13 +351,13 @@ class DrawableSet {
return skin.createComponent(ComponentType.ENGLOBER, s, englober.getTitle()); return skin.createComponent(ComponentType.ENGLOBER, s, englober.getTitle());
} }
private double getX1(ParticipantEngloberContexted englober) { public double getX1(ParticipantEngloberContexted englober) {
final Participant first = englober.getFirst2(); final Participant first = englober.getFirst2();
final ParticipantBox firstBox = participants.get(first).getParticipantBox(); final ParticipantBox firstBox = participants.get(first).getParticipantBox();
return firstBox.getStartingX() + 1; return firstBox.getStartingX() + 1;
} }
private double getX2(StringBounder stringBounder, ParticipantEngloberContexted englober) { public double getX2(StringBounder stringBounder, ParticipantEngloberContexted englober) {
final Participant last = englober.getLast2(); final Participant last = englober.getLast2();
final ParticipantBox lastBox = participants.get(last).getParticipantBox(); final ParticipantBox lastBox = participants.get(last).getParticipantBox();
return lastBox.getMaxX(stringBounder) - 1; return lastBox.getMaxX(stringBounder) - 1;
@ -394,7 +394,7 @@ class DrawableSet {
// } // }
private ParticipantEngloberContexted getParticipantEnglober(Participant p) { private ParticipantEngloberContexted getParticipantEnglober(Participant p) {
for (ParticipantEngloberContexted pe : getExistingParticipantEnglober2()) { for (ParticipantEngloberContexted pe : getExistingParticipantEnglober()) {
if (pe.contains(p)) { if (pe.contains(p)) {
return pe; return pe;
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6113 $ * Revision $Revision: 6198 $
* *
*/ */
package net.sourceforge.plantuml.sequencediagram.graphic; package net.sourceforge.plantuml.sequencediagram.graphic;
@ -154,9 +154,10 @@ class DrawableSetInitializer {
} }
} }
takeParticipantEngloberTitleWidth(stringBounder); //takeParticipantEngloberTitleWidth(stringBounder);
constraintSet.takeConstraintIntoAccount(stringBounder); constraintSet.takeConstraintIntoAccount(stringBounder);
//takeParticipantEngloberTitleWidth2(stringBounder);
takeParticipantEngloberTitleWidth3(stringBounder);
prepareMissingSpace(stringBounder); prepareMissingSpace(stringBounder);
@ -164,26 +165,66 @@ class DrawableSetInitializer {
return drawableSet; return drawableSet;
} }
private void takeParticipantEngloberTitleWidth(StringBounder stringBounder) { private void takeParticipantEngloberTitleWidth3(StringBounder stringBounder) {
for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober2()) { for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober()) {
final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder, final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder,
pe.getParticipantEnglober()); pe.getParticipantEnglober());
final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2()).getParticipantBox(); final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2()).getParticipantBox();
final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2()).getParticipantBox(); final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2()).getParticipantBox();
final double x1 = drawableSet.getX1(pe);
final double x2 = drawableSet.getX2(stringBounder, pe);
final double missing = preferredWidth - (x2 - x1);
System.err.println("x1=" + x1 + " x2=" + x2 + " preferredWidth=" + preferredWidth + " missing=" + missing);
if (missing>0) {
constraintSet
.pushToLeftParticipantBox(missing / 2, first, true);
constraintSet
.pushToLeftParticipantBox(missing / 2, last, false);
}
}
}
private void takeParticipantEngloberTitleWidth2(StringBounder stringBounder) {
double lastX2;
for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober()) {
final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder,
pe.getParticipantEnglober());
final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2()).getParticipantBox();
final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2()).getParticipantBox();
final double x1 = drawableSet.getX1(pe);
final double x2 = drawableSet.getX2(stringBounder, pe);
final double missing = preferredWidth - (x2 - x1);
System.err.println("x1=" + x1 + " x2=" + x2 + " preferredWidth=" + preferredWidth + " missing=" + missing);
if (missing > 0) {
constraintSet.getConstraintAfter(last).push(missing);
constraintSet.takeConstraintIntoAccount(stringBounder);
}
lastX2 = x2;
}
}
private void takeParticipantEngloberTitleWidth(StringBounder stringBounder) {
ParticipantBox previousLast = null;
for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober()) {
final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder,
pe.getParticipantEnglober());
final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2()).getParticipantBox();
final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2()).getParticipantBox();
final double margin = 5;
if (first == last) { if (first == last) {
final Constraint constraint1 = constraintSet.getConstraintBefore(first); final Constraint constraint1 = constraintSet.getConstraintBefore(first);
final Constraint constraint2 = constraintSet.getConstraintAfter(last); final Constraint constraint2 = constraintSet.getConstraintAfter(last);
final double w1 = constraint1.getParticipant1().getPreferredWidth(stringBounder); final double w1 = constraint1.getParticipant1().getPreferredWidth(stringBounder);
final double w2 = constraint2.getParticipant2().getPreferredWidth(stringBounder); final double w2 = constraint2.getParticipant2().getPreferredWidth(stringBounder);
constraint1.ensureValue(preferredWidth / 2 + w1 / 2 + 5); constraint1.ensureValue(preferredWidth / 2 + w1 / 2 + margin);
constraint2.ensureValue(preferredWidth / 2 + w2 / 2 + 5); constraint2.ensureValue(preferredWidth / 2 + w2 / 2 + margin);
} else { } else {
final Pushable beforeFirst = constraintSet.getPrevious(first); final Pushable beforeFirst = constraintSet.getPrevious(first);
final Pushable afterLast = constraintSet.getNext(last); final Pushable afterLast = constraintSet.getNext(last);
final Constraint constraint1 = constraintSet.getConstraint(beforeFirst, afterLast); final Constraint constraint1 = constraintSet.getConstraint(beforeFirst, afterLast);
constraint1.ensureValue(preferredWidth + beforeFirst.getPreferredWidth(stringBounder) / 2 constraint1.ensureValue(preferredWidth + beforeFirst.getPreferredWidth(stringBounder) / 2
+ afterLast.getPreferredWidth(stringBounder) / 2 + 10); + afterLast.getPreferredWidth(stringBounder) / 2 + 2 * margin);
} }
previousLast = last;
} }
} }

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6113 $ * Revision $Revision: 6208 $
* *
*/ */
package net.sourceforge.plantuml.sequencediagram.graphic; package net.sourceforge.plantuml.sequencediagram.graphic;
@ -408,4 +408,8 @@ public class SequenceDiagramFileMaker implements FileMaker {
text.drawU(ug, area.getHeaderX(diagram.getHeaderAlignement()), area.getHeaderY()); text.drawU(ug, area.getHeaderX(diagram.getHeaderAlignement()), area.getHeaderY());
} }
public static StringBounder getDummystringbounder() {
return dummyStringBounder;
}
} }

View File

@ -34,6 +34,7 @@
package net.sourceforge.plantuml.statediagram.command; package net.sourceforge.plantuml.statediagram.command;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
@ -57,14 +58,15 @@ public class CommandLinkState2 extends SingleLineCommand2<StateDiagram> {
static RegexConcat getRegex() { static RegexConcat getRegex() {
return new RegexConcat( return new RegexConcat(
new RegexLeaf("^"), new RegexLeaf("^"), //
getStatePattern("ENT1"), getStatePattern("ENT1"), //
new RegexLeaf("\\s*"), new RegexLeaf("\\s*"), //
new RegexLeaf("ARROW", "((-+)(left|right|up|down|le?|ri?|up?|do?)?(-*)([\\]>]))"), new RegexLeaf("ARROW",
new RegexLeaf("\\s*"), "((-+)(left|right|up|down|le?|ri?|up?|do?)?(?:\\[((?:#\\w+|dotted|dashed|bold)(?:,#\\w+|,dotted|,dashed|,bold)*)\\])?(-*)\\>)"),
getStatePattern("ENT2"), new RegexLeaf("\\s*"), //
new RegexLeaf("\\s*"), getStatePattern("ENT2"), //
new RegexLeaf("LABEL", "(?::\\s*([^\"]+))?"), new RegexLeaf("\\s*"), //
new RegexLeaf("LABEL", "(?::\\s*([^\"]+))?"), //
new RegexLeaf("$")); new RegexLeaf("$"));
} }
@ -79,7 +81,7 @@ public class CommandLinkState2 extends SingleLineCommand2<StateDiagram> {
final IEntity cl1 = getEntityStart(ent1); final IEntity cl1 = getEntityStart(ent1);
final IEntity cl2 = getEntityEnd(ent2); final IEntity cl2 = getEntityEnd(ent2);
if (arg.get("ENT1").get(1) != null) { if (arg.get("ENT1").get(1) != null) {
cl1.setStereotype(new Stereotype(arg.get("ENT1").get(1))); cl1.setStereotype(new Stereotype(arg.get("ENT1").get(1)));
} }
@ -93,7 +95,7 @@ public class CommandLinkState2 extends SingleLineCommand2<StateDiagram> {
cl2.setSpecificBackcolor(arg.get("ENT2").get(2)); cl2.setSpecificBackcolor(arg.get("ENT2").get(2));
} }
String queue = arg.get("ARROW").get(1) + arg.get("ARROW").get(3); String queue = arg.get("ARROW").get(1) + arg.get("ARROW").get(4);
final Direction dir = getDirection(arg); final Direction dir = getDirection(arg);
if (dir == Direction.LEFT || dir == Direction.RIGHT) { if (dir == Direction.LEFT || dir == Direction.RIGHT) {
@ -106,6 +108,21 @@ public class CommandLinkState2 extends SingleLineCommand2<StateDiagram> {
if (dir == Direction.LEFT || dir == Direction.UP) { if (dir == Direction.LEFT || dir == Direction.UP) {
link = link.getInv(); link = link.getInv();
} }
if (arg.get("ARROW").get(3) != null) {
final StringTokenizer st = new StringTokenizer(arg.get("ARROW").get(3), ",");
while (st.hasMoreTokens()) {
final String s = st.nextToken();
if (s.equalsIgnoreCase("dashed")) {
link = link.getDashed();
} else if (s.equalsIgnoreCase("bold")) {
link = link.getBold();
} else if (s.equalsIgnoreCase("dotted")) {
link = link.getDotted();
} else {
link.setSpecificColor(s);
}
}
}
getSystem().addLink(link); getSystem().addLink(link);
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.usecasediagram.command.CommandCreateUsecase2;
import net.sourceforge.plantuml.usecasediagram.command.CommandLinkUsecase2; import net.sourceforge.plantuml.usecasediagram.command.CommandLinkUsecase2;
import net.sourceforge.plantuml.usecasediagram.command.CommandMultilinesUsecaseNoteEntity; import net.sourceforge.plantuml.usecasediagram.command.CommandMultilinesUsecaseNoteEntity;
import net.sourceforge.plantuml.usecasediagram.command.CommandRankDirUsecase; import net.sourceforge.plantuml.usecasediagram.command.CommandRankDirUsecase;
import net.sourceforge.plantuml.usecasediagram.command.CommandSetStrategy;
public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory { public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory {
@ -77,5 +78,7 @@ public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory {
addCommand(new CommandMultilinesUsecaseNoteEntity(system)); addCommand(new CommandMultilinesUsecaseNoteEntity(system));
addCommand(new CommandMultilinesStandaloneNote(system)); addCommand(new CommandMultilinesStandaloneNote(system));
}
addCommand(new CommandSetStrategy(system));
}
} }

View File

@ -0,0 +1,55 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.usecasediagram.command;
import java.util.List;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
public class CommandSetStrategy extends SingleLineCommand<CucaDiagram> {
public CommandSetStrategy(CucaDiagram diagram) {
super(
diagram,
"(?i)^layout with neato$");
}
@Override
protected CommandExecutionResult executeArg(List<String> arg) {
getSystem().setStrategy(GraphvizLayoutStrategy.NEATO);
return CommandExecutionResult.ok();
}
}

View File

@ -28,7 +28,7 @@
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* Revision $Revision: 6142 $ * Revision $Revision: 6211 $
* *
*/ */
package net.sourceforge.plantuml.version; package net.sourceforge.plantuml.version;
@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version;
public class Version { public class Version {
public static int version() { public static int version() {
return 6141; return 6210;
} }
public static long compileTime() { public static long compileTime() {
return 1298495043843L; return 1300656476468L;
} }
} }

View File

@ -195,7 +195,7 @@ public class XmiClassDiagram {
final Element feature = document.createElement("UML:Classifier.feature"); final Element feature = document.createElement("UML:Classifier.feature");
cla.appendChild(feature); cla.appendChild(feature);
for (Member m : entity.fields2()) { for (Member m : entity.getFieldsToDisplay()) {
// <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1" // <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
// visibility="public" isSpecification="false" // visibility="public" isSpecification="false"
// ownerScope="instance" changeability="changeable" // ownerScope="instance" changeability="changeable"
@ -206,7 +206,7 @@ public class XmiClassDiagram {
feature.appendChild(attribute); feature.appendChild(attribute);
} }
for (Member m : entity.methods2()) { for (Member m : entity.getMethodsToDisplay()) {
// <UML:Operation xmi.id="UMLOperation.7" name="Operation1" // <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
// visibility="public" isSpecification="false" // visibility="public" isSpecification="false"
// ownerScope="instance" isQuery="false" concurrency="sequential" // ownerScope="instance" isQuery="false" concurrency="sequential"