From 6ace15b789754582d9fd5a46d26e5fce49b6f5e3 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Wed, 12 Jan 2011 20:06:53 +0100 Subject: [PATCH] Version 5994 --- src/net/sourceforge/plantuml/FontParam.java | 3 +- .../activitydiagram2/ActivityDiagram2.java | 43 ++++++--- .../ActivityDiagramFactory2.java | 2 + .../activitydiagram2/ConditionalContext2.java | 81 ++++++++++++++++ .../command/CommandElse2.java | 68 ++++++++++++++ .../command/CommandEndif2.java | 6 +- .../plantuml/asciiart/TextSkin.java | 5 +- .../AbstractClassOrObjectDiagram.java | 40 +------- .../plantuml/posimo/PathDrawerInterface.java | 2 +- .../plantuml/sequencediagram/Delay.java | 50 ++++++++++ .../sequencediagram/SequenceDiagram.java | 4 + .../SequenceDiagramFactory.java | 4 +- .../sequencediagram/command/CommandDelay.java | 57 ++++++++++++ .../graphic/DrawableSetInitializer.java | 24 ++++- .../graphic/GraphicalDelayText.java | 80 ++++++++++++++++ .../graphic/GraphicalDivider.java | 1 - .../graphic/ParticipantBox.java | 52 ++++++++--- .../plantuml/skin/AbstractComponent.java | 10 +- .../plantuml/skin/ComponentType.java | 2 + .../AbstractComponentBlueModernArrow.java | 19 ++-- .../plantuml/skin/bluemodern/BlueModern.java | 7 +- .../bluemodern/ComponentBlueModernArrow.java | 92 +++++++++++++------ .../ComponentBlueModernSelfArrow.java | 51 +++++++--- .../skin/rose/ComponentRoseArrow.java | 4 +- .../skin/rose/ComponentRoseDelayLine.java | 73 +++++++++++++++ .../skin/rose/ComponentRoseDelayText.java | 77 ++++++++++++++++ .../skin/rose/ComponentRoseGroupingElse.java | 4 +- .../plantuml/skin/rose/ComponentRoseLine.java | 4 +- .../skin/rose/ComponentRoseNewpage.java | 4 +- .../skin/rose/ComponentRoseSelfArrow.java | 4 +- .../sourceforge/plantuml/skin/rose/Rose.java | 11 ++- .../plantuml/ugraphic/UStroke.java | 28 +++--- .../plantuml/ugraphic/g2d/DriverLineG2d.java | 9 +- .../sourceforge/plantuml/version/Version.java | 6 +- 34 files changed, 762 insertions(+), 165 deletions(-) create mode 100644 src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java create mode 100644 src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java create mode 100644 src/net/sourceforge/plantuml/sequencediagram/Delay.java create mode 100644 src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java create mode 100644 src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java create mode 100644 src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java create mode 100644 src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java diff --git a/src/net/sourceforge/plantuml/FontParam.java b/src/net/sourceforge/plantuml/FontParam.java index d267a8e4d..e654bf9df 100644 --- a/src/net/sourceforge/plantuml/FontParam.java +++ b/src/net/sourceforge/plantuml/FontParam.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5218 $ + * Revision $Revision: 5942 $ * */ package net.sourceforge.plantuml; @@ -57,6 +57,7 @@ public enum FontParam { SEQUENCE_ARROW(13, Font.PLAIN, "black", null), SEQUENCE_ENGLOBER(13, Font.BOLD, "black", null), SEQUENCE_DIVIDER(13, Font.BOLD, "black", null), + SEQUENCE_DELAY(11, Font.PLAIN, "black", null), SEQUENCE_GROUPING(11, Font.BOLD, "black", null), SEQUENCE_GROUPING_HEADER(13, Font.BOLD, "black", null), SEQUENCE_PARTICIPANT(13, Font.PLAIN, "black", null), diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java index ee2d6417b..7a7b315ad 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java @@ -33,13 +33,14 @@ */ package net.sourceforge.plantuml.activitydiagram2; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UniqueSequence; -import net.sourceforge.plantuml.activitydiagram.ConditionalContext; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Entity; import net.sourceforge.plantuml.cucadiagram.EntityType; @@ -50,8 +51,9 @@ import net.sourceforge.plantuml.cucadiagram.LinkType; public class ActivityDiagram2 extends CucaDiagram { - private IEntity last; - private ConditionalContext currentContext; + private Collection last2 = new ArrayList(); + private ConditionalContext2 currentContext; + private int futureLength = 2; final protected List getDotStrings() { return Arrays.asList("nodesep=.20;", "ranksep=0.4;", "edge [fontsize=11,labelfontsize=11];", @@ -68,12 +70,16 @@ public class ActivityDiagram2 extends CucaDiagram { } public void newActivity(String display) { - if (last == null) { + if (last2.size() == 0) { throw new IllegalStateException(); } final Entity act = createEntity(getAutoCode(), display, EntityType.ACTIVITY); - this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, 2)); - last = act; + for (IEntity last : this.last2) { + this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength)); + } + this.last2.clear(); + this.last2.add(act); + this.futureLength = 2; } @@ -82,25 +88,36 @@ public class ActivityDiagram2 extends CucaDiagram { } public void start() { - if (last != null) { + if (last2.size() != 0) { throw new IllegalStateException(); } - last = createEntity("start", "start", EntityType.CIRCLE_START); + this.last2.add(createEntity("start", "start", EntityType.CIRCLE_START)); } public void startIf(String test) { final IEntity br = createEntity(getAutoCode(), "", EntityType.BRANCH); - currentContext = new ConditionalContext(currentContext, br, Direction.DOWN); - this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, 2)); - last = br; + currentContext = new ConditionalContext2(currentContext, br, Direction.DOWN); + for (IEntity last : this.last2) { + this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength)); + } + this.last2.clear(); + this.last2.add(br); + this.futureLength = 1; } - public IEntity getLastEntityConsulted() { - return last; + public Collection getLastEntityConsulted2() { + return this.last2; } public void endif() { + this.last2.add(currentContext.getPending()); currentContext = currentContext.getParent(); } + public void else2() { + this.currentContext.setPending(this.last2.iterator().next()); + this.last2.clear(); + this.last2.add(currentContext.getBranch()); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java index 701469b71..bdedc8fac 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java @@ -33,6 +33,7 @@ */ package net.sourceforge.plantuml.activitydiagram2; +import net.sourceforge.plantuml.activitydiagram2.command.CommandElse2; import net.sourceforge.plantuml.activitydiagram2.command.CommandEndif2; import net.sourceforge.plantuml.activitydiagram2.command.CommandIf2; import net.sourceforge.plantuml.activitydiagram2.command.CommandNewActivity; @@ -56,6 +57,7 @@ public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory { addCommand(new CommandNewActivity(system)); addCommand(new CommandIf2(system)); addCommand(new CommandEndif2(system)); + addCommand(new CommandElse2(system)); // addCommand(new CommandLinkActivity(system)); // addCommand(new CommandPartition(system)); diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java b/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java new file mode 100644 index 000000000..2da4e4837 --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java @@ -0,0 +1,81 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 3828 $ + * + */ +package net.sourceforge.plantuml.activitydiagram2; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.cucadiagram.EntityType; +import net.sourceforge.plantuml.cucadiagram.IEntity; + +public class ConditionalContext2 { + + private IEntity pending; + private final IEntity branch; + private final Direction direction; + private final ConditionalContext2 parent; + + public ConditionalContext2(ConditionalContext2 parent, IEntity branch, Direction direction) { + if (branch.getType() != EntityType.BRANCH) { + throw new IllegalArgumentException(); + } + this.branch = branch; + this.direction = direction; + this.parent = parent; + this.pending = branch; + } + + public Direction getDirection() { + return direction; + } + + public final ConditionalContext2 getParent() { + return parent; + } + + public final IEntity getPending() { + return pending; + } + + public final void setPending(IEntity pending) { + this.pending = pending; + } + + public final IEntity getBranch() { + return branch; + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java new file mode 100644 index 000000000..c5099522f --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandElse2.java @@ -0,0 +1,68 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4762 $ + * + */ +package net.sourceforge.plantuml.activitydiagram2.command; + +import java.util.Map; + +import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexPartialMatch; + +public class CommandElse2 extends SingleLineCommand2 { + + public CommandElse2(ActivityDiagram2 diagram) { + super(diagram, getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), + new RegexLeaf("else"), + new RegexLeaf("$")); + } + + + @Override + protected CommandExecutionResult executeArg(Map arg) { +// if (getSystem().getLastEntityConsulted() == null) { +// return CommandExecutionResult.error("No if for this endif"); +// } + getSystem().else2(); + + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandEndif2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandEndif2.java index ef31f5cff..1706feffd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandEndif2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandEndif2.java @@ -57,9 +57,9 @@ public class CommandEndif2 extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(Map arg) { - if (getSystem().getLastEntityConsulted() == null) { - return CommandExecutionResult.error("No if for this endif"); - } +// if (getSystem().getLastEntityConsulted() == null) { +// return CommandExecutionResult.error("No if for this endif"); +// } getSystem().endif(); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index 936b0e9c2..cb5b82f1c 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java +++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5921 $ + * Revision $Revision: 5941 $ * */ package net.sourceforge.plantuml.asciiart; @@ -67,6 +67,9 @@ public class TextSkin implements Skin { if (type == ComponentType.PARTICIPANT_LINE || type == ComponentType.ACTOR_LINE) { return new ComponentTextLine(fileFormat); } + if (type == ComponentType.DELAY_LINE) { + return new ComponentTextLine(fileFormat); + } if (type == ComponentType.ALIVE_LINE) { return new ComponentTextActiveLine(fileFormat); } diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index a9cae1870..ef0e853bf 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -46,9 +46,6 @@ import net.sourceforge.plantuml.cucadiagram.LinkType; public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram { - // private Link last = null; - // private IEntity lastNode = null; - final public boolean insertBetween(IEntity entity1, IEntity entity2, IEntity node) { final Link link = foundLink(entity1, entity2); if (link == null) { @@ -65,18 +62,14 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram } private Link foundLink(IEntity entity1, IEntity entity2) { - Link result = null; final List links = getLinks(); for (int i = links.size() - 1; i >= 0; i--) { final Link l = links.get(i); if (l.isBetween(entity1, entity2)) { - if (result != null) { - return null; - } - result = l; + return l; } } - return result; + return null; } public int getNbOfHozizontalLollipop(IEntity entity) { @@ -93,35 +86,6 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram return result; } - // final public void insertBetweenNew(IEntity entity1, IEntity entity2, - // IEntity node) { - // Link link = foundLink(entity1, entity2); - // if (link == null) { - // link = last; - // } - // final Link l1 = new Link(entity1, node, link.getType(), link.getLabel(), - // link.getLength(), - // link.getQualifier1(), null, link.getLabeldistance(), - // link.getLabelangle()); - // final Link l2 = new Link(node, entity2, link.getType(), link.getLabel(), - // link.getLength(), null, link - // .getQualifier2(), link.getLabeldistance(), link.getLabelangle()); - // addLink(l1); - // addLink(l2); - // if (last == null) { - // removeLink(link); - // } else { - // final Link lnode = new Link(lastNode, node, link.getType(), - // link.getLabel(), 1); - // lnode.setInvis(true); - // // lnode.setWeight(100); - // addLink(lnode); - // } - // last = link; - // lastNode = node; - // // return true; - // } - private final List assocations = new ArrayList(); public boolean associationClass(int mode, String clName1, String clName2, IEntity associed, LinkType linkType, diff --git a/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java b/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java index 1559f9aab..5f640d075 100644 --- a/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java +++ b/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java @@ -77,7 +77,7 @@ public class PathDrawerInterface implements PathDrawer { } private void goDash(UGraphic ug) { - ug.getParam().setStroke(new UStroke(8, 1.0)); + ug.getParam().setStroke(new UStroke(8, 8, 1.0)); } public void drawPathAfter(UGraphic ug, Positionable start, Positionable end, Path path) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/Delay.java b/src/net/sourceforge/plantuml/sequencediagram/Delay.java new file mode 100644 index 000000000..8afafc2a3 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/Delay.java @@ -0,0 +1,50 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 3835 $ + * + */ +package net.sourceforge.plantuml.sequencediagram; + +import java.util.List; + +public class Delay implements Event { + + private final List text; + + public Delay(List text) { + this.text = text; + } + + public final List getText() { + return text; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index d29a6a936..6d13d2292 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -143,6 +143,10 @@ public class SequenceDiagram extends UmlDiagram { events.add(new Divider(strings)); } + public void delay(List strings) { + events.add(new Delay(strings)); + } + public List events() { return Collections.unmodifiableList(events); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java index ca11e2976..aa1376816 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5925 $ + * Revision $Revision: 5933 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandAutoNewpage; import net.sourceforge.plantuml.sequencediagram.command.CommandAutonumber; import net.sourceforge.plantuml.sequencediagram.command.CommandBoxEnd; import net.sourceforge.plantuml.sequencediagram.command.CommandBoxStart; +import net.sourceforge.plantuml.sequencediagram.command.CommandDelay; import net.sourceforge.plantuml.sequencediagram.command.CommandDivider; import net.sourceforge.plantuml.sequencediagram.command.CommandExoArrowLeft; import net.sourceforge.plantuml.sequencediagram.command.CommandExoArrowRight; @@ -97,6 +98,7 @@ public class SequenceDiagramFactory extends AbstractUmlSystemCommandFactory { addCommand(new CommandSkin(system)); addCommand(new CommandAutonumber(system)); addCommand(new CommandFootbox(system)); + addCommand(new CommandDelay(system)); addCommand(new CommandFootboxOld(system)); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java new file mode 100644 index 000000000..c732e0c55 --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 5158 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.command; + +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand; +import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; + +public class CommandDelay extends SingleLineCommand { + + public CommandDelay(SequenceDiagram sequenceDiagram) { + super(sequenceDiagram, "(?i)^\\.{3}(?:(.*)\\.{3})?$$"); + } + + @Override + protected CommandExecutionResult executeArg(List arg) { + final List strings = arg.get(0) == null ? Collections. emptyList() : StringUtils + .getWithNewlines(arg.get(0)); + getSystem().delay(strings); + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index eceb2770e..ceec85d30 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5875 $ + * Revision $Revision: 5942 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.SkinParamBackcolored; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.sequencediagram.Delay; import net.sourceforge.plantuml.sequencediagram.Divider; import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.GroupingLeaf; @@ -136,6 +137,8 @@ class DrawableSetInitializer { prepareNewpage(stringBounder, (Newpage) ev); } else if (ev instanceof Divider) { prepareDivider(stringBounder, (Divider) ev); + } else if (ev instanceof Delay) { + prepareDelay(stringBounder, (Delay) ev, col); } else { throw new IllegalStateException(); } @@ -251,6 +254,17 @@ class DrawableSetInitializer { drawableSet.addEvent(divider, graphicalDivider); } + private void prepareDelay(StringBounder stringBounder, Delay delay, Collection participants) { + final Component compText = drawableSet.getSkin().createComponent(ComponentType.DELAY_TEXT, + drawableSet.getSkinParam(), delay.getText()); + final GraphicalDelayText graphicalDivider = new GraphicalDelayText(freeY, compText); + for (ParticipantBox p : participants) { + p.addDelay(graphicalDivider); + } + freeY += graphicalDivider.getPreferredHeight(stringBounder); + drawableSet.addEvent(delay, graphicalDivider); + } + private List inGroupableLists = new ArrayList(); private void prepareGroupingStart(StringBounder stringBounder, GroupingStart m) { @@ -375,7 +389,9 @@ class DrawableSetInitializer { p.getDisplay()); final Component line = drawableSet.getSkin().createComponent(ComponentType.PARTICIPANT_LINE, drawableSet.getSkinParam(), p.getDisplay()); - box = new ParticipantBox(head, line, tail, this.freeX); + final Component delayLine = drawableSet.getSkin().createComponent(ComponentType.DELAY_LINE, + drawableSet.getSkinParam(), p.getDisplay()); + box = new ParticipantBox(head, line, tail, delayLine, this.freeX); } else if (p.getType() == ParticipantType.ACTOR) { final ISkinParam skinParam = new SkinParamBackcolored(drawableSet.getSkinParam(), p.getSpecificBackColor()); final Component head = drawableSet.getSkin().createComponent(ComponentType.ACTOR_HEAD, skinParam, @@ -384,7 +400,9 @@ class DrawableSetInitializer { p.getDisplay()); final Component line = drawableSet.getSkin().createComponent(ComponentType.ACTOR_LINE, drawableSet.getSkinParam(), p.getDisplay()); - box = new ParticipantBox(head, line, tail, this.freeX); + final Component delayLine = drawableSet.getSkin().createComponent(ComponentType.DELAY_LINE, + drawableSet.getSkinParam(), p.getDisplay()); + box = new ParticipantBox(head, line, tail, delayLine, this.freeX); } else { throw new IllegalArgumentException(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java new file mode 100644 index 000000000..2b820cc9e --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java @@ -0,0 +1,80 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 3916 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.graphic; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.Context2D; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +class GraphicalDelayText extends GraphicalElement { + + private final Component compText; + + public GraphicalDelayText(double startingY, Component compText) { + super(startingY); + this.compText = compText; + } + + @Override + protected void drawInternalU(UGraphic ug, double maxX, Context2D context) { + ug.translate(0, getStartingY()); + final StringBounder stringBounder = ug.getStringBounder(); + final Dimension2D dim = new Dimension2DDouble(maxX, compText.getPreferredHeight(stringBounder)); + compText.drawU(ug, dim, context); + } + + @Override + public double getPreferredHeight(StringBounder stringBounder) { + return compText.getPreferredHeight(stringBounder); + } + + @Override + public double getPreferredWidth(StringBounder stringBounder) { + return compText.getPreferredWidth(stringBounder); + } + + @Override + public double getStartingX(StringBounder stringBounder) { + return 0; + } + + public double getEndingY(StringBounder stringBounder) { + return getStartingY() + compText.getPreferredHeight(stringBounder); + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java index 036fb29d3..b857b45f7 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java @@ -52,7 +52,6 @@ class GraphicalDivider extends GraphicalElement { @Override protected void drawInternalU(UGraphic ug, double maxX, Context2D context) { - //final double x = ug.getTranslateX(); ug.translate(0, getStartingY()); final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D dim = new Dimension2DDouble(maxX, comp.getPreferredHeight(stringBounder)); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java index d0c7e902c..d9afb7d64 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java @@ -28,11 +28,14 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5249 $ + * Revision $Revision: 5942 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; +import java.util.ArrayList; +import java.util.List; + import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.skin.Component; @@ -50,13 +53,15 @@ public class ParticipantBox implements Pushable { private final Component head; private final Component line; private final Component tail; + private final Component delayLine; private int cpt = CPT++; - public ParticipantBox(Component head, Component line, Component tail, double startingX) { + public ParticipantBox(Component head, Component line, Component tail, Component delayLine, double startingX) { this.startingX = startingX; this.head = head; this.line = line; this.tail = tail; + this.delayLine = delayLine; } @Override @@ -107,11 +112,12 @@ public class ParticipantBox implements Pushable { } if (positionTail > 0) { - // final double y2 = positionTail - topStartingY + line.getPreferredHeight(stringBounder) / 2 - 1; + // final double y2 = positionTail - topStartingY + + // line.getPreferredHeight(stringBounder) / 2 - 1; positionTail += line.getPreferredHeight(stringBounder) / 2 - 1; -// if (y2 != y22) { -// throw new IllegalStateException(); -// } + // if (y2 != y22) { + // throw new IllegalStateException(); + // } ug.translate(startingX + outMargin, positionTail); tail.drawU(ug, new Dimension2DDouble(tail.getPreferredWidth(stringBounder), tail .getPreferredHeight(stringBounder)), new SimpleContext2D(false)); @@ -130,16 +136,33 @@ public class ParticipantBox implements Pushable { public void drawLineU(UGraphic ug, double startingY, double endingY, boolean showTail) { final double atX = ug.getTranslateX(); final double atY = ug.getTranslateY(); - final StringBounder stringBounder = ug.getStringBounder(); - ug.translate(startingX, startingY); - line.drawU(ug, - new Dimension2DDouble(head.getPreferredWidth(stringBounder) + outMargin * 2, endingY - startingY), - new SimpleContext2D(false)); + ug.translate(startingX, 0); + if (delays.size() > 0) { + final StringBounder stringBounder = ug.getStringBounder(); + for (GraphicalDelayText delay : delays) { + drawLine(ug, startingY, delay.getStartingY(), line); + drawLine(ug, delay.getStartingY(), delay.getEndingY(stringBounder), delayLine); + startingY = delay.getEndingY(stringBounder); + } + drawLine(ug, delays.get(delays.size() - 1).getEndingY(stringBounder), endingY, line); + } else { + drawLine(ug, startingY, endingY, line); + } ug.setTranslate(atX, atY); } + private void drawLine(UGraphic ug, double startingY, double endingY, Component comp) { + final double atY = ug.getTranslateY(); + ug.translate(0, startingY); + final StringBounder stringBounder = ug.getStringBounder(); + comp.drawU(ug, + new Dimension2DDouble(head.getPreferredWidth(stringBounder) + outMargin * 2, endingY - startingY), + new SimpleContext2D(false)); + ug.setTranslate(ug.getTranslateX(), atY); + } + public double magicMargin(StringBounder stringBounder) { return line.getPreferredHeight(stringBounder) / 2; } @@ -148,4 +171,11 @@ public class ParticipantBox implements Pushable { return startingX; } + private final List delays = new ArrayList(); + + public void addDelay(GraphicalDelayText delay) { + this.delays.add(delay); + + } + } diff --git a/src/net/sourceforge/plantuml/skin/AbstractComponent.java b/src/net/sourceforge/plantuml/skin/AbstractComponent.java index 542d98506..71c296c66 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractComponent.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4168 $ + * Revision $Revision: 5939 $ * */ package net.sourceforge.plantuml.skin; @@ -48,16 +48,16 @@ public abstract class AbstractComponent implements Component { g2d.setStroke(new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, style, 0)); } - final protected void stroke(UGraphic ug, int dash, double thickness) { - ug.getParam().setStroke(new UStroke(dash, thickness)); + final protected void stroke(UGraphic ug, double dashVisible, double dashSpace, double thickness) { + ug.getParam().setStroke(new UStroke(dashVisible, dashSpace, thickness)); } final protected void stroke(Graphics2D g2d, float dash) { stroke(g2d, dash, 1); } - final protected void stroke(UGraphic ug, int dash) { - stroke(ug, dash, 1); + final protected void stroke(UGraphic ug, double dashVisible, double dashSpace) { + stroke(ug, dashVisible, dashSpace, 1); } abstract protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse); diff --git a/src/net/sourceforge/plantuml/skin/ComponentType.java b/src/net/sourceforge/plantuml/skin/ComponentType.java index 95206fd2a..f37582939 100644 --- a/src/net/sourceforge/plantuml/skin/ComponentType.java +++ b/src/net/sourceforge/plantuml/skin/ComponentType.java @@ -51,6 +51,8 @@ public class ComponentType { // static public final ComponentType ALIVE_LINE = new ComponentType("ALIVE_LINE"); + static public final ComponentType DELAY_LINE = new ComponentType("DELAY_LINE"); + static public final ComponentType DELAY_TEXT = new ComponentType("DELAY_TEXT"); static public final ComponentType DESTROY = new ComponentType("DESTROY"); // diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java index 671cf9daf..b1de16ae3 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5355 $ + * Revision $Revision: 5944 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -39,6 +39,7 @@ import java.util.List; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.skin.AbstractTextualComponent; +import net.sourceforge.plantuml.skin.ArrowConfiguration; public abstract class AbstractComponentBlueModernArrow extends AbstractTextualComponent { @@ -47,15 +48,13 @@ public abstract class AbstractComponentBlueModernArrow extends AbstractTextualCo private final int arrowDeltaX2 = 10; private final int arrowDeltaY2 = 5; - private final boolean dotted; - private final boolean full; + private final ArrowConfiguration arrowConfiguration; private final Color foregroundColor; public AbstractComponentBlueModernArrow(Color foregroundColor, Color fontColor, Font font, - List stringsToDisplay, boolean dotted, boolean full) { + List stringsToDisplay, ArrowConfiguration arrowConfiguration) { super(stringsToDisplay, fontColor, font, HorizontalAlignement.LEFT, 17, 17, 2); - this.dotted = dotted; - this.full = full; + this.arrowConfiguration = arrowConfiguration; this.foregroundColor = foregroundColor; } @@ -84,12 +83,8 @@ public abstract class AbstractComponentBlueModernArrow extends AbstractTextualCo return 6; } - final protected boolean isDotted() { - return dotted; - } - - final protected boolean isFull() { - return full; + final protected ArrowConfiguration getArrowConfiguration() { + return arrowConfiguration; } } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java index 4bf36c6ff..f9bc9e931 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5926 $ + * Revision $Revision: 5944 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -68,11 +68,10 @@ public class BlueModern implements Skin { if (type.isArrow()) { if (type.getArrowConfiguration().isSelfArrow()) { return new ComponentBlueModernSelfArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, type - .getArrowConfiguration().isDotted(), true); + .getArrowConfiguration()); } return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, type - .getArrowConfiguration().isLeftToRightNormal() ? 1 : -1, type.getArrowConfiguration().isDotted(), - type.getArrowConfiguration().isASync()==false); + .getArrowConfiguration()); } if (type == ComponentType.PARTICIPANT_HEAD) { return new ComponentBlueModernParticipant(blue1, blue2, Color.WHITE, participantFont, stringsToDisplay); diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java index f04a1d3f3..0d223c9cc 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4634 $ + * Revision $Revision: 5945 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -40,6 +40,8 @@ import java.awt.geom.Dimension2D; import java.util.List; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.ArrowPart; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -47,15 +49,9 @@ import net.sourceforge.plantuml.ugraphic.UStroke; public class ComponentBlueModernArrow extends AbstractComponentBlueModernArrow { - private final int direction; - public ComponentBlueModernArrow(Color foregroundColor, Color fontColor, Font font, - List stringsToDisplay, int direction, boolean dotted, boolean full) { - super(foregroundColor, fontColor, font, stringsToDisplay, dotted, full); - this.direction = direction; - if (direction != 1 && direction != -1) { - throw new IllegalArgumentException(); - } + List stringsToDisplay, ArrowConfiguration arrowConfiguration) { + super(foregroundColor, fontColor, font, stringsToDisplay, arrowConfiguration); } @Override @@ -68,7 +64,7 @@ public class ComponentBlueModernArrow extends AbstractComponentBlueModernArrow { final int x2 = (int) dimensionToUse.getWidth(); - if (isDotted()) { + if (getArrowConfiguration().isDotted()) { stroke(ug, 5, 2); } else { ug.getParam().setStroke(new UStroke(2)); @@ -80,40 +76,82 @@ public class ComponentBlueModernArrow extends AbstractComponentBlueModernArrow { final int direction = getDirection(); final UPolygon polygon = new UPolygon(); - if (isFull() == false) { + if (getArrowConfiguration().isASync()) { ug.getParam().setStroke(new UStroke(1.5)); if (direction == 1) { - ug.draw(x2 - getArrowDeltaX2(), textHeight - getArrowDeltaY2(), new ULine(getArrowDeltaX2(), - getArrowDeltaY2())); - ug.draw(x2 - getArrowDeltaX2(), textHeight + getArrowDeltaY2(), new ULine(getArrowDeltaX2(), - -getArrowDeltaY2())); + if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { + ug.draw(x2 - getArrowDeltaX2(), textHeight - getArrowDeltaY2(), new ULine(getArrowDeltaX2(), + getArrowDeltaY2())); + } + if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { + ug.draw(x2 - getArrowDeltaX2(), textHeight + getArrowDeltaY2(), new ULine(getArrowDeltaX2(), + -getArrowDeltaY2())); + } } else { - ug.draw(getArrowDeltaX2(), textHeight - getArrowDeltaY2(), new ULine(-getArrowDeltaX2(), - getArrowDeltaY2())); - ug.draw(getArrowDeltaX2(), textHeight + getArrowDeltaY2(), new ULine(-getArrowDeltaX2(), - -getArrowDeltaY2())); + if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { + ug.draw(getArrowDeltaX2(), textHeight - getArrowDeltaY2(), new ULine(-getArrowDeltaX2(), + getArrowDeltaY2())); + } + if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { + ug.draw(getArrowDeltaX2(), textHeight + getArrowDeltaY2(), new ULine(-getArrowDeltaX2(), + -getArrowDeltaY2())); + } } ug.getParam().setStroke(new UStroke()); } else if (direction == 1) { - polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); + createPolygonNormal(textHeight, x2, polygon); } else { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); + createPolygonReverse(textHeight, polygon); } ug.draw(0, 0, polygon); getTextBlock().drawU(ug, getMarginX1(), 0); } + private void createPolygonReverse(final int textHeight, final UPolygon polygon) { + if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight); + } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); + } else { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); + } + } + + private void createPolygonNormal(final int textHeight, final int x2, final UPolygon polygon) { + if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight); + } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); + } else { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); + } + } + protected int getDirection(Graphics2D g2d) { - return direction; + return getDirection(); } protected int getDirection() { - return direction; + if (getArrowConfiguration().isLeftToRightNormal()) { + return 1; + } + if (getArrowConfiguration().isRightToLeftReverse()) { + return -1; + } + throw new IllegalStateException(); } @Override diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java index 1697eed82..d56c634b1 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4634 $ + * Revision $Revision: 5945 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -39,6 +39,8 @@ import java.awt.geom.Dimension2D; import java.util.List; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.ArrowPart; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -49,8 +51,8 @@ public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArr private final double arrowWidth = 45; public ComponentBlueModernSelfArrow(Color foregroundColor, Color colorFont, Font font, - List stringsToDisplay, boolean dotted, boolean full) { - super(foregroundColor, colorFont, font, stringsToDisplay, dotted, full); + List stringsToDisplay, ArrowConfiguration arrowConfiguration) { + super(foregroundColor, colorFont, font, stringsToDisplay, arrowConfiguration); } @Override @@ -62,7 +64,7 @@ public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArr ug.getParam().setColor(getForegroundColor()); final int x2 = (int) arrowWidth; - if (isDotted()) { + if (getArrowConfiguration().isDotted()) { stroke(ug, 5, 2); } else { ug.getParam().setStroke(new UStroke(2)); @@ -79,25 +81,44 @@ public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArr final int delta = (int) getArrowOnlyHeight(stringBounder); - if (isFull()) { - final UPolygon polygon = new UPolygon(); - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); - polygon.addPoint(0, textHeight + delta); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); - ug.draw(0, 0, polygon); - } else { + if (getArrowConfiguration().isASync()) { ug.getParam().setStroke(new UStroke(1.5)); - ug.draw(getArrowDeltaX2(), textHeight - getArrowDeltaY2() + delta, new ULine(-getArrowDeltaX2(), - getArrowDeltaY2())); - ug.draw(getArrowDeltaX2(), textHeight + getArrowDeltaY2() + delta, new ULine(-getArrowDeltaX2(), - -getArrowDeltaY2())); + if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { + ug.draw(getArrowDeltaX2(), textHeight - getArrowDeltaY2() + delta, new ULine(-getArrowDeltaX2(), + getArrowDeltaY2())); + } + if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { + ug.draw(getArrowDeltaX2(), textHeight + getArrowDeltaY2() + delta, new ULine(-getArrowDeltaX2(), + -getArrowDeltaY2())); + } ug.getParam().setStroke(new UStroke()); + } else { + final UPolygon polygon = getPolygon(textHeight, delta); + ug.draw(0, 0, polygon); } getTextBlock().drawU(ug, getMarginX1(), 0); } + private UPolygon getPolygon(final int textHeight, final int delta) { + final UPolygon polygon = new UPolygon(); + if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); + polygon.addPoint(0, textHeight + delta); + polygon.addPoint(getArrowDeltaX(), textHeight + delta); + } else if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); + polygon.addPoint(0, textHeight + delta); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); + } else { + polygon.addPoint(getArrowDeltaX(), textHeight + delta); + polygon.addPoint(0, textHeight + delta); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); + } + return polygon; + } + @Override public double getPreferredHeight(StringBounder stringBounder) { return getTextHeight(stringBounder) + getArrowDeltaY() + getArrowOnlyHeight(stringBounder) + 2 * getPaddingY(); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java index cddea1982..938919bd2 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5926 $ + * Revision $Revision: 5937 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -63,7 +63,7 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { final int x2 = (int) dimensionToUse.getWidth(); if (getArrowConfiguration().isDotted()) { - stroke(ug, 2); + stroke(ug, 2, 2); } // diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java new file mode 100644 index 000000000..4981cbf57 --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java @@ -0,0 +1,73 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 5937 $ + * + */ +package net.sourceforge.plantuml.skin.rose; + +import java.awt.Color; +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.AbstractComponent; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UStroke; + +public class ComponentRoseDelayLine extends AbstractComponent { + + private final Color color; + + public ComponentRoseDelayLine(Color color) { + this.color = color; + } + + @Override + protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { + ug.getParam().setColor(color); + //stroke(ug, 0.4, 2.5); + stroke(ug, 0.2, 1.5); + final int x = (int) (dimensionToUse.getWidth() / 2); + ug.draw(x, 0, new ULine(0, dimensionToUse.getHeight())); + ug.getParam().setStroke(new UStroke()); + } + + @Override + public double getPreferredHeight(StringBounder stringBounder) { + return 20; + } + + @Override + public double getPreferredWidth(StringBounder stringBounder) { + return 1; + } + +} diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java new file mode 100644 index 000000000..4a384f837 --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java @@ -0,0 +1,77 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009, Arnaud Roques + * + * Project Info: http://plantuml.sourceforge.net + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 3837 $ + * + */ +package net.sourceforge.plantuml.skin.rose; + +import java.awt.Color; +import java.awt.Font; +import java.awt.geom.Dimension2D; +import java.util.List; + +import net.sourceforge.plantuml.graphic.HorizontalAlignement; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.skin.AbstractTextualComponent; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +public class ComponentRoseDelayText extends AbstractTextualComponent { + + public ComponentRoseDelayText(Color fontColor, Font font, List stringsToDisplay) { + super(stringsToDisplay, fontColor, font, HorizontalAlignement.CENTER, 4, 4, 4); + } + + @Override + protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { + final TextBlock textBlock = getTextBlock(); + final StringBounder stringBounder = ug.getStringBounder(); + final double textWidth = getTextWidth(stringBounder); + final double textHeight = getTextHeight(stringBounder); + + final double xpos = (dimensionToUse.getWidth() - textWidth) / 2; + final double ypos = (dimensionToUse.getHeight() - textHeight) / 2; + + ug.getParam().setColor(getFontColor()); + textBlock.drawU(ug, xpos, ypos + getMarginY()); + } + + @Override + public double getPreferredHeight(StringBounder stringBounder) { + return getTextHeight(stringBounder) + 20; + } + + @Override + public double getPreferredWidth(StringBounder stringBounder) { + return getTextWidth(stringBounder) + 30; + } + +} diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java index 13646a04a..bbc028a83 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4258 $ + * Revision $Revision: 5937 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -53,7 +53,7 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent { @Override protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { - stroke(ug, 2); + stroke(ug, 2, 2); ug.getParam().setColor(getFontColor()); ug.draw(0, 1, new ULine(dimensionToUse.getWidth(), 0)); ug.getParam().setStroke(new UStroke()); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java index c052531ae..35a76fd0e 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4167 $ + * Revision $Revision: 5937 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -53,7 +53,7 @@ public class ComponentRoseLine extends AbstractComponent { @Override protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { ug.getParam().setColor(color); - stroke(ug, 5); + stroke(ug, 5, 5); final int x = (int) (dimensionToUse.getWidth() / 2); ug.draw(x, 0, new ULine(0, dimensionToUse.getHeight())); ug.getParam().setStroke(new UStroke()); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java index 89303ff1a..efc0b1382 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4167 $ + * Revision $Revision: 5937 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -52,7 +52,7 @@ public class ComponentRoseNewpage extends AbstractComponent { @Override protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { - stroke(ug, 2); + stroke(ug, 2, 2); ug.getParam().setColor(foregroundColor); ug.draw(0, 0, new ULine(dimensionToUse.getWidth(), 0)); ug.getParam().setStroke(new UStroke()); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java index 19384a00c..a7f4d71d9 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5926 $ + * Revision $Revision: 5937 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -65,7 +65,7 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow { final double x2 = arrowWidth; if (getArrowConfiguration().isDotted()) { - stroke(ug, 2); + stroke(ug, 2, 2); } ug.draw(0, textHeight, new ULine(x2, 0)); diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index 741904000..1d18cf4f2 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5922 $ + * Revision $Revision: 5943 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -220,6 +220,15 @@ public class Rose implements Skin { final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor); } + if (type == ComponentType.DELAY_LINE) { + // final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); + final Color borderColor = getFontColor(param, FontParam.SEQUENCE_DELAY); + return new ComponentRoseDelayLine(borderColor); + } + if (type == ComponentType.DELAY_TEXT) { + return new ComponentRoseDelayText(getFontColor(param, FontParam.SEQUENCE_DELAY), param.getFont( + FontParam.SEQUENCE_DELAY, null), stringsToDisplay); + } if (type == ComponentType.DESTROY) { final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); return new ComponentRoseDestroy(borderColor); diff --git a/src/net/sourceforge/plantuml/ugraphic/UStroke.java b/src/net/sourceforge/plantuml/ugraphic/UStroke.java index ccf104dbe..cdc1791ed 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UStroke.java +++ b/src/net/sourceforge/plantuml/ugraphic/UStroke.java @@ -28,31 +28,37 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5289 $ + * Revision $Revision: 5939 $ * */ package net.sourceforge.plantuml.ugraphic; public class UStroke { - private final int dash; + private final double dashVisible; + private final double dashSpace; private final double thickness; - public UStroke(int dash, double thickness) { - this.dash = dash; + public UStroke(double dashVisible, double dashSpace, double thickness) { + this.dashVisible = dashVisible; + this.dashSpace = dashSpace; this.thickness = thickness; } public UStroke(double thickness) { - this(0, thickness); + this(0, 0, thickness); } public UStroke() { this(1.0); } - public int getDash() { - return dash; + public double getDashVisible() { + return dashVisible; + } + + public double getDashSpace() { + return dashSpace; } public double getThickness() { @@ -60,17 +66,17 @@ public class UStroke { } public String getDasharraySvg() { - if (dash == 0) { + if (dashVisible == 0) { return null; } - return "" + dash + "," + dash; + return "" + dashVisible + "," + dashSpace; } public String getDasharrayEps() { - if (dash == 0) { + if (dashVisible == 0) { return null; } - return "" + dash + " " + (2*dash); + return "" + dashVisible + " " + dashSpace; } } diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java index 315d0b908..73905f00b 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5546 $ + * Revision $Revision: 5939 $ * */ package net.sourceforge.plantuml.ugraphic.g2d; @@ -58,11 +58,12 @@ public class DriverLineG2d implements UDriver { static void manageStroke(UParam param, Graphics2D g2d) { final UStroke stroke = param.getStroke(); final float thickness = (float) stroke.getThickness(); - if (stroke.getDash() == 0) { + if (stroke.getDashVisible() == 0) { g2d.setStroke(new BasicStroke(thickness)); } else { - final float dash = (float) stroke.getDash(); - final float[] style = { dash, dash }; + final float dash1 = (float) stroke.getDashVisible(); + final float dash2 = (float) stroke.getDashSpace(); + final float[] style = { dash1, dash2 }; g2d.setStroke(new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, style, 0)); } } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index ebfe1231c..985b54565 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5931 $ + * Revision $Revision: 5955 $ * */ package net.sourceforge.plantuml.version; @@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version; public class Version { public static int version() { - return 5930; + return 5954; } public static long compileTime() { - return 1294686127593L; + return 1294857964687L; } }