1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-07 02:40:52 +00:00

version 8023

This commit is contained in:
Arnaud Roques 2015-04-20 21:54:30 +02:00
parent f2872e630b
commit 36ce60c4c1
32 changed files with 0 additions and 5121 deletions

View File

@ -1,61 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 6719 $
*
*/
package net.sourceforge.plantuml;
public class MathUtils {
public static double max(double a, double b) {
return Math.max(a, b);
}
public static double max(double a, double b, double c) {
return Math.max(Math.max(a, b), c);
}
public static double limitation(double v, double min, double max) {
if (min >= max) {
assert false : "min="+min+" max="+max+" v="+v;
return v;
// throw new IllegalArgumentException("min="+min+" max="+max+" v="+v);
}
if (v < min) {
return min;
}
if (v > max) {
return max;
}
return v;
}
}

View File

@ -1,49 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 6110 $
*
*/
package net.sourceforge.plantuml;
public class StartUtils {
public static boolean isArobaseStartDiagram(String s) {
s = s.trim();
return s.startsWith("@start");
}
public static boolean isArobaseEndDiagram(String s) {
s = s.trim();
return s.startsWith("@end");
}
}

View File

@ -1,56 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 9786 $
*
*/
package net.sourceforge.plantuml;
import java.util.concurrent.atomic.AtomicInteger;
import net.sourceforge.plantuml.cucadiagram.Code;
public class UniqueSequence {
private static final AtomicInteger cpt = new AtomicInteger(1);
public static void reset() {
cpt.set(0);
}
public static int getValue() {
return cpt.addAndGet(1);
}
public static Code getCode(String prefix) {
return Code.of(prefix + getValue());
}
}

View File

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

View File

@ -1,148 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 9786 $
*
*/
package net.sourceforge.plantuml.activitydiagram3;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
public class InstructionIf1 implements Instruction {
private final List<Branch> thens = new ArrayList<Branch>();
private Branch elseBranch;
private final Instruction parent;
private Branch current;
private final LinkRendering inlinkRendering;
private final Swimlane swimlane;
public InstructionIf1(Swimlane swimlane, Instruction parent, Display labelTest, Display whenThen,
LinkRendering inlinkRendering) {
this.parent = parent;
this.inlinkRendering = inlinkRendering;
this.swimlane = swimlane;
this.thens.add(new Branch(swimlane, whenThen, labelTest));
this.current = this.thens.get(0);
}
public void add(Instruction ins) {
current.add(ins);
}
public Ftile createFtile(FtileFactory factory) {
for (Branch branch : thens) {
branch.updateFtile(factory);
}
if (elseBranch == null) {
this.elseBranch = new Branch(swimlane, null, null);
}
elseBranch.updateFtile(factory);
return factory.createIf(swimlane, thens, elseBranch);
}
public Instruction getParent() {
return parent;
}
public void swithToElse(Display whenElse, LinkRendering nextLinkRenderer) {
if (elseBranch != null) {
throw new IllegalStateException();
}
this.current.setInlinkRendering(nextLinkRenderer);
this.elseBranch = new Branch(swimlane, whenElse, null);
// this.elseBranch.setLabelPositive(whenElse);
this.current = elseBranch;
}
public void elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer) {
if (elseBranch != null) {
throw new IllegalStateException();
}
this.current.setInlinkRendering(nextLinkRenderer);
this.current = new Branch(swimlane, whenThen, test);
this.thens.add(current);
}
public void endif(LinkRendering nextLinkRenderer) {
if (elseBranch == null) {
this.elseBranch = new Branch(swimlane, null, null);
}
this.current.setInlinkRendering(nextLinkRenderer);
}
final public boolean kill() {
return current.kill();
}
public LinkRendering getInLinkRendering() {
return inlinkRendering;
}
public void addNote(Display note, NotePosition position) {
current.addNote(note, position);
}
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>();
if (swimlane != null) {
result.add(swimlane);
}
for (Branch branch : thens) {
result.addAll(branch.getSwimlanes());
}
result.addAll(elseBranch.getSwimlanes());
return Collections.unmodifiableSet(result);
}
public Swimlane getSwimlaneIn() {
return swimlane;
}
public Swimlane getSwimlaneOut() {
return swimlane;
}
}

View File

@ -1,159 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 8475 $
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMarged;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBlackBlock;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class FtileFactoryDelegatorCreateFork2 extends FtileFactoryDelegator {
private final double spaceArroundBlackBar = 20;
private final double barHeight = 6;
private final double xMargin = 14;
private final Rose rose = new Rose();
public FtileFactoryDelegatorCreateFork2(FtileFactory factory, ISkinParam skinParam) {
super(factory, skinParam);
}
@Override
public Ftile createFork(List<Ftile> all) {
final HtmlColor colorBar = rose.getHtmlColor(getSkinParam(), ColorParam.activityBar);
final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
final Dimension2D dimSuper = super.createFork(all).asTextBlock().calculateDimension(getStringBounder());
final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
final List<Ftile> list = new ArrayList<Ftile>();
for (Ftile tmp : all) {
list.add(new FtileHeightFixed(new FtileMarged(tmp, xMargin), height1));
}
final Ftile inner = super.createFork(list);
final List<Connection> conns1 = new ArrayList<Connection>();
final List<Connection> conns2 = new ArrayList<Connection>();
double x = 0;
for (Ftile tmp : list) {
final Dimension2D dim = tmp.asTextBlock().calculateDimension(getStringBounder());
conns1.add(new ConnectionIn(tmp, x, arrowColor, barHeight));
conns2.add(new ConnectionOut(tmp, x, arrowColor, height1));
x += dim.getWidth();
}
Ftile black1 = new FtileBlackBlock(shadowing(), inner.asTextBlock().calculateDimension(getStringBounder())
.getWidth(), barHeight, colorBar, list.get(0).getSwimlaneIn());
black1 = FtileUtils.addConnection(black1, conns1);
Ftile black2 = new FtileBlackBlock(shadowing(), inner.asTextBlock().calculateDimension(getStringBounder())
.getWidth(), barHeight, colorBar, list.get(0).getSwimlaneIn());
// black2 = FtileUtils.addConnection(black2, conns2);
// return new FtileAssemblySimple(black1, inner);
return new FtileAssemblySimple(new FtileAssemblySimple(black1, inner), black2);
}
class ConnectionIn extends AbstractConnection {
private final double x;
private final HtmlColor arrowColor;
private final double barHeight;
public ConnectionIn(Ftile tmp, double x, HtmlColor arrowColor, double barHeight) {
super(null, tmp);
this.x = x;
this.arrowColor = arrowColor;
this.barHeight = barHeight;
}
public void drawU(UGraphic ug) {
ug = ug.apply(new UTranslate(x, barHeight));
final Point2D p = getFtile2().getPointIn(getStringBounder());
final Snake s = new Snake(arrowColor, Arrows.asToDown());
s.addPoint(p.getX(), 0);
s.addPoint(p.getX(), p.getY());
ug.draw(s);
}
}
class ConnectionOut extends AbstractConnection {
private final double x;
private final HtmlColor arrowColor;
private final double height;
public ConnectionOut(Ftile tmp, double x, HtmlColor arrowColor, double height) {
super(tmp, null);
this.x = x;
this.arrowColor = arrowColor;
this.height = height;
}
public void drawU(UGraphic ug) {
ug = ug.apply(new UTranslate(x, 0));
final Point2D p = getFtile1().getPointOut(getStringBounder());
if (p == null) {
return;
}
final Snake s = new Snake(arrowColor, Arrows.asToDown());
s.addPoint(p.getX(), p.getY());
s.addPoint(p.getX(), height);
ug.draw(s);
}
}
}

View File

@ -1,524 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 8475 $
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class FtileIf2 extends AbstractFtile {
private final double xSeparation = 20;
private final List<Ftile> tiles;
private final Ftile tile2;
private final List<Ftile> diamonds;
private final HtmlColor arrowColor;
private FtileIf2(List<Ftile> diamonds, List<Ftile> tiles, Ftile tile2, HtmlColor arrowColor) {
super(tiles.get(0).shadowing() || tile2.shadowing());
this.diamonds = diamonds;
this.tiles = tiles;
this.tile2 = tile2;
this.arrowColor = arrowColor;
}
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>();
if (getSwimlaneIn() != null) {
result.add(getSwimlaneIn());
}
for (Ftile tile : tiles) {
result.addAll(tile.getSwimlanes());
}
result.addAll(tile2.getSwimlanes());
return Collections.unmodifiableSet(result);
}
public Swimlane getSwimlaneIn() {
return diamonds.get(0).getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
return getSwimlaneIn();
}
static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont font,
HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, List<Branch> thens,
Branch branch2) {
final List<Ftile> tiles = new ArrayList<Ftile>();
for (Branch branch : thens) {
tiles.add(new FtileMinWidth(branch.getFtile(), 30));
}
final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK);
final List<Ftile> diamonds = new ArrayList<Ftile>();
final List<Connection> conns = new ArrayList<Connection>();
for (Branch branch : thens) {
final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT,
ftileFactory);
final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT,
ftileFactory);
FtileDiamondInside diamond = new FtileDiamondInside(branch.shadowing(), backColor, borderColor, swimlane,
tbTest);
diamond = diamond.withNorth(tb1);
diamonds.add(diamond);
}
final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT,
ftileFactory);
final int last = diamonds.size() - 1;
diamonds.set(last, ((FtileDiamondInside) diamonds.get(last)).withEast(tb2));
final FtileIf2 result = new FtileIf2(diamonds, tiles, tile2, arrowColor);
for (int i = 0; i < thens.size(); i++) {
final Ftile ftile = tiles.get(i);
final Ftile diam = diamonds.get(i);
final HtmlColor color = thens.get(i).getInlinkRenderingColor();
conns.add(result.new ConnectionHorizontalIn(diam, ftile, color == null ? arrowColor : color));
conns.add(result.new ConnectionHorizontalOut(ftile, arrowColor));
}
for (int i = 0; i < diamonds.size() - 1; i++) {
final Ftile diam1 = diamonds.get(i);
final Ftile diam2 = diamonds.get(i + 1);
conns.add(result.new ConnectionVertical(diam1, diam2, arrowColor));
}
conns.add(result.new ConnectionIn(arrowColor));
conns.add(result.new ConnectionLastElseIn(arrowColor));
conns.add(result.new ConnectionLastElseOut(arrowColor));
conns.add(result.new ConnectionHline(arrowColor));
return FtileUtils.addConnection(result, conns);
}
class ConnectionVertical extends AbstractConnection {
private final HtmlColor color;
public ConnectionVertical(Ftile diam1, Ftile diam2, HtmlColor color) {
super(diam1, diam2);
this.color = color;
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Point2D p1 = getP1(stringBounder);
final Point2D p2 = getP2(stringBounder);
final Snake snake = new Snake(color, Arrows.asToRight());
snake.addPoint(p1);
snake.addPoint(p2);
ug.draw(snake);
}
private Point2D getP1(StringBounder stringBounder) {
final Dimension2D dimDiamond1 = getFtile1().asTextBlock().calculateDimension(stringBounder);
final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getHeight() / 2);
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
}
private Point2D getP2(StringBounder stringBounder) {
final Dimension2D dimDiamond1 = getFtile2().asTextBlock().calculateDimension(stringBounder);
final Point2D p = new Point2D.Double(0, dimDiamond1.getHeight() / 2);
return getTranslateDiamond1(getFtile2(), stringBounder).getTranslated(p);
}
}
class ConnectionIn extends AbstractConnection {
private final HtmlColor arrowColor;
public ConnectionIn(HtmlColor arrowColor) {
super(null, diamonds.get(0));
this.arrowColor = arrowColor;
}
public void drawU(UGraphic ug) {
final Point2D p1 = getPointIn(ug.getStringBounder());
final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder());
final Point2D p2 = tr.getTranslated(getFtile2().getPointIn(ug.getStringBounder()));
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
snake.addPoint(p1);
snake.addPoint(p2.getX(), p1.getY());
snake.addPoint(p2);
ug.draw(snake);
}
}
class ConnectionLastElseIn extends AbstractConnection {
private final HtmlColor arrowColor;
public ConnectionLastElseIn(HtmlColor arrowColor) {
super(diamonds.get(diamonds.size() - 1), tile2);
this.arrowColor = arrowColor;
}
public void drawU(UGraphic ug) {
final Point2D p1 = getP1(ug.getStringBounder());
final UTranslate tr2 = getTranslate2(ug.getStringBounder());
final Point2D p2 = tr2.getTranslated(getFtile2().getPointIn(ug.getStringBounder()));
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
snake.addPoint(p1);
snake.addPoint(p2.getX(), p1.getY());
snake.addPoint(p2);
ug.draw(snake);
}
private Point2D getP1(StringBounder stringBounder) {
final Dimension2D dimDiamond1 = getFtile1().asTextBlock().calculateDimension(stringBounder);
final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getHeight() / 2);
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
}
}
class ConnectionLastElseOut extends AbstractConnection {
private final HtmlColor arrowColor;
public ConnectionLastElseOut(HtmlColor arrowColor) {
super(tile2, null);
this.arrowColor = arrowColor;
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final UTranslate tr1 = getTranslate2(stringBounder);
final Point2D p1 = tr1.getTranslated(getFtile1().getPointOut(stringBounder));
final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
snake.addPoint(p1);
snake.addPoint(p2);
ug.draw(snake);
}
}
class ConnectionHorizontalIn extends AbstractConnection {
private final HtmlColor color;
public ConnectionHorizontalIn(Ftile diamond, Ftile tile, HtmlColor color) {
super(diamond, tile);
this.color = color;
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Point2D p1 = getP1(stringBounder);
final Point2D p2 = getP2(stringBounder);
final Snake snake = new Snake(color, Arrows.asToDown());
snake.addPoint(p1);
snake.addPoint(p2);
ug.draw(snake);
}
private Point2D getP1(StringBounder stringBounder) {
final Point2D p = getFtile1().getPointOut(stringBounder);
return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
}
private Point2D getP2(StringBounder stringBounder) {
final Point2D p = getFtile2().getPointIn(stringBounder);
return getTranslate1(getFtile2(), stringBounder).getTranslated(p);
}
}
class ConnectionHorizontalOut extends AbstractConnection {
private final HtmlColor color;
public ConnectionHorizontalOut(Ftile tile, HtmlColor color) {
super(tile, null);
this.color = color;
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
final Point2D p1 = getP1(stringBounder);
if (p1 == null) {
return;
}
final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
final Snake snake = new Snake(color, Arrows.asToDown());
snake.addPoint(p1);
snake.addPoint(p2);
ug.draw(snake);
}
private Point2D getP1(StringBounder stringBounder) {
final Point2D p = getFtile1().getPointOut(stringBounder);
return getTranslate1(getFtile1(), stringBounder).getTranslated(p);
}
}
class ConnectionHline extends AbstractConnection {
private final HtmlColor arrowColor;
public ConnectionHline(HtmlColor arrowColor) {
super(null, null);
this.arrowColor = arrowColor;
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D totalDim = calculateDimensionInternal(stringBounder);
final List<Ftile> all = new ArrayList<Ftile>(tiles);
all.add(tile2);
double minX = Double.MAX_VALUE;
double maxX = 0;
for (Ftile tmp : all) {
if (tmp.isKilled()) {
continue;
}
final UTranslate ut = getTranslateFor(tmp, stringBounder);
final double middle = ut.getTranslated(tmp.getPointOut(stringBounder)).getX();
minX = Math.min(minX, middle);
maxX = Math.max(maxX, middle);
}
final Snake s = new Snake(arrowColor);
final double height = totalDim.getHeight();
s.addPoint(minX, height);
s.addPoint(maxX, height);
ug.draw(s);
}
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (child == tile2) {
return getTranslate2(stringBounder);
}
if (tiles.contains(child)) {
return getTranslate1(child, stringBounder);
}
throw new UnsupportedOperationException();
}
private UTranslate getTranslate2(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
// final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dim2 = tile2.asTextBlock().calculateDimension(stringBounder);
final double x2 = dimTotal.getWidth() - dim2.getWidth();
final double h = getAllDiamondsHeight(stringBounder);
final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
// final double y2 = (dimTotal.getHeight() - dimDiamond1.getHeight() * 2 - dim2.getHeight()) / 2
// + dimDiamond1.getHeight();
return new UTranslate(x2, y2);
}
private UTranslate getTranslateDiamond1(Ftile diamond1, StringBounder stringBounder) {
double x1 = 0;
for (Ftile diamond : diamonds) {
final Dimension2D dim1 = dimDiamondAndTile(stringBounder, diamond);
if (diamond == diamond1) {
final Dimension2D dimDiamond = diamond.asTextBlock().calculateDimension(stringBounder);
return new UTranslate(x1 + (dim1.getWidth() - dimDiamond.getWidth()) / 2, 25);
}
x1 += dim1.getWidth() + xSeparation;
}
throw new IllegalArgumentException();
}
private UTranslate getTranslate1(Ftile tile1, StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
double x1 = 0;
for (Ftile tile : tiles) {
final Dimension2D dim1 = dimDiamondAndTile(stringBounder, tile);
if (tile == tile1) {
final Dimension2D dimTile = tile.asTextBlock().calculateDimension(stringBounder);
final double h = getAllDiamondsHeight(stringBounder);
final double y1 = (dimTotal.getHeight() - 2 * h - dimTile.getHeight()) / 2 + h;
return new UTranslate(x1 + (dim1.getWidth() - dimTile.getWidth()) / 2, y1);
}
x1 += dim1.getWidth() + xSeparation;
}
throw new IllegalArgumentException();
}
public TextBlock asTextBlock() {
return new TextBlock() {
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
for (Ftile tile : tiles) {
ug.apply(getTranslate1(tile, stringBounder)).draw(tile);
}
for (Ftile diamond : diamonds) {
ug.apply(getTranslateDiamond1(diamond, stringBounder)).draw(diamond);
}
// ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
// ug.apply(getTranslate1(stringBounder)).draw(tile1);
ug.apply(getTranslate2(stringBounder)).draw(tile2);
// ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2);
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return calculateDimensionInternal(stringBounder);
}
};
}
public boolean isKilled() {
for (Ftile tile : tiles) {
if (tile.isKilled() == false) {
return false;
}
}
return tile2.isKilled();
}
private Dimension2D dimDiamondAndTile(StringBounder stringBounder, Ftile tileOrDiamond) {
for (int i = 0; i < tiles.size(); i++) {
final Ftile tile = tiles.get(i);
final Ftile diamond = diamonds.get(i);
if (tile != tileOrDiamond && diamond != tileOrDiamond) {
continue;
}
final Dimension2D dimTile = tile.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimDiamond = diamond.asTextBlock().calculateDimension(stringBounder);
return Dimension2DDouble.mergeTB(dimDiamond, dimTile);
}
throw new UnsupportedOperationException();
}
private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
Dimension2D dimOnlyTiles = new Dimension2DDouble(0, 0);
Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
Dimension2D dimBoth = new Dimension2DDouble(0, 0);
for (int i = 0; i < tiles.size(); i++) {
final Ftile tile = tiles.get(i);
final Ftile diamond = diamonds.get(i);
final Dimension2D dimTile = tile.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimDiamond = diamond.asTextBlock().calculateDimension(stringBounder);
final Dimension2D both = Dimension2DDouble.mergeTB(dimDiamond, dimTile);
dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile);
dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
dimBoth = Dimension2DDouble.mergeLR(dimBoth, both);
}
final Dimension2D dimTile2 = tile2.asTextBlock().calculateDimension(stringBounder);
dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile2);
dimBoth = Dimension2DDouble.mergeLR(dimBoth, dimTile2);
final Dimension2D result = new Dimension2DDouble(dimBoth.getWidth(), dimOnlyDiamond.getHeight() * 4
+ dimOnlyTiles.getHeight());
return Dimension2DDouble.delta(result, xSeparation * tiles.size(), 50);
}
private double getAllDiamondsHeight(StringBounder stringBounder) {
Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
for (Ftile diamond : diamonds) {
final Dimension2D dimDiamond = diamond.asTextBlock().calculateDimension(stringBounder);
dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
}
return dimOnlyDiamond.getHeight();
}
public Point2D getPointIn(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
return new Point2D.Double(dimTotal.getWidth() / 2, 0);
}
public Point2D getPointOut(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
return new Point2D.Double(dimTotal.getWidth() / 2, dimTotal.getHeight());
}
}

View File

@ -1,316 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 8475 $
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.MathUtils;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondFoo1;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class FtileRepeat2 extends AbstractFtile {
private final Ftile repeat;
private final Ftile diamond1;
private final Ftile diamond2;
private final TextBlock tbTest;
private FtileRepeat2(Ftile repeat, Ftile diamond1, Ftile diamond2, TextBlock tbTest) {
super(repeat.shadowing());
this.repeat = repeat;
this.diamond1 = diamond1;
this.diamond2 = diamond2;
this.tbTest = tbTest;
}
public Swimlane getSwimlaneIn() {
return repeat.getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
return getSwimlaneIn();
}
public Set<Swimlane> getSwimlanes() {
return repeat.getSwimlanes();
}
public static Ftile create(Swimlane swimlane, Ftile repeat, Display test, HtmlColor borderColor,
HtmlColor backColor, UFont font, HtmlColor arrowColor, HtmlColor endRepeatLinkColor,
ConditionStyle conditionStyle, SpriteContainer spriteContainer) {
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK);
final TextBlock tbTest = TextBlockUtils.create(test, fc, HorizontalAlignment.LEFT, spriteContainer);
final Ftile diamond1 = new FtileDiamond(repeat.shadowing(), backColor, borderColor, swimlane);
final FtileRepeat2 result;
if (conditionStyle == ConditionStyle.INSIDE) {
final Ftile diamond2 = new FtileDiamondInside(repeat.shadowing(), backColor, borderColor, swimlane, tbTest);
result = new FtileRepeat2(repeat, diamond1, diamond2, TextBlockUtils.empty(0, 0));
} else if (conditionStyle == ConditionStyle.DIAMOND) {
final Ftile diamond2 = new FtileDiamond(repeat.shadowing(), backColor, borderColor, swimlane)
.withEast(tbTest);
result = new FtileRepeat2(repeat, diamond1, diamond2, tbTest);
} else if (conditionStyle == ConditionStyle.FOO1) {
final Ftile diamond2 = new FtileDiamondFoo1(repeat.shadowing(), backColor, borderColor, swimlane, tbTest);
result = new FtileRepeat2(repeat, diamond1, diamond2, TextBlockUtils.empty(0, 0));
} else {
throw new IllegalStateException();
}
final List<Connection> conns = new ArrayList<Connection>();
conns.add(result.new ConnectionIn(LinkRendering.getColor(repeat.getInLinkRendering(), arrowColor)));
conns.add(result.new ConnectionBack(arrowColor));
conns.add(result.new ConnectionOut(LinkRendering.getColor(endRepeatLinkColor, arrowColor)));
return FtileUtils.addConnection(result, conns);
}
class ConnectionIn extends AbstractConnection {
private final HtmlColor arrowColor;
public ConnectionIn(HtmlColor arrowColor) {
super(diamond1, repeat);
this.arrowColor = arrowColor;
}
private Point2D getP1(final StringBounder stringBounder) {
return getTranslateDiamond1(stringBounder).getTranslated(getFtile1().getPointOut(stringBounder));
}
private Point2D getP2(final StringBounder stringBounder) {
return getTranslateForRepeat(stringBounder).getTranslated(getFtile2().getPointIn(stringBounder));
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
snake.addPoint(getP1(stringBounder));
snake.addPoint(getP2(stringBounder));
ug.draw(snake);
}
}
class ConnectionOut extends AbstractConnection {
private final HtmlColor arrowColor;
public ConnectionOut(HtmlColor arrowColor) {
super(repeat, diamond2);
this.arrowColor = arrowColor;
}
private Point2D getP1(final StringBounder stringBounder) {
return getTranslateForRepeat(stringBounder).getTranslated(getFtile1().getPointOut(stringBounder));
}
private Point2D getP2(final StringBounder stringBounder) {
return getTranslateDiamond2(stringBounder).getTranslated(getFtile2().getPointIn(stringBounder));
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
snake.addPoint(getP1(stringBounder));
snake.addPoint(getP2(stringBounder));
ug.draw(snake);
}
}
class ConnectionBack extends AbstractConnection {
private final HtmlColor arrowColor;
public ConnectionBack(HtmlColor arrowColor) {
super(diamond2, repeat);
this.arrowColor = arrowColor;
}
private Point2D getP1(final StringBounder stringBounder) {
return getTranslateDiamond2(stringBounder).getTranslated(new Point2D.Double(0, 0));
}
private Point2D getP2(final StringBounder stringBounder) {
return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0));
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(arrowColor, Arrows.asToLeft());
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Point2D p1 = getP1(stringBounder);
final Point2D p2 = getP2(stringBounder);
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimDiamond2 = diamond2.asTextBlock().calculateDimension(stringBounder);
final double x1 = p1.getX() + dimDiamond2.getWidth();
final double y1 = p1.getY() + dimDiamond2.getHeight() / 2;
final double x2 = p2.getX() + dimDiamond1.getWidth();
final double y2 = p2.getY() + dimDiamond1.getHeight() / 2;
snake.addPoint(x1, y1);
final double yy = dimTotal.getWidth() - Diamond.diamondHalfSize;
snake.addPoint(yy, y1);
snake.addPoint(yy, y2);
snake.addPoint(x2, y2);
ug.draw(snake);
ug = ug.apply(new UChangeColor(arrowColor)).apply(new UChangeBackColor(arrowColor));
ug.apply(new UTranslate(yy, dimTotal.getHeight() / 2)).draw(Arrows.asToUp());
}
}
public TextBlock asTextBlock() {
return new TextBlock() {
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
ug.apply(getTranslateForRepeat(stringBounder)).draw(repeat);
ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2);
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return calculateDimensionInternal(stringBounder);
}
};
}
public boolean isKilled() {
return false;
}
private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimDiamond2 = diamond2.asTextBlock().calculateDimension(stringBounder);
final double w = tbTest.calculateDimension(stringBounder).getWidth();
final Dimension2D dim = Dimension2DDouble.atLeast(repeat.asTextBlock().calculateDimension(stringBounder), 2 * w
+ 2 * Diamond.diamondHalfSize, 0);
final double width = MathUtils.max(dimDiamond1.getWidth(), dim.getWidth(), dimDiamond2.getWidth());
final double height = dimDiamond1.getHeight() + dim.getHeight() + dimDiamond2.getHeight();
final Dimension2D result = new Dimension2DDouble(width, height);
return Dimension2DDouble.delta(result, 4 * Diamond.diamondHalfSize, 8 * Diamond.diamondHalfSize);
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (child == repeat) {
return getTranslateForRepeat(stringBounder);
}
if (child == diamond1) {
return getTranslateDiamond1(stringBounder);
}
throw new UnsupportedOperationException();
}
private UTranslate getTranslateForRepeat(StringBounder stringBounder) {
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimDiamond2 = diamond2.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Dimension2D dimRepeat = repeat.asTextBlock().calculateDimension(stringBounder);
final double x = (dimTotal.getWidth() - dimRepeat.getWidth()) / 2;
final double y = (dimTotal.getHeight() - dimDiamond1.getHeight() - dimDiamond2.getHeight() - dimRepeat
.getHeight()) / 2;
return new UTranslate(x, y);
}
private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final double x1 = (dimTotal.getWidth() - dimDiamond1.getWidth()) / 2;
final double y1 = 0;
return new UTranslate(x1, y1);
}
private UTranslate getTranslateDiamond2(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Dimension2D dimDiamond2 = diamond2.asTextBlock().calculateDimension(stringBounder);
final double x2 = (dimTotal.getWidth() - dimDiamond2.getWidth()) / 2;
final double y2 = dimTotal.getHeight() - dimDiamond2.getHeight();
return new UTranslate(x2, y2);
}
public Point2D getPointIn(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
return new Point2D.Double(dimTotal.getWidth() / 2, 0);
}
public Point2D getPointOut(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
return new Point2D.Double(dimTotal.getWidth() / 2, dimTotal.getHeight());
}
}

View File

@ -1,407 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 8475 $
*
*/
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.MathUtils;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondFoo1;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.svek.ConditionStyle;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UEmpty;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class FtileWhile2 extends AbstractFtile {
private final Ftile whileBlock;
private final Ftile diamond1;
private final TextBlock supplementarySouthText;
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>(whileBlock.getSwimlanes());
result.add(getSwimlaneIn());
return result;
}
public Swimlane getSwimlaneIn() {
return diamond1.getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
return getSwimlaneIn();
}
private FtileWhile2(Ftile whileBlock, Ftile diamond1, TextBlock supplementarySouthText) {
super(whileBlock.shadowing());
this.whileBlock = whileBlock;
this.diamond1 = diamond1;
this.supplementarySouthText = supplementarySouthText;
}
private static TextBlock createLabel1(Display test, Display yes, UFont font, SpriteContainer spriteContainer) {
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK);
final TextBlock tmpb = TextBlockUtils.create(yes, fc, HorizontalAlignment.LEFT, spriteContainer);
if (test == null) {
return tmpb;
}
return TextBlockUtils.mergeTB(TextBlockUtils.create(test, fc, HorizontalAlignment.LEFT, spriteContainer), tmpb,
HorizontalAlignment.CENTER);
}
public static Ftile create(Swimlane swimlane, Ftile whileBlock, Display test, HtmlColor borderColor,
HtmlColor backColor, HtmlColor arrowColor, Display yes, Display out2, UFont font, HtmlColor endInlinkColor,
LinkRendering afterEndwhile, FtileFactory ftileFactory, ConditionStyle conditionStyle) {
// final TextBlock label1 = createLabel1(test, yes, font);
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK);
final TextBlock yesTb = TextBlockUtils.create(yes, fc, HorizontalAlignment.LEFT, ftileFactory);
final TextBlock testTb = TextBlockUtils.create(test, fc, HorizontalAlignment.LEFT, ftileFactory);
final TextBlock out = TextBlockUtils.create(out2, fc, HorizontalAlignment.LEFT, ftileFactory);
final Ftile diamond1;
final TextBlock supplementarySouthText;
if (conditionStyle == ConditionStyle.INSIDE) {
supplementarySouthText = TextBlockUtils.empty(0, 0);
diamond1 = new FtileDiamondInside(whileBlock.shadowing(), backColor, borderColor, swimlane, testTb)
.withNorth(yesTb).withWest(out);
} else if (conditionStyle == ConditionStyle.FOO1) {
supplementarySouthText = TextBlockUtils.empty(0, 0);
diamond1 = new FtileDiamondFoo1(whileBlock.shadowing(), backColor, borderColor, swimlane, testTb)
.withNorth(yesTb).withWest(out);
} else if (conditionStyle == ConditionStyle.DIAMOND) {
supplementarySouthText = createLabel1(test, yes, font, ftileFactory);
diamond1 = new FtileDiamond(whileBlock.shadowing(), backColor, borderColor, swimlane).withWest(out)
.withSouth(supplementarySouthText);
} else {
throw new IllegalStateException();
}
final FtileWhile2 result = new FtileWhile2(whileBlock, diamond1, supplementarySouthText);
HtmlColor afterEndwhileColor = arrowColor;
if (afterEndwhile != null && afterEndwhile.getColor() != null) {
afterEndwhileColor = afterEndwhile.getColor();
}
final List<Connection> conns = new ArrayList<Connection>();
conns.add(result.new ConnectionIn(LinkRendering.getColor(whileBlock.getInLinkRendering(), arrowColor)));
conns.add(result.new ConnectionBack(endInlinkColor));
conns.add(result.new ConnectionOut(afterEndwhileColor));
return FtileUtils.addConnection(result, conns);
}
class ConnectionIn extends AbstractConnection implements ConnectionTranslatable {
private final HtmlColor arrowColor;
public ConnectionIn(HtmlColor arrowColor) {
super(diamond1, whileBlock);
this.arrowColor = arrowColor;
}
private Point2D getP1(final StringBounder stringBounder) {
return getTranslateDiamond1(stringBounder).getTranslated(getFtile1().getPointOut(stringBounder));
}
private Point2D getP2(final StringBounder stringBounder) {
return getTranslateForWhile(stringBounder).getTranslated(getFtile2().getPointIn(stringBounder));
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
snake.addPoint(getP1(stringBounder));
snake.addPoint(getP2(stringBounder));
ug.draw(snake);
}
public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
final StringBounder stringBounder = ug.getStringBounder();
final Point2D p1 = getP1(stringBounder);
final Point2D p2 = getP2(stringBounder);
final Snake snake = new Snake(arrowColor, Arrows.asToDown());
final Point2D mp1a = translate1.getTranslated(p1);
final Point2D mp2b = translate2.getTranslated(p2);
final double middle = (mp1a.getY() + mp2b.getY()) / 2.0;
snake.addPoint(mp1a);
snake.addPoint(mp1a.getX(), middle);
snake.addPoint(mp2b.getX(), middle);
snake.addPoint(mp2b);
ug.draw(snake);
}
}
class ConnectionBack extends AbstractConnection implements ConnectionTranslatable {
private final HtmlColor endInlinkColor;
public ConnectionBack(HtmlColor endInlinkColor) {
super(whileBlock, diamond1);
this.endInlinkColor = endInlinkColor;
}
private Point2D getP1(final StringBounder stringBounder) {
return getTranslateForWhile(stringBounder).getTranslated(whileBlock.getPointOut(stringBounder));
}
private Point2D getP2(final StringBounder stringBounder) {
return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0));
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(endInlinkColor, Arrows.asToLeft());
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Point2D p1 = getP1(stringBounder);
if (p1 == null) {
return;
}
final Point2D p2 = getP2(stringBounder);
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final double x1 = p1.getX();
final double y1 = p1.getY();
final double x2 = p2.getX() + dimDiamond1.getWidth();
final double y2 = p2.getY() + dimDiamond1.getHeight() / 2;
snake.addPoint(x1, y1);
snake.addPoint(x1, y1 + Diamond.diamondHalfSize);
final double xx = dimTotal.getWidth() - Diamond.diamondHalfSize;
snake.addPoint(xx, y1 + Diamond.diamondHalfSize);
snake.addPoint(xx, y2);
snake.addPoint(x2, y2);
ug.draw(snake);
ug.apply(new UTranslate(x1, y1 + Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug = ug.apply(new UChangeColor(endInlinkColor)).apply(new UChangeBackColor(endInlinkColor));
ug.apply(new UTranslate(xx, (y1 + y2) / 2)).draw(Arrows.asToUp());
}
public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(endInlinkColor, Arrows.asToLeft());
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Point2D ap1 = getP1(stringBounder);
final Point2D ap2 = getP2(stringBounder);
final Point2D p1 = translate1.getTranslated(ap1);
final Point2D p2 = translate2.getTranslated(ap2);
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final double x1 = p1.getX();
final double y1 = p1.getY();
final double x2 = p2.getX() + dimDiamond1.getWidth();
final double y2 = p2.getY() + dimDiamond1.getHeight() / 2;
snake.addPoint(x1, y1);
snake.addPoint(x1, y1 + Diamond.diamondHalfSize);
final double xx = Math.max(translate1.getDx(), translate2.getDx()) + dimTotal.getWidth()
- Diamond.diamondHalfSize;
snake.addPoint(xx, y1 + Diamond.diamondHalfSize);
snake.addPoint(xx, y2);
snake.addPoint(x2, y2);
ug.draw(snake);
ug.apply(new UTranslate(x1, y1 + Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize));
ug = ug.apply(new UChangeColor(endInlinkColor)).apply(new UChangeBackColor(endInlinkColor));
ug.apply(new UTranslate(xx, (y1 + y2) / 2)).draw(Arrows.asToUp());
}
}
class ConnectionOut extends AbstractConnection {
private final HtmlColor afterEndwhileColor;
public ConnectionOut(HtmlColor afterEndwhileColor) {
super(diamond1, null);
this.afterEndwhileColor = afterEndwhileColor;
}
private Point2D getP1(final StringBounder stringBounder) {
return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0));
}
private Point2D getP2(final StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
return new Point2D.Double(dimTotal.getWidth() / 2, dimTotal.getHeight());
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(afterEndwhileColor);
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final Point2D p1 = getP1(stringBounder);
final Point2D p2 = getP2(stringBounder);
final double x1 = p1.getX();
final double y1 = p1.getY() + dimDiamond1.getHeight() / 2;
final double x2 = p2.getX();
final double y2 = p2.getY();
snake.addPoint(x1, y1);
snake.addPoint(Diamond.diamondHalfSize, y1);
snake.addPoint(Diamond.diamondHalfSize, y2);
// snake.addPoint(x2, y2);
ug.draw(snake);
ug = ug.apply(new UChangeColor(afterEndwhileColor)).apply(new UChangeBackColor(afterEndwhileColor));
ug.apply(new UTranslate(Diamond.diamondHalfSize, (y1 + y2) / 2)).draw(Arrows.asToDown());
final Snake snake2 = new Snake(afterEndwhileColor, true);
snake2.addPoint(Diamond.diamondHalfSize, y2);
snake2.addPoint(x2, y2);
ug.draw(snake2);
}
}
public TextBlock asTextBlock() {
return new TextBlock() {
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
ug.apply(getTranslateForWhile(stringBounder)).draw(whileBlock);
ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return calculateDimensionInternal(stringBounder);
}
};
}
private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimSupplementarySouth = supplementarySouthText.calculateDimension(stringBounder);
final Dimension2D dimWhile = whileBlock.asTextBlock().calculateDimension(stringBounder);
final double width = MathUtils.max(dimDiamond1.getWidth(), dimWhile.getWidth());
final double height = dimDiamond1.getHeight() + dimWhile.getHeight();
Dimension2D result = new Dimension2DDouble(width, height);
result = Dimension2DDouble.max(result, dimSupplementarySouth);
return Dimension2DDouble.delta(result, 4 * Diamond.diamondHalfSize, 8 * Diamond.diamondHalfSize);
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (child == whileBlock) {
return getTranslateForWhile(stringBounder);
}
if (child == diamond1) {
return getTranslateDiamond1(stringBounder);
}
throw new UnsupportedOperationException();
}
private UTranslate getTranslateForWhile(StringBounder stringBounder) {
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Dimension2D dimWhile = whileBlock.asTextBlock().calculateDimension(stringBounder);
final double x = (dimTotal.getWidth() - dimWhile.getWidth()) / 2;
// final double y = dimDiamond1.getHeight();
final double y = dimDiamond1.getHeight()
+ (dimTotal.getHeight() - dimDiamond1.getHeight() - dimWhile.getHeight()) / 2;
return new UTranslate(x, y);
}
private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
final Dimension2D dimDiamond1 = diamond1.asTextBlock().calculateDimension(stringBounder);
final double x1 = (dimTotal.getWidth() - dimDiamond1.getWidth()) / 2;
final double y1 = 0;
return new UTranslate(x1, y1);
}
public boolean isKilled() {
return false;
}
public Point2D getPointIn(StringBounder stringBounder) {
final Dimension2D dimTotal = asTextBlock().calculateDimension(stringBounder);
return new Point2D.Double(dimTotal.getWidth() / 2, 0);
}
public Point2D getPointOut(StringBounder stringBounder) {
final Dimension2D dimTotal = asTextBlock().calculateDimension(stringBounder);
return new Point2D.Double(dimTotal.getWidth() / 2, dimTotal.getHeight());
}
}

View File

@ -1,57 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 3828 $
*
*/
package net.sourceforge.plantuml.command;
import java.util.List;
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
import net.sourceforge.plantuml.cucadiagram.IEntity;
public class CommandEndNamespace extends SingleLineCommand<AbstractEntityDiagram> {
public CommandEndNamespace() {
super("(?i)^end ?namespace$");
}
@Override
protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, List<String> arg) {
final IEntity currentPackage = diagram.getCurrentGroup();
if (currentPackage == null) {
return CommandExecutionResult.error("No namesspace defined");
}
diagram.endGroup();
return CommandExecutionResult.ok();
}
}

View File

@ -1,109 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 11025 $
*
*/
package net.sourceforge.plantuml.creole;
import java.awt.geom.Dimension2D;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
import net.sourceforge.plantuml.ugraphic.UStroke;
public class SheetBlock implements TextBlock, Atom {
private final Sheet sheet;
private final UStroke defaultStroke;
private final Stencil stencil;
private Map<Stripe, Double> heights;
private Map<Atom, Position> positions;
private MinMax minMax;
public SheetBlock(Sheet sheet, Stencil stencil, UStroke defaultStroke) {
this.sheet = sheet;
this.stencil = stencil;
this.defaultStroke = defaultStroke;
}
private void initMap(StringBounder stringBounder) {
if (positions != null) {
return;
}
positions = new LinkedHashMap<Atom, Position>();
heights = new LinkedHashMap<Stripe, Double>();
minMax = MinMax.getEmpty(true);
double y = 0;
for (Stripe stripe : sheet) {
if (stripe.getAtoms().size() == 0) {
continue;
}
final Sea sea = new Sea(stringBounder);
for (Atom atom : stripe.getAtoms()) {
sea.add(atom);
}
sea.doAlign();
sea.translateMinYto(y);
sea.exportAllPositions(positions);
minMax = sea.update(minMax);
final double height = sea.getHeight();
heights.put(stripe, height);
y += height;
}
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
initMap(stringBounder);
return minMax.getDimension();
}
public void drawU(UGraphic ug) {
if (stencil != null) {
ug = new UGraphicStencil(ug, stencil, defaultStroke);
}
for (Stripe stripe : sheet) {
for (Atom atom : stripe.getAtoms()) {
final Position position = positions.get(atom);
atom.drawU(position.translate(ug));
// position.drawDebug(ug);
}
}
}
public double getStartingAltitude(StringBounder stringBounder) {
return 0;
}
}

View File

@ -1,39 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 11025 $
*
*/
package net.sourceforge.plantuml.creole;
public class Table {
}

View File

@ -1,77 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 8770 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
public class Code2 {
private final Namespace namespace;
private final String unqualifiedCode;
private Code2(Namespace namespace, String unqualifiedCode) {
if (namespace == null) {
throw new IllegalArgumentException();
}
if (unqualifiedCode == null) {
throw new IllegalArgumentException();
}
this.namespace = namespace;
this.unqualifiedCode = unqualifiedCode;
}
public final Namespace getNamespace() {
return namespace;
}
public final String getUnqualifiedCode() {
return unqualifiedCode;
}
public final String getFullQualifiedCode() {
if (namespace.isMain()) {
return unqualifiedCode;
}
return namespace.getNamespace() + "." + unqualifiedCode;
}
@Override
public int hashCode() {
return namespace.hashCode() + 43 * unqualifiedCode.hashCode();
}
@Override
public boolean equals(Object obj) {
final Code2 other = (Code2) obj;
return this.unqualifiedCode.equals(other.unqualifiedCode) && this.namespace.equals(other.namespace);
}
}

View File

@ -1,171 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 4749 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.skin.VisibilityModifier;
public class MemberImpl implements Member {
private final String display;
private final boolean staticModifier;
private final boolean abstractModifier;
private final Url url;
private final VisibilityModifier visibilityModifier;
public MemberImpl(String display, boolean isMethod, boolean manageModifier) {
// manageModifier = true;
final Pattern p = Pattern.compile("^(.*)(" + UrlBuilder.getRegexp() + ")(.*)$");
final Matcher m = p.matcher(display);
if (m.matches()) {
if (m.groupCount() != 6) {
throw new IllegalStateException();
}
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.STRICT);
url = urlBuilder.getUrl(m.group(2));
url.setMember(true);
display = m.group(1).trim() + m.group(m.groupCount()).trim();
} else {
url = null;
}
final String lower = display.toLowerCase();
if (manageModifier) {
this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}");
this.abstractModifier = lower.contains("{abstract}");
String displayClean = display.replaceAll("(?i)\\{(static|classifier|abstract)\\}", "").trim();
if (displayClean.length() == 0) {
displayClean = " ";
}
if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
visibilityModifier = VisibilityModifier.getVisibilityModifier(display.charAt(0), isMethod == false);
this.display = displayClean.substring(1).trim();
} else {
this.display = displayClean;
visibilityModifier = null;
}
} else {
this.staticModifier = false;
this.visibilityModifier = null;
this.abstractModifier = false;
display = display.trim();
this.display = display.length() == 0 ? " " : display.trim();
}
}
public String getDisplay(boolean withVisibilityChar) {
if (withVisibilityChar) {
return getDisplayWithVisibilityChar();
}
return getDisplayWithoutVisibilityChar();
}
public String getDisplayWithoutVisibilityChar() {
// assert display.length() == 0 || VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false;
return display;
}
public String getDisplayWithVisibilityChar() {
if (isPrivate()) {
return "-" + display;
}
if (isPublic()) {
return "+" + display;
}
if (isPackagePrivate()) {
return "~" + display;
}
if (isProtected()) {
return "#" + display;
}
return display;
}
@Override
public boolean equals(Object obj) {
final MemberImpl other = (MemberImpl) obj;
return this.display.equals(other.display);
}
@Override
public int hashCode() {
return display.hashCode();
}
public final boolean isStatic() {
return staticModifier;
}
public final boolean isAbstract() {
return abstractModifier;
}
private boolean isPrivate() {
return visibilityModifier == VisibilityModifier.PRIVATE_FIELD
|| visibilityModifier == VisibilityModifier.PRIVATE_METHOD;
}
private boolean isProtected() {
return visibilityModifier == VisibilityModifier.PROTECTED_FIELD
|| visibilityModifier == VisibilityModifier.PROTECTED_METHOD;
}
private boolean isPublic() {
return visibilityModifier == VisibilityModifier.PUBLIC_FIELD
|| visibilityModifier == VisibilityModifier.PUBLIC_METHOD;
}
private boolean isPackagePrivate() {
return visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_FIELD
|| visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_METHOD;
}
public final VisibilityModifier getVisibilityModifier() {
return visibilityModifier;
}
public final Url getUrl() {
return url;
}
}

View File

@ -1,374 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 10765 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class ProcessRunnerDebug {
// http://steveliles.github.io/invoking_processes_from_java.html
public static boolean DEBUG = false;
private static final AtomicInteger CPT = new AtomicInteger();
private void DEBUG(String s) {
if (DEBUG == false) {
return;
}
final StringBuilder sb = new StringBuilder();
final int activeCount = Thread.activeCount();
final long freeMemory = Runtime.getRuntime().freeMemory() / 1024L / 1024L;
final long totalMemory = Runtime.getRuntime().totalMemory() / 1024L / 1024L;
sb.append(new Date().toGMTString() + " {");
sb.append(ident + "} " + freeMemory + "/" + totalMemory + "/" + activeCount + " " + s);
DebugTrace.DEBUG(sb.toString());
}
private void DEBUG(String s, Throwable t) {
if (DEBUG == false) {
return;
}
DebugTrace.DEBUG(s, t);
}
private static final long TIMEOUT_MINUTE = 15;
private final String[] cmd;
private final String ident = myFormat(CPT.getAndIncrement());
private static String myFormat(int v) {
final StringBuilder sb = new StringBuilder(Integer.toHexString(v).toUpperCase());
while (sb.length() < 5) {
sb.insert(0, '0');
}
return sb.toString();
}
private String error;
private String out;
private volatile ProcessState state = ProcessState.INIT;
private final Lock changeState = new ReentrantLock();
public ProcessRunnerDebug(String[] cmd) {
this.cmd = cmd;
}
public ProcessState run2(byte in[], OutputStream redirection) {
return run2(in, redirection, null);
}
public ProcessState run2(byte in[], OutputStream redirection, File dir) {
if (this.state != ProcessState.INIT) {
throw new IllegalStateException();
}
this.state = ProcessState.RUNNING;
DEBUG("run A100");
final MainThread mainThread = new MainThread(cmd, dir, redirection, in);
DEBUG("run A200");
try {
mainThread.start();
DEBUG("run A300");
mainThread.join(TIMEOUT_MINUTE * 60 * 1000L);
DEBUG("run A400");
} catch (InterruptedException e) {
e.printStackTrace();
DEBUG("run A500", e);
} finally {
DEBUG("run A600");
changeState.lock();
DEBUG("run A700");
try {
if (state == ProcessState.RUNNING) {
state = ProcessState.TIMEOUT;
DEBUG("run A800");
mainThread.cancel();
DEBUG("run A900");
}
} finally {
changeState.unlock();
}
}
if (state == ProcessState.TERMINATED_OK) {
DEBUG("run A1000");
// Ok!
assert mainThread != null;
this.error = mainThread.getError();
this.out = mainThread.getOut();
} else {
DEBUG("run A1100");
}
return state;
}
class MainThread extends Thread {
private final String[] cmd;
private final File dir;
private final OutputStream redirection;
private final byte[] in;
private volatile Process process;
private volatile ThreadStream errorStream;
private volatile ThreadStream outStream;
public MainThread(String[] cmd, File dir, OutputStream redirection, byte[] in) {
this.cmd = cmd;
this.dir = dir;
this.redirection = redirection;
this.in = in;
}
public String getOut() {
return outStream.getString();
}
public String getError() {
return errorStream.getString();
}
@Override
public void run() {
try {
DEBUG("MainThread B100");
runInternal();
DEBUG("MainThread B200");
if (state == ProcessState.RUNNING) {
final int result = joinInternal();
DEBUG("MainThread B300 " + result);
}
} catch (InterruptedException e) {
e.printStackTrace();
DEBUG("MainThread B400", e);
} finally {
changeState.lock();
try {
if (state == ProcessState.RUNNING) {
DEBUG("MainThread B500");
state = ProcessState.TERMINATED_OK;
} else {
DEBUG("MainThread B600");
}
} finally {
changeState.unlock();
}
if (process != null) {
DEBUG("MainThread B700");
process.destroy();
DEBUG("MainThread B800");
close(process.getErrorStream());
DEBUG("MainThread B900");
close(process.getOutputStream());
DEBUG("MainThread B1000");
close(process.getInputStream());
}
}
}
private void cancel() {
// The changeState lock is ok
assert changeState.tryLock();
assert state == ProcessState.TIMEOUT;
DEBUG("MainThread B2000");
if (process != null) {
DEBUG("MainThread B2000");
errorStream.cancel();
DEBUG("MainThread B2000");
outStream.cancel();
DEBUG("MainThread B2000");
process.destroy();
DEBUG("MainThread B2000");
interrupt();
DEBUG("MainThread B2000");
close(process.getErrorStream());
DEBUG("MainThread B2000");
close(process.getOutputStream());
DEBUG("MainThread B2000");
close(process.getInputStream());
DEBUG("MainThread B2000");
} else {
DEBUG("MainThread B2000");
}
}
public void runInternal() {
try {
DEBUG("MainThread runInternal B3010");
process = Runtime.getRuntime().exec(cmd, null, dir);
DEBUG("MainThread runInternal B3020");
} catch (IOException e) {
DEBUG("MainThread runInternal B3030", e);
changeState.lock();
try {
state = ProcessState.IO_EXCEPTION1;
} finally {
changeState.unlock();
}
e.printStackTrace();
return;
}
DEBUG("MainThread runInternal B3040");
errorStream = new ThreadStream(process.getErrorStream(), null);
DEBUG("MainThread runInternal B3050");
outStream = new ThreadStream(process.getInputStream(), redirection);
DEBUG("MainThread runInternal B3060");
errorStream.start();
DEBUG("MainThread runInternal B3070");
outStream.start();
if (in != null) {
DEBUG("MainThread runInternal B3080");
final OutputStream os = process.getOutputStream();
DEBUG("MainThread runInternal B3090");
try {
try {
DEBUG("MainThread runInternal B3100");
os.write(in);
DEBUG("MainThread runInternal B3110");
} finally {
os.close();
}
} catch (IOException e) {
DEBUG("MainThread runInternal B3120", e);
changeState.lock();
try {
state = ProcessState.IO_EXCEPTION2;
} finally {
changeState.unlock();
}
e.printStackTrace();
}
}
}
public int joinInternal() throws InterruptedException {
DEBUG("MainThread joinInternal B4000");
errorStream.join();
DEBUG("MainThread joinInternal B4010");
outStream.join();
DEBUG("MainThread joinInternal B4020");
final int result = process.waitFor();
DEBUG("MainThread joinInternal B4030 r=" + result);
return result;
}
}
class ThreadStream extends Thread {
private volatile InputStream streamToRead;
private volatile OutputStream redirection;
private volatile StringBuffer sb = new StringBuffer();
ThreadStream(InputStream streamToRead, OutputStream redirection) {
this.streamToRead = streamToRead;
this.redirection = redirection;
}
public String getString() {
return sb.toString();
}
public void cancel() {
assert state == ProcessState.TIMEOUT;
this.interrupt();
sb = null;
streamToRead = null;
redirection = null;
// Because of this, some NPE may occurs in run() method, but we do not care
}
@Override
public void run() {
int read = 0;
try {
while ((read = streamToRead.read()) != -1) {
if (state == ProcessState.TIMEOUT) {
DEBUG("ThreadStream TIMEOUT");
return;
}
if (redirection == null) {
sb.append((char) read);
} else {
redirection.write(read);
}
}
DEBUG("ThreadStream end ok");
} catch (Throwable e) {
DEBUG("ThreadStream BB1", e);
e.printStackTrace();
sb.append('\n');
sb.append(e.toString());
}
}
}
public final String getError() {
return error;
}
public final String getOut() {
return out;
}
private void close(InputStream is) {
try {
if (is != null) {
is.close();
DEBUG("closing AA1 ok");
}
} catch (IOException e) {
DEBUG("closing error AA2", e);
e.printStackTrace();
}
}
private void close(OutputStream os) {
try {
if (os != null) {
os.close();
DEBUG("closing BB1 ok");
}
} catch (IOException e) {
DEBUG("closing error BB1", e);
e.printStackTrace();
}
}
}

View File

@ -1,120 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 10765 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import net.sourceforge.plantuml.Log;
public class ProcessRunnerOld {
private final String[] cmd;
private String error;
private String out;
public ProcessRunnerOld(String[] cmd) {
this.cmd = cmd;
}
static private int cpt = 0;
public void run(byte in[], OutputStream redirection) throws IOException, InterruptedException {
run(in, redirection, null);
}
public void run(byte in[], OutputStream redirection, File dir) throws IOException, InterruptedException {
final Process process = Runtime.getRuntime().exec(cmd, null, dir);
final ThreadStream errorStream = new ThreadStream(process.getErrorStream(), null);
final ThreadStream outStream = new ThreadStream(process.getInputStream(), redirection);
errorStream.start();
outStream.start();
if (in != null) {
final OutputStream os = process.getOutputStream();
os.write(in);
os.close();
}
process.waitFor();
errorStream.join(10000L);
outStream.join(10000L);
this.out = outStream.sb.toString();
this.error = errorStream.sb.toString();
cpt++;
Log.info("RUN nb = " + cpt);
}
static class ThreadStream extends Thread {
private final InputStream streamToRead;
private final OutputStream redirection;
private final StringBuilder sb = new StringBuilder();
ThreadStream(InputStream streamToRead, OutputStream redirection) {
this.streamToRead = streamToRead;
this.redirection = redirection;
}
@Override
public void run() {
Log.debug("STARTING " + this);
int read = 0;
try {
while ((read = streamToRead.read()) != -1) {
if (redirection == null) {
sb.append((char) read);
} else {
redirection.write(read);
}
}
} catch (IOException e) {
e.printStackTrace();
sb.append('\n');
sb.append(e.toString());
}
Log.debug("FINISHING " + this);
}
}
public final String getError() {
return error;
}
public final String getOut() {
return out;
}
}

View File

@ -1,177 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 4173 $
*
*/
package net.sourceforge.plantuml.eps;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.io.IOException;
import java.util.List;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.VerticalPosition;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
public final class EpsTitler {
private final List<? extends CharSequence> text;
private final HorizontalAlignment horizontalAlignment;
private final VerticalPosition verticalPosition;
private final int margin;
private final TextBlock textBloc;
private final EpsStrategy epsStrategy;
private final ColorMapper colorMapper;
public EpsTitler(ColorMapper colorMapper, EpsStrategy epsStrategy, HtmlColor textColor,
List<? extends CharSequence> text, int fontSize, String fontFamily,
HorizontalAlignment horizontalAlignment, VerticalPosition verticalPosition, int margin) {
this.text = text;
this.colorMapper = colorMapper;
this.epsStrategy = epsStrategy;
this.horizontalAlignment = horizontalAlignment;
this.verticalPosition = verticalPosition;
this.margin = margin;
if (text == null || text.size() == 0) {
textBloc = null;
} else {
final UFont normalFont = new UFont(fontFamily, Font.PLAIN, fontSize);
textBloc = TextBlockUtils.create(new Display(text), new FontConfiguration(normalFont, textColor),
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
}
}
public double getHeight() {
if (textBloc == null) {
return 0;
}
return textBloc.calculateDimension(new UGraphicEps(colorMapper, epsStrategy).getStringBounder()).getHeight()
+ margin;
}
public String addTitleEps(String eps) throws IOException {
if (text == null || text.size() == 0) {
return eps;
}
final int idx = eps.indexOf("%%BoundingBox:");
if (idx == -1) {
throw new IllegalArgumentException();
}
final StringTokenizer st = new StringTokenizer(eps.substring(idx + "%%BoundingBox:".length()), " \n\t\r");
final int x1 = Integer.parseInt(st.nextToken());
final int y1 = Integer.parseInt(st.nextToken());
final int x2 = Integer.parseInt(st.nextToken());
final int y2 = Integer.parseInt(st.nextToken());
assert x2 >= x1;
assert y2 >= y1;
final double width = x2 - x1;
final double height = y2 - y1;
final UGraphicEps uGraphicEps = new UGraphicEps(colorMapper, epsStrategy);
final Dimension2D dimText = textBloc.calculateDimension(uGraphicEps.getStringBounder());
final double xpos;
if (horizontalAlignment == HorizontalAlignment.LEFT) {
xpos = 2;
} else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
xpos = width - dimText.getWidth() - 2;
} else if (horizontalAlignment == HorizontalAlignment.CENTER) {
xpos = (width - dimText.getWidth()) / 2;
} else {
xpos = 0;
assert false;
}
final double yText;
if (verticalPosition == VerticalPosition.TOP) {
yText = 0;
} else {
yText = height + margin;
}
textBloc.drawU(uGraphicEps.apply(new UTranslate(xpos, yText)));
final double yImage;
if (verticalPosition == VerticalPosition.TOP) {
yImage = dimText.getHeight();
} else {
yImage = 0;
}
uGraphicEps.drawEps(eps, 0, yImage);
uGraphicEps.close();
return uGraphicEps.getEPSCode();
// String svgTitle = CucaDiagramFileMaker.getSvg(uGraphicSvg);
// svgTitle = svgTitle.replaceFirst("(?i)<g>", "<g
// transform=\"translate(0 0)\">");
//
// if (verticalPosition == VerticalPosition.TOP) {
// final Pattern p =
// Pattern.compile("(?i)translate\\((\\d+)\\s+(\\d+)");
// final Matcher m = p.matcher(svg);
//
// final StringBuffer sb = new StringBuffer();
// while (m.find()) {
// final int tx = Integer.parseInt(m.group(1));
// final int ty = Integer.parseInt(m.group(2)) + (int)
// (dimText.getHeight()) + margin;
// m.appendReplacement(sb, "translate(" + tx + " " + ty);
// }
// m.appendTail(sb);
// svg = sb.toString();
// }
//
// final int x = svg.indexOf("<g ");
// if (x == -1) {
// throw new IllegalStateException();
// }
// svg = svg.substring(0, x) + svgTitle + svg.substring(x);
//
// return svg;
}
}

View File

@ -1,85 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 11154 $
*
*/
package net.sourceforge.plantuml.graph;
import java.awt.Graphics2D;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
class EntityImageActor extends AbstractEntityImage {
// final private TextBlock name;
// final private StickMan stickman;
//
public EntityImageActor(IEntity entity) {
super(entity);
// this.name = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(
// getFont14(), HtmlColorUtils.BLACK), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
// this.stickman = new StickMan(getYellow(), getRed());
}
//
@Override
public Dimension2D getDimension(StringBounder stringBounder) {
// final Dimension2D nameDim = name.calculateDimension(stringBounder);
// final double manWidth = stickman.getPreferredWidth();
// final double manHeight = stickman.getPreferredHeight();
// return new Dimension2DDouble(Math.max(manWidth, nameDim.getWidth()), manHeight + nameDim.getHeight());
throw new UnsupportedOperationException();
}
//
@Override
public void draw(ColorMapper colorMapper, Graphics2D g2d) {
// final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));
// final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d));
//
// final double manWidth = stickman.getPreferredWidth();
// final double manHeight = stickman.getPreferredHeight();
//
// final double manX = (dimTotal.getWidth() - manWidth) / 2;
//
// g2d.setColor(Color.WHITE);
// g2d.fill(new Rectangle2D.Double(0, 0, dimTotal.getWidth(), dimTotal.getHeight()));
//
// g2d.translate(manX, 0);
// // stickman.draw(g2d);
// g2d.translate(-manX, 0);
//
// g2d.setColor(Color.BLACK);
//// name.drawTOBEREMOVED(colorMapper, g2d, (dimTotal.getWidth() - nameDim.getWidth()) / 2, manHeight);
throw new UnsupportedOperationException();
}
}

View File

@ -1,57 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 10266 $
*
*/
package net.sourceforge.plantuml.graphic;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class TextBlockInterceptorTextBlockable implements TextBlock {
private final TextBlock textBlock;
public TextBlockInterceptorTextBlockable(TextBlock textBlock) {
this.textBlock = textBlock;
}
public void drawU(UGraphic ug) {
textBlock.drawU(new UGraphicInterceptorTextBlockable(ug));
ug.flushUg();
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return TextBlockUtils.getMinMax(this, stringBounder).getDimension();
}
}

View File

@ -1,81 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 11154 $
*
*/
package net.sourceforge.plantuml.graphic;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
class TextBlockWithNumber extends TextBlockSimple {
private final TextBlock numText;
public TextBlockWithNumber(String number, Display texts, FontConfiguration fontConfiguration,
HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, double maxMessageSize) {
super(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize);
this.numText = TextBlockUtils.create(Display.asList(number), fontConfiguration, HorizontalAlignment.LEFT,
spriteContainer);
}
@Override
public Dimension2D calculateDimension(StringBounder stringBounder) {
final double widthNum = getNumberWithAndMargin(stringBounder);
final double heightNum = numText.calculateDimension(stringBounder).getHeight();
final Dimension2D dim = super.calculateDimension(stringBounder);
return new Dimension2DDouble(dim.getWidth() + widthNum, Math.max(heightNum, dim.getHeight()));
}
private double getNumberWithAndMargin(StringBounder stringBounder) {
final double widthNum = numText.calculateDimension(stringBounder).getWidth();
return widthNum + 4.0;
}
@Override
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final double heightNum = numText.calculateDimension(stringBounder).getHeight();
final double deltaY = calculateDimension(stringBounder).getHeight() - heightNum;
numText.drawU(ug.apply(new UTranslate(0, deltaY / 2.0)));
super.drawU(ug.apply(new UTranslate(getNumberWithAndMargin(stringBounder), 0)));
}
}

View File

@ -1,44 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 10266 $
*
*/
package net.sourceforge.plantuml.graphic;
import net.sourceforge.plantuml.ugraphic.UShape;
public interface TextBlockable extends UShape {
public TextBlock asTextBlock();
}

View File

@ -1,63 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 10266 $
*
*/
package net.sourceforge.plantuml.graphic;
import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UShape;
public class UGraphicInterceptorTextBlockable extends UGraphicDelegator {
public UGraphicInterceptorTextBlockable(UGraphic ug) {
super(ug);
}
public void draw(UShape shape) {
if (shape instanceof TextBlockable) {
final TextBlock textBlock = ((TextBlockable) shape).asTextBlock();
textBlock.drawU(this);
} else if (shape instanceof UDrawable) {
final UDrawable drawable = (UDrawable) shape;
drawable.drawU(this);
} else {
getUg().draw(shape);
}
}
public UGraphic apply(UChange change) {
return new UGraphicInterceptorTextBlockable(getUg().apply(change));
}
}

View File

@ -1,85 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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.salt;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import net.sourceforge.plantuml.salt.element.Element;
public class Positionner {
private int row;
private int col;
private int maxRow;
private int maxCol;
private final Map<Element, Position> positions = new LinkedHashMap<Element, Position>();
public void add(Terminated<Element> element) {
positions.put(element.getElement(), new Position(row, col));
updateMax();
final Terminator terminator = element.getTerminator();
if (terminator == Terminator.NEWCOL) {
col++;
} else {
row++;
col = 0;
}
}
private void updateMax() {
if (row > maxRow) {
maxRow = row;
}
if (col > maxCol) {
maxCol = col;
}
}
public Map<Element, Position> getAll() {
return Collections.unmodifiableMap(positions);
}
public final int getNbRows() {
return maxRow + 1;
}
public final int getNbCols() {
return maxCol + 1;
}
}

View File

@ -1,152 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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.salt.element;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.salt.Cell;
import net.sourceforge.plantuml.salt.Positionner2;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class ElementPyramid2 implements Element {
private int rows;
private int cols;
private final TableStrategy tableStrategy;
private final Map<Element, Cell> positions1;
private final Map<Cell, Element> positions2 = new HashMap<Cell, Element>();
private double rowsStart[];
private double colsStart[];
public ElementPyramid2(Positionner2 positionner, TableStrategy tableStrategy) {
positions1 = positionner.getAll();
for (Map.Entry<Element, Cell> ent : positions1.entrySet()) {
positions2.put(ent.getValue(), ent.getKey());
}
this.rows = positionner.getNbRows();
this.cols = positionner.getNbCols();
this.tableStrategy = tableStrategy;
for (Cell c : positions1.values()) {
rows = Math.max(rows, c.getMaxRow());
cols = Math.max(cols, c.getMaxCol());
}
}
public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
init(stringBounder);
return new Dimension2DDouble(colsStart[colsStart.length - 1], rowsStart[rowsStart.length - 1]);
}
public void drawU(UGraphic ug, final double x, final double y, int zIndex, Dimension2D dimToUse) {
init(ug.getStringBounder());
final Grid grid = new Grid(rowsStart, colsStart, tableStrategy);
for (Map.Entry<Element, Cell> ent : positions1.entrySet()) {
final Element elt = ent.getKey();
final Cell cell = ent.getValue();
final double xcell = colsStart[cell.getMinCol()];
final double ycell = rowsStart[cell.getMinRow()];
final double width = colsStart[cell.getMaxCol() + 1] - colsStart[cell.getMinCol()] - 1;
final double height = rowsStart[cell.getMaxRow() + 1] - rowsStart[cell.getMinRow()] - 1;
grid.addCell(cell);
// ug.draw(x + xcell, y + ycell, new ULine(width, 0));
// ug.draw(x + xcell, y + ycell, new ULine(0, height));
// ug.draw(x + xcell, y + ycell, new URectangle(width, height));
elt.drawU(ug, x + xcell + 1, y + ycell + 1, zIndex, new Dimension2DDouble(width, height));
}
if (zIndex == 0) {
grid.drawU(ug, x, y);
}
}
private void init(StringBounder stringBounder) {
if (rowsStart != null) {
return;
}
rowsStart = new double[rows + 1];
colsStart = new double[cols + 1];
final List<Cell> all = new ArrayList<Cell>(positions1.values());
Collections.sort(all, new LeftFirst());
for (Cell cell : all) {
final Element elt = positions2.get(cell);
final Dimension2D dim = elt.getPreferredDimension(stringBounder, 0, 0);
ensureColWidth(cell.getMinCol(), cell.getMaxCol() + 1, dim.getWidth() + 2);
}
Collections.sort(all, new TopFirst());
for (Cell cell : all) {
final Element elt = positions2.get(cell);
final Dimension2D dim = elt.getPreferredDimension(stringBounder, 0, 0);
ensureRowHeight(cell.getMinRow(), cell.getMaxRow() + 1, dim.getHeight() + 2);
}
}
private void ensureColWidth(int first, int last, double width) {
final double actual = colsStart[last] - colsStart[first];
final double missing = width - actual;
if (missing > 0) {
for (int i = last; i < colsStart.length; i++) {
colsStart[i] += missing;
}
}
}
private void ensureRowHeight(int first, int last, double height) {
final double actual = rowsStart[last] - rowsStart[first];
final double missing = height - actual;
if (missing > 0) {
for (int i = last; i < rowsStart.length; i++) {
rowsStart[i] += missing;
}
}
}
public final int getNbRows() {
return rows + 1;
}
public final int getNbCols() {
return cols + 1;
}
}

View File

@ -1,95 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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.salt.factory;
import net.sourceforge.plantuml.salt.DataSource;
import net.sourceforge.plantuml.salt.Dictionary;
import net.sourceforge.plantuml.salt.Positionner2;
import net.sourceforge.plantuml.salt.Terminated;
import net.sourceforge.plantuml.salt.element.Element;
import net.sourceforge.plantuml.salt.element.ElementPyramid2;
import net.sourceforge.plantuml.salt.element.ElementText;
import net.sourceforge.plantuml.salt.element.TableStrategy;
public class ElementFactoryPyramid2 extends AbstractElementFactoryComplex {
public ElementFactoryPyramid2(DataSource dataSource, Dictionary dictionary) {
super(dataSource, dictionary);
}
public Terminated<Element> create() {
if (ready() == false) {
throw new IllegalStateException();
}
final String header = getDataSource().next().getElement();
assert header.startsWith("{");
TableStrategy strategy = TableStrategy.DRAW_NONE;
if (header.length() == 2) {
strategy = TableStrategy.fromChar(header.charAt(1));
}
final Positionner2 positionner = new Positionner2();
while (getDataSource().peek(0).getElement().equals("}") == false) {
final Terminated<Element> next = getNextElement();
if (isStar(next.getElement())) {
positionner.mergeLeft(next.getTerminator());
} else {
positionner.add(next);
}
}
final Terminated<String> next = getDataSource().next();
return new Terminated<Element>(new ElementPyramid2(positionner, strategy), next.getTerminator());
}
private boolean isStar(Element element) {
if (element instanceof ElementText == false) {
return false;
}
return "*".equals(((ElementText) element).getText());
}
public boolean ready() {
final String text = getDataSource().peek(0).getElement();
if (text.equals("{") || text.equals("{+") || text.equals("{#") || text.equals("{!") || text.equals("{-")) {
final String text1 = getDataSource().peek(1).getElement();
if (text1.matches("[NSEW]=|T")) {
return false;
}
return true;
}
return false;
}
}

View File

@ -1,391 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 9591 $
*
*/
package net.sourceforge.plantuml.sequencediagram.graphic;
import java.awt.Color;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sourceforge.plantuml.CMapData;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.api.ImageDataComplex;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.graphic.HtmlColorSimple;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.png.PngTitler;
import net.sourceforge.plantuml.sequencediagram.Event;
import net.sourceforge.plantuml.sequencediagram.LifeEvent;
import net.sourceforge.plantuml.sequencediagram.LifeEventType;
import net.sourceforge.plantuml.sequencediagram.Message;
import net.sourceforge.plantuml.sequencediagram.Newpage;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.SimpleContext2D;
import net.sourceforge.plantuml.skin.Skin;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5;
import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
public class SequenceDiagramFileMakerPuma implements FileMaker {
private static final StringBounder dummyStringBounder = TextBlockUtils.getDummyStringBounder();
private final SequenceDiagram diagram;
private final DrawableSet drawableSet;
private final Dimension2D fullDimension;
private final List<Page> pages;
private final FileFormatOption fileFormatOption;
private final List<BufferedImage> flashcodes;
private double scale;
private int offsetX;
private int offsetY;
public SequenceDiagramFileMakerPuma(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption,
List<BufferedImage> flashcodes) {
// HtmlColor.setForceMonochrome(sequenceDiagram.getSkinParam().isMonochrome());
this.flashcodes = flashcodes;
this.diagram = sequenceDiagram;
this.fileFormatOption = fileFormatOption;
final DrawableSetInitializer initializer = new DrawableSetInitializer(skin, sequenceDiagram.getSkinParam(),
sequenceDiagram.isShowFootbox(), sequenceDiagram.getAutonewpage());
for (Participant p : sequenceDiagram.participants().values()) {
initializer.addParticipant(p, sequenceDiagram.getEnglober(p));
}
for (Event ev : sequenceDiagram.events()) {
initializer.addEvent(ev);
if (ev instanceof Message) {
// TODO mieux faire
final Message m = (Message) ev;
for (LifeEvent lifeEvent : m.getLiveEvents()) {
if (lifeEvent.getType() == LifeEventType.DESTROY
/*
* || lifeEvent.getType() == LifeEventType.CREATE
*/) {
initializer.addEvent(lifeEvent);
}
}
}
}
drawableSet = initializer.createDrawableSet(dummyStringBounder);
final List<Newpage> newpages = new ArrayList<Newpage>();
for (Event ev : drawableSet.getAllEvents()) {
if (ev instanceof Newpage) {
newpages.add((Newpage) ev);
}
}
fullDimension = drawableSet.getDimension();
final Map<Newpage, Double> positions = new LinkedHashMap<Newpage, Double>();
for (Newpage n : newpages) {
positions.put(n, initializer.getYposition(dummyStringBounder, n));
}
pages = create(drawableSet, positions, sequenceDiagram.isShowFootbox(), sequenceDiagram.getTitle()).getPages();
}
public int getNbPages() {
return pages.size();
}
private PageSplitter create(DrawableSet drawableSet, Map<Newpage, Double> positions, boolean showFootbox,
Display title) {
final double headerHeight = drawableSet.getHeadHeight(dummyStringBounder);
final double tailHeight = drawableSet.getTailHeight(dummyStringBounder, showFootbox);
final double signatureHeight = 0;
final double newpageHeight = drawableSet.getSkin()
.createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), Display.asList(""))
.getPreferredHeight(dummyStringBounder);
return new PageSplitter(fullDimension.getHeight(), headerHeight, positions, tailHeight, signatureHeight,
newpageHeight, title);
}
public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
final UGraphic ug = createImage((int) fullDimension.getWidth(), pages.get(index), index);
ug.writeImage(os, isWithMetadata ? diagram.getMetadata() : null, diagram.getDpi(fileFormatOption));
final Dimension2D info = new Dimension2DDouble(fullDimension.getWidth(), fullDimension.getHeight());
if (fileFormatOption.getFileFormat() == FileFormat.PNG && ug instanceof UGraphicG2d) {
final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered();
if (urls.size() > 0) {
if (scale == 0) {
throw new IllegalStateException();
}
final CMapData cmap = CMapData.cmapString(urls, scale);
return new ImageDataComplex(info, cmap, null);
}
}
return new ImageDataSimple(info);
}
private double getImageWidth(SequenceDiagramArea area, boolean rotate, double dpiFactor, double legendWidth) {
final int minsize = diagram.getMinwidth();
final double w = Math.max(getImageWidthWithoutMinsize(area, rotate, dpiFactor), legendWidth);
if (minsize == Integer.MAX_VALUE) {
return w;
}
if (w >= minsize) {
return w;
}
return minsize;
}
private double getScale(double width, double height) {
if (diagram.getScale() == null) {
return 1;
}
return diagram.getScale().getScale(width, height);
}
private double getImageWidthWithoutMinsize(SequenceDiagramArea area, boolean rotate, double dpiFactor) {
final double w;
if (rotate) {
w = area.getHeight() * getScale(area.getWidth(), area.getHeight()) * dpiFactor;
} else {
w = area.getWidth() * getScale(area.getWidth(), area.getHeight()) * dpiFactor;
}
return w;
}
private double getImageHeight(SequenceDiagramArea area, final Page page, boolean rotate, double dpiFactor) {
if (rotate) {
return area.getWidth() * getScale(area.getWidth(), area.getHeight()) * dpiFactor;
}
return area.getHeight() * getScale(area.getWidth(), area.getHeight()) * dpiFactor;
}
private UGraphic createImage(final int diagramWidth, final Page page, final int indice) {
double delta = 0;
if (indice > 0) {
delta = page.getNewpage1() - page.getHeaderHeight();
}
if (delta < 0) {
delta = 0;
}
final SequenceDiagramArea area = new SequenceDiagramArea(diagramWidth, page.getHeight());
Component compTitle = null;
if (page.getTitle() != null) {
compTitle = drawableSet.getSkin().createComponent(ComponentType.TITLE, null, drawableSet.getSkinParam(),
page.getTitle());
area.setTitleArea(compTitle.getPreferredWidth(dummyStringBounder),
compTitle.getPreferredHeight(dummyStringBounder));
}
addFooter2(area);
addHeader2(area);
offsetX = (int) Math.round(area.getSequenceAreaX());
offsetY = (int) Math.round(area.getSequenceAreaY());
Color backColor = null;
if (diagram.getSkinParam().getBackgroundColor() instanceof HtmlColorSimple) {
backColor = diagram.getSkinParam().getColorMapper()
.getMappedColor(diagram.getSkinParam().getBackgroundColor());
}
final FileFormat fileFormat = fileFormatOption.getFileFormat();
final double dpiFactor = diagram.getDpiFactor(fileFormatOption);
final Display legend = diagram.getLegend();
final TextBlock legendBlock;
if (legend == null) {
legendBlock = TextBlockUtils.empty(0, 0);
} else {
legendBlock = EntityImageLegend.create(legend, diagram.getSkinParam());
}
final Dimension2D dimLegend = TextBlockUtils.getDimension(legendBlock);
scale = getScale(area.getWidth(), area.getHeight());
UGraphic ug;
if (fileFormat == FileFormat.PNG) {
double imageHeight = getImageHeight(area, page, diagram.isRotation(), 1);
if (imageHeight == 0) {
imageHeight = 1;
}
final double flashCodeHeight = flashcodes == null ? 0 : flashcodes.get(0).getHeight();
final Dimension2D dim;
final double imageWidthWithDpi = getImageWidth(area, diagram.isRotation(), 1, dimLegend.getWidth());
if (diagram.isRotation()) {
dim = new Dimension2DDouble(imageHeight + dimLegend.getHeight(), imageWidthWithDpi + flashCodeHeight);
} else {
dim = new Dimension2DDouble(imageWidthWithDpi, imageHeight + flashCodeHeight + dimLegend.getHeight());
}
ug = fileFormatOption.createUGraphic(diagram.getSkinParam().getColorMapper(), dpiFactor, dim, diagram
.getSkinParam().getBackgroundColor(), diagram.isRotation());
if (flashcodes != null) {
((UGraphicG2d) ug).getGraphics2D().drawImage(flashcodes.get(0), null, 0, (int) imageHeight);
}
final AffineTransform scaleAt = ((UGraphicG2d) ug).getGraphics2D().getTransform();
scaleAt.scale(scale, scale);
((UGraphicG2d) ug).getGraphics2D().setTransform(scaleAt);
} else if (fileFormat == FileFormat.SVG) {
if (diagram.getSkinParam().getBackgroundColor() instanceof HtmlColorGradient) {
ug = new UGraphicSvg(diagram.getSkinParam().getColorMapper(), (HtmlColorGradient) diagram
.getSkinParam().getBackgroundColor(), false, scale);
} else if (backColor == null || backColor.equals(Color.WHITE)) {
ug = new UGraphicSvg(diagram.getSkinParam().getColorMapper(), false, scale);
} else {
ug = new UGraphicSvg(diagram.getSkinParam().getColorMapper(), StringUtils.getAsHtml(backColor), false,
scale);
}
} else if (fileFormat == FileFormat.EPS) {
ug = new UGraphicEps(diagram.getSkinParam().getColorMapper(), EpsStrategy.getDefault2());
} else if (fileFormat == FileFormat.EPS_TEXT) {
ug = new UGraphicEps(diagram.getSkinParam().getColorMapper(), EpsStrategy.WITH_MACRO_AND_TEXT);
} else if (fileFormat == FileFormat.HTML5) {
ug = new UGraphicHtml5(diagram.getSkinParam().getColorMapper());
} else if (fileFormat == FileFormat.VDX) {
ug = new UGraphicVdx(diagram.getSkinParam().getColorMapper());
} else {
throw new UnsupportedOperationException();
}
if (compTitle != null) {
final StringBounder stringBounder = ug.getStringBounder();
final double h = compTitle.getPreferredHeight(stringBounder);
final double w = compTitle.getPreferredWidth(stringBounder);
compTitle.drawU(ug.apply(new UTranslate(area.getTitleX(), area.getTitleY())), new Area(
new Dimension2DDouble(w, h)), new SimpleContext2D(false));
}
addHeader3(area, ug);
addFooter3(area, ug);
final double delta1 = Math.max(0, dimLegend.getWidth() - area.getWidth());
// bugnewway X*58
drawableSet.drawU(ug.apply(new UTranslate(area.getSequenceAreaX() + delta1 / 2, area.getSequenceAreaY())),
delta, diagramWidth, page, diagram.isShowFootbox());
if (legend != null) {
final double delta2;
if (diagram.getLegendAlignment() == HorizontalAlignment.LEFT) {
delta2 = 0;
} else if (diagram.getLegendAlignment() == HorizontalAlignment.RIGHT) {
delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth());
} else {
delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth()) / 2;
}
legendBlock.drawU(ug.apply(new UTranslate(delta2, area.getHeight())));
}
return ug;
}
private void addFooter2(SequenceDiagramArea area) {
final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null).getFamily(null);
final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null).getSize();
final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
diagram.getFooterAlignment());
final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder);
if (dim != null) {
area.setFooterArea(dim.getWidth(), dim.getHeight(), 3);
}
}
private void addHeader2(SequenceDiagramArea area) {
final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null).getFamily(null);
final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null).getSize();
final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
diagram.getHeaderAlignment());
final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder);
if (dim != null) {
area.setHeaderArea(dim.getWidth(), dim.getHeight(), 3);
}
}
private void addFooter3(SequenceDiagramArea area, UGraphic ug) {
final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null).getFamily(null);
final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null).getSize();
final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
diagram.getFooterAlignment());
final TextBlock text = pngTitler.getTextBlock();
if (text == null) {
return;
}
text.drawU(ug.apply(new UTranslate(area.getFooterX(diagram.getFooterAlignment()), area.getFooterY())));
}
private void addHeader3(SequenceDiagramArea area, UGraphic ug) {
final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null).getFamily(null);
final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null).getSize();
final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
diagram.getHeaderAlignment());
final TextBlock text = pngTitler.getTextBlock();
if (text == null) {
return;
}
text.drawU(ug.apply(new UTranslate(area.getHeaderX(diagram.getHeaderAlignment()), area.getHeaderY())));
}
}

View File

@ -1,295 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 9696 $
*
*/
package net.sourceforge.plantuml.skin.rose;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowDecoration;
import net.sourceforge.plantuml.skin.ArrowDirection;
import net.sourceforge.plantuml.skin.ArrowDressing;
import net.sourceforge.plantuml.skin.ArrowHead;
import net.sourceforge.plantuml.skin.ArrowPart;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class ComponentRoseArrow2 extends AbstractComponentRoseArrow {
private final HorizontalAlignment messagePosition;
private final boolean niceArrow;
public ComponentRoseArrow2(HtmlColor foregroundColor, HtmlColor fontColor, UFont font, Display stringsToDisplay,
ArrowConfiguration arrowConfiguration, HorizontalAlignment messagePosition,
SpriteContainer spriteContainer, HorizontalAlignment textHorizontalAlignment, double maxMessageSize,
boolean niceArrow) {
super(foregroundColor, fontColor, font, stringsToDisplay, arrowConfiguration, spriteContainer,
textHorizontalAlignment, maxMessageSize);
this.messagePosition = messagePosition;
this.niceArrow = niceArrow;
}
private final double spaceCrossX = 6;
private final double diamCircle = 8;
private final double thinCircle = 1.5;
@Override
public void drawInternalU(UGraphic ug, Area area) {
final Dimension2D dimensionToUse = area.getDimensionToUse();
final StringBounder stringBounder = ug.getStringBounder();
final int textHeight = (int) getTextHeight(stringBounder);
ug = ug.apply(new UChangeColor(getForegroundColor()));
final ArrowDressing dressing1 = getArrowConfiguration().getDressing1();
final ArrowDressing dressing2 = getArrowConfiguration().getDressing2();
double start = 0;
double len = dimensionToUse.getWidth() - 1;
final double pos1 = start + 1;
final double pos2 = len - 1;
if (dressing2.getDecoration() == ArrowDecoration.CIRCLE && dressing2.getHead() == ArrowHead.NONE) {
len -= diamCircle / 2;
}
if (dressing2.getDecoration() == ArrowDecoration.CIRCLE && dressing2.getHead() != ArrowHead.NONE) {
len -= diamCircle / 2 + thinCircle;
}
if (dressing1.getDecoration() == ArrowDecoration.CIRCLE && dressing1.getHead() == ArrowHead.NONE) {
start += diamCircle / 2;
len -= diamCircle / 2;
}
if (dressing1.getDecoration() == ArrowDecoration.CIRCLE && dressing1.getHead() == ArrowHead.NORMAL) {
start += diamCircle + thinCircle;
len -= diamCircle + thinCircle;
}
drawDressing1(ug, pos1, dressing1);
drawDressing2(ug, pos2, dressing2);
if (dressing2.getPart() == ArrowPart.FULL && dressing2.getHead() == ArrowHead.NORMAL) {
len -= getArrowDeltaX() / 2;
}
if (dressing1.getPart() == ArrowPart.FULL && dressing1.getHead() == ArrowHead.NORMAL) {
start += getArrowDeltaX() / 2;
len -= getArrowDeltaX() / 2;
}
if (dressing2.getHead() == ArrowHead.CROSSX) {
len -= 2 * spaceCrossX;
}
if (dressing1.getHead() == ArrowHead.CROSSX) {
start += 2 * spaceCrossX;
len -= 2 * spaceCrossX;
}
if (getArrowConfiguration().isDotted()) {
ug = stroke(ug, 2, 2);
}
ug.apply(new UTranslate(start, textHeight)).draw(new ULine(len, 0));
if (getArrowConfiguration().isDotted()) {
ug = ug.apply(new UStroke());
}
final ArrowDirection direction2 = getDirection2();
final double textPos;
if (messagePosition == HorizontalAlignment.CENTER) {
final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth();
textPos = (dimensionToUse.getWidth() - textWidth) / 2;
} else if (messagePosition == HorizontalAlignment.RIGHT) {
final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth();
textPos = dimensionToUse.getWidth() - textWidth - getMarginX2()
- (direction2 == ArrowDirection.LEFT_TO_RIGHT_NORMAL ? getArrowDeltaX() : 0);
} else {
textPos = getMarginX1()
+ (direction2 == ArrowDirection.RIGHT_TO_LEFT_REVERSE
|| direction2 == ArrowDirection.BOTH_DIRECTION ? getArrowDeltaX() : 0);
}
getTextBlock().drawU(ug.apply(new UTranslate(textPos, 0)));
}
private void drawDressing1(UGraphic ug, double x, ArrowDressing dressing) {
final StringBounder stringBounder = ug.getStringBounder();
final int textHeight = (int) getTextHeight(stringBounder);
if (dressing.getDecoration() == ArrowDecoration.CIRCLE) {
ug = ug.apply(new UStroke(thinCircle)).apply(new UChangeColor(getForegroundColor()));
final UEllipse circle = new UEllipse(diamCircle, diamCircle);
ug.apply(new UTranslate(x - diamCircle / 2 - thinCircle, textHeight - diamCircle / 2 - thinCircle / 2))
.draw(circle);
ug = ug.apply(new UStroke());
x += diamCircle / 2 + thinCircle;
}
if (dressing.getHead() == ArrowHead.ASYNC) {
if (dressing.getPart() != ArrowPart.BOTTOM_PART) {
ug.apply(new UTranslate(x - 1, textHeight)).draw(new ULine(getArrowDeltaX(), -getArrowDeltaY()));
}
if (dressing.getPart() != ArrowPart.TOP_PART) {
ug.apply(new UTranslate(x - 1, textHeight)).draw(new ULine(getArrowDeltaX(), getArrowDeltaY()));
}
} else if (dressing.getHead() == ArrowHead.CROSSX) {
ug = ug.apply(new UStroke(2));
ug.apply(new UTranslate(spaceCrossX, textHeight - getArrowDeltaX() / 2)).draw(
new ULine(getArrowDeltaX(), getArrowDeltaX()));
ug.apply(new UTranslate(spaceCrossX, textHeight + getArrowDeltaX() / 2)).draw(
new ULine(getArrowDeltaX(), -getArrowDeltaX()));
} else if (dressing.getHead() == ArrowHead.NORMAL) {
final UPolygon polygon = getPolygonReverse(dressing.getPart(), textHeight);
ug.apply(new UChangeBackColor(getForegroundColor())).apply(new UTranslate(x, 0)).draw(polygon);
}
}
private void drawDressing2(UGraphic ug, double x, ArrowDressing dressing) {
final StringBounder stringBounder = ug.getStringBounder();
final int textHeight = (int) getTextHeight(stringBounder);
if (dressing.getDecoration() == ArrowDecoration.CIRCLE) {
ug = ug.apply(new UStroke(thinCircle)).apply(new UChangeColor(getForegroundColor()));
final UEllipse circle = new UEllipse(diamCircle, diamCircle);
ug.apply(new UTranslate(x - diamCircle / 2 + thinCircle, textHeight - diamCircle / 2 - thinCircle / 2))
.draw(circle);
ug = ug.apply(new UStroke());
x -= diamCircle / 2 + thinCircle;
}
if (dressing.getHead() == ArrowHead.ASYNC) {
if (dressing.getPart() != ArrowPart.BOTTOM_PART) {
ug.apply(new UTranslate(x, textHeight)).draw(new ULine(-getArrowDeltaX(), -getArrowDeltaY()));
}
if (dressing.getPart() != ArrowPart.TOP_PART) {
ug.apply(new UTranslate(x, textHeight)).draw(new ULine(-getArrowDeltaX(), getArrowDeltaY()));
}
} else if (dressing.getHead() == ArrowHead.CROSSX) {
ug = ug.apply(new UStroke(2));
ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), textHeight - getArrowDeltaX() / 2)).draw(
new ULine(getArrowDeltaX(), getArrowDeltaX()));
ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), textHeight + getArrowDeltaX() / 2)).draw(
new ULine(getArrowDeltaX(), -getArrowDeltaX()));
ug = ug.apply(new UStroke());
} else if (dressing.getHead() == ArrowHead.NORMAL) {
final UPolygon polygon = getPolygonNormal(dressing.getPart(), textHeight, x);
ug.apply(new UChangeBackColor(getForegroundColor())).draw(polygon);
}
}
private UPolygon getPolygonNormal(ArrowPart part, final int textHeight, final double x2) {
final UPolygon polygon = new UPolygon();
if (part == ArrowPart.TOP_PART) {
polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY());
polygon.addPoint(x2, textHeight);
polygon.addPoint(x2 - getArrowDeltaX(), textHeight);
} else if (part == ArrowPart.BOTTOM_PART) {
polygon.addPoint(x2 - getArrowDeltaX(), textHeight + 1);
polygon.addPoint(x2, textHeight + 1);
polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY() + 1);
} else {
polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY());
polygon.addPoint(x2, textHeight);
polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY());
if (niceArrow) {
polygon.addPoint(x2 - getArrowDeltaX() + 4, textHeight);
}
}
return polygon;
}
private UPolygon getPolygonReverse(ArrowPart part, final int textHeight) {
final UPolygon polygon = new UPolygon();
if (part == ArrowPart.TOP_PART) {
polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY());
polygon.addPoint(0, textHeight);
polygon.addPoint(getArrowDeltaX(), textHeight);
} else if (part == ArrowPart.BOTTOM_PART) {
polygon.addPoint(getArrowDeltaX(), textHeight + 1);
polygon.addPoint(0, textHeight + 1);
polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + 1);
} else {
polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY());
polygon.addPoint(0, textHeight);
polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY());
if (niceArrow) {
polygon.addPoint(getArrowDeltaX() - 4, textHeight);
}
}
return polygon;
}
public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
final int textHeight = (int) getTextHeight(stringBounder);
if (getDirection2() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
}
return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY());
}
public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
final int textHeight = (int) getTextHeight(stringBounder);
if (getDirection2() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY());
}
return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
}
final private ArrowDirection getDirection2() {
return getArrowConfiguration().getArrowDirection();
}
@Override
public double getPreferredHeight(StringBounder stringBounder) {
return getTextHeight(stringBounder) + getArrowDeltaY() + 2 * getPaddingY();
}
@Override
public double getPreferredWidth(StringBounder stringBounder) {
return getTextWidth(stringBounder) + getArrowDeltaX();
}
}

View File

@ -1,100 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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.statediagram.command;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.statediagram.StateDiagram;
public class CommandCreateState2 extends SingleLineCommand2<StateDiagram> {
public CommandCreateState2() {
super(getRegexConcat());
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("(?:state\\s+)"), //
new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
new RegexLeaf("\\s+as\\s+"), //
new RegexLeaf("DISPLAY", "\"([^\"]+)\""), //
new RegexLeaf("\\s*"), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("\\s*"), //
new RegexLeaf("COLOR", "(#\\w+[-\\\\|/]?\\w+)?"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(StateDiagram system, RegexResult arg2) {
final Code code = Code.of(arg2.get("CODE", 0));
final String display = arg2.get("DISPLAY", 0);
final IEntity ent = system.getOrCreateLeaf(code, null);
if (system.checkConcurrentStateOk(code) == false) {
return CommandExecutionResult.error("The state " + code
+ " has been created in a concurrent state : it cannot be used here.");
}
ent.setDisplay(Display.getWithNewlines(display));
final String stereotype = arg2.get("STEREOTYPE", 0);
if (stereotype != null) {
ent.setStereotype(new Stereotype(stereotype));
}
final String urlString = arg2.get("URL", 0);
if (urlString != null) {
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url url = urlBuilder.getUrl(urlString);
ent.addUrl(url);
}
final String color = arg2.get("COLOR", 0);
if (color != null) {
ent.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(color));
}
return CommandExecutionResult.ok();
}
}

View File

@ -1,89 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 6711 $
*
*/
package net.sourceforge.plantuml.svek;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke;
public final class InnerStateConcurrent implements IEntityImage {
private final IEntityImage im;
public InnerStateConcurrent(final IEntityImage im) {
this.im = im;
}
public final static double THICKNESS_BORDER = 1.5;
private static final int DASH = 8;
public void drawU(UGraphic ug) {
final Dimension2D dim = calculateDimension(ug.getStringBounder());
final UShape rect = new URectangle(dim.getWidth(), dim.getHeight());
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
ug.apply(new UStroke(DASH, 10, THICKNESS_BORDER)).draw(rect);
im.drawU(ug);
}
public HtmlColor getBackcolor() {
return null;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D img = im.calculateDimension(stringBounder);
return img;
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
public int getShield() {
return 0;
}
public boolean isHidden() {
return im.isHidden();
}
}

View File

@ -1,133 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 5183 $
*
*/
package net.sourceforge.plantuml.svek.image;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class EntityImageActor2 extends AbstractEntityImage {
private final TextBlock stickman;
private final TextBlock name;
private final TextBlock stereo;
final private Url url;
public EntityImageActor2(ILeaf entity, ISkinParam skinParam, FontParam fontStereotype, FontParam fontName,
TextBlock stickman) {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
this.name = TextBlockUtils.create(
entity.getDisplay(),
new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), fontName, stereotype), SkinParamUtils
.getFontColor(getSkinParam(), fontName, stereotype)), HorizontalAlignment.CENTER, skinParam);
this.stickman = stickman;
if (stereotype == null || stereotype.getLabel() == null) {
this.stereo = null;
} else {
this.stereo = TextBlockUtils.create(Display.getWithNewlines(stereotype.getLabel()),
new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), fontStereotype, stereotype),
SkinParamUtils.getFontColor(getSkinParam(), fontStereotype, null)),
HorizontalAlignment.CENTER, skinParam);
}
this.url = entity.getUrl99();
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D dimName = name.calculateDimension(stringBounder);
final Dimension2D dimStereo = getStereoDimension(stringBounder);
final Dimension2D dimActor = stickman.calculateDimension(stringBounder);
return Dimension2DDouble.mergeLayoutT12B3(dimStereo, dimActor, dimName);
}
private Dimension2D getStereoDimension(StringBounder stringBounder) {
if (stereo == null) {
return new Dimension2DDouble(0, 0);
}
return stereo.calculateDimension(stringBounder);
}
final public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimStickMan = stickman.calculateDimension(stringBounder);
final Dimension2D dimStereo = getStereoDimension(stringBounder);
final Dimension2D dimTotal = calculateDimension(stringBounder);
final Dimension2D dimName = name.calculateDimension(stringBounder);
final double manX = (dimTotal.getWidth() - dimStickMan.getWidth()) / 2;
final double manY = dimStereo.getHeight();
if (url != null) {
ug.startUrl(url);
}
stickman.drawU(ug.apply(new UTranslate(manX, manY)));
final double nameX = (dimTotal.getWidth() - dimName.getWidth()) / 2;
final double nameY = dimStickMan.getHeight() + dimStereo.getHeight();
name.drawU(ug.apply(new UTranslate(nameX, nameY)));
if (stereo != null) {
final double stereoX = (dimTotal.getWidth() - dimStereo.getWidth()) / 2;
stereo.drawU(ug.apply(new UTranslate(stereoX, 0)));
}
if (url != null) {
ug.closeAction();
}
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
public int getShield() {
return 0;
}
}

View File

@ -1,152 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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: 5183 $
*
*/
package net.sourceforge.plantuml.svek.image;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class EntityImageCircleInterface extends AbstractEntityImage {
private static final int SIZE = 16;
private final TextBlock name;
private final TextBlock stereo;
final private Url url;
public EntityImageCircleInterface(ILeaf entity, ISkinParam skinParam) {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
this.name = TextBlockUtils.create(entity.getDisplay(),
new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.COMPONENT, stereotype),
SkinParamUtils.getFontColor(getSkinParam(), FontParam.COMPONENT, stereotype)),
HorizontalAlignment.CENTER, skinParam);
if (stereotype == null || stereotype.getLabel() == null) {
this.stereo = null;
} else {
this.stereo = TextBlockUtils.create(
Display.getWithNewlines(stereotype.getLabel()),
new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.COMPONENT_STEREOTYPE,
stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.COMPONENT_STEREOTYPE,
null)), HorizontalAlignment.CENTER, skinParam);
}
this.url = entity.getUrl99();
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D dimName = name.calculateDimension(stringBounder);
final Dimension2D dimStereo = getStereoDimension(stringBounder);
final Dimension2D circle = new Dimension2DDouble(SIZE, SIZE);
return Dimension2DDouble.mergeLayoutT12B3(dimStereo, circle, dimName);
}
final public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimStereo = getStereoDimension(stringBounder);
final Dimension2D dimTotal = calculateDimension(stringBounder);
final Dimension2D dimName = name.calculateDimension(stringBounder);
final double circleX = (dimTotal.getWidth() - SIZE) / 2;
final double circleY = dimStereo.getHeight();
final UEllipse circle = new UEllipse(SIZE, SIZE);
if (getSkinParam().shadowing()) {
circle.setDeltaShadow(4);
}
ug = ug.apply(new UStroke(2));
ug = ug.apply(
new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.componentInterfaceBackground,
getStereo()))).apply(
new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.componentInterfaceBorder,
getStereo())));
if (url != null) {
ug.startUrl(url);
}
ug.apply(new UTranslate(circleX, circleY)).draw(circle);
ug = ug.apply(new UStroke());
final double nameX = (dimTotal.getWidth() - dimName.getWidth()) / 2;
final double nameY = SIZE + dimStereo.getHeight();
name.drawU(ug.apply(new UTranslate(nameX, nameY)));
if (stereo != null) {
final double stereoX = (dimTotal.getWidth() - dimStereo.getWidth()) / 2;
stereo.drawU(ug.apply(new UTranslate(stereoX, 0)));
}
if (url != null) {
ug.closeAction();
}
}
private Dimension2D getStereoDimension(StringBounder stringBounder) {
if (stereo == null) {
return new Dimension2DDouble(0, 0);
}
return stereo.calculateDimension(stringBounder);
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
public int getShield() {
return 0;
}
}

View File

@ -1,187 +0,0 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2013, 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 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
* Modified by : Arno Peterson
*
* Revision $Revision: 5183 $
*
*/
package net.sourceforge.plantuml.svek.image;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
public class EntityImageComponentForDescriptionDiagram extends AbstractEntityImage {
final private Url url;
private final TextBlock asSmall;
public EntityImageComponentForDescriptionDiagram(ILeaf entity, ISkinParam skinParam) {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
final USymbol symbol = entity.getUSymbol();
if (symbol == null) {
throw new IllegalArgumentException();
}
final TextBlock desc = new BodyEnhanced(entity.getDisplay(), getFontParam(symbol), skinParam,
HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false);
// final TextBlock desc = TextBlockUtils.create(
// entity.getDisplay(),
// new FontConfiguration(getFont(getFontParam(symbol), stereotype), getFontColor(getFontParam(symbol),
// stereotype)), HorizontalAlignment.CENTER, skinParam);
this.url = entity.getUrl99();
HtmlColor backcolor = getEntity().getSpecificBackColor();
if (backcolor == null) {
backcolor = SkinParamUtils.getColor(getSkinParam(), getColorParamBack(symbol), getStereo());
}
final HtmlColor forecolor = SkinParamUtils.getColor(getSkinParam(), getColorParamBorder(symbol), getStereo());
final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(new UStroke(1.5)).withShadow(
getSkinParam().shadowing());
TextBlock stereo = TextBlockUtils.empty(0, 0);
if (stereotype != null && stereotype.getLabel() != null) {
stereo = TextBlockUtils.create(
Display.getWithNewlines(stereotype.getLabel()),
new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), getFontParamStereotype(symbol),
stereotype), SkinParamUtils.getFontColor(getSkinParam(), getFontParamStereotype(symbol),
null)), HorizontalAlignment.CENTER, skinParam);
}
asSmall = symbol.asSmall(desc, stereo, ctx);
}
private FontParam getFontParamStereotype(USymbol symbol) {
if (symbol == USymbol.COMPONENT1 || symbol == USymbol.COMPONENT2 || symbol == USymbol.INTERFACE) {
return FontParam.COMPONENT_STEREOTYPE;
}
if (symbol == USymbol.ACTOR) {
return FontParam.USECASE_ACTOR_STEREOTYPE;
}
if (symbol == USymbol.ARTIFACT || symbol == USymbol.FOLDER || symbol == USymbol.BOUNDARY
|| symbol == USymbol.ENTITY_DOMAIN || symbol == USymbol.CONTROL) {
return FontParam.USECASE_ACTOR_STEREOTYPE;
}
return FontParam.USECASE_ACTOR_STEREOTYPE;
// throw new UnsupportedOperationException("symbol=" + symbol.getClass());
}
private FontParam getFontParam(USymbol symbol) {
if (symbol == USymbol.COMPONENT1 || symbol == USymbol.COMPONENT2 || symbol == USymbol.INTERFACE) {
return FontParam.COMPONENT;
}
if (symbol == USymbol.ACTOR) {
return FontParam.USECASE_ACTOR;
}
if (symbol == USymbol.ARTIFACT || symbol == USymbol.FOLDER || symbol == USymbol.BOUNDARY
|| symbol == USymbol.ENTITY_DOMAIN || symbol == USymbol.CONTROL) {
return FontParam.USECASE_ACTOR;
}
return FontParam.USECASE_ACTOR;
// throw new UnsupportedOperationException("symbol=" + symbol.getClass());
}
private ColorParam getColorParamBorder(USymbol symbol) {
if (symbol == USymbol.COMPONENT1 || symbol == USymbol.COMPONENT2 || symbol == USymbol.INTERFACE) {
return ColorParam.componentBorder;
}
if (symbol == USymbol.ACTOR) {
return ColorParam.usecaseActorBorder;
}
if (symbol == USymbol.ARTIFACT || symbol == USymbol.FOLDER || symbol == USymbol.BOUNDARY
|| symbol == USymbol.ENTITY_DOMAIN || symbol == USymbol.CONTROL) {
return ColorParam.usecaseActorBorder;
}
return ColorParam.usecaseActorBorder;
// throw new UnsupportedOperationException("symbol=" + symbol.getClass());
}
private ColorParam getColorParamBack(USymbol symbol) {
if (symbol == USymbol.COMPONENT1 || symbol == USymbol.COMPONENT2 || symbol == USymbol.INTERFACE) {
return ColorParam.componentBackground;
}
if (symbol == USymbol.ACTOR) {
return ColorParam.usecaseActorBackground;
}
if (symbol == USymbol.ARTIFACT || symbol == USymbol.FOLDER || symbol == USymbol.BOUNDARY
|| symbol == USymbol.ENTITY_DOMAIN || symbol == USymbol.CONTROL) {
return ColorParam.usecaseActorBackground;
}
return ColorParam.usecaseActorBackground;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return asSmall.calculateDimension(stringBounder);
}
final public void drawU(UGraphic ug) {
if (url != null) {
ug.startUrl(url);
}
asSmall.drawU(ug);
if (url != null) {
ug.closeAction();
}
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
public int getShield() {
return 0;
}
}