mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 02:49:06 +00:00
Version 6210
This commit is contained in:
parent
573aac6a1c
commit
a53403952e
2
pom.xml
2
pom.xml
@ -36,7 +36,7 @@
|
||||
|
||||
<groupId>net.sourceforge.plantuml</groupId>
|
||||
<artifactId>plantuml</artifactId>
|
||||
<version>6141-SNAPSHOT</version>
|
||||
<version>6210-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PlantUML</name>
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6130 $
|
||||
* Revision $Revision: 6187 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
@ -57,6 +57,7 @@ public class Option {
|
||||
private boolean decodeurl = false;
|
||||
private boolean pipe = false;
|
||||
private boolean syntax = false;
|
||||
private boolean pattern = false;
|
||||
|
||||
private File outputDir = null;
|
||||
private final List<String> result = new ArrayList<String>();
|
||||
@ -147,6 +148,8 @@ public class Option {
|
||||
OptionFlags.getInstance().setVerbose(true);
|
||||
} else if (s.equalsIgnoreCase("-pipe") || s.equalsIgnoreCase("-p")) {
|
||||
pipe = true;
|
||||
} else if (s.equalsIgnoreCase("-pattern")) {
|
||||
pattern = true;
|
||||
} else if (s.equalsIgnoreCase("-syntax")) {
|
||||
syntax = true;
|
||||
OptionFlags.getInstance().setQuiet(true);
|
||||
@ -270,6 +273,10 @@ public class Option {
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public final boolean isPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public FileFormatOption getFileFormatOption() {
|
||||
return new FileFormatOption(getFileFormat());
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ 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.postit.PostIdDiagramFactory;
|
||||
import net.sourceforge.plantuml.printskin.PrintSkinFactory;
|
||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
|
||||
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
|
||||
@ -71,6 +72,7 @@ public class PSystemBuilder {
|
||||
factories.add(new ActivityDiagramFactory2());
|
||||
factories.add(new CompositeDiagramFactory());
|
||||
factories.add(new ObjectDiagramFactory());
|
||||
factories.add(new PostIdDiagramFactory());
|
||||
factories.add(new PrintSkinFactory());
|
||||
factories.add(new PSystemVersionFactory());
|
||||
factories.add(new PSystemSudokuFactory());
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5969 $
|
||||
* Revision $Revision: 6188 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
@ -39,15 +39,34 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.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.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.usecasediagram.UsecaseDiagramFactory;
|
||||
import net.sourceforge.plantuml.version.PSystemVersionFactory;
|
||||
|
||||
public class Run {
|
||||
|
||||
@ -56,7 +75,9 @@ public class Run {
|
||||
if (OptionFlags.getInstance().isVerbose()) {
|
||||
Log.info("GraphicsEnvironment.isHeadless() " + GraphicsEnvironment.isHeadless());
|
||||
}
|
||||
if (OptionFlags.getInstance().isGui()) {
|
||||
if (option.isPattern()) {
|
||||
managePattern();
|
||||
} else if (OptionFlags.getInstance().isGui()) {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
} 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 {
|
||||
final String charset = option.getCharset();
|
||||
final BufferedReader br;
|
||||
@ -127,8 +166,8 @@ public class Run {
|
||||
System.out.println(new MetadataTag(f, "plantuml").getData());
|
||||
System.out.println("------------------------");
|
||||
} else {
|
||||
final SourceFileReader sourceFileReader = new SourceFileReader(option.getDefaultDefines(), f, option
|
||||
.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption());
|
||||
final SourceFileReader sourceFileReader = new SourceFileReader(option.getDefaultDefines(), f,
|
||||
option.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption());
|
||||
if (option.isComputeurl()) {
|
||||
final List<String> urls = sourceFileReader.getEncodedUrl();
|
||||
for (String s : urls) {
|
||||
|
@ -100,10 +100,10 @@ public class ActivityDiagram2 extends CucaDiagram {
|
||||
afterAdd(act);
|
||||
}
|
||||
|
||||
private void afterAdd(final Entity act) {
|
||||
private void afterAdd(final IEntity act) {
|
||||
for (IEntity last : this.waitings) {
|
||||
System.err.println("last=" + last);
|
||||
System.err.println("act=" + act);
|
||||
// System.err.println("last=" + last);
|
||||
// System.err.println("act=" + act);
|
||||
this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), futureLabel, futureLength));
|
||||
futureLabel = null;
|
||||
}
|
||||
@ -117,15 +117,14 @@ public class ActivityDiagram2 extends CucaDiagram {
|
||||
this.waitings.add(act);
|
||||
this.futureLength = 2;
|
||||
}
|
||||
|
||||
|
||||
public IEntity getLastEntityConsulted() {
|
||||
if (waitings.size()==1) {
|
||||
if (waitings.size() == 1) {
|
||||
return waitings.iterator().next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private String getAutoCode() {
|
||||
return "ac" + UniqueSequence.getValue();
|
||||
}
|
||||
@ -142,7 +141,8 @@ public class ActivityDiagram2 extends CucaDiagram {
|
||||
currentContext = new ConditionalContext2(currentContext, br, Direction.DOWN, when);
|
||||
for (IEntity last : this.waitings) {
|
||||
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();
|
||||
} else {
|
||||
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() {
|
||||
final boolean hasElse = currentContext.isHasElse();
|
||||
System.err.println("CALL endif hasElse " + hasElse);
|
||||
// System.err.println("CALL endif hasElse " + hasElse);
|
||||
this.waitings.addAll(currentContext.getPendings());
|
||||
currentContext = currentContext.getParent();
|
||||
if (currentContext == null) {
|
||||
System.err.println("after endif " + currentContext);
|
||||
} else {
|
||||
System.err.println("after endif " + currentContext.getPendings());
|
||||
}
|
||||
// if (currentContext == null) {
|
||||
// System.err.println("after endif " + currentContext);
|
||||
// } else {
|
||||
// System.err.println("after endif " + currentContext.getPendings());
|
||||
// }
|
||||
}
|
||||
|
||||
public void else2(String when) {
|
||||
@ -196,7 +196,7 @@ public class ActivityDiagram2 extends CucaDiagram {
|
||||
private final Collection<PendingLink> pendingLinks = new ArrayList<PendingLink>();
|
||||
|
||||
public void callGoto(String gotoLabel) {
|
||||
System.err.println("CALL goto " + gotoLabel);
|
||||
// System.err.println("CALL goto " + gotoLabel);
|
||||
final IEntity dest = labels.get(gotoLabel);
|
||||
for (IEntity last : this.waitings) {
|
||||
if (dest == null) {
|
||||
@ -206,14 +206,17 @@ public class ActivityDiagram2 extends CucaDiagram {
|
||||
this.futureLength));
|
||||
}
|
||||
}
|
||||
System.err.println("Avant fin goto, waitings=" + waitings);
|
||||
// System.err.println("Avant fin goto, waitings=" + waitings);
|
||||
this.waitings.clear();
|
||||
// currentContext.clearPendingsButFirst();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ import net.sourceforge.plantuml.activitydiagram2.command.CommandIf2;
|
||||
import net.sourceforge.plantuml.activitydiagram2.command.CommandLabel2;
|
||||
import net.sourceforge.plantuml.activitydiagram2.command.CommandMultilinesNoteActivity2;
|
||||
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.command.AbstractUmlSystemCommandFactory;
|
||||
|
||||
@ -83,6 +84,7 @@ public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory {
|
||||
// addCommand(new CommandElse(system));
|
||||
// addCommand(new CommandEndif(system));
|
||||
// addCommand(new CommandInnerConcurrent(system));
|
||||
addCommand(new CommandNewMultilinesActivity2(system));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -28,12 +28,14 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6095 $
|
||||
* Revision $Revision: 6192 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
|
||||
@ -43,16 +45,24 @@ public abstract class AbstractEntityDiagram extends CucaDiagram {
|
||||
|
||||
abstract public IEntity getOrCreateClass(String code);
|
||||
|
||||
protected List<String> getDotStrings() {
|
||||
// return Arrays.asList("nodesep=.5;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];",
|
||||
// "node [fontsize=11,height=.35,width=.55];");
|
||||
return Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];",
|
||||
"node [fontsize=11,height=.35,width=.55];");
|
||||
final protected List<String> getDotStrings() {
|
||||
// return Arrays.asList("nodesep=.5;", "ranksep=0.8;", "edge
|
||||
// [fontsize=11,labelfontsize=11];",
|
||||
// "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() {
|
||||
return "(" + entities().size() + " entities)";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5895 $
|
||||
* Revision $Revision: 6167 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram;
|
||||
@ -146,4 +146,5 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
|
||||
return UmlDiagramType.CLASS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5613 $
|
||||
* Revision $Revision: 6169 $
|
||||
*
|
||||
*/
|
||||
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.CommandEndNamespace;
|
||||
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.CommandLinkClass2;
|
||||
import net.sourceforge.plantuml.classdiagram.command.CommandLinkLollipop;
|
||||
@ -93,6 +94,7 @@ public class ClassDiagramFactory extends AbstractUmlSystemCommandFactory {
|
||||
// addCommand(new CommandCreateEntityClassMultilines(system));
|
||||
addCommand(new CommandCreateEntityClassMultilines2(system));
|
||||
|
||||
addCommand(new CommandHideShow3(system));
|
||||
addCommand(new CommandHideShow(system));
|
||||
|
||||
}
|
||||
|
@ -34,19 +34,22 @@
|
||||
package net.sourceforge.plantuml.classdiagram.command;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
|
||||
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.EntityGenderUtils;
|
||||
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
|
||||
import net.sourceforge.plantuml.cucadiagram.EntityType;
|
||||
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_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);
|
||||
|
||||
public CommandHideShow(ClassDiagram classDiagram) {
|
||||
super(
|
||||
classDiagram,
|
||||
"(?i)^(hide|show)\\s+(?:(class|interface|enum|abstract|[\\p{L}0-9_.]+|\"[^\"]+\"|\\<\\<.*\\>\\>)\\s+)*?(?:(empty)\\s+)?(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)$");
|
||||
super(classDiagram, getRegexConcat());
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -73,35 +85,38 @@ public class CommandHideShow extends SingleLineCommand<ClassDiagram> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(List<String> arg) {
|
||||
final Set<EntityPortion> portion = getEntityPortion(arg.get(3));
|
||||
protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) {
|
||||
|
||||
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION").get(0));
|
||||
EntityGender gender = null;
|
||||
|
||||
if (arg.get(1) == null) {
|
||||
final String arg1 = arg.get("GENDER").get(0);
|
||||
|
||||
if (arg1 == null) {
|
||||
gender = EntityGenderUtils.all();
|
||||
} else if (arg.get(1).equalsIgnoreCase("class")) {
|
||||
} else if (arg1.equalsIgnoreCase("class")) {
|
||||
gender = EntityGenderUtils.byEntityType(EntityType.CLASS);
|
||||
} else if (arg.get(1).equalsIgnoreCase("interface")) {
|
||||
} else if (arg1.equalsIgnoreCase("interface")) {
|
||||
gender = EntityGenderUtils.byEntityType(EntityType.INTERFACE);
|
||||
} else if (arg.get(1).equalsIgnoreCase("enum")) {
|
||||
} else if (arg1.equalsIgnoreCase("enum")) {
|
||||
gender = EntityGenderUtils.byEntityType(EntityType.ENUM);
|
||||
} else if (arg.get(1).equalsIgnoreCase("abstract")) {
|
||||
} else if (arg1.equalsIgnoreCase("abstract")) {
|
||||
gender = EntityGenderUtils.byEntityType(EntityType.ABSTRACT_CLASS);
|
||||
} else if (arg.get(1).startsWith("<<")) {
|
||||
gender = EntityGenderUtils.byStereotype(arg.get(1));
|
||||
} else if (arg1.startsWith("<<")) {
|
||||
gender = EntityGenderUtils.byStereotype(arg1);
|
||||
} else {
|
||||
final IEntity entity = getSystem().getOrCreateClass(arg.get(1));
|
||||
final IEntity entity = getSystem().getOrCreateClass(arg1);
|
||||
gender = EntityGenderUtils.byEntityAlone(entity);
|
||||
}
|
||||
if (gender != null) {
|
||||
final boolean empty = arg.get(2) != null;
|
||||
final boolean empty = arg.get("EMPTY").get(0) != null;
|
||||
if (empty == true) {
|
||||
gender = EntityGenderUtils.and(gender, emptyByGender(portion));
|
||||
}
|
||||
if (getSystem().getCurrentGroup() != null) {
|
||||
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();
|
||||
}
|
||||
@ -125,4 +140,5 @@ public class CommandHideShow extends SingleLineCommand<ClassDiagram> {
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 3827 $
|
||||
* Revision $Revision: 6170 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.code;
|
||||
@ -55,7 +55,9 @@ public class AsciiEncoder implements URLEncoder {
|
||||
}
|
||||
|
||||
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];
|
||||
int pos = 0;
|
||||
for (int i = 0; i < s.length(); i += 4) {
|
||||
|
@ -28,12 +28,14 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6097 $
|
||||
* Revision $Revision: 6191 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
@ -82,6 +84,7 @@ public abstract class AbstractUmlSystemCommandFactory implements PSystemCommandF
|
||||
|
||||
final protected void addCommonCommands(UmlDiagram system) {
|
||||
addCommand(new CommandNope(system));
|
||||
addCommand(new CommandMultilinesComment(system));
|
||||
addCommand(new CommandPragma(system));
|
||||
addCommand(new CommandTitle(system));
|
||||
addCommand(new CommandMultilinesTitle(system));
|
||||
@ -107,4 +110,13 @@ public abstract class AbstractUmlSystemCommandFactory implements PSystemCommandF
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 4762 $
|
||||
* Revision $Revision: 6184 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -44,5 +44,7 @@ public interface Command {
|
||||
boolean isDeprecated(List<String> lines);
|
||||
|
||||
String getHelpMessageForDeprecated(List<String> lines);
|
||||
|
||||
String[] getDescription();
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5749 $
|
||||
* Revision $Revision: 6186 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -57,6 +57,10 @@ public abstract class CommandMultilines<S extends PSystem> implements Command {
|
||||
this.starting = Pattern.compile(patternStart);
|
||||
this.ending = Pattern.compile(patternEnd);
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return new String[] { "START: " + starting.pattern(), "END: " + ending.pattern() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
if (isCommandForbidden()) {
|
||||
|
@ -58,6 +58,10 @@ public abstract class CommandMultilines2<S extends PSystem> implements Command {
|
||||
this.starting = patternStart;
|
||||
this.ending = Pattern.compile(patternEnd);
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return new String[] { "START: "+starting.getPattern(), "END: "+ending.pattern() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
if (isCommandForbidden()) {
|
||||
|
@ -56,6 +56,10 @@ public abstract class CommandMultilinesBracket<S extends PSystem> implements Com
|
||||
protected boolean isCommandForbidden() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return new String[] { "BRACKET: " + starting.pattern() };
|
||||
}
|
||||
|
||||
protected void actionIfCommandValid() {
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5983 $
|
||||
* Revision $Revision: 6209 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -36,6 +36,7 @@ package net.sourceforge.plantuml.command;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UniqueSequence;
|
||||
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
|
||||
import net.sourceforge.plantuml.cucadiagram.Group;
|
||||
import net.sourceforge.plantuml.cucadiagram.GroupType;
|
||||
@ -45,7 +46,8 @@ public class CommandPackage extends SingleLineCommand<AbstractEntityDiagram> {
|
||||
|
||||
public CommandPackage(AbstractEntityDiagram 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
|
||||
@ -53,16 +55,22 @@ public class CommandPackage extends SingleLineCommand<AbstractEntityDiagram> {
|
||||
final String code;
|
||||
final String display;
|
||||
if (arg.get(1) == null) {
|
||||
code = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
|
||||
display = code;
|
||||
if (StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)).length() == 0) {
|
||||
code = "##" + UniqueSequence.getValue();
|
||||
display = null;
|
||||
} else {
|
||||
code = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
|
||||
display = code;
|
||||
}
|
||||
} else {
|
||||
display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
|
||||
code = arg.get(1);
|
||||
}
|
||||
final Group currentPackage = getSystem().getCurrentGroup();
|
||||
// if (getSystem().entityExist(code)) {
|
||||
// return CommandExecutionResult.error("Package cannot have the same name as an existing class");
|
||||
// }
|
||||
// if (getSystem().entityExist(code)) {
|
||||
// return CommandExecutionResult.error("Package cannot have the same
|
||||
// name as an existing class");
|
||||
// }
|
||||
final Group p = getSystem().getOrCreateGroup(code, display, null, GroupType.PACKAGE, currentPackage);
|
||||
p.setBold(true);
|
||||
final String color = arg.get(2);
|
||||
|
@ -75,4 +75,8 @@ public class ProtectedCommand implements Command {
|
||||
return cmd.isValid(lines);
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return cmd.getDescription();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5041 $
|
||||
* Revision $Revision: 6186 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -67,6 +67,10 @@ public abstract class SingleLineCommand<S extends PSystem> implements Command {
|
||||
this.system = system;
|
||||
this.pattern = Pattern.compile(pattern);
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return new String[]{pattern.pattern()};
|
||||
}
|
||||
|
||||
final protected S getSystem() {
|
||||
return system;
|
||||
|
@ -63,6 +63,10 @@ public abstract class SingleLineCommand2<S extends PSystem> implements Command {
|
||||
final protected S getSystem() {
|
||||
return system;
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return new String[] { pattern.getPattern() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
if (lines.size() != 1) {
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6062 $
|
||||
* Revision $Revision: 6199 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
@ -40,6 +40,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
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.CucaDiagramPngMaker3;
|
||||
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;
|
||||
|
||||
public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower {
|
||||
@ -105,7 +108,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
|
||||
if (display == null) {
|
||||
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);
|
||||
nbLinks.put(entity, 0);
|
||||
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,
|
||||
Group parent) {
|
||||
// if (entityExist(code)) {
|
||||
// throw new IllegalArgumentException("code=" + code);
|
||||
// }
|
||||
// if (entityExist(code)) {
|
||||
// throw new IllegalArgumentException("code=" + code);
|
||||
// }
|
||||
Group g = groups.get(code);
|
||||
if (g == null) {
|
||||
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);
|
||||
if (entityGroup == null) {
|
||||
entityGroup = new Entity("$$" + code, code, EntityType.GROUP, g);
|
||||
entityGroup = new Entity("$$" + code, code, EntityType.GROUP, g, getHides());
|
||||
} else {
|
||||
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,
|
||||
InterruptedException {
|
||||
|
||||
|
||||
final FileFormat fileFormat = fileFormatOption.getFileFormat();
|
||||
|
||||
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 Set<VisibilityModifier> hides = new HashSet<VisibilityModifier>();
|
||||
|
||||
static class HideOrShow {
|
||||
private final EntityGender gender;
|
||||
@ -498,5 +510,19 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
|
||||
public int getNbImages() {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6121 $
|
||||
* Revision $Revision: 6169 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
@ -38,10 +38,12 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.UniqueSequence;
|
||||
import net.sourceforge.plantuml.cucadiagram.dot.DrawFile;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
|
||||
public class Entity implements IEntity {
|
||||
|
||||
@ -53,14 +55,15 @@ public class Entity implements IEntity {
|
||||
|
||||
private Stereotype stereotype;
|
||||
|
||||
private final List<Member> fields2 = new ArrayList<Member>();
|
||||
private final List<Member> methods2 = new ArrayList<Member>();
|
||||
private final List<Member> fields = new ArrayList<Member>();
|
||||
private final List<Member> methods = new ArrayList<Member>();
|
||||
private final Set<VisibilityModifier> hides;
|
||||
|
||||
private Group container;
|
||||
|
||||
private DrawFile imageFile;
|
||||
private String url;
|
||||
|
||||
|
||||
private boolean top;
|
||||
|
||||
public final boolean isTop() {
|
||||
@ -71,17 +74,19 @@ public class Entity implements IEntity {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public Entity(String code, String display, EntityType type, Group entityPackage) {
|
||||
this("cl" + UniqueSequence.getValue(), code, display, type, entityPackage);
|
||||
public Entity(String code, String display, EntityType type, Group entityPackage, Set<VisibilityModifier> hides) {
|
||||
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) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (display == null /* || display.length() == 0 */) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.hides = hides;
|
||||
this.uid = uid;
|
||||
this.type = type;
|
||||
this.code = code;
|
||||
@ -105,30 +110,48 @@ public class Entity implements IEntity {
|
||||
|
||||
public void addFieldOrMethod(String s) {
|
||||
if (isMethod(s)) {
|
||||
methods2.add(new Member(s, true));
|
||||
methods.add(new Member(s, true));
|
||||
} else {
|
||||
addField(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void addField(String s) {
|
||||
fields2.add(new Member(s, false));
|
||||
fields.add(new Member(s, false));
|
||||
}
|
||||
|
||||
public void addField(Member s) {
|
||||
fields2.add(s);
|
||||
fields.add(s);
|
||||
}
|
||||
|
||||
private boolean isMethod(String s) {
|
||||
return s.contains("(") || s.contains(")");
|
||||
}
|
||||
|
||||
public List<Member> methods2() {
|
||||
return Collections.unmodifiableList(methods2);
|
||||
public List<Member> getMethodsToDisplay() {
|
||||
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() {
|
||||
return Collections.unmodifiableList(fields2);
|
||||
public List<Member> getFieldsToDisplay() {
|
||||
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() {
|
||||
|
@ -99,7 +99,7 @@ public class EntityGenderUtils {
|
||||
static public EntityGender emptyMethods() {
|
||||
return new EntityGender() {
|
||||
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() {
|
||||
return new EntityGender() {
|
||||
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() {
|
||||
return new EntityGender() {
|
||||
public boolean contains(IEntity test) {
|
||||
return test.methods2().size()==0 && test.fields2().size()==0;
|
||||
return test.getMethodsToDisplay().size()==0 && test.getFieldsToDisplay().size()==0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ public abstract class EntityUtils {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return new IEntity() {
|
||||
public List<Member> fields2() {
|
||||
return ent.fields2();
|
||||
public List<Member> getFieldsToDisplay() {
|
||||
return ent.getFieldsToDisplay();
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
@ -79,8 +79,8 @@ public abstract class EntityUtils {
|
||||
return ent.getUrl();
|
||||
}
|
||||
|
||||
public List<Member> methods2() {
|
||||
return ent.methods2();
|
||||
public List<Member> getMethodsToDisplay() {
|
||||
return ent.getMethodsToDisplay();
|
||||
}
|
||||
|
||||
public DrawFile getImageFile() {
|
||||
|
@ -52,13 +52,13 @@ public interface IEntity extends Imaged, SpecificBackcolorable {
|
||||
|
||||
public String getUrl();
|
||||
|
||||
public List<Member> fields2();
|
||||
public List<Member> getFieldsToDisplay();
|
||||
|
||||
public Stereotype getStereotype();
|
||||
|
||||
public void setStereotype(Stereotype stereotype);
|
||||
|
||||
public List<Member> methods2();
|
||||
public List<Member> getMethodsToDisplay();
|
||||
|
||||
public String getCode();
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6009 $
|
||||
* Revision $Revision: 6152 $
|
||||
*
|
||||
*/
|
||||
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.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
@ -66,12 +67,19 @@ public class Link implements Imaged {
|
||||
private final String labeldistance;
|
||||
private final String labelangle;
|
||||
|
||||
private HtmlColor specificColor;
|
||||
|
||||
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,
|
||||
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) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@ -87,10 +95,27 @@ public class Link implements Imaged {
|
||||
this.qualifier2 = qualifier2;
|
||||
this.labeldistance = labeldistance;
|
||||
this.labelangle = labelangle;
|
||||
this.specificColor = specificColor;
|
||||
}
|
||||
|
||||
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() {
|
||||
@ -281,4 +306,12 @@ public class Link implements Imaged {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public HtmlColor getSpecificColor() {
|
||||
return specificColor;
|
||||
}
|
||||
|
||||
public void setSpecificColor(String s) {
|
||||
this.specificColor = HtmlColor.getColorIfValid(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
public enum LinkStyle {
|
||||
|
||||
NORMAL, DASHED, INTERFACE_PROVIDER, INTERFACE_USER;
|
||||
NORMAL, DASHED, INTERFACE_PROVIDER, INTERFACE_USER, DOTTED, BOLD;
|
||||
|
||||
}
|
||||
|
@ -73,10 +73,26 @@ public class LinkType {
|
||||
return style == LinkStyle.DASHED;
|
||||
}
|
||||
|
||||
public boolean isDotted() {
|
||||
return style == LinkStyle.DOTTED;
|
||||
}
|
||||
|
||||
public boolean isBold() {
|
||||
return style == LinkStyle.BOLD;
|
||||
}
|
||||
|
||||
public LinkType getDashed() {
|
||||
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() {
|
||||
return new LinkType(decor1, LinkStyle.INTERFACE_PROVIDER, decor2);
|
||||
}
|
||||
@ -114,6 +130,12 @@ public class LinkType {
|
||||
if (style == LinkStyle.DASHED) {
|
||||
sb.append(",style=dashed");
|
||||
}
|
||||
if (style == LinkStyle.DOTTED) {
|
||||
sb.append(",style=dotted,");
|
||||
}
|
||||
if (style == LinkStyle.BOLD) {
|
||||
sb.append(",style=bold,");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -41,11 +41,6 @@ public class Member {
|
||||
private final boolean staticModifier;
|
||||
private final boolean abstractModifier;
|
||||
|
||||
private boolean privateModifier;
|
||||
private boolean protectedModifier;
|
||||
private boolean publicModifier;
|
||||
private boolean packagePrivateModifier;
|
||||
|
||||
private final VisibilityModifier visibilityModifier;
|
||||
|
||||
public Member(String display, boolean isMethod) {
|
||||
@ -55,30 +50,15 @@ public class Member {
|
||||
final String displayClean = display.replaceAll("(?i)\\{(static|classifier|abstract)\\}", "").trim();
|
||||
|
||||
if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
|
||||
updateVisibility(display.charAt(0));
|
||||
visibilityModifier = VisibilityModifier.getVisibilityModifier(display.charAt(0), isMethod == false);
|
||||
this.display = displayClean.substring(1).trim();
|
||||
} else {
|
||||
this.display = displayClean;
|
||||
visibilityModifier = null;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
// assert
|
||||
// VisibilityModifier.isVisibilityCharacter(this.display.charAt(0)) ==
|
||||
// false;
|
||||
|
||||
}
|
||||
|
||||
@ -130,23 +110,27 @@ public class Member {
|
||||
}
|
||||
|
||||
public final boolean isVisibilityModified() {
|
||||
return privateModifier || publicModifier || protectedModifier || packagePrivateModifier;
|
||||
return visibilityModifier != null;
|
||||
}
|
||||
|
||||
public final boolean isPrivate() {
|
||||
return privateModifier;
|
||||
return visibilityModifier == VisibilityModifier.PRIVATE_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PRIVATE_METHOD;
|
||||
}
|
||||
|
||||
public final boolean isProtected() {
|
||||
return protectedModifier;
|
||||
return visibilityModifier == VisibilityModifier.PROTECTED_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PROTECTED_METHOD;
|
||||
}
|
||||
|
||||
public final boolean isPublic() {
|
||||
return publicModifier;
|
||||
return visibilityModifier == VisibilityModifier.PUBLIC_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PUBLIC_METHOD;
|
||||
}
|
||||
|
||||
public final boolean isPackagePrivate() {
|
||||
return packagePrivateModifier;
|
||||
return visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_METHOD;
|
||||
}
|
||||
|
||||
public final VisibilityModifier getVisibilityModifier() {
|
||||
|
@ -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 + " ");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6130 $
|
||||
* Revision $Revision: 6197 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
@ -57,6 +57,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
|
||||
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.EmptyImageBuilder;
|
||||
@ -966,8 +968,9 @@ public final class CucaDiagramFileMaker {
|
||||
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 {
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5789 $
|
||||
* Revision $Revision: 6169 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
@ -83,11 +83,11 @@ public final class CucaDiagramSimplifier {
|
||||
} else {
|
||||
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) {
|
||||
manageBackColorForState(diagram, g, proxy);
|
||||
}
|
||||
for (Member field : g.getEntityCluster().fields2()) {
|
||||
for (Member field : g.getEntityCluster().getFieldsToDisplay()) {
|
||||
proxy.addField(field);
|
||||
}
|
||||
computeImageGroup(g, proxy, dotStrings);
|
||||
|
@ -126,14 +126,14 @@ public final class CucaDiagramTxtMaker {
|
||||
int y = 2;
|
||||
ug.getCharArea().drawHLine('-', y, 1, w - 1);
|
||||
y++;
|
||||
for (Member att : ent.fields2()) {
|
||||
for (Member att : ent.getFieldsToDisplay()) {
|
||||
final List<String> disp = StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar());
|
||||
ug.getCharArea().drawStringsLR(disp, 1, y);
|
||||
y += StringUtils.getHeight(disp);
|
||||
}
|
||||
ug.getCharArea().drawHLine('-', y, 1, w - 1);
|
||||
y++;
|
||||
for (Member att : ent.methods2()) {
|
||||
for (Member att : ent.getMethodsToDisplay()) {
|
||||
final List<String> disp = StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar());
|
||||
ug.getCharArea().drawStringsLR(disp, 1, y);
|
||||
y += StringUtils.getHeight(disp);
|
||||
@ -151,10 +151,10 @@ public final class CucaDiagramTxtMaker {
|
||||
|
||||
private int getHeight(Entity entity) {
|
||||
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()));
|
||||
}
|
||||
for (Member att : entity.fields2()) {
|
||||
for (Member att : entity.getFieldsToDisplay()) {
|
||||
result += StringUtils.getHeight(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()));
|
||||
}
|
||||
return result + 4;
|
||||
@ -162,13 +162,13 @@ public final class CucaDiagramTxtMaker {
|
||||
|
||||
private int getWidth(Entity entity) {
|
||||
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()));
|
||||
if (w > result) {
|
||||
result = w;
|
||||
}
|
||||
}
|
||||
for (Member att : entity.fields2()) {
|
||||
for (Member att : entity.getFieldsToDisplay()) {
|
||||
final int w = StringUtils.getWidth(StringUtils.getWithNewlines(att.getDisplayWithVisibilityChar()));
|
||||
if (w > result) {
|
||||
result = w;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6141 $
|
||||
* Revision $Revision: 6195 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
@ -148,7 +148,6 @@ final public class DotMaker implements GraphvizMaker {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initPrintWriter(StringBuilder sb) {
|
||||
|
||||
Log.info("Entities = " + data.getEntities().size());
|
||||
@ -195,7 +194,7 @@ final public class DotMaker implements GraphvizMaker {
|
||||
for (Group g : data.getGroupHierarchy().getChildrenGroups(parent)) {
|
||||
if (data.isEmpty(g) && g.getType() == GroupType.PACKAGE) {
|
||||
final IEntity folder = new Entity(g.getUid(), g.getCode(), g.getDisplay(), EntityType.EMPTY_PACKAGE,
|
||||
null);
|
||||
null, null);
|
||||
printEntity(sb, folder);
|
||||
} else {
|
||||
printGroup(sb, g);
|
||||
@ -346,9 +345,9 @@ final public class DotMaker implements GraphvizMaker {
|
||||
|
||||
if (g.getDisplay() != 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\"/>");
|
||||
for (Member att : g.getEntityCluster().fields2()) {
|
||||
for (Member att : g.getEntityCluster().getFieldsToDisplay()) {
|
||||
label.append(manageHtmlIB(" " + att.getDisplayWithVisibilityChar() + " ",
|
||||
FontParam.STATE_ATTRIBUTE, null));
|
||||
label.append("<BR ALIGN=\"LEFT\"/>");
|
||||
@ -512,7 +511,7 @@ final public class DotMaker implements GraphvizMaker {
|
||||
}
|
||||
|
||||
private void printLink(StringBuilder sb, Link link) throws IOException {
|
||||
final StringBuilder decoration = getLinkDecoration();
|
||||
final StringBuilder decoration = getLinkDecoration(link);
|
||||
|
||||
if (link.getWeight() > 1) {
|
||||
decoration.append("weight=" + link.getWeight() + ",");
|
||||
@ -611,8 +610,14 @@ final public class DotMaker implements GraphvizMaker {
|
||||
return g.getUid() + "_" + link.getUid();
|
||||
}
|
||||
|
||||
private StringBuilder getLinkDecoration() {
|
||||
final StringBuilder decoration = new StringBuilder("[color=" + getColorString(getArrowColorParam(), null) + ",");
|
||||
private StringBuilder getLinkDecoration(Link link) {
|
||||
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("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 + "\"];");
|
||||
} else if (type == EntityType.ACTIVITY) {
|
||||
String shape = "octagon";
|
||||
if (data.getSkinParam().useOctagonForActivity()==false || entity.getImageFile() != null) {
|
||||
if (data.getSkinParam().useOctagonForActivity() == false || entity.getImageFile() != null) {
|
||||
shape = "rect";
|
||||
}
|
||||
sb.append(entity.getUid() + " [fontcolor=" + getFontColorString(FontParam.ACTIVITY, stereo) + ",fillcolor="
|
||||
@ -908,7 +913,7 @@ final public class DotMaker implements GraphvizMaker {
|
||||
} else {
|
||||
throw new IllegalStateException(type.toString() + " " + data.getUmlDiagramType());
|
||||
}
|
||||
|
||||
|
||||
if (entity.isTop()) {
|
||||
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("</TABLE>");
|
||||
|
||||
if (entity.fields2().size() > 0) {
|
||||
if (entity.getFieldsToDisplay().size() > 0) {
|
||||
sb.append("|");
|
||||
for (Member att : entity.fields2()) {
|
||||
for (Member att : entity.getFieldsToDisplay()) {
|
||||
sb.append(manageHtmlIB(att.getDisplayWithVisibilityChar(), FontParam.STATE_ATTRIBUTE, stereotype));
|
||||
sb.append("<BR ALIGN=\"LEFT\"/>");
|
||||
}
|
||||
@ -1046,7 +1051,7 @@ final public class DotMaker implements GraphvizMaker {
|
||||
sb.append("</TABLE>");
|
||||
}
|
||||
|
||||
if (entity.fields2().size() == 0 && cFile == null) {
|
||||
if (entity.getFieldsToDisplay().size() == 0 && cFile == null) {
|
||||
sb.append("|");
|
||||
}
|
||||
|
||||
@ -1252,9 +1257,9 @@ final public class DotMaker implements GraphvizMaker {
|
||||
// if (fileFormat == FileFormat.EPS) {
|
||||
// sb.append(addFieldsEps(entity.fields2(), true));
|
||||
// } else {
|
||||
final boolean hasStatic = hasStatic(entity.fields2());
|
||||
final boolean hasStatic = hasStatic(entity.getFieldsToDisplay());
|
||||
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(
|
||||
ColorParam.classBackground, stereo), true));
|
||||
sb.append("<BR ALIGN=\"LEFT\"/>");
|
||||
@ -1266,9 +1271,9 @@ final public class DotMaker implements GraphvizMaker {
|
||||
// if (fileFormat == FileFormat.EPS) {
|
||||
// sb.append(addFieldsEps(entity.methods2(), true));
|
||||
// } else {
|
||||
final boolean hasStatic = hasStatic(entity.methods2());
|
||||
final boolean hasStatic = hasStatic(entity.getMethodsToDisplay());
|
||||
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(
|
||||
ColorParam.classBackground, stereo), true));
|
||||
sb.append("<BR ALIGN=\"LEFT\"/>");
|
||||
@ -1365,14 +1370,14 @@ final public class DotMaker implements GraphvizMaker {
|
||||
|
||||
if (showFields) {
|
||||
sb.append("<TR><TD " + getWitdh55() + ">");
|
||||
if (entity.fields2().size() > 0) {
|
||||
if (entity.getFieldsToDisplay().size() > 0) {
|
||||
buildTableVisibility(entity, true, sb, springField);
|
||||
}
|
||||
sb.append("</TD></TR>");
|
||||
}
|
||||
if (showMethods) {
|
||||
sb.append("<TR><TD>");
|
||||
if (entity.methods2().size() > 0) {
|
||||
if (entity.getMethodsToDisplay().size() > 0) {
|
||||
buildTableVisibility(entity, false, sb, springMethod);
|
||||
}
|
||||
sb.append("</TD></TR>");
|
||||
@ -1400,9 +1405,9 @@ final public class DotMaker implements GraphvizMaker {
|
||||
throws IOException {
|
||||
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;
|
||||
for (Member att : isField ? entity.fields2() : entity.methods2()) {
|
||||
for (Member att : isField ? entity.getFieldsToDisplay() : entity.getMethodsToDisplay()) {
|
||||
sb.append("<TR>");
|
||||
if (dpiNormal) {
|
||||
sb.append("<TD WIDTH=\"10\">");
|
||||
@ -1454,7 +1459,7 @@ final public class DotMaker implements GraphvizMaker {
|
||||
|
||||
private int getLongestMethods(IEntity entity) {
|
||||
int result = 0;
|
||||
for (Member att : entity.methods2()) {
|
||||
for (Member att : entity.getMethodsToDisplay()) {
|
||||
final int size = att.getDisplayWithVisibilityChar().length();
|
||||
if (size > result) {
|
||||
result = size;
|
||||
@ -1466,7 +1471,7 @@ final public class DotMaker implements GraphvizMaker {
|
||||
|
||||
private int getLongestField(IEntity entity) {
|
||||
int result = 0;
|
||||
for (Member att : entity.fields2()) {
|
||||
for (Member att : entity.getFieldsToDisplay()) {
|
||||
final int size = att.getDisplayWithVisibilityChar().length();
|
||||
if (size > result) {
|
||||
result = size;
|
||||
@ -1501,7 +1506,7 @@ final public class DotMaker implements GraphvizMaker {
|
||||
sb.append("</TD></TR>");
|
||||
sb.append("<TR><TD " + getWitdh55() + ">");
|
||||
|
||||
if (entity.fields2().size() == 0) {
|
||||
if (entity.getFieldsToDisplay().size() == 0) {
|
||||
sb.append(manageHtmlIB(" ", FontParam.OBJECT_ATTRIBUTE, stereo));
|
||||
} else {
|
||||
buildTableVisibility(entity, true, sb, springField);
|
||||
@ -1532,10 +1537,10 @@ final public class DotMaker implements GraphvizMaker {
|
||||
sb.append("</TD></TR>");
|
||||
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));
|
||||
} else {
|
||||
for (Member att : entity.fields2()) {
|
||||
for (Member att : entity.getFieldsToDisplay()) {
|
||||
sb.append(manageHtmlIB(att.getDisplayWithVisibilityChar(), FontParam.OBJECT_ATTRIBUTE, stereo));
|
||||
sb.append("<BR ALIGN=\"LEFT\"/>");
|
||||
}
|
||||
|
135
src/net/sourceforge/plantuml/cucadiagram/dot/Executable.java
Normal file
135
src/net/sourceforge/plantuml/cucadiagram/dot/Executable.java
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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());
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6007 $
|
||||
* Revision $Revision: 6200 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
@ -51,6 +51,7 @@ public class GraphvizUtils {
|
||||
return File.separatorChar == '\\';
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Graphviz create(String dotString, String... type) {
|
||||
if (isWindows()) {
|
||||
return new GraphvizWindows(dotString, type);
|
||||
@ -58,6 +59,10 @@ public class GraphvizUtils {
|
||||
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() {
|
||||
return create(null, "png").getDotExe();
|
||||
}
|
||||
@ -161,5 +166,12 @@ public class GraphvizUtils {
|
||||
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
public static OS getOS() {
|
||||
if (isWindows()) {
|
||||
return new OSWindows();
|
||||
}
|
||||
return new OSLinux();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5872 $
|
||||
* Revision $Revision: 6197 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
@ -47,6 +47,8 @@ import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileUtils;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
@ -214,7 +216,8 @@ public final class GroupPngMaker {
|
||||
// dotData.putAllStaticImages(staticImages);
|
||||
// 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() {
|
||||
|
50
src/net/sourceforge/plantuml/cucadiagram/dot/OS.java
Normal file
50
src/net/sourceforge/plantuml/cucadiagram/dot/OS.java
Normal 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);
|
||||
|
||||
}
|
66
src/net/sourceforge/plantuml/cucadiagram/dot/OSLinux.java
Normal file
66
src/net/sourceforge/plantuml/cucadiagram/dot/OSLinux.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
94
src/net/sourceforge/plantuml/cucadiagram/dot/OSWindows.java
Normal file
94
src/net/sourceforge/plantuml/cucadiagram/dot/OSWindows.java
Normal 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() + "\"";
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6009 $
|
||||
* Revision $Revision: 6168 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.graph;
|
||||
@ -63,8 +63,8 @@ class EntityImageClass extends AbstractEntityImage {
|
||||
super(entity);
|
||||
this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration(
|
||||
getFont14(), Color.BLACK), HorizontalAlignement.CENTER);
|
||||
this.methods = new MethodsOrFieldsArea(entity.methods2(), getFont14());
|
||||
this.fields = new MethodsOrFieldsArea(entity.fields2(), getFont14());
|
||||
this.methods = new MethodsOrFieldsArea(entity.getMethodsToDisplay(), getFont14());
|
||||
this.fields = new MethodsOrFieldsArea(entity.getFieldsToDisplay(), getFont14());
|
||||
|
||||
circledCharacter = getCircledCharacter(entity);
|
||||
|
||||
|
@ -82,8 +82,8 @@ public class EntityImageClass2 extends AbstractEntityImage2 {
|
||||
getFont(FontParam.CLASS_STEREOTYPE), getFontColor(FontParam.CLASS_STEREOTYPE)),
|
||||
HorizontalAlignement.CENTER);
|
||||
}
|
||||
this.methods = new MethodsOrFieldsArea2(entity.methods2(), FontParam.CLASS_ATTRIBUTE, skinParam);
|
||||
this.fields = new MethodsOrFieldsArea2(entity.fields2(), FontParam.CLASS_ATTRIBUTE, skinParam);
|
||||
this.methods = new MethodsOrFieldsArea2(entity.getMethodsToDisplay(), FontParam.CLASS_ATTRIBUTE, skinParam);
|
||||
this.fields = new MethodsOrFieldsArea2(entity.getFieldsToDisplay(), FontParam.CLASS_ATTRIBUTE, skinParam);
|
||||
|
||||
circledCharacter = getCircledCharacter(entity);
|
||||
}
|
||||
|
112
src/net/sourceforge/plantuml/postit/Area.java
Normal file
112
src/net/sourceforge/plantuml/postit/Area.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
46
src/net/sourceforge/plantuml/postit/AreaLayout.java
Normal file
46
src/net/sourceforge/plantuml/postit/AreaLayout.java
Normal 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);
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
67
src/net/sourceforge/plantuml/postit/CommandCreatePostIt.java
Normal file
67
src/net/sourceforge/plantuml/postit/CommandCreatePostIt.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
55
src/net/sourceforge/plantuml/postit/CommandWidth.java
Normal file
55
src/net/sourceforge/plantuml/postit/CommandWidth.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
44
src/net/sourceforge/plantuml/postit/Elastic.java
Normal file
44
src/net/sourceforge/plantuml/postit/Elastic.java
Normal 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);
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
114
src/net/sourceforge/plantuml/postit/PostIt.java
Normal file
114
src/net/sourceforge/plantuml/postit/PostIt.java
Normal 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;
|
||||
}
|
||||
}
|
147
src/net/sourceforge/plantuml/postit/PostItDiagram.java
Normal file
147
src/net/sourceforge/plantuml/postit/PostItDiagram.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5251 $
|
||||
* Revision $Revision: 6198 $
|
||||
*
|
||||
*/
|
||||
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) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@ -145,6 +145,9 @@ class ConstraintSet {
|
||||
for (Pushable box : participantList) {
|
||||
if (box.equals(firstToChange)) {
|
||||
founded = true;
|
||||
if (including==false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (founded) {
|
||||
box.pushToLeft(deltaX);
|
||||
@ -153,7 +156,7 @@ class ConstraintSet {
|
||||
}
|
||||
|
||||
public void pushToLeft(double delta) {
|
||||
pushToLeftParticipantBox(delta, firstBorder);
|
||||
pushToLeftParticipantBox(delta, firstBorder, true);
|
||||
}
|
||||
|
||||
private void ensureSpaceAfter(StringBounder stringBounder, Pushable p1, Pushable p2, double space) {
|
||||
@ -167,7 +170,7 @@ class ConstraintSet {
|
||||
assert p1.getCenterX(stringBounder) < p2.getCenterX(stringBounder);
|
||||
final double existingSpace = p2.getCenterX(stringBounder) - p1.getCenterX(stringBounder);
|
||||
if (existingSpace < space) {
|
||||
pushToLeftParticipantBox(space - existingSpace, p2);
|
||||
pushToLeftParticipantBox(space - existingSpace, p2, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6113 $
|
||||
* Revision $Revision: 6198 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.sequencediagram.graphic;
|
||||
@ -141,7 +141,7 @@ class DrawableSet {
|
||||
return height + heightEnglober;
|
||||
}
|
||||
|
||||
public List<ParticipantEngloberContexted> getExistingParticipantEnglober2() {
|
||||
public List<ParticipantEngloberContexted> getExistingParticipantEnglober() {
|
||||
final List<ParticipantEngloberContexted> result = new ArrayList<ParticipantEngloberContexted>();
|
||||
ParticipantEngloberContexted pending = null;
|
||||
for (Map.Entry<Participant, ParticipantEnglober> ent : participantEnglobers2.entrySet()) {
|
||||
@ -163,7 +163,7 @@ class DrawableSet {
|
||||
|
||||
public double getOffsetForEnglobers(StringBounder stringBounder) {
|
||||
double result = 0;
|
||||
for (ParticipantEngloberContexted englober : getExistingParticipantEnglober2()) {
|
||||
for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
|
||||
final Component comp = skin.createComponent(ComponentType.ENGLOBER, skinParam, englober
|
||||
.getParticipantEnglober().getTitle());
|
||||
final double height = comp.getPreferredHeight(stringBounder);
|
||||
@ -178,7 +178,7 @@ class DrawableSet {
|
||||
static private final int MARGIN_FOR_ENGLOBERS1 = 2;
|
||||
|
||||
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) {
|
||||
return 1 + marginForEnglobers;
|
||||
@ -315,7 +315,7 @@ class DrawableSet {
|
||||
}
|
||||
|
||||
private void drawEnglobers(UGraphic ug, double height, Context2D context) {
|
||||
for (ParticipantEngloberContexted englober : getExistingParticipantEnglober2()) {
|
||||
for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
|
||||
double x1 = getX1(englober);
|
||||
final double x2 = getX2(ug.getStringBounder(), englober);
|
||||
|
||||
@ -325,9 +325,9 @@ class DrawableSet {
|
||||
final double preferedWidth = getEngloberPreferedWidth(ug.getStringBounder(),
|
||||
englober.getParticipantEnglober());
|
||||
if (preferedWidth > width) {
|
||||
if (englober.getFirst2() == englober.getLast2()) {
|
||||
//if (englober.getFirst2() == englober.getLast2()) {
|
||||
x1 -= (preferedWidth - width) / 2;
|
||||
}
|
||||
//}
|
||||
final Dimension2DDouble dim = new Dimension2DDouble(preferedWidth, height);
|
||||
ug.translate(x1, 1);
|
||||
comp.drawU(ug, dim, context);
|
||||
@ -351,13 +351,13 @@ class DrawableSet {
|
||||
return skin.createComponent(ComponentType.ENGLOBER, s, englober.getTitle());
|
||||
}
|
||||
|
||||
private double getX1(ParticipantEngloberContexted englober) {
|
||||
public double getX1(ParticipantEngloberContexted englober) {
|
||||
final Participant first = englober.getFirst2();
|
||||
final ParticipantBox firstBox = participants.get(first).getParticipantBox();
|
||||
return firstBox.getStartingX() + 1;
|
||||
}
|
||||
|
||||
private double getX2(StringBounder stringBounder, ParticipantEngloberContexted englober) {
|
||||
public double getX2(StringBounder stringBounder, ParticipantEngloberContexted englober) {
|
||||
final Participant last = englober.getLast2();
|
||||
final ParticipantBox lastBox = participants.get(last).getParticipantBox();
|
||||
return lastBox.getMaxX(stringBounder) - 1;
|
||||
@ -394,7 +394,7 @@ class DrawableSet {
|
||||
// }
|
||||
|
||||
private ParticipantEngloberContexted getParticipantEnglober(Participant p) {
|
||||
for (ParticipantEngloberContexted pe : getExistingParticipantEnglober2()) {
|
||||
for (ParticipantEngloberContexted pe : getExistingParticipantEnglober()) {
|
||||
if (pe.contains(p)) {
|
||||
return pe;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6113 $
|
||||
* Revision $Revision: 6198 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.sequencediagram.graphic;
|
||||
@ -154,9 +154,10 @@ class DrawableSetInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
takeParticipantEngloberTitleWidth(stringBounder);
|
||||
|
||||
//takeParticipantEngloberTitleWidth(stringBounder);
|
||||
constraintSet.takeConstraintIntoAccount(stringBounder);
|
||||
//takeParticipantEngloberTitleWidth2(stringBounder);
|
||||
takeParticipantEngloberTitleWidth3(stringBounder);
|
||||
|
||||
prepareMissingSpace(stringBounder);
|
||||
|
||||
@ -164,26 +165,66 @@ class DrawableSetInitializer {
|
||||
return drawableSet;
|
||||
}
|
||||
|
||||
private void takeParticipantEngloberTitleWidth(StringBounder stringBounder) {
|
||||
for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober2()) {
|
||||
private void takeParticipantEngloberTitleWidth3(StringBounder stringBounder) {
|
||||
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
|
||||
.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) {
|
||||
final Constraint constraint1 = constraintSet.getConstraintBefore(first);
|
||||
final Constraint constraint2 = constraintSet.getConstraintAfter(last);
|
||||
final double w1 = constraint1.getParticipant1().getPreferredWidth(stringBounder);
|
||||
final double w2 = constraint2.getParticipant2().getPreferredWidth(stringBounder);
|
||||
constraint1.ensureValue(preferredWidth / 2 + w1 / 2 + 5);
|
||||
constraint2.ensureValue(preferredWidth / 2 + w2 / 2 + 5);
|
||||
constraint1.ensureValue(preferredWidth / 2 + w1 / 2 + margin);
|
||||
constraint2.ensureValue(preferredWidth / 2 + w2 / 2 + margin);
|
||||
} else {
|
||||
final Pushable beforeFirst = constraintSet.getPrevious(first);
|
||||
final Pushable afterLast = constraintSet.getNext(last);
|
||||
final Constraint constraint1 = constraintSet.getConstraint(beforeFirst, afterLast);
|
||||
constraint1.ensureValue(preferredWidth + beforeFirst.getPreferredWidth(stringBounder) / 2
|
||||
+ afterLast.getPreferredWidth(stringBounder) / 2 + 10);
|
||||
+ afterLast.getPreferredWidth(stringBounder) / 2 + 2 * margin);
|
||||
}
|
||||
previousLast = last;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6113 $
|
||||
* Revision $Revision: 6208 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.sequencediagram.graphic;
|
||||
@ -408,4 +408,8 @@ public class SequenceDiagramFileMaker implements FileMaker {
|
||||
text.drawU(ug, area.getHeaderX(diagram.getHeaderAlignement()), area.getHeaderY());
|
||||
}
|
||||
|
||||
public static StringBounder getDummystringbounder() {
|
||||
return dummyStringBounder;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
package net.sourceforge.plantuml.statediagram.command;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
@ -57,14 +58,15 @@ public class CommandLinkState2 extends SingleLineCommand2<StateDiagram> {
|
||||
|
||||
static RegexConcat getRegex() {
|
||||
return new RegexConcat(
|
||||
new RegexLeaf("^"),
|
||||
getStatePattern("ENT1"),
|
||||
new RegexLeaf("\\s*"),
|
||||
new RegexLeaf("ARROW", "((-+)(left|right|up|down|le?|ri?|up?|do?)?(-*)([\\]>]))"),
|
||||
new RegexLeaf("\\s*"),
|
||||
getStatePattern("ENT2"),
|
||||
new RegexLeaf("\\s*"),
|
||||
new RegexLeaf("LABEL", "(?::\\s*([^\"]+))?"),
|
||||
new RegexLeaf("^"), //
|
||||
getStatePattern("ENT1"), //
|
||||
new RegexLeaf("\\s*"), //
|
||||
new RegexLeaf("ARROW",
|
||||
"((-+)(left|right|up|down|le?|ri?|up?|do?)?(?:\\[((?:#\\w+|dotted|dashed|bold)(?:,#\\w+|,dotted|,dashed|,bold)*)\\])?(-*)\\>)"),
|
||||
new RegexLeaf("\\s*"), //
|
||||
getStatePattern("ENT2"), //
|
||||
new RegexLeaf("\\s*"), //
|
||||
new RegexLeaf("LABEL", "(?::\\s*([^\"]+))?"), //
|
||||
new RegexLeaf("$"));
|
||||
}
|
||||
|
||||
@ -79,7 +81,7 @@ public class CommandLinkState2 extends SingleLineCommand2<StateDiagram> {
|
||||
|
||||
final IEntity cl1 = getEntityStart(ent1);
|
||||
final IEntity cl2 = getEntityEnd(ent2);
|
||||
|
||||
|
||||
if (arg.get("ENT1").get(1) != null) {
|
||||
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));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (dir == Direction.LEFT || dir == Direction.RIGHT) {
|
||||
@ -106,6 +108,21 @@ public class CommandLinkState2 extends SingleLineCommand2<StateDiagram> {
|
||||
if (dir == Direction.LEFT || dir == Direction.UP) {
|
||||
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);
|
||||
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -45,6 +45,7 @@ import net.sourceforge.plantuml.usecasediagram.command.CommandCreateUsecase2;
|
||||
import net.sourceforge.plantuml.usecasediagram.command.CommandLinkUsecase2;
|
||||
import net.sourceforge.plantuml.usecasediagram.command.CommandMultilinesUsecaseNoteEntity;
|
||||
import net.sourceforge.plantuml.usecasediagram.command.CommandRankDirUsecase;
|
||||
import net.sourceforge.plantuml.usecasediagram.command.CommandSetStrategy;
|
||||
|
||||
public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory {
|
||||
|
||||
@ -77,5 +78,7 @@ public class UsecaseDiagramFactory extends AbstractUmlSystemCommandFactory {
|
||||
|
||||
addCommand(new CommandMultilinesUsecaseNoteEntity(system));
|
||||
addCommand(new CommandMultilinesStandaloneNote(system));
|
||||
}
|
||||
|
||||
addCommand(new CommandSetStrategy(system));
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 6142 $
|
||||
* Revision $Revision: 6211 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.version;
|
||||
@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version;
|
||||
public class Version {
|
||||
|
||||
public static int version() {
|
||||
return 6141;
|
||||
return 6210;
|
||||
}
|
||||
|
||||
public static long compileTime() {
|
||||
return 1298495043843L;
|
||||
return 1300656476468L;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class XmiClassDiagram {
|
||||
final Element feature = document.createElement("UML:Classifier.feature");
|
||||
cla.appendChild(feature);
|
||||
|
||||
for (Member m : entity.fields2()) {
|
||||
for (Member m : entity.getFieldsToDisplay()) {
|
||||
// <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
|
||||
// visibility="public" isSpecification="false"
|
||||
// ownerScope="instance" changeability="changeable"
|
||||
@ -206,7 +206,7 @@ public class XmiClassDiagram {
|
||||
feature.appendChild(attribute);
|
||||
}
|
||||
|
||||
for (Member m : entity.methods2()) {
|
||||
for (Member m : entity.getMethodsToDisplay()) {
|
||||
// <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
|
||||
// visibility="public" isSpecification="false"
|
||||
// ownerScope="instance" isQuery="false" concurrency="sequential"
|
||||
|
Loading…
Reference in New Issue
Block a user