summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/sequencediagram
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/sequencediagram')
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java53
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java206
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Delay.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Divider.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Event.java49
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java46
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Grouping.java81
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java117
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java96
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/GroupingType.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/HSpace.java57
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/InGroupable.java47
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java219
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java108
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Message.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/MessageExo.java93
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java64
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Newpage.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Note.java134
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/NotePosition.java39
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java50
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Notes.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Participant.java162
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java59
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java57
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Reference.java103
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java451
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java146
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java284
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java72
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java58
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java162
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java95
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java95
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java92
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java60
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java128
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java64
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java92
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java98
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java85
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java57
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java65
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java126
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java138
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java148
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java186
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java461
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java613
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java47
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java44
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java48
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java43
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java106
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java60
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java44
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java128
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java93
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java79
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java70
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java69
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java81
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java117
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java106
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java99
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java73
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java77
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java242
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java51
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java122
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java190
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java210
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java147
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java160
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java149
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java122
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java116
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java255
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java52
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java125
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java159
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java145
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java315
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java124
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java129
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java151
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java251
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java159
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java59
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java72
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java70
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java149
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java214
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java124
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java125
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java189
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java124
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java126
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java108
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java111
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java186
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java166
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java96
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java121
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java120
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java205
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java101
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java144
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java84
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java148
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java130
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java243
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java114
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java71
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java121
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java155
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java84
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java43
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java42
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java70
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java56
152 files changed, 16503 insertions, 0 deletions
diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java
new file mode 100644
index 0000000..0670a72
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.Url;
+
+public abstract class AbstractEvent implements Event {
+
+ public boolean isParallel() {
+ return false;
+ }
+
+ public Url getUrl() {
+ return null;
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java
new file mode 100644
index 0000000..a601b2f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java
@@ -0,0 +1,206 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public abstract class AbstractMessage implements EventWithDeactivate {
+
+ final private Display label;
+ final private ArrowConfiguration arrowConfiguration;
+
+ final private Set<LifeEventType> lifeEventsType = EnumSet.noneOf(LifeEventType.class);
+
+ private Display notes;
+ private NotePosition notePosition;
+ private HtmlColor noteBackColor;
+ private Url urlNote;
+ private final Url url;
+ private final String messageNumber;
+ private boolean parallel = false;
+
+ public AbstractMessage(Display label, ArrowConfiguration arrowConfiguration, String messageNumber) {
+ this.url = label.initUrl();
+ this.label = label.removeUrl(url);
+ this.arrowConfiguration = arrowConfiguration;
+ this.messageNumber = messageNumber;
+ }
+
+ public void goParallel() {
+ this.parallel = true;
+ }
+
+ public boolean isParallel() {
+ return parallel;
+ }
+
+ final public Url getUrl() {
+ if (url == null) {
+ return urlNote;
+ }
+ return url;
+ }
+
+ public boolean hasUrl() {
+ if (notes != null && notes.hasUrl()) {
+ return true;
+ }
+ if (label != null && label.hasUrl()) {
+ return true;
+ }
+ return getUrl() != null;
+ }
+
+ private boolean firstIsActivate = false;
+ private final Set<Participant> noActivationAuthorized2 = new HashSet<Participant>();
+
+ public final boolean addLifeEvent(LifeEvent lifeEvent) {
+ lifeEvent.setMessage(this);
+ lifeEventsType.add(lifeEvent.getType());
+ if (lifeEventsType.size() == 1 && isActivate()) {
+ firstIsActivate = true;
+ }
+
+ if (lifeEvent.getType() == LifeEventType.ACTIVATE
+ && noActivationAuthorized2.contains(lifeEvent.getParticipant())) {
+ return false;
+ }
+
+ if (lifeEvent.getType() == LifeEventType.DEACTIVATE || lifeEvent.getType() == LifeEventType.DESTROY) {
+ noActivationAuthorized2.add(lifeEvent.getParticipant());
+ }
+
+ return true;
+ }
+
+ public final boolean isCreate() {
+ return lifeEventsType.contains(LifeEventType.CREATE);
+ }
+
+ public boolean isActivate() {
+ return lifeEventsType.contains(LifeEventType.ACTIVATE);
+ }
+
+ public boolean isDeactivate() {
+ return lifeEventsType.contains(LifeEventType.DEACTIVATE);
+ }
+
+ private boolean isDeactivateOrDestroy() {
+ return lifeEventsType.contains(LifeEventType.DEACTIVATE) || lifeEventsType.contains(LifeEventType.DESTROY);
+ }
+
+ public final boolean isActivateAndDeactive() {
+ return firstIsActivate && isDeactivateOrDestroy();
+ }
+
+ public final Display getLabel() {
+ return label;
+ }
+
+ public final ArrowConfiguration getArrowConfiguration() {
+ return arrowConfiguration;
+ }
+
+ public final Display getNote() {
+ return notes == null ? notes : notes;
+ }
+
+ public final Url getUrlNote() {
+ return urlNote;
+ }
+
+ public final void setNote(Display strings, NotePosition notePosition, String backcolor, Url url) {
+ if (notePosition != NotePosition.LEFT && notePosition != NotePosition.RIGHT) {
+ throw new IllegalArgumentException();
+ }
+ this.notes = strings;
+ this.urlNote = url;
+ this.notePosition = overideNotePosition(notePosition);
+ this.noteBackColor = HtmlColorSet.getInstance().getColorIfValid(backcolor);
+ }
+
+ protected NotePosition overideNotePosition(NotePosition notePosition) {
+ return notePosition;
+ }
+
+ private final HtmlColor getSpecificBackColor() {
+ return noteBackColor;
+ }
+
+ public SkinParamBackcolored getSkinParamNoteBackcolored(ISkinParam skinParam) {
+ return new SkinParamBackcolored(skinParam, getSpecificBackColor());
+ }
+
+ public final NotePosition getNotePosition() {
+ return notePosition;
+ }
+
+ public final String getMessageNumber() {
+ return messageNumber;
+ }
+
+ public abstract boolean compatibleForCreate(Participant p);
+
+ public abstract boolean isSelfMessage();
+
+ private double posYendLevel;
+ private double posYstartLevel;
+
+ public double getPosYstartLevel() {
+ return posYstartLevel;
+ }
+
+ public void setPosYstartLevel(double posYstartLevel) {
+ this.posYstartLevel = posYstartLevel;
+ }
+
+ public void setPosYendLevel(double posYendLevel) {
+ this.posYendLevel = posYendLevel;
+ }
+
+ public double getPosYendLevel() {
+ return posYendLevel;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Delay.java b/src/net/sourceforge/plantuml/sequencediagram/Delay.java
new file mode 100644
index 0000000..788fb7d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Delay.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class Delay extends AbstractEvent implements Event {
+
+ private final Display text;
+
+ public Delay(Display text) {
+ this.text = text;
+ }
+
+ public final Display getText() {
+ return text;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Divider.java b/src/net/sourceforge/plantuml/sequencediagram/Divider.java
new file mode 100644
index 0000000..422a41a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Divider.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class Divider extends AbstractEvent implements Event {
+
+ private final Display text;
+
+ public Divider(Display text) {
+ this.text = text;
+ }
+
+ public final Display getText() {
+ return text;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Event.java b/src/net/sourceforge/plantuml/sequencediagram/Event.java
new file mode 100644
index 0000000..c128bbc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Event.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.Url;
+
+public interface Event {
+
+ boolean dealWith(Participant someone);
+
+ Url getUrl();
+
+ boolean hasUrl();
+
+ boolean isParallel();
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java b/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java
new file mode 100644
index 0000000..7d55aa0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public interface EventWithDeactivate extends Event {
+
+ public void setPosYendLevel(double posYendLevel);
+
+ public double getPosYendLevel();
+
+ public boolean addLifeEvent(LifeEvent lifeEvent);
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Grouping.java b/src/net/sourceforge/plantuml/sequencediagram/Grouping.java
new file mode 100644
index 0000000..21ae2a5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Grouping.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public abstract class Grouping implements Event {
+
+ private final String title;
+ private final GroupingType type;
+ private final String comment;
+ private final HtmlColor backColorElement;
+
+ public Grouping(String title, String comment, GroupingType type,
+ HtmlColor backColorElement) {
+ this.title = title;
+ this.comment = comment;
+ this.type = type;
+ this.backColorElement = backColorElement;
+ }
+
+ @Override
+ public final String toString() {
+ return super.toString() + " " + type + " " + title;
+ }
+
+ final public String getTitle() {
+ return title;
+ }
+
+ final public GroupingType getType() {
+ return type;
+ }
+
+ public abstract int getLevel();
+
+ public abstract HtmlColor getBackColorGeneral();
+
+ final public String getComment() {
+ return comment;
+ }
+
+ public final HtmlColor getBackColorElement() {
+ return backColorElement;
+ }
+
+ public abstract boolean isParallel();
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java
new file mode 100644
index 0000000..9841962
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+final public class GroupingLeaf extends Grouping implements EventWithDeactivate {
+
+ private final GroupingStart start;
+ private final HtmlColor backColorGeneral;
+
+ public GroupingLeaf(String title, String comment, GroupingType type, HtmlColor backColorGeneral,
+ HtmlColor backColorElement, GroupingStart start) {
+ super(title, comment, type, backColorElement);
+ if (start == null) {
+ throw new IllegalArgumentException();
+ }
+ this.backColorGeneral = backColorGeneral;
+ this.start = start;
+ start.addChildren(this);
+ }
+
+ public Grouping getJustAfter() {
+ final int idx = start.getChildren().indexOf(this);
+ if (idx == -1) {
+ throw new IllegalStateException();
+ }
+ if (idx + 1 >= start.getChildren().size()) {
+ return null;
+ }
+ return start.getChildren().get(idx + 1);
+ }
+
+ public GroupingStart getGroupingStart() {
+ return start;
+ }
+
+ @Override
+ public int getLevel() {
+ return start.getLevel();
+ }
+
+ @Override
+ public final HtmlColor getBackColorGeneral() {
+ if (backColorGeneral == null) {
+ return start.getBackColorGeneral();
+ }
+ return backColorGeneral;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+ public Url getUrl() {
+ return null;
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+ @Override
+ public boolean isParallel() {
+ return start.isParallel();
+ }
+
+ private double posYendLevel;
+
+ public void setPosYendLevel(double posYendLevel) {
+ this.posYendLevel = posYendLevel;
+ }
+
+ public double getPosYendLevel() {
+ return posYendLevel;
+ }
+
+ public boolean addLifeEvent(LifeEvent lifeEvent) {
+ lifeEvent.setLinkedToGroupingEnd(true);
+ return true;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java
new file mode 100644
index 0000000..6b0e8df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class GroupingStart extends Grouping {
+
+ private final List<GroupingLeaf> children = new ArrayList<GroupingLeaf>();
+ private final HtmlColor backColorGeneral;
+
+ final private GroupingStart parent;
+
+ public GroupingStart(String title, String comment, HtmlColor backColorGeneral, HtmlColor backColorElement,
+ GroupingStart parent) {
+ super(title, comment, GroupingType.START, backColorElement);
+ this.backColorGeneral = backColorGeneral;
+ this.parent = parent;
+ }
+
+ List<GroupingLeaf> getChildren() {
+ return Collections.unmodifiableList(children);
+ }
+
+ public void addChildren(GroupingLeaf g) {
+ children.add(g);
+ }
+
+ public int getLevel() {
+ if (parent == null) {
+ return 0;
+ }
+ return parent.getLevel() + 1;
+ }
+
+ @Override
+ public HtmlColor getBackColorGeneral() {
+ return backColorGeneral;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+ public Url getUrl() {
+ return null;
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+
+ @Override
+ public boolean isParallel() {
+ return getTitle().equals("par2");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingType.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingType.java
new file mode 100644
index 0000000..7f8fe63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingType.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum GroupingType {
+ START, ELSE, END;
+ public static GroupingType getType(String s) {
+ if (s.equalsIgnoreCase("opt")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("alt")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("loop")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("par")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("par2")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("break")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("group")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("critical")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("also")) {
+ return GroupingType.ELSE;
+ } else if (s.equalsIgnoreCase("else")) {
+ return GroupingType.ELSE;
+ } else if (s.equalsIgnoreCase("end")) {
+ return GroupingType.END;
+ }
+
+ throw new IllegalArgumentException();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/HSpace.java b/src/net/sourceforge/plantuml/sequencediagram/HSpace.java
new file mode 100644
index 0000000..f7d3a7e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/HSpace.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public class HSpace extends AbstractEvent implements Event {
+
+ private final int pixel;
+
+ public HSpace() {
+ this(25);
+ }
+
+ public HSpace(int pixel) {
+ this.pixel = pixel;
+ }
+
+ public int getPixel() {
+ return pixel;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/InGroupable.java b/src/net/sourceforge/plantuml/sequencediagram/InGroupable.java
new file mode 100644
index 0000000..080189f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/InGroupable.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface InGroupable {
+
+ public double getMinX(StringBounder stringBounder);
+
+ public double getMaxX(StringBounder stringBounder);
+
+ public String toString(StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java b/src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java
new file mode 100644
index 0000000..57c9b2d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java
@@ -0,0 +1,219 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.graphic.GroupingGraphicalElementElse;
+import net.sourceforge.plantuml.sequencediagram.graphic.LivingParticipantBox;
+import net.sourceforge.plantuml.sequencediagram.graphic.MessageExoArrow;
+import net.sourceforge.plantuml.sequencediagram.graphic.ParticipantBox;
+
+public class InGroupableList implements InGroupable {
+
+ private static final int MARGIN5 = 5;
+ public static final int MARGIN10 = 10;
+
+ private final Grouping grouping;
+ private final Set<InGroupable> inGroupables = new HashSet<InGroupable>();
+
+ private double minWidth;
+
+ public List<InGroupableList> getInnerList() {
+ final List<InGroupableList> result = new ArrayList<InGroupableList>();
+ for (InGroupable i : inGroupables) {
+ if (i instanceof InGroupableList) {
+ result.add((InGroupableList) i);
+ }
+ }
+ return result;
+ }
+
+ private final ParticipantBox veryfirst;
+
+ public InGroupableList(ParticipantBox veryfirst, Grouping grouping, double startingY) {
+ this.grouping = grouping;
+ this.veryfirst = veryfirst;
+ }
+
+ public void addInGroupable(InGroupable in) {
+ // Thread.dumpStack();
+ this.inGroupables.add(in);
+ cacheMin = null;
+ cacheMax = null;
+ }
+
+ public boolean isEmpty() {
+ return inGroupables.isEmpty();
+ }
+
+ @Override
+ public String toString() {
+ return "GS " + grouping + " " + inGroupables.toString();
+ }
+
+ public String toString(StringBounder stringBounder) {
+ final StringBuilder sb = new StringBuilder("GS " + grouping + " ");
+ for (InGroupable in : inGroupables) {
+ sb.append(in.toString(stringBounder));
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ private InGroupable getMinSlow(StringBounder stringBounder) {
+ InGroupable result = null;
+ for (InGroupable in : inGroupables) {
+ if (in instanceof GroupingGraphicalElementElse) {
+ continue;
+ }
+ if (result == null || in.getMinX(stringBounder) < result.getMinX(stringBounder)) {
+ result = in;
+ }
+ }
+ return result;
+ }
+
+ private InGroupable getMaxSlow(StringBounder stringBounder) {
+ InGroupable result = null;
+ for (InGroupable in : inGroupables) {
+ if (result == null || in.getMaxX(stringBounder) > result.getMaxX(stringBounder)) {
+ result = in;
+ }
+ }
+ return result;
+ }
+
+ private InGroupable cacheMin = null;
+ private InGroupable cacheMax = null;
+
+ private InGroupable getMin(StringBounder stringBounder) {
+ if (cacheMin == null) {
+ cacheMin = getMinSlow(stringBounder);
+ }
+ // Since // MODIF42 // the assert does not work...
+ // System.err.println("cacheMin1="+cacheMin+" cacheMin2="+getMinSlow(stringBounder));
+ assert cacheMin == getMinSlow(stringBounder);
+ return cacheMin;
+ }
+
+ private InGroupable getMax(StringBounder stringBounder) {
+ if (cacheMax == null) {
+ cacheMax = getMaxSlow(stringBounder);
+ }
+ assert cacheMax == getMaxSlow(stringBounder);
+ return cacheMax;
+ }
+
+ public void setMinWidth(double minWidth) {
+ this.minWidth = minWidth;
+ }
+
+ public ParticipantBox getFirstParticipantBox() {
+ ParticipantBox first = null;
+ for (InGroupable in : inGroupables) {
+ if (in instanceof LivingParticipantBox) {
+ final ParticipantBox participantBox = ((LivingParticipantBox) in).getParticipantBox();
+ if (first == null || participantBox.getStartingX() < first.getStartingX()) {
+ first = participantBox;
+ }
+ }
+ }
+ return first;
+ }
+
+ public ParticipantBox getLastParticipantBox() {
+ ParticipantBox last = null;
+ for (InGroupable in : inGroupables) {
+ if (in instanceof LivingParticipantBox) {
+ final ParticipantBox participantBox = ((LivingParticipantBox) in).getParticipantBox();
+ if (last == null || participantBox.getStartingX() > last.getStartingX()) {
+ last = participantBox;
+ }
+ }
+ }
+ return last;
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ final InGroupable min = getMin(stringBounder);
+ if (min == null) {
+ return MARGIN10 + MARGIN5 + (veryfirst == null ? 0 : veryfirst.getStartingX());
+ // return MARGIN10 + MARGIN5;
+ }
+ double m = min.getMinX(stringBounder);
+ if (min instanceof MessageExoArrow
+ && (((MessageExoArrow) min).getType() == MessageExoType.FROM_LEFT || ((MessageExoArrow) min).getType() == MessageExoType.TO_LEFT)) {
+ m += 3;
+ } else if (min instanceof InGroupableList) {
+ m -= MARGIN10;
+ } else {
+ m -= MARGIN5;
+ }
+ return m;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ final double min = getMinX(stringBounder);
+ final double max = getMaxXInternal(stringBounder);
+ assert max - min >= 0;
+ if (max - min < minWidth) {
+ return min + minWidth;
+ }
+ return max;
+ }
+
+ private final double getMaxXInternal(StringBounder stringBounder) {
+ final InGroupable max = getMax(stringBounder);
+ if (max == null) {
+ return MARGIN10 + MARGIN5 + minWidth;
+ }
+ double m = max.getMaxX(stringBounder);
+ if (max instanceof MessageExoArrow
+ && (((MessageExoArrow) max).getType() == MessageExoType.FROM_RIGHT || ((MessageExoArrow) max).getType() == MessageExoType.TO_RIGHT)) {
+ m -= 3;
+ } else if (max instanceof InGroupableList) {
+ m += MARGIN10;
+ } else {
+ m += MARGIN5;
+ }
+ return m;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java b/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java
new file mode 100644
index 0000000..a719f5a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class LifeEvent extends AbstractEvent implements Event {
+
+ private final Participant p;
+ private final LifeEventType type;
+ private final HtmlColor backcolor;
+
+ public LifeEvent(Participant p, LifeEventType type, HtmlColor backcolor) {
+ this.p = p;
+ this.type = type;
+ this.backcolor = backcolor;
+ }
+
+ @Override
+ public String toString() {
+ return "LifeEvent:" + p + " " + type;
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+ public LifeEventType getType() {
+ return type;
+ }
+
+ public HtmlColor getSpecificBackColor() {
+ return backcolor;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return this.p == someone;
+ }
+
+ public boolean isActivate() {
+ return type == LifeEventType.ACTIVATE;
+ }
+
+ public boolean isDeactivateOrDestroy() {
+ return type == LifeEventType.DEACTIVATE || type == LifeEventType.DESTROY;
+ }
+
+ public boolean isDestroy() {
+ return type == LifeEventType.DESTROY;
+ }
+
+ // public double getStrangePos() {
+ // return message.getPosYendLevel();
+ // }
+ //
+ private AbstractMessage message;
+
+ public void setMessage(AbstractMessage message) {
+ this.message = message;
+ }
+
+ public AbstractMessage getMessage() {
+ return message;
+ }
+
+ // private boolean linkedToGroupingEnd;
+ //
+ // // public boolean isLinkedToGroupingEnd() {
+ // // return linkedToGroupingEnd;
+ // // }
+
+ public void setLinkedToGroupingEnd(boolean linkedToGroupingEnd) {
+ // this.linkedToGroupingEnd = linkedToGroupingEnd;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java b/src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java
new file mode 100644
index 0000000..e606589
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum LifeEventType {
+ ACTIVATE, DEACTIVATE, DESTROY, CREATE
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Message.java b/src/net/sourceforge/plantuml/sequencediagram/Message.java
new file mode 100644
index 0000000..69c7bb7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Message.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public final class Message extends AbstractMessage {
+
+ final private Participant p1;
+ final private Participant p2;
+
+ public Message(Participant p1, Participant p2, Display label, ArrowConfiguration arrowConfiguration,
+ String messageNumber) {
+ super(label, arrowConfiguration, messageNumber);
+ this.p1 = p1;
+ this.p2 = p2;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + p1 + "->" + p2 + " " + getLabel();
+ }
+
+ public Participant getParticipant1() {
+ return p1;
+ }
+
+ public Participant getParticipant2() {
+ return p2;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return someone == p1 || someone == p2;
+ }
+
+ @Override
+ public boolean compatibleForCreate(Participant p) {
+ return p1 != p && p2 == p;
+ }
+
+ public boolean isSelfMessage() {
+ return p1 == p2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java
new file mode 100644
index 0000000..a950c75
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public class MessageExo extends AbstractMessage {
+
+ final private MessageExoType type;
+ final private Participant participant;
+ final private boolean shortArrow;
+
+ public MessageExo(Participant p, MessageExoType type, Display label, ArrowConfiguration arrowConfiguration,
+ String messageNumber, boolean shortArrow) {
+ super(label, arrowConfiguration, messageNumber);
+ this.participant = p;
+ this.type = type;
+ this.shortArrow = shortArrow;
+ }
+
+ public boolean isShortArrow() {
+ return shortArrow;
+ }
+
+
+ @Override
+ protected NotePosition overideNotePosition(NotePosition notePosition) {
+ if (type == MessageExoType.FROM_LEFT || type == MessageExoType.TO_LEFT) {
+ return NotePosition.RIGHT;
+ }
+ if (type == MessageExoType.FROM_RIGHT || type == MessageExoType.TO_RIGHT) {
+ return NotePosition.LEFT;
+ }
+ throw new IllegalStateException();
+ }
+
+ public Participant getParticipant() {
+ return participant;
+ }
+
+ public final MessageExoType getType() {
+ return type;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return participant == someone;
+ }
+
+ @Override
+ public boolean compatibleForCreate(Participant p) {
+ return p == participant;
+ }
+
+ public boolean isSelfMessage() {
+ return false;
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java
new file mode 100644
index 0000000..498aaef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum MessageExoType {
+ FROM_LEFT, TO_LEFT, FROM_RIGHT, TO_RIGHT;
+
+ public int getDirection() {
+ if (this == MessageExoType.FROM_LEFT) {
+ return 1;
+ }
+ if (this == MessageExoType.TO_LEFT) {
+ return -1;
+ }
+ if (this == MessageExoType.TO_RIGHT) {
+ return 1;
+ }
+ if (this == MessageExoType.FROM_RIGHT) {
+ return -1;
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isLeftBorder() {
+ return this == MessageExoType.FROM_LEFT || this == MessageExoType.TO_LEFT;
+ }
+
+ public boolean isRightBorder() {
+ return this == MessageExoType.FROM_RIGHT || this == MessageExoType.TO_RIGHT;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java b/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java
new file mode 100644
index 0000000..bc7f460
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public class MessageNumber implements CharSequence {
+
+ private final String representation;
+
+ @Override
+ public String toString() {
+ return representation;
+ }
+
+ public MessageNumber(String s) {
+ this.representation = s;
+ }
+
+ public String getNumber() {
+ return representation;
+ }
+
+ public char charAt(int arg0) {
+ return representation.charAt(arg0);
+ }
+
+ public int length() {
+ return representation.length();
+ }
+
+ public CharSequence subSequence(int arg0, int arg1) {
+ return representation.subSequence(arg0, arg1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Newpage.java b/src/net/sourceforge/plantuml/sequencediagram/Newpage.java
new file mode 100644
index 0000000..e3760e5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Newpage.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class Newpage extends AbstractEvent implements Event {
+
+ private final Display title;
+
+ public Newpage(Display strings) {
+ this.title = strings;
+ }
+
+ public final Display getTitle() {
+ return title;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Note.java b/src/net/sourceforge/plantuml/sequencediagram/Note.java
new file mode 100644
index 0000000..ccad6ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Note.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SpecificBackcolorable;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Note extends AbstractEvent implements Event, SpecificBackcolorable {
+
+ private final Participant p;
+ private final Participant p2;
+
+ private final Display strings;
+
+ private final NotePosition position;
+ private NoteStyle style = NoteStyle.NORMAL;
+
+ private final Url url;
+
+ public Note(Participant p, NotePosition position, Display strings) {
+ this(p, null, position, strings);
+ }
+
+ public Note(Participant p, Participant p2, Display strings) {
+ this(p, p2, NotePosition.OVER_SEVERAL, strings);
+ }
+
+ private Note(Participant p, Participant p2, NotePosition position, Display strings) {
+ this.p = p;
+ this.p2 = p2;
+ this.position = position;
+ if (strings != null && strings.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.STRICT);
+ this.url = urlBuilder.getUrl(strings.get(0).toString());
+ } else {
+ this.url = null;
+ }
+
+ if (this.url == null) {
+ this.strings = strings;
+ } else {
+ this.strings = strings.subList(1, strings.size());
+ }
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+ public Participant getParticipant2() {
+ return p2;
+ }
+
+ public Display getStrings() {
+ return strings;
+ }
+
+ public NotePosition getPosition() {
+ return position;
+ }
+
+ private HtmlColor specificBackcolor;
+
+ public HtmlColor getSpecificBackColor() {
+ return specificBackcolor;
+ }
+
+ public void setSpecificBackcolor(HtmlColor color) {
+ this.specificBackcolor = color;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return p == someone || p2 == someone;
+ }
+
+ public Url getUrl() {
+ return url;
+ }
+
+ public boolean hasUrl() {
+ return url != null;
+ }
+
+ public final NoteStyle getStyle() {
+ return style;
+ }
+
+ public final void setStyle(NoteStyle style) {
+ this.style = style;
+ }
+
+ public SkinParamBackcolored getSkinParamBackcolored(ISkinParam skinParam) {
+ return new SkinParamBackcolored(skinParam, getSpecificBackColor());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/NotePosition.java b/src/net/sourceforge/plantuml/sequencediagram/NotePosition.java
new file mode 100644
index 0000000..549f8d5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/NotePosition.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum NotePosition {
+ LEFT, RIGHT, OVER, OVER_SEVERAL
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java
new file mode 100644
index 0000000..1201068
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum NoteStyle {
+
+ NORMAL, HEXAGONAL, BOX;
+
+ public static NoteStyle getNoteStyle(String s) {
+ if (s.equalsIgnoreCase("hnote")) {
+ return NoteStyle.HEXAGONAL;
+ } else if (s.equalsIgnoreCase("rnote")) {
+ return NoteStyle.BOX;
+ }
+ return NoteStyle.NORMAL;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Notes.java b/src/net/sourceforge/plantuml/sequencediagram/Notes.java
new file mode 100644
index 0000000..51d26a0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Notes.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class Notes extends AbstractEvent implements Event, Iterable<Note> {
+
+ private final List<Note> notes = new ArrayList<Note>();
+
+ public Notes(Note n1, Note n2) {
+ notes.add(n1);
+ notes.add(n2);
+ }
+
+ public void add(Note n) {
+ notes.add(n);
+ }
+
+ public boolean dealWith(Participant someone) {
+ for (Note n : notes) {
+ if (n.dealWith(someone)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Iterator<Note> iterator() {
+ return notes.iterator();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Participant.java b/src/net/sourceforge/plantuml/sequencediagram/Participant.java
new file mode 100644
index 0000000..f514763
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Participant.java
@@ -0,0 +1,162 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SpecificBackcolorable;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Participant implements SpecificBackcolorable {
+
+ private final String code;
+ private Display display;
+ private final ParticipantType type;
+
+ private int initialLife = 0;
+
+ private Stereotype stereotype;
+
+ public Participant(ParticipantType type, String code, Display display) {
+ if (type == null) {
+ throw new IllegalArgumentException();
+ }
+ if (code == null || code.length() == 0) {
+ throw new IllegalArgumentException();
+ }
+ if (display == null || display.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.code = code;
+ this.type = type;
+ this.display = display;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ @Override
+ public String toString() {
+ return getCode();
+ }
+
+ public Display getDisplay(boolean underlined) {
+ if (underlined) {
+ return display.underlined();
+ }
+ return display;
+ }
+
+ public ParticipantType getType() {
+ return type;
+ }
+
+ public final void setStereotype(Stereotype stereotype, boolean stereotypePositionTop) {
+ // if (type == ParticipantType.ACTOR) {
+ // return;
+ // }
+ if (this.stereotype != null) {
+ throw new IllegalStateException();
+ }
+ if (stereotype == null) {
+ throw new IllegalArgumentException();
+ }
+ this.stereotype = stereotype;
+ if (stereotypePositionTop) {
+ display = display.addFirst(stereotype);
+ } else {
+ display = display.add(stereotype);
+ }
+ }
+
+ public final int getInitialLife() {
+ return initialLife;
+ }
+
+ private HtmlColor liveBackcolor;
+
+ public final void incInitialLife(HtmlColor backcolor) {
+ initialLife++;
+ this.liveBackcolor = backcolor;
+ }
+
+ public HtmlColor getLiveSpecificBackColor() {
+ return liveBackcolor;
+ }
+
+ private HtmlColor specificBackcolor;
+
+ public HtmlColor getSpecificBackColor() {
+ return specificBackcolor;
+ }
+
+ public void setSpecificBackcolor(HtmlColor color) {
+ this.specificBackcolor = color;
+ }
+
+ private Url url;
+
+ public final Url getUrl() {
+ return url;
+ }
+
+ public final void setUrl(Url url) {
+ this.url = url;
+ }
+
+ public final Stereotype getStereotype() {
+ return stereotype;
+ }
+
+ public ColorParam getBackgroundColorParam() {
+ return type.getBackgroundColorParam();
+ }
+
+ public SkinParamBackcolored getSkinParamBackcolored(ISkinParam skinParam) {
+ HtmlColor specificBackColor = getSpecificBackColor();
+ final boolean clickable = getUrl() != null;
+ final HtmlColor stereoBackColor = skinParam.getHtmlColor(getBackgroundColorParam(), getStereotype(), clickable);
+ if (stereoBackColor != null && specificBackColor == null) {
+ specificBackColor = stereoBackColor;
+ }
+ return new SkinParamBackcolored(skinParam, specificBackColor, clickable);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java
new file mode 100644
index 0000000..8dfc4ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class ParticipantEnglober {
+
+ final private Display title;
+ final private HtmlColor boxColor;
+
+ public ParticipantEnglober(Display title, HtmlColor boxColor) {
+ this.title = title;
+ this.boxColor = boxColor;
+ }
+
+ public final Display getTitle() {
+ return title;
+ }
+
+ public final HtmlColor getBoxColor() {
+ return boxColor;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java
new file mode 100644
index 0000000..5ab0b33
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ParticipantEngloberContexted {
+
+ final private ParticipantEnglober participantEnglober;
+ final private List<Participant> participants = new ArrayList<Participant>();
+
+ public ParticipantEngloberContexted(ParticipantEnglober participantEnglober, Participant first) {
+ this.participantEnglober = participantEnglober;
+ this.participants.add(first);
+ }
+
+ public final ParticipantEnglober getParticipantEnglober() {
+ return participantEnglober;
+ }
+
+ public boolean contains(Participant p) {
+ return participants.contains(p);
+ }
+
+ public void add(Participant p) {
+ if (participants.contains(p)) {
+ throw new IllegalArgumentException();
+ }
+ participants.add(p);
+ }
+
+ public final Participant getFirst2() {
+ return participants.get(0);
+ }
+
+ public final Participant getLast2() {
+ return participants.get(participants.size() - 1);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString()+" "+participants;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java
new file mode 100644
index 0000000..001adc9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.ColorParam;
+
+public enum ParticipantType {
+ PARTICIPANT(ColorParam.participantBackground), //
+ ACTOR(ColorParam.actorBackground), //
+ BOUNDARY(ColorParam.boundaryBackground), //
+ CONTROL(ColorParam.controlBackground), //
+ ENTITY(ColorParam.entityBackground), //
+ DATABASE(ColorParam.databaseBackground);
+
+ private final ColorParam background;
+
+ private ParticipantType(ColorParam background) {
+ this.background = background;
+ }
+
+ public ColorParam getBackgroundColorParam() {
+ return background;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Reference.java b/src/net/sourceforge/plantuml/sequencediagram/Reference.java
new file mode 100644
index 0000000..b2e027e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Reference.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Reference extends AbstractEvent implements Event {
+
+ private final List<Participant> participants;
+ private final Url url;
+ private final HtmlColor backColorGeneral;
+ private final HtmlColor backColorElement;
+
+ private final Display strings;
+
+ public Reference(List<Participant> participants, Url url, Display strings, HtmlColor backColorGeneral,
+ HtmlColor backColorElement) {
+ this.participants = participants;
+ this.url = url;
+ this.strings = strings;
+ this.backColorGeneral = backColorGeneral;
+ this.backColorElement = backColorElement;
+ }
+
+ public List<Participant> getParticipant() {
+ return Collections.unmodifiableList(participants);
+ }
+
+ public Display getStrings() {
+ return strings;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return participants.contains(someone);
+ }
+
+ public final Url getUrl() {
+ return url;
+ }
+
+ public boolean hasUrl() {
+ return url != null;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ for (final Iterator<Participant> it = participants.iterator(); it.hasNext();) {
+ sb.append(it.next().getCode());
+ if (it.hasNext()) {
+ sb.append("-");
+ }
+
+ }
+ return sb.toString();
+ }
+
+ public final HtmlColor getBackColorGeneral() {
+ return backColorGeneral;
+ }
+
+ public final HtmlColor getBackColorElement() {
+ return backColorElement;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java
new file mode 100644
index 0000000..48d351c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java
@@ -0,0 +1,451 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker;
+import net.sourceforge.plantuml.sequencediagram.graphic.SequenceDiagramFileMakerPuma2;
+import net.sourceforge.plantuml.sequencediagram.graphic.SequenceDiagramTxtMaker;
+import net.sourceforge.plantuml.sequencediagram.teoz.SequenceDiagramFileMakerTeoz;
+import net.sourceforge.plantuml.skin.ProtectedSkin;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.SkinUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+
+public class SequenceDiagram extends UmlDiagram {
+
+ private final Map<String, Participant> participants = new LinkedHashMap<String, Participant>();
+
+ private final List<Event> events = new ArrayList<Event>();
+
+ private final Map<Participant, ParticipantEnglober> participantEnglobers2 = new HashMap<Participant, ParticipantEnglober>();
+
+ private Skin skin = new ProtectedSkin(new Rose());
+
+ @Deprecated
+ public Participant getOrCreateParticipant(String code) {
+ return getOrCreateParticipant(code, Display.getWithNewlines(code));
+ }
+
+ public Participant getOrCreateParticipant(String code, Display display) {
+ Participant result = participants.get(code);
+ if (result == null) {
+ result = new Participant(ParticipantType.PARTICIPANT, code, display);
+ participants.put(code, result);
+ participantEnglobers2.put(result, participantEnglober);
+ }
+ return result;
+ }
+
+ private EventWithDeactivate lastEventWithDeactivate;
+
+ public EventWithDeactivate getLastEventWithDeactivate() {
+ return lastEventWithDeactivate;
+ }
+
+ public Participant createNewParticipant(ParticipantType type, String code, Display display) {
+ if (participants.containsKey(code)) {
+ throw new IllegalArgumentException();
+ }
+ if (display == null) {
+ // display = Arrays.asList(code);
+ display = Display.getWithNewlines(code);
+ }
+ final Participant result = new Participant(type, code, display);
+ participants.put(code, result);
+ participantEnglobers2.put(result, participantEnglober);
+ return result;
+ }
+
+ public Map<String, Participant> participants() {
+ return Collections.unmodifiableMap(participants);
+ }
+
+ public String addMessage(AbstractMessage m) {
+ lastEventWithDeactivate = m;
+ lastDelay = null;
+ events.add(m);
+ if (pendingCreate != null) {
+ if (m.compatibleForCreate(pendingCreate.getParticipant()) == false) {
+ return "After create command, you have to send a message to \"" + pendingCreate.getParticipant() + "\"";
+ }
+ m.addLifeEvent(pendingCreate);
+ pendingCreate = null;
+ }
+ return null;
+ }
+
+ public void addNote(Note n, boolean tryMerge) {
+ if (tryMerge && events.size() > 0) {
+ final Event last = events.get(events.size() - 1);
+ if (last instanceof Note) {
+ final Notes notes = new Notes((Note) last, n);
+ events.set(events.size() - 1, notes);
+ return;
+ }
+ if (last instanceof Notes) {
+ ((Notes) last).add(n);
+ return;
+ }
+ }
+ events.add(n);
+ }
+
+ public void newpage(Display strings) {
+ if (ignoreNewpage) {
+ return;
+ }
+ events.add(new Newpage(strings));
+ }
+
+ private boolean ignoreNewpage = false;
+
+ public void ignoreNewpage() {
+ this.ignoreNewpage = true;
+ }
+
+ private int autonewpage = -1;
+
+ public final int getAutonewpage() {
+ return autonewpage;
+ }
+
+ public void setAutonewpage(int autonewpage) {
+ this.autonewpage = autonewpage;
+ }
+
+ public void divider(Display strings) {
+ events.add(new Divider(strings));
+ }
+
+ public void hspace() {
+ events.add(new HSpace());
+ }
+
+ public void hspace(int pixel) {
+ events.add(new HSpace(pixel));
+ }
+
+ private Delay lastDelay;
+
+ public void delay(Display strings) {
+ final Delay delay = new Delay(strings);
+ events.add(delay);
+ lastDelay = delay;
+ }
+
+ public List<Event> events() {
+ return Collections.unmodifiableList(events);
+ }
+
+ private FileMaker getSequenceDiagramPngMaker(FileFormatOption fileFormatOption) {
+
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+
+ if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) {
+ return new SequenceDiagramTxtMaker(this, fileFormat);
+ }
+
+ if (OptionFlags.FORCE_TEOZ || getPragma().useTeozLayout()) {
+ return new SequenceDiagramFileMakerTeoz(this, skin, fileFormatOption);
+ }
+
+ return new SequenceDiagramFileMakerPuma2(this, skin, fileFormatOption);
+ }
+
+ @Override
+ protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormat)
+ throws IOException {
+ final FileMaker sequenceDiagramPngMaker = getSequenceDiagramPngMaker(fileFormat);
+ return sequenceDiagramPngMaker.createOne(os, index, fileFormat.isWithMetadata());
+ }
+
+ // support for CommandReturn
+ private final Stack<Message> activationState = new Stack<Message>();
+
+ public Message getActivatingMessage() {
+ if (activationState.empty()) {
+ return null;
+ }
+ return activationState.peek();
+ }
+
+ private LifeEvent pendingCreate = null;
+
+ public String activate(Participant p, LifeEventType lifeEventType, HtmlColor backcolor) {
+ if (lastDelay != null) {
+ return "You cannot Activate/Deactivate just after a ...";
+ }
+ final LifeEvent lifeEvent = new LifeEvent(p, lifeEventType, backcolor);
+ events.add(lifeEvent);
+ if (lifeEventType == LifeEventType.CREATE) {
+ pendingCreate = lifeEvent;
+ return null;
+ }
+ if (lastEventWithDeactivate == null) {
+ if (lifeEventType == LifeEventType.ACTIVATE) {
+ p.incInitialLife(backcolor);
+ return null;
+ }
+ return "Only activate command can occur before message are send";
+ }
+ if (lifeEventType == LifeEventType.ACTIVATE && lastEventWithDeactivate instanceof Message) {
+ activationState.push((Message) lastEventWithDeactivate);
+ } else if (lifeEventType == LifeEventType.DEACTIVATE && activationState.empty() == false) {
+ activationState.pop();
+ }
+ final boolean ok = lastEventWithDeactivate.addLifeEvent(lifeEvent);
+ if (lastEventWithDeactivate instanceof AbstractMessage) {
+ lifeEvent.setMessage((AbstractMessage) lastEventWithDeactivate);
+ }
+ if (ok) {
+ return null;
+ }
+ return "Activate/Deactivate already done on " + p.getCode();
+ }
+
+ private final List<GroupingStart> openGroupings = new ArrayList<GroupingStart>();
+
+ public boolean grouping(String title, String comment, GroupingType type, HtmlColor backColorGeneral,
+ HtmlColor backColorElement) {
+ if (type != GroupingType.START && openGroupings.size() == 0) {
+ return false;
+ }
+
+ final GroupingStart top = openGroupings.size() > 0 ? openGroupings.get(0) : null;
+
+ final Grouping g = type == GroupingType.START ? new GroupingStart(title, comment, backColorGeneral,
+ backColorElement, top)
+ : new GroupingLeaf(title, comment, type, backColorGeneral, backColorElement, top);
+ events.add(g);
+
+ if (type == GroupingType.START) {
+ openGroupings.add(0, (GroupingStart) g);
+ } else if (type == GroupingType.END) {
+ openGroupings.remove(0);
+ lastEventWithDeactivate = (GroupingLeaf) g;
+ }
+
+ return true;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(" + participants.size() + " participants)", getClass());
+ }
+
+ public boolean changeSkin(String className) {
+ final Skin s = SkinUtils.loadSkin(className);
+ final Integer expected = new Integer(1);
+ if (s != null && expected.equals(s.getProtocolVersion())) {
+ this.skin = new ProtectedSkin(s);
+ return true;
+ }
+ return false;
+ }
+
+ public Skin getSkin() {
+ return skin;
+ }
+
+ private Integer messageNumber = null;
+ private int incrementMessageNumber;
+
+ private DecimalFormat decimalFormat;
+
+ public final void goAutonumber(int startingNumber, int increment, DecimalFormat decimalFormat) {
+ this.messageNumber = startingNumber;
+ this.incrementMessageNumber = increment;
+ this.decimalFormat = decimalFormat;
+ }
+
+ public String getNextMessageNumber() {
+ if (messageNumber == null) {
+ return null;
+ }
+ final Integer result = messageNumber;
+ messageNumber += incrementMessageNumber;
+ return decimalFormat.format(result);
+ }
+
+ public boolean isShowFootbox() {
+ if (getSkinParam().strictUmlStyle()) {
+ return false;
+ }
+ final String footbox = getSkinParam().getValue("footbox");
+ if (footbox == null) {
+ return showFootbox;
+ }
+ if (footbox.equalsIgnoreCase("hide")) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean showFootbox = true;
+
+ public void setShowFootbox(boolean footbox) {
+ this.showFootbox = footbox;
+
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.SEQUENCE;
+ }
+
+ private ParticipantEnglober participantEnglober;
+
+ public void boxStart(Display comment, HtmlColor color) {
+ if (participantEnglober != null) {
+ throw new IllegalStateException();
+ }
+ this.participantEnglober = new ParticipantEnglober(comment, color);
+ }
+
+ public void endBox() {
+ if (participantEnglober == null) {
+ throw new IllegalStateException();
+ }
+ this.participantEnglober = null;
+ }
+
+ public boolean isBoxPending() {
+ return participantEnglober != null;
+ }
+
+ @Override
+ public int getNbImages() {
+ return getSequenceDiagramPngMaker(new FileFormatOption(FileFormat.PNG)).getNbPages();
+ }
+
+ public void removeHiddenParticipants() {
+ for (Participant p : new ArrayList<Participant>(participants.values())) {
+ if (isAlone(p)) {
+ remove(p);
+ }
+ }
+ }
+
+ private void remove(Participant p) {
+ final boolean ok = participants.values().remove(p);
+ if (ok == false) {
+ throw new IllegalArgumentException();
+ }
+ participantEnglobers2.remove(p);
+ }
+
+ private boolean isAlone(Participant p) {
+ for (Event ev : events) {
+ if (ev.dealWith(p)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void putParticipantInLast(String code) {
+ final Participant p = participants.get(code);
+ if (p == null) {
+ throw new IllegalArgumentException(code);
+ }
+ participants.remove(code);
+ participants.put(code, p);
+ participantEnglobers2.put(p, participantEnglober);
+ }
+
+ public ParticipantEnglober getEnglober(Participant p) {
+ return participantEnglobers2.get(p);
+ }
+
+ private boolean autoactivate;
+
+ public final void setAutoactivate(boolean autoactivate) {
+ this.autoactivate = autoactivate;
+ }
+
+ public final boolean isAutoactivate() {
+ return autoactivate;
+ }
+
+ public boolean hasUrl() {
+ for (Participant p : participants.values()) {
+ if (p.getUrl() != null) {
+ return true;
+ }
+ }
+ for (Event ev : events) {
+ if (ev.hasUrl()) {
+ return true;
+ }
+ }
+ if (getLegend() != null && getLegend().hasUrl()) {
+ return true;
+ }
+ return false;
+ }
+
+ public void addReference(Reference ref) {
+ events.add(ref);
+ }
+
+ @Override
+ public boolean isOk() {
+ if (participants.size() == 0) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java
new file mode 100644
index 0000000..2fdc66b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java
@@ -0,0 +1,146 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteCommand;
+import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteOnArrowCommand;
+import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteOverSeveralCommand;
+import net.sourceforge.plantuml.sequencediagram.command.CommandActivate;
+import net.sourceforge.plantuml.sequencediagram.command.CommandActivate2;
+import net.sourceforge.plantuml.sequencediagram.command.CommandArrow;
+import net.sourceforge.plantuml.sequencediagram.command.CommandAutoNewpage;
+import net.sourceforge.plantuml.sequencediagram.command.CommandAutoactivate;
+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;
+import net.sourceforge.plantuml.sequencediagram.command.CommandFootbox;
+import net.sourceforge.plantuml.sequencediagram.command.CommandFootboxOld;
+import net.sourceforge.plantuml.sequencediagram.command.CommandGrouping;
+import net.sourceforge.plantuml.sequencediagram.command.CommandHSpace;
+import net.sourceforge.plantuml.sequencediagram.command.CommandIgnoreNewpage;
+import net.sourceforge.plantuml.sequencediagram.command.CommandNewpage;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA2;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA3;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA4;
+import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceMultilinesOverSeveral;
+import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceOverSeveral;
+import net.sourceforge.plantuml.sequencediagram.command.CommandReturn;
+import net.sourceforge.plantuml.sequencediagram.command.CommandSkin;
+import net.sourceforge.plantuml.sequencediagram.command.CommandUrl;
+
+public class SequenceDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ public SequenceDiagram createEmptyDiagram() {
+ return new SequenceDiagram();
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+
+ final List<Command> cmds = new ArrayList<Command>();
+
+ addCommonCommands(cmds);
+
+ cmds.add(new CommandActivate());
+
+ cmds.add(new CommandParticipantA());
+ cmds.add(new CommandParticipantA2());
+ cmds.add(new CommandParticipantA3());
+ cmds.add(new CommandParticipantA4());
+ cmds.add(new CommandArrow());
+ // addCommand(new CommandArrowCrossX());
+ cmds.add(new CommandExoArrowLeft());
+ cmds.add(new CommandExoArrowRight());
+
+ final FactorySequenceNoteCommand factorySequenceNoteCommand = new FactorySequenceNoteCommand();
+ cmds.add(factorySequenceNoteCommand.createSingleLine());
+
+ final FactorySequenceNoteOverSeveralCommand factorySequenceNoteOverSeveralCommand = new FactorySequenceNoteOverSeveralCommand();
+ cmds.add(factorySequenceNoteOverSeveralCommand.createSingleLine());
+
+ cmds.add(new CommandBoxStart());
+ cmds.add(new CommandBoxEnd());
+ cmds.add(new CommandGrouping());
+
+ cmds.add(new CommandActivate2());
+ cmds.add(new CommandReturn());
+
+ final FactorySequenceNoteOnArrowCommand factorySequenceNoteOnArrowCommand = new FactorySequenceNoteOnArrowCommand();
+ cmds.add(factorySequenceNoteOnArrowCommand.createSingleLine());
+
+ cmds.add(factorySequenceNoteCommand.createMultiLine());
+ cmds.add(factorySequenceNoteOverSeveralCommand.createMultiLine());
+ cmds.add(factorySequenceNoteOnArrowCommand.createMultiLine());
+
+ cmds.add(new CommandNewpage());
+ cmds.add(new CommandIgnoreNewpage());
+ cmds.add(new CommandAutoNewpage());
+ cmds.add(new CommandDivider());
+ cmds.add(new CommandHSpace());
+ cmds.add(new CommandReferenceOverSeveral());
+ cmds.add(new CommandReferenceMultilinesOverSeveral());
+ cmds.add(new CommandSkin());
+ cmds.add(new CommandAutonumber());
+ cmds.add(new CommandAutoactivate());
+ cmds.add(new CommandFootbox());
+ cmds.add(new CommandDelay());
+ cmds.add(new CommandFootboxOld());
+ cmds.add(new CommandUrl());
+
+ return cmds;
+ }
+
+ @Override
+ public String checkFinalError(AbstractPSystem sys) {
+ final SequenceDiagram system = (SequenceDiagram) sys;
+ if (system.isHideUnlinkedData()) {
+ system.removeHiddenParticipants();
+ }
+ return super.checkFinalError(system);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java
new file mode 100644
index 0000000..3d8b195
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandActivate extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandActivate() {
+ super("(?i)^(activate|deactivate|destroy|create)[%s]+([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*(#\\w+)?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ final LifeEventType type = LifeEventType.valueOf(StringUtils.goUpperCase(arg.get(0)));
+ final Participant p = diagram.getOrCreateParticipant(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(1)));
+ final String error = diagram.activate(p, type,
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(2)));
+ if (error == null) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error(error);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
new file mode 100644
index 0000000..2214319
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandActivate2 extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandActivate2() {
+ super("(?i)^([\\p{L}0-9_.@]+)[%s]*(\\+\\+|--)[%s]*(#\\w+)?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ final LifeEventType type = arg.get(1).equals("++") ? LifeEventType.ACTIVATE : LifeEventType.DEACTIVATE;
+ final Participant p = diagram.getOrCreateParticipant(arg.get(0));
+ final String error = diagram.activate(p, type,
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(2)));
+ if (error == null) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error(error);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java
new file mode 100644
index 0000000..96357fc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java
@@ -0,0 +1,284 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.StringUtils;
+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.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.ArrowPart;
+
+public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandArrow() {
+ super(getRegexConcat());
+ }
+
+ public static String getColorOrStylePattern() {
+ return "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(
+ new RegexLeaf("^"), //
+ new RegexLeaf("PARALLEL", "(&%s*)?"), //
+ new RegexOr("PART1", //
+ new RegexLeaf("PART1CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART1LONG", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("PART1LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART1CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ARROW_DRESSING1", "([%s][ox]|(?:[%s][ox])?<<?|(?:[%s][ox])?//?|(?:[%s][ox])?\\\\\\\\?)?"), //
+ new RegexOr(new RegexConcat( //
+ new RegexLeaf("ARROW_BODYA1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1", getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB1", "(-*)")), //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_BODYA2", "(-*)"), //
+ new RegexLeaf("ARROW_STYLE2", getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB2", "(-+)"))), //
+ new RegexLeaf("ARROW_DRESSING2", "(>>?(?:[ox][%s])?|//?(?:[ox][%s])?|\\\\\\\\?(?:[ox][%s])?|[ox][%s])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr("PART2", //
+ new RegexLeaf("PART2CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART2LONG", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("PART2LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART2CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?$"));
+ }
+
+ private Participant getOrCreateParticipant(SequenceDiagram system, RegexResult arg2, String n) {
+ final String code;
+ final Display display;
+ if (arg2.get(n + "CODE", 0) != null) {
+ code = arg2.get(n + "CODE", 0);
+ display = Display.getWithNewlines(code);
+ } else if (arg2.get(n + "LONG", 0) != null) {
+ code = arg2.get(n + "LONG", 0);
+ display = Display.getWithNewlines(code);
+ } else if (arg2.get(n + "LONGCODE", 0) != null) {
+ display = Display.getWithNewlines(arg2.get(n + "LONGCODE", 0));
+ code = arg2.get(n + "LONGCODE", 1);
+ } else if (arg2.get(n + "CODELONG", 0) != null) {
+ code = arg2.get(n + "CODELONG", 0);
+ display = Display.getWithNewlines(arg2.get(n + "CODELONG", 1));
+ return system.getOrCreateParticipant(code, display);
+ } else {
+ throw new IllegalStateException();
+ }
+ return system.getOrCreateParticipant(code, display);
+ }
+
+ private boolean contains(String string, String... totest) {
+ for (String t : totest) {
+ if (string.contains(t)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+
+ Participant p1;
+ Participant p2;
+
+ final String dressing1 = StringUtils.goLowerCase(CommandLinkClass.notNull(arg.get("ARROW_DRESSING1", 0)));
+ final String dressing2 = StringUtils.goLowerCase(CommandLinkClass.notNull(arg.get("ARROW_DRESSING2", 0)));
+
+ final boolean circleAtStart;
+ final boolean circleAtEnd;
+
+ final boolean hasDressing2 = contains(dressing2, ">", "\\", "/", "x");
+ final boolean hasDressing1 = contains(dressing1, "x", "<", "\\", "/");
+ if (hasDressing2) {
+ p1 = getOrCreateParticipant(diagram, arg, "PART1");
+ p2 = getOrCreateParticipant(diagram, arg, "PART2");
+ circleAtStart = dressing1.contains("o");
+ circleAtEnd = dressing2.contains("o");
+ } else if (hasDressing1) {
+ p2 = getOrCreateParticipant(diagram, arg, "PART1");
+ p1 = getOrCreateParticipant(diagram, arg, "PART2");
+ circleAtStart = dressing2.contains("o");
+ circleAtEnd = dressing1.contains("o");
+ } else {
+ return CommandExecutionResult.error("Illegal sequence arrow");
+
+ }
+
+ final boolean sync = contains(dressing1, "<<", "\\\\", "//") || contains(dressing2, ">>", "\\\\", "//");
+
+ final boolean dotted = getLength(arg) > 1;
+
+ final Display labels;
+ if (arg.get("MESSAGE", 0) == null) {
+ labels = Display.create("");
+ } else {
+ labels = Display.getWithNewlines(arg.get("MESSAGE", 0));
+ }
+
+ ArrowConfiguration config = hasDressing1 && hasDressing2 ? ArrowConfiguration.withDirectionBoth()
+ : ArrowConfiguration.withDirectionNormal();
+ if (dotted) {
+ config = config.withDotted();
+ }
+ if (sync) {
+ config = config.withHead(ArrowHead.ASYNC);
+ }
+ if (dressing2.contains("\\") || dressing1.contains("/")) {
+ config = config.withPart(ArrowPart.TOP_PART);
+ }
+ if (dressing2.contains("/") || dressing1.contains("\\")) {
+ config = config.withPart(ArrowPart.BOTTOM_PART);
+ }
+ if (circleAtEnd) {
+ config = config.withDecoration2(ArrowDecoration.CIRCLE);
+ }
+ if (circleAtStart) {
+ config = config.withDecoration1(ArrowDecoration.CIRCLE);
+ }
+ if (dressing1.contains("x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+
+ }
+ if (dressing2.contains("x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+ }
+
+ config = applyStyle(arg.getLazzy("ARROW_STYLE", 0), config);
+
+ final String activationSpec = arg.get("ACTIVATION", 0);
+
+ if (activationSpec != null && activationSpec.charAt(0) == '*') {
+ diagram.activate(p2, LifeEventType.CREATE, null);
+ }
+
+ final Message msg = new Message(p1, p2, labels, config, diagram.getNextMessageNumber());
+ final boolean parallel = arg.get("PARALLEL", 0) != null;
+ if (parallel) {
+ msg.goParallel();
+ }
+
+ final String error = diagram.addMessage(msg);
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+
+ final HtmlColor activationColor = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("LIFECOLOR", 0));
+
+ if (activationSpec != null) {
+ switch (activationSpec.charAt(0)) {
+ case '+':
+ diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
+ break;
+ case '-':
+ diagram.activate(p1, LifeEventType.DEACTIVATE, null);
+ break;
+ case '!':
+ diagram.activate(p2, LifeEventType.DESTROY, null);
+ break;
+ default:
+ break;
+ }
+ } else if (diagram.isAutoactivate()
+ && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
+ if (config.isDotted()) {
+ diagram.activate(p1, LifeEventType.DEACTIVATE, null);
+ } else {
+ diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
+ }
+
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private int getLength(RegexResult arg2) {
+ String sa = arg2.getLazzy("ARROW_BODYA", 0);
+ if (sa == null) {
+ sa = "";
+ }
+ String sb = arg2.getLazzy("ARROW_BODYB", 0);
+ if (sb == null) {
+ sb = "";
+ }
+ return sa.length() + sb.length();
+ }
+
+ public static ArrowConfiguration applyStyle(String arrowStyle, ArrowConfiguration config) {
+ if (arrowStyle == null) {
+ return config;
+ }
+ final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
+ while (st.hasMoreTokens()) {
+ final String s = st.nextToken();
+ if (s.equalsIgnoreCase("dashed")) {
+ // link.goDashed();
+ } else if (s.equalsIgnoreCase("bold")) {
+ // link.goBold();
+ } else if (s.equalsIgnoreCase("dotted")) {
+ // link.goDotted();
+ } else if (s.equalsIgnoreCase("hidden")) {
+ // link.goHidden();
+ } else {
+ config = config.withColor(HtmlColorSet.getInstance().getColorIfValid(s));
+ }
+ }
+ return config;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java
new file mode 100644
index 0000000..e03dd9b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandAutoNewpage extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandAutoNewpage() {
+ super("(?i)^autonewpage[%s]+(\\d+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ sequenceDiagram.setAutonewpage(Integer.parseInt(arg.get(0)));
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java
new file mode 100644
index 0000000..32d8536
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandAutoactivate extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandAutoactivate() {
+ super("(?i)^autoactivate[%s]+(off|on)*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ sequenceDiagram.setAutoactivate("on".equalsIgnoreCase(arg.get(0)));
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java
new file mode 100644
index 0000000..37f936c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.text.DecimalFormat;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandAutonumber extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandAutonumber() {
+ super("(?i)^autonumber[%s]*(\\d+)?(?:[%s]+(\\d+))?(?:[%s]+[%g]([^%g]+)[%g])?[%s]*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ int start = 1;
+ if (arg.get(0) != null) {
+ start = Integer.parseInt(arg.get(0));
+ }
+ int inc = 1;
+ if (arg.get(1) != null) {
+ inc = Integer.parseInt(arg.get(1));
+ }
+
+ final String df = arg.get(2) == null ? "<b>0</b>" : arg.get(2);
+ final DecimalFormat decimalFormat;
+ try {
+ decimalFormat = new DecimalFormat(df);
+ } catch (IllegalArgumentException e) {
+ return CommandExecutionResult.error("Error in pattern : " + df);
+ }
+
+ sequenceDiagram.goAutonumber(start, inc, decimalFormat);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java
new file mode 100644
index 0000000..8465258
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandBoxEnd extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandBoxEnd() {
+ super("(?i)^end[%s]?box$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ if (sequenceDiagram.isBoxPending() == false) {
+ return CommandExecutionResult.error("Missing starting box");
+ }
+ sequenceDiagram.endBox();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java
new file mode 100644
index 0000000..f899e7c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandBoxStart extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandBoxStart() {
+ super("(?i)^box(?:[%s]+[%g]([^%g]+)[%g])?(?:[%s]+(#\\w+))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ if (diagram.isBoxPending()) {
+ return CommandExecutionResult.error("Box cannot be nested");
+ }
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(1));
+ final String title = arg.get(0) == null ? "" : arg.get(0);
+ diagram.boxStart(Display.getWithNewlines(title), color);
+ return CommandExecutionResult.ok();
+ }
+
+}
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 0000000..d73165e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandDelay extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandDelay() {
+ super("(?i)^(?:\\.{3}|\u2026)(?:(.*)(?:\\.{3}|\u2026))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final Display strings = arg.get(0) == null ? Display.empty() : Display.getWithNewlines(arg.get(0));
+ sequenceDiagram.delay(strings);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java
new file mode 100644
index 0000000..025dab6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandDivider extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandDivider() {
+ super("(?i)^==[%s]*(.*)[%s]*==$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final Display strings = Display.getWithNewlines(arg.get(0));
+ sequenceDiagram.divider(strings);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java
new file mode 100644
index 0000000..3ce2ebe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java
@@ -0,0 +1,162 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+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.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.ArrowPart;
+import net.sourceforge.plantuml.StringUtils;
+
+abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandExoArrowAny(RegexConcat pattern) {
+ super(pattern);
+ }
+
+ @Override
+ final protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, RegexResult arg2) {
+ final String body = arg2.getLazzy("ARROW_BODYA", 0) + arg2.getLazzy("ARROW_BODYB", 0);
+ final String dressing = arg2.getLazzy("ARROW_DRESSING", 0);
+ final Participant p = sequenceDiagram.getOrCreateParticipant(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg2.get("PARTICIPANT", 0)));
+
+ final boolean sync = dressing.length() == 2;
+ final boolean dotted = body.contains("--");
+
+ final Display labels;
+ if (arg2.get("LABEL", 0) == null) {
+ labels = Display.create("");
+ } else {
+ labels = Display.getWithNewlines(arg2.get("LABEL", 0));
+ }
+
+ final boolean bothDirection = arg2.get("ARROW_BOTHDRESSING", 0) != null;
+
+ ArrowConfiguration config = bothDirection ? ArrowConfiguration.withDirectionBoth() : ArrowConfiguration
+ .withDirectionNormal();
+ if (dotted) {
+ config = config.withDotted();
+ }
+ if (sync) {
+ config = config.withHead(ArrowHead.ASYNC);
+ }
+ config = config.withPart(getArrowPart(dressing));
+ config = CommandArrow.applyStyle(arg2.getLazzy("ARROW_STYLE", 0), config);
+ final MessageExoType messageExoType = getMessageExoType(arg2);
+
+ if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) {
+ if (containsSymbolExterior(arg2, "o")) {
+ config = config.withDecoration2(ArrowDecoration.CIRCLE);
+ }
+ if (containsSymbol(arg2, "o")) {
+ config = config.withDecoration1(ArrowDecoration.CIRCLE);
+ }
+ } else {
+ if (containsSymbolExterior(arg2, "o")) {
+ config = config.withDecoration1(ArrowDecoration.CIRCLE);
+ }
+ if (containsSymbol(arg2, "o")) {
+ config = config.withDecoration2(ArrowDecoration.CIRCLE);
+ }
+ }
+
+ if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+ }
+// if (messageExoType.getDirection() == 1) {
+// if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) {
+// config = config.withHead2(ArrowHead.CROSSX);
+// }
+// } else {
+// if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) {
+// config = config.withHead2(ArrowHead.CROSSX);
+// }
+// }
+
+ final String error = sequenceDiagram.addMessage(new MessageExo(p, messageExoType, labels, config,
+ sequenceDiagram.getNextMessageNumber(), isShortArrow(arg2)));
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private ArrowPart getArrowPart(String dressing) {
+ if (dressing.contains("/")) {
+ return ArrowPart.BOTTOM_PART;
+ }
+ if (dressing.contains("\\")) {
+ return ArrowPart.TOP_PART;
+ }
+ return ArrowPart.FULL;
+ }
+
+ abstract MessageExoType getMessageExoType(RegexResult arg2);
+
+ private boolean isShortArrow(RegexResult arg2) {
+ final String s = arg2.get("SHORT", 0);
+ if (s != null && s.contains("?")) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean containsSymbolExterior(RegexResult arg2, String symbol) {
+ final String s = arg2.get("SHORT", 0);
+ if (s != null && s.contains(symbol)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean containsSymbol(RegexResult arg2, String symbol) {
+ final String s = arg2.get("ARROW_SUPPCIRCLE", 0);
+ if (s != null && s.contains(symbol)) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java
new file mode 100644
index 0000000..e419541
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+
+public class CommandExoArrowLeft extends CommandExoArrowAny {
+
+ public CommandExoArrowLeft() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("SHORT", "([?\\[\\]][ox]?)?"), //
+ new RegexOr( //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), //
+ new RegexLeaf("ARROW_BODYA1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB1", "(-*)"), //
+ new RegexLeaf("ARROW_DRESSING1", "(>>?|//?|\\\\\\\\?)")), //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_DRESSING2", "(<<?|//?|\\\\\\\\?)"), //
+ new RegexLeaf("ARROW_BODYB2", "(-*)"), //
+ new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
+ new RegexLeaf("ARROW_SUPPCIRCLE", "([ox][%s]+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL", "(?::[%s]*(.*))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ MessageExoType getMessageExoType(RegexResult arg2) {
+ final String start = arg2.get("SHORT", 0);
+ final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
+ final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
+ if (start != null && start.contains("]")) {
+ if (dressing1 != null) {
+ return MessageExoType.FROM_RIGHT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.TO_RIGHT;
+ }
+ throw new IllegalArgumentException();
+ }
+ if (dressing1 != null) {
+ return MessageExoType.FROM_LEFT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.TO_LEFT;
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java
new file mode 100644
index 0000000..fbe168c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+
+public class CommandExoArrowRight extends CommandExoArrowAny {
+
+ public CommandExoArrowRight() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ARROW_SUPPCIRCLE", "([%s]+[ox])?"), //
+ new RegexOr( //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), //
+ new RegexLeaf("ARROW_BODYA1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB1", "(-*)"), //
+ new RegexLeaf("ARROW_DRESSING1", "(>>?|//?|\\\\\\\\?)")), //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_DRESSING2", "(<<?|//?|\\\\\\\\?)"), //
+ new RegexLeaf("ARROW_BODYB2", "(-*)"), //
+ new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
+ new RegexLeaf("SHORT", "([ox]?[?\\]\\[])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL", "(?::[%s]*(.*))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ MessageExoType getMessageExoType(RegexResult arg2) {
+ final String start = arg2.get("SHORT", 0);
+ final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
+ final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
+ if (start != null && start.contains("[")) {
+ if (dressing1 != null) {
+ return MessageExoType.TO_LEFT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.FROM_LEFT;
+ }
+ throw new IllegalArgumentException();
+ }
+ if (dressing1 != null) {
+ return MessageExoType.TO_RIGHT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.FROM_RIGHT;
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java
new file mode 100644
index 0000000..2d932c8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandFootbox extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandFootbox() {
+ super("(?i)^(hide|show)?[%s]*footbox$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final boolean footbox = arg.get(0).equalsIgnoreCase("show");
+ sequenceDiagram.setShowFootbox(footbox);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java
new file mode 100644
index 0000000..3cf62c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandFootboxOld extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandFootboxOld() {
+ super("(?i)^footbox[%s]*(on|off)?[%s]*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final boolean footbox = arg.get(0).equalsIgnoreCase("on");
+ sequenceDiagram.setShowFootbox(footbox);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java
new file mode 100644
index 0000000..79c24e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+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.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandGrouping extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandGrouping() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", "(opt|alt|loop|par|par2|break|critical|else|end|also|group)"), //
+ new RegexLeaf("COLORS", "((?<!else)(?<!also)(?<!end)#\\w+)?(?:[%s]+(#\\w+))?"), //
+ new RegexLeaf("COMMENT", "(?:[%s]+(.*?))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ String type = StringUtils.goLowerCase(arg.get("TYPE", 0));
+ final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("COLORS", 0));
+ final HtmlColor backColorGeneral = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("COLORS", 1));
+ String comment = arg.get("COMMENT", 0);
+ final GroupingType groupingType = GroupingType.getType(type);
+ if ("group".equals(type)) {
+ if (StringUtils.isEmpty(comment)) {
+ comment = "group";
+ } else {
+ final Pattern p = Pattern.compile("^(.*?)\\[(.*)\\]$");
+ final Matcher m = p.matcher(comment);
+ if (m.find()) {
+ type = m.group(1);
+ comment = m.group(2);
+ }
+ }
+ }
+ final boolean result = diagram.grouping(type, comment, groupingType, backColorGeneral, backColorElement);
+ if (result == false) {
+ return CommandExecutionResult.error("Cannot create group");
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java
new file mode 100644
index 0000000..92bbfdf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandHSpace extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandHSpace() {
+ super("(?i)^\\|\\|(\\d+)?\\|+$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final String size = arg.get(0);
+ if (StringUtils.isNotEmpty(size)) {
+ sequenceDiagram.hspace(Integer.parseInt(size));
+ } else {
+ sequenceDiagram.hspace();
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java
new file mode 100644
index 0000000..5ffa480
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandIgnoreNewpage extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandIgnoreNewpage() {
+ super("(?i)^ignore[%s]*newpage$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ sequenceDiagram.ignoreNewpage();
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java
new file mode 100644
index 0000000..8ef40bd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandNewpage extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandNewpage() {
+ super("(?i)^@?newpage(?:(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final Display strings = arg.get(0) == null ? null : Display.getWithNewlines(arg.get(0));
+ sequenceDiagram.newpage(strings);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java
new file mode 100644
index 0000000..8c3d999
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+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.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.IRegex;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantType;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandParticipant(RegexConcat pattern) {
+ super(pattern);
+ }
+
+ static IRegex getRegexType() {
+ return new RegexOr(new RegexLeaf("TYPE", "(participant|actor|create|boundary|control|entity|database)"), //
+ new RegexLeaf("CREATE", "create[%s](participant|actor|boundary|control|entity|database)"));
+ }
+
+ @Override
+ final protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ final String code = arg.get("CODE", 0);
+ if (diagram.participants().containsKey(code)) {
+ diagram.putParticipantInLast(code);
+ return CommandExecutionResult.ok();
+ }
+
+ Display strings = null;
+ if (arg.get("FULL", 0) != null) {
+ strings = Display.getWithNewlines(arg.get("FULL", 0));
+ }
+
+ final String typeString1 = arg.get("TYPE", 0);
+ final String typeCreate1 = arg.get("CREATE", 0);
+ final ParticipantType type;
+ final boolean create;
+ if (typeCreate1 != null) {
+ type = ParticipantType.valueOf(StringUtils.goUpperCase(typeCreate1));
+ create = true;
+ } else if (typeString1.equalsIgnoreCase("CREATE")) {
+ type = ParticipantType.PARTICIPANT;
+ create = true;
+ } else {
+ type = ParticipantType.valueOf(StringUtils.goUpperCase(typeString1));
+ create = false;
+ }
+ final Participant participant = diagram.createNewParticipant(type, code, strings);
+
+ final String stereotype = arg.get("STEREO", 0);
+
+ if (stereotype != null) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ final boolean stereotypePositionTop = skinParam.stereotypePositionTop();
+ final UFont font = skinParam.getFont(FontParam.CIRCLED_CHARACTER, null, false);
+ participant.setStereotype(new Stereotype(stereotype, skinParam.getCircledCharacterRadius(), font, diagram
+ .getSkinParam().getIHtmlColorSet()), stereotypePositionTop);
+ }
+ participant
+ .setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ participant.setUrl(url);
+ }
+
+ if (create) {
+ final String error = diagram.activate(participant, LifeEventType.CREATE, null);
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java
new file mode 100644
index 0000000..1acc19f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA extends CommandParticipant {
+
+ public CommandParticipantA() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("FULL", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java
new file mode 100644
index 0000000..b3545c6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA2 extends CommandParticipant {
+
+ public CommandParticipantA2() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java
new file mode 100644
index 0000000..4c8d538
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA3 extends CommandParticipant {
+
+ public CommandParticipantA3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("FULL", "([\\p{L}0-9_.@]+)[%s]+as[%s]+"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java
new file mode 100644
index 0000000..bf1032e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA4 extends CommandParticipant {
+
+ public CommandParticipantA4() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("CODE", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java
new file mode 100644
index 0000000..4e0bd43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.CommandMultilines;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<SequenceDiagram> {
+
+ public CommandReferenceMultilinesOverSeveral() {
+ super(
+ "(?i)^ref(#\\w+)?[%s]+over[%s]+((?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g]))*)[%s]*(#\\w+)?$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?(ref)?$";
+ }
+
+ public CommandExecutionResult execute(final SequenceDiagram diagram, List<String> lines) {
+ final List<String> line0 = StringUtils.getSplit(getStartingPattern(), lines.get(0).trim());
+ final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get(0));
+ // final HtmlColor backColorGeneral = HtmlColorSet.getInstance().getColorIfValid(line0.get(1));
+
+ final List<String> participants = StringUtils.splitComma(line0.get(1));
+ final List<Participant> p = new ArrayList<Participant>();
+ for (String s : participants) {
+ p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
+ }
+
+ Display strings = Display.create(lines.subList(1, lines.size() - 1)).removeEmptyColumns();
+
+ Url u = null;
+ if (strings.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ u = urlBuilder.getUrl(strings.get(0).toString());
+ }
+ if (u != null) {
+ strings = strings.subList(1, strings.size());
+ }
+
+ final HtmlColor backColorGeneral = null;
+ final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement);
+ diagram.addReference(ref);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java
new file mode 100644
index 0000000..46e2821
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+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.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandReferenceOverSeveral() {
+ super(getConcat());
+ }
+
+ private static RegexConcat getConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("REF", "ref(#\\w+)?[%s]+over[%s]+"), //
+ new RegexLeaf("PARTS",
+ "(([\\p{L}0-9_.@]+|[%g][^%g]+[%g])([%s]*,[%s]*([\\p{L}0-9_.@]+|[%g][^%g]+[%g]))*)"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("URL", "(?:\\[\\[([^|]*)(?:\\|([^|]*))?\\]\\])?"), //
+ new RegexLeaf("TEXT", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("REF", 0));
+ // final HtmlColor backColorGeneral = HtmlColorSet.getInstance().getColorIfValid(arg.get("REF").get(1));
+
+ final List<String> participants = StringUtils.splitComma(arg.get("PARTS", 0));
+ final String url = arg.get("URL", 0);
+ final String title = arg.get("URL", 1);
+ final String text = arg.get("TEXT", 0).trim();
+
+ final List<Participant> p = new ArrayList<Participant>();
+ for (String s : participants) {
+ p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
+ }
+
+ final Display strings = Display.getWithNewlines(text);
+
+ Url u = null;
+ if (url != null) {
+ u = new Url(url, title);
+ }
+
+ final HtmlColor backColorGeneral = null;
+ final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement);
+ diagram.addReference(ref);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java
new file mode 100644
index 0000000..5e9e278
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public class CommandReturn extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandReturn() {
+ super("(?i)^return[%s]*(.*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+
+ Message message = sequenceDiagram.getActivatingMessage();
+ boolean doDeactivation = true;
+ if (message == null) {
+ final EventWithDeactivate last = sequenceDiagram.getLastEventWithDeactivate();
+ if (last instanceof Message == false) {
+ return CommandExecutionResult.error("Nowhere to return to.");
+ }
+ message = (Message) last;
+ doDeactivation = false;
+ }
+
+ final ArrowConfiguration arrow = message.getArrowConfiguration().withDotted();
+
+ sequenceDiagram.addMessage(
+ new Message(message.getParticipant2(), message.getParticipant1(), Display.getWithNewlines(arg
+ .get(0)), arrow, sequenceDiagram.getNextMessageNumber()));
+
+ if (doDeactivation) {
+ final String error = sequenceDiagram.activate(message.getParticipant2(), LifeEventType.DEACTIVATE, null);
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+ }
+ return CommandExecutionResult.ok();
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java
new file mode 100644
index 0000000..5ba2ca4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandSkin extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandSkin() {
+ super("(?i)^skin[%s]+([\\w.]+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram system, List<String> arg) {
+ if (system.changeSkin(arg.get(0))) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot change skin");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java
new file mode 100644
index 0000000..8241f1d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+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.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandUrl extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandUrl() {
+ super("(?i)^url[%s]*(?:of|for)?[%s]+([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]+(?:is)?[%s]*(" + UrlBuilder.getRegexp() + ")$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ final String code = arg.get(0);
+ final String urlString = arg.get(1);
+ // final String title = arg.get(2);
+ final Participant p = diagram.getOrCreateParticipant(code);
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ p.setUrl(url);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java
new file mode 100644
index 0000000..08e215e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java
@@ -0,0 +1,126 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+abstract class Arrow extends GraphicalElement implements InGroupable {
+
+ private final Skin skin;
+ private final Component arrowComponent;
+ private double paddingArrowHead = 0;
+ private double maxX;
+ private final Url url;
+
+ public void setMaxX(double m) {
+ if (maxX != 0) {
+ throw new IllegalStateException();
+ }
+ this.maxX = m;
+ }
+
+ final protected double getMaxX() {
+ if (maxX == 0) {
+ // throw new IllegalStateException();
+ }
+ return maxX;
+ }
+
+ public abstract double getActualWidth(StringBounder stringBounder);
+
+ Arrow(double startingY, Skin skin, Component arrowComponent, Url url) {
+ super(startingY);
+ this.skin = skin;
+ this.arrowComponent = arrowComponent;
+ this.url = url;
+ }
+
+ protected Url getUrl() {
+ return url;
+ }
+
+ protected final void startUrl(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ }
+
+ protected final void endUrl(UGraphic ug) {
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+
+ public abstract int getDirection(StringBounder stringBounder);
+
+ protected Skin getSkin() {
+ return skin;
+ }
+
+ protected final Component getArrowComponent() {
+ return arrowComponent;
+ }
+
+ public double getArrowOnlyWidth(StringBounder stringBounder) {
+ return getPreferredWidth(stringBounder);
+ }
+
+ public abstract double getArrowYStartLevel(StringBounder stringBounder);
+
+ public abstract double getArrowYEndLevel(StringBounder stringBounder);
+
+ public abstract LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position);
+
+ protected final double getPaddingArrowHead() {
+ return paddingArrowHead;
+ }
+
+ protected final void setPaddingArrowHead(double paddingArrowHead) {
+ this.paddingArrowHead = paddingArrowHead;
+ }
+
+ final public double getMargin() {
+ return 5;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java
new file mode 100644
index 0000000..25c2361
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java
@@ -0,0 +1,138 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+class ArrowAndNoteBox extends Arrow implements InGroupable {
+
+ private final Arrow arrow;
+ private final NoteBox noteBox;
+
+ public ArrowAndNoteBox(StringBounder stringBounder, Arrow arrow, NoteBox noteBox) {
+ super(arrow.getStartingY(), arrow.getSkin(), arrow.getArrowComponent(), arrow.getUrl());
+ this.arrow = arrow;
+ this.noteBox = noteBox;
+
+ final double arrowHeight = arrow.getPreferredHeight(stringBounder);
+ final double noteHeight = noteBox.getPreferredHeight(stringBounder);
+ final double myHeight = getPreferredHeight(stringBounder);
+
+ final double diffHeightArrow = myHeight - arrowHeight;
+ final double diffHeightNote = myHeight - noteHeight;
+ if (diffHeightArrow > 0) {
+ arrow.pushToDown(diffHeightArrow / 2);
+ }
+ if (diffHeightNote > 0) {
+ noteBox.pushToDown(diffHeightNote / 2);
+ }
+ }
+
+ @Override
+ final public double getArrowOnlyWidth(StringBounder stringBounder) {
+ return arrow.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public void setMaxX(double m) {
+ super.setMaxX(m);
+ arrow.setMaxX(m);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ arrow.drawU(ug, maxX, context);
+ noteBox.drawU(ug, maxX, context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return Math.max(arrow.getPreferredHeight(stringBounder), noteBox.getPreferredHeight(stringBounder));
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ double w = arrow.getPreferredWidth(stringBounder);
+ w = Math.max(w, arrow.getActualWidth(stringBounder));
+ return w + noteBox.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return Math.min(arrow.getStartingX(stringBounder), noteBox.getStartingX(stringBounder));
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return arrow.getDirection(stringBounder);
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ return arrow.getArrowYStartLevel(stringBounder);
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ return arrow.getArrowYEndLevel(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getStartingX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return arrow.getParticipantAt(stringBounder, position);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java
new file mode 100644
index 0000000..3944bb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java
@@ -0,0 +1,148 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ArrowAndParticipant extends Arrow implements InGroupable {
+
+ private final Arrow arrow;
+ private final ParticipantBox participantBox;
+
+ public ArrowAndParticipant(StringBounder stringBounder, Arrow arrow, ParticipantBox participantBox) {
+ super(arrow.getStartingY(), arrow.getSkin(), arrow.getArrowComponent(), arrow.getUrl());
+ this.arrow = arrow;
+ this.participantBox = participantBox;
+ arrow.setPaddingArrowHead(participantBox.getPreferredWidth(stringBounder) / 2);
+ }
+
+ @Override
+ public void setMaxX(double m) {
+ super.setMaxX(m);
+ arrow.setMaxX(m);
+ }
+
+ @Override
+ final public double getArrowOnlyWidth(StringBounder stringBounder) {
+ return arrow.getPreferredWidth(stringBounder) + participantBox.getPreferredWidth(stringBounder) / 2;
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ return arrow.getArrowYEndLevel(stringBounder);
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ return arrow.getArrowYStartLevel(stringBounder);
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return arrow.getDirection(stringBounder);
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return arrow.getParticipantAt(stringBounder, position);
+ }
+
+ @Override
+ protected void drawInternalU(final UGraphic ug, double maxX, Context2D context) {
+ final double participantBoxStartingX = participantBox.getStartingX();
+ final double arrowStartingX = arrow.getStartingX(ug.getStringBounder());
+
+ if (arrowStartingX < participantBoxStartingX) {
+ arrow.drawInternalU(ug, maxX, context);
+ } else {
+ final double boxWidth = participantBox.getPreferredWidth(ug.getStringBounder());
+ arrow.drawInternalU(ug.apply(new UTranslate(boxWidth / 2, 0)), maxX, context);
+ }
+
+ final double arrowHeight = arrow.getPreferredHeight(ug.getStringBounder());
+ final double boxHeight = participantBox.getHeadHeight(ug.getStringBounder());
+ // final double diff = getDiff(ug);
+ double diff = 0;
+ if (arrowHeight > boxHeight) {
+ diff = arrowHeight - boxHeight;
+ }
+ participantBox.drawParticipantHead(ug.apply(new UTranslate(participantBoxStartingX, getStartingY() + diff)));
+ }
+
+ private double getDiff(UGraphic ug) {
+ final double y1 = arrow.getPreferredHeight(ug.getStringBounder());
+ final double y2 = participantBox.getHeadHeight(ug.getStringBounder());
+ final double diff = y1 - y2;
+ return diff;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return Math.max(arrow.getPreferredHeight(stringBounder), participantBox.getHeadHeight(stringBounder));
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return arrow.getPreferredWidth(stringBounder) + participantBox.getPreferredWidth(stringBounder) / 2;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return arrow.getActualWidth(stringBounder) + participantBox.getPreferredWidth(stringBounder) / 2;
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return arrow.getStartingX(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return arrow.getMaxX(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return arrow.getMinX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return arrow.toString(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java
new file mode 100644
index 0000000..4fa69d7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+public class Constraint {
+
+ private final Pushable p1;
+ private final Pushable p2;
+ private double value;
+
+ public Constraint(Pushable p1, Pushable p2) {
+ if (p1 == null || p2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.p1 = p1;
+ this.p2 = p2;
+ }
+
+ public final Pushable getParticipant1() {
+ return p1;
+ }
+
+ public final Pushable getParticipant2() {
+ return p2;
+ }
+
+ public final double getValue() {
+ return value;
+ }
+
+ public final void ensureValue(double newValue) {
+ if (newValue > value) {
+ this.value = newValue;
+ }
+ }
+
+ public void push(double delta) {
+ value += delta;
+ }
+
+ @Override
+ public String toString() {
+ return "Constraint " + p1 + " " + p2 + " " + value;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java
new file mode 100644
index 0000000..535fcc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java
@@ -0,0 +1,186 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class ConstraintSet {
+
+ private final ParticipantBoxSimple firstBorder;
+
+ private final ParticipantBoxSimple lastborder;
+
+ final private List<Pushable> participantList = new ArrayList<Pushable>();
+ final private Map<List<Pushable>, Constraint> constraints = new HashMap<List<Pushable>, Constraint>();
+
+ public ConstraintSet(Collection<? extends Pushable> all, double freeX) {
+ this.participantList.add(firstBorder = new ParticipantBoxSimple(0, "LEFT"));
+ this.participantList.addAll(all);
+ this.participantList.add(lastborder = new ParticipantBoxSimple(freeX, "RIGHT"));
+ }
+
+ @Override
+ public String toString() {
+ return constraints.values().toString();
+ }
+
+ public double getMaxX() {
+ return lastborder.getCenterX(null);
+ }
+
+ public Constraint getConstraint(Pushable p1, Pushable p2) {
+ if (p1 == null || p2 == null || p1 == p2) {
+ throw new IllegalArgumentException();
+ }
+ final int i1 = participantList.indexOf(p1);
+ final int i2 = participantList.indexOf(p2);
+ if (i1 == -1 || i2 == -1) {
+ throw new IllegalArgumentException();
+ }
+ if (i1 > i2) {
+ return getConstraint(p2, p1);
+ }
+ final List<Pushable> key = Arrays.asList(p1, p2);
+ Constraint result = constraints.get(key);
+ if (result == null) {
+ result = new Constraint(p1, p2);
+ constraints.put(key, result);
+ }
+ return result;
+ }
+
+ public Constraint getConstraintAfter(Pushable p1) {
+ if (p1 == null) {
+ throw new IllegalArgumentException();
+ }
+ return getConstraint(p1, getNext(p1));
+ }
+
+ public Constraint getConstraintBefore(Pushable p1) {
+ if (p1 == null) {
+ throw new IllegalArgumentException();
+ }
+ return getConstraint(p1, getPrevious(p1));
+ }
+
+ public Pushable getPrevious(Pushable p) {
+ return getOtherParticipant(p, -1);
+ }
+
+ public Pushable getNext(Pushable p) {
+ return getOtherParticipant(p, 1);
+ }
+
+ private Pushable getOtherParticipant(Pushable p, int delta) {
+ final int i = participantList.indexOf(p);
+ if (i == -1) {
+ throw new IllegalArgumentException();
+ }
+ return participantList.get(i + delta);
+ }
+
+ public void takeConstraintIntoAccount(StringBounder stringBounder) {
+ for (int dist = 1; dist < participantList.size(); dist++) {
+ pushEverybody(stringBounder, dist);
+ }
+ }
+
+ private void pushEverybody(StringBounder stringBounder, int dist) {
+ for (int i = 0; i < participantList.size() - dist; i++) {
+ final Pushable p1 = participantList.get(i);
+ final Pushable p2 = participantList.get(i + dist);
+ final Constraint c = getConstraint(p1, p2);
+ ensureSpaceAfter(stringBounder, p1, p2, c.getValue());
+ }
+ }
+
+ public void pushToLeftParticipantBox(double deltaX, Pushable firstToChange, boolean including) {
+ if (deltaX <= 0) {
+ throw new IllegalArgumentException();
+ }
+ if (firstToChange == null) {
+ throw new IllegalArgumentException();
+ }
+ // freeX += deltaX;
+ boolean founded = false;
+ for (Pushable box : participantList) {
+ if (box.equals(firstToChange)) {
+ founded = true;
+ if (including == false) {
+ continue;
+ }
+ }
+ if (founded) {
+ box.pushToLeft(deltaX);
+ }
+ }
+ }
+
+ public void pushToLeft(double delta) {
+ pushToLeftParticipantBox(delta, firstBorder, true);
+ }
+
+ private void ensureSpaceAfter(StringBounder stringBounder, Pushable p1, Pushable p2, double space) {
+ if (p1.equals(p2)) {
+ throw new IllegalArgumentException();
+ }
+ if (p1.getCenterX(stringBounder) > p2.getCenterX(stringBounder)) {
+ ensureSpaceAfter(stringBounder, p2, p1, space);
+ return;
+ }
+ assert p1.getCenterX(stringBounder) < p2.getCenterX(stringBounder);
+ final double existingSpace = p2.getCenterX(stringBounder) - p1.getCenterX(stringBounder);
+ if (existingSpace < space) {
+ pushToLeftParticipantBox(space - existingSpace, p2, true);
+ }
+
+ }
+
+ public final Pushable getFirstBorder() {
+ return firstBorder;
+ }
+
+ public final Pushable getLastborder() {
+ return lastborder;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java
new file mode 100644
index 0000000..fc2f0c0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java
@@ -0,0 +1,461 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Newpage;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEngloberContexted;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class DrawableSet {
+
+ private final Map<Participant, LivingParticipantBox> participants = new LinkedHashMap<Participant, LivingParticipantBox>();
+ private final Map<Event, GraphicalElement> events = new HashMap<Event, GraphicalElement>();
+ private final Map<Participant, ParticipantEnglober> participantEnglobers2 = new LinkedHashMap<Participant, ParticipantEnglober>();
+
+ private final List<Event> eventsList = new ArrayList<Event>();
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private Dimension2D dimension;
+ private double topStartingY;
+
+ DrawableSet(Skin skin, ISkinParam skinParam) {
+ if (skin == null) {
+ throw new IllegalArgumentException();
+ }
+ if (skinParam == null) {
+ throw new IllegalArgumentException();
+ }
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ public ParticipantBox getVeryfirst() {
+ return participants.values().iterator().next().getParticipantBox();
+ }
+
+ public final Skin getSkin() {
+ return skin;
+ }
+
+ public final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ public Collection<Event> getAllEvents() {
+ return Collections.unmodifiableCollection(eventsList);
+ }
+
+ public Set<Participant> getAllParticipants() {
+ return Collections.unmodifiableSet(participants.keySet());
+ }
+
+ public Collection<LivingParticipantBox> getAllLivingParticipantBox() {
+ return Collections.unmodifiableCollection(participants.values());
+ }
+
+ public Collection<GraphicalElement> getAllGraphicalElements() {
+ final Collection<GraphicalElement> result = new ArrayList<GraphicalElement>();
+ for (Event ev : eventsList) {
+ result.add(events.get(ev));
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public LivingParticipantBox getLivingParticipantBox(Participant p) {
+ return participants.get(p);
+ }
+
+ public GraphicalElement getEvent(Event ev) {
+ return events.get(ev);
+ }
+
+ public double getHeadHeight(StringBounder stringBounder) {
+ double r = 0;
+ for (Participant p : participants.keySet()) {
+ final double y = getHeadAndEngloberHeight(p, stringBounder);
+ r = Math.max(r, y);
+ }
+ return r;
+ }
+
+ public double getHeadAndEngloberHeight(Participant p, StringBounder stringBounder) {
+ final LivingParticipantBox box = participants.get(p);
+ final double height = box.getParticipantBox().getHeadHeight(stringBounder);
+ final ParticipantEngloberContexted englober = getParticipantEnglober(p);
+ if (englober == null) {
+ return height;
+ }
+ final Component comp = skin.createComponent(ComponentType.ENGLOBER, null, skinParam, englober
+ .getParticipantEnglober().getTitle());
+ final double heightEnglober = comp.getPreferredHeight(stringBounder);
+ return height + heightEnglober;
+ }
+
+ public List<ParticipantEngloberContexted> getExistingParticipantEnglober() {
+ final List<ParticipantEngloberContexted> result = new ArrayList<ParticipantEngloberContexted>();
+ ParticipantEngloberContexted pending = null;
+ for (Map.Entry<Participant, ParticipantEnglober> ent : participantEnglobers2.entrySet()) {
+ final ParticipantEnglober englober = ent.getValue();
+ if (englober == null) {
+ pending = null;
+ continue;
+ }
+ assert englober != null;
+ if (pending != null && englober == pending.getParticipantEnglober()) {
+ pending.add(ent.getKey());
+ continue;
+ }
+ pending = new ParticipantEngloberContexted(englober, ent.getKey());
+ result.add(pending);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public double getOffsetForEnglobers(StringBounder stringBounder) {
+ double result = 0;
+ for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
+ final Component comp = skin.createComponent(ComponentType.ENGLOBER, null, skinParam, englober
+ .getParticipantEnglober().getTitle());
+ final double height = comp.getPreferredHeight(stringBounder);
+ if (height > result) {
+ result = height;
+ }
+ }
+ return result;
+ }
+
+ static private final int MARGIN_FOR_ENGLOBERS = 4;
+ static private final int MARGIN_FOR_ENGLOBERS1 = 2;
+
+ public double getTailHeight(StringBounder stringBounder, boolean showTail) {
+ final double marginForEnglobers = getExistingParticipantEnglober().size() > 0 ? MARGIN_FOR_ENGLOBERS : 0;
+
+ if (showTail == false) {
+ return 1 + marginForEnglobers;
+ }
+ double r = 0;
+ for (LivingParticipantBox livingParticipantBox : participants.values()) {
+ final double y = livingParticipantBox.getParticipantBox().getTailHeight(stringBounder);
+ r = Math.max(r, y);
+ }
+ return r + marginForEnglobers;
+ }
+
+ public void addParticipant(Participant p, ParticipantEnglober participantEnglober) {
+ participants.put(p, null);
+ participantEnglobers2.put(p, participantEnglober);
+ }
+
+ public void setLivingParticipantBox(Participant p, LivingParticipantBox box) {
+ if (participants.containsKey(p) == false) {
+ throw new IllegalArgumentException();
+ }
+ participants.put(p, box);
+ }
+
+ public void addEvent(Event event, GraphicalElement object) {
+ if (events.keySet().contains(event) == false) {
+ eventsList.add(event);
+ }
+ events.put(event, object);
+ }
+
+ public void addEvent(Newpage newpage, GraphicalNewpage object, Event justBefore) {
+ final int idx = eventsList.indexOf(justBefore);
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ eventsList.add(idx, newpage);
+ events.put(newpage, object);
+ assert events.size() == eventsList.size();
+ }
+
+ void setDimension(Dimension2D dim) {
+ if (dimension != null) {
+ throw new IllegalStateException();
+ }
+ this.dimension = dim;
+ }
+
+ public Dimension2D getDimension() {
+ return dimension;
+ }
+
+ void drawU_REMOVEDME_4243(UGraphic ug, final double delta, double width, Page page, boolean showTail) {
+
+ final UGraphic ugOrig = ug;
+
+ final int height = (int) page.getHeight();
+
+ ug = clipAndTranslate2(delta, width, page, ug);
+ final SimpleContext2D context = new SimpleContext2D(true);
+ this.drawPlaygroundU(ug, context);
+ ug = ugOrig;
+
+ this.drawEnglobers(ug, height - MARGIN_FOR_ENGLOBERS1, context);
+
+ this.drawLineU_REMOVEDME_4243(ug, showTail, page);
+ this.drawHeadTailU(ug, page, showTail ? height - getTailHeight(ug.getStringBounder(), true) : 0);
+
+ ug = clipAndTranslate2(delta, width, page, ug);
+ this.drawPlaygroundU(ug, new SimpleContext2D(false));
+ }
+
+ void drawU22(final UGraphic ug, final double delta, double width, Page page, boolean showTail) {
+ // final UGraphic ugOrig = ug;
+ final double height = page.getHeight();
+
+ final UGraphic ugTranslated = clipAndTranslate2(delta, width, page, ug);
+ final SimpleContext2D context = new SimpleContext2D(true);
+ this.drawPlaygroundU(ugTranslated, context);
+ // ug = ugOrig;
+
+ this.drawEnglobers(ug, height - MARGIN_FOR_ENGLOBERS1, context);
+
+ this.drawLineU22(ug, showTail, page);
+ this.drawHeadTailU(ug, page, showTail ? height - getTailHeight(ug.getStringBounder(), true) : 0);
+
+ // ug = clipAndTranslate2(delta, width, page, ug);
+ this.drawPlaygroundU(ugTranslated, new SimpleContext2D(false));
+ }
+
+ private UGraphic clipAndTranslate2(final double delta, double width, Page p, UGraphic ug) {
+ ug = ug.apply(new UClip(0, p.getBodyRelativePosition(), width, p.getBodyHeight() + 1));
+ if (delta > 0) {
+ ug = ug.apply(new UTranslate(0, -delta));
+ }
+ return ug;
+ }
+
+ private void drawLineU22(UGraphic ug, boolean showTail, Page page) {
+ for (LivingParticipantBox box : getAllLivingParticipantBox()) {
+ final double create = box.getCreate();
+ final double startMin = page.getBodyRelativePosition() - box.magicMargin(ug.getStringBounder());
+ final double endMax = startMin + page.getBodyHeight() + 2 * box.magicMargin(ug.getStringBounder());
+ double start = startMin;
+ if (create > 0) {
+ if (create > page.getNewpage2()) {
+ continue;
+ }
+ if (create >= page.getNewpage1() && create < page.getNewpage2()) {
+ start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder());
+ }
+ }
+ final double myDelta = page.getNewpage1() - page.getHeaderHeight();
+ box.drawLineU22(ug, start, endMax, showTail, myDelta);
+ }
+ }
+
+ private void drawLineU_REMOVEDME_4243(UGraphic ug, boolean showTail, Page page) {
+ for (LivingParticipantBox box : getAllLivingParticipantBox()) {
+ final double create = box.getCreate();
+ final double startMin = page.getBodyRelativePosition() - box.magicMargin(ug.getStringBounder());
+ // final double endMax = page.getHeight() - 1;
+ final double endMax = startMin + page.getBodyHeight() + 2 * box.magicMargin(ug.getStringBounder());
+ double start = startMin;
+ if (create > 0) {
+ if (create > page.getNewpage2()) {
+ continue;
+ }
+ if (create >= page.getNewpage1() && create < page.getNewpage2()) {
+ start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder());
+ }
+ }
+ final double myDelta = page.getNewpage1() - page.getHeaderHeight();
+ box.drawLineUTOBEREMOVED_4243(ug, start, endMax, showTail, myDelta);
+ }
+ }
+
+ private void drawHeadTailU(UGraphic ug, Page page, double positionTail) {
+ for (Map.Entry<Participant, LivingParticipantBox> ent : participants.entrySet()) {
+ final Participant p = ent.getKey();
+ final LivingParticipantBox box = ent.getValue();
+ final double create = box.getCreate();
+ boolean showHead = true;
+ if (create > 0) {
+ if (create > page.getNewpage2()) {
+ continue;
+ }
+ if (create >= page.getNewpage1() && create < page.getNewpage2()) {
+ showHead = false;
+ }
+ }
+ final Url url = p.getUrl();
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ box.getParticipantBox().drawHeadTailU(ug, topStartingY, showHead, positionTail);
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+ }
+
+ private double getMaxX() {
+ return dimension.getWidth();
+ }
+
+ private double getMaxY() {
+ return dimension.getHeight();
+ }
+
+ private void drawPlaygroundU(UGraphic ug, Context2D context) {
+ for (Participant p : getAllParticipants()) {
+ drawLifeLineU(ug, p);
+ }
+
+ for (GraphicalElement element : getAllGraphicalElements()) {
+ element.drawU(ug, getMaxX(), context);
+ }
+ }
+
+ private void drawEnglobers(UGraphic ug, double height, Context2D context) {
+ for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
+ double x1 = getX1(englober);
+ final double x2 = getX2(ug.getStringBounder(), englober);
+
+ final Component comp = getEngloberComponent(englober.getParticipantEnglober());
+
+ final double width = x2 - x1;
+ final double preferedWidth = getEngloberPreferedWidth(ug.getStringBounder(),
+ englober.getParticipantEnglober());
+ if (preferedWidth > width) {
+ // if (englober.getFirst2() == englober.getLast2()) {
+ x1 -= (preferedWidth - width) / 2;
+ // }
+ final Dimension2DDouble dim = new Dimension2DDouble(preferedWidth, height);
+ comp.drawU(ug.apply(new UTranslate(x1, 1)), new Area(dim), context);
+ } else {
+ final Dimension2DDouble dim = new Dimension2DDouble(width, height);
+ comp.drawU(ug.apply(new UTranslate(x1, 1)), new Area(dim), context);
+ }
+ }
+ }
+
+ public double getEngloberPreferedWidth(StringBounder stringBounder, ParticipantEnglober englober) {
+ return getEngloberComponent(englober).getPreferredWidth(stringBounder);
+ }
+
+ private Component getEngloberComponent(ParticipantEnglober englober) {
+ final ISkinParam s = englober.getBoxColor() == null ? skinParam : new SkinParamBackcolored(skinParam,
+ englober.getBoxColor());
+ return skin.createComponent(ComponentType.ENGLOBER, null, s, englober.getTitle());
+ }
+
+ public double getX1(ParticipantEngloberContexted englober) {
+ final Participant first = englober.getFirst2();
+ final ParticipantBox firstBox = participants.get(first).getParticipantBox();
+ return firstBox.getStartingX() + 1;
+ }
+
+ public double getX2(StringBounder stringBounder, ParticipantEngloberContexted englober) {
+ final Participant last = englober.getLast2();
+ final ParticipantBox lastBox = participants.get(last).getParticipantBox();
+ return lastBox.getMaxX(stringBounder) - 1;
+ }
+
+ private void drawLifeLineU(UGraphic ug, Participant p) {
+ final LifeLine line = getLivingParticipantBox(p).getLifeLine();
+
+ line.finish(getMaxY());
+ line.drawU(ug, getSkin(), skinParam);
+ }
+
+ private ParticipantEngloberContexted getParticipantEnglober(Participant p) {
+ for (ParticipantEngloberContexted pe : getExistingParticipantEnglober()) {
+ if (pe.contains(p)) {
+ return pe;
+ }
+ }
+ return null;
+ }
+
+ public void setTopStartingY(double topStartingY) {
+ this.topStartingY = topStartingY;
+ }
+
+ Participant getFirst(Collection<Participant> someParticipants) {
+ final List<Participant> list = new ArrayList<Participant>(participants.keySet());
+ int min = -1;
+ for (Participant p : someParticipants) {
+ final int n = list.indexOf(p);
+ assert n != -1;
+ if (min == -1 || min > n) {
+ min = n;
+ }
+ }
+ return list.get(min);
+ }
+
+ Participant getLast(Collection<Participant> someParticipants) {
+ final List<Participant> list = new ArrayList<Participant>(participants.keySet());
+ int max = -1;
+ for (Participant p : someParticipants) {
+ final int n = list.indexOf(p);
+ assert n != -1;
+ if (max == -1 || max < n) {
+ max = n;
+ }
+ }
+ return list.get(max);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java
new file mode 100644
index 0000000..4d9d995
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java
@@ -0,0 +1,613 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SkinParamBackcoloredReference;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Divider;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
+import net.sourceforge.plantuml.sequencediagram.GroupingStart;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.sequencediagram.HSpace;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.Newpage;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NoteStyle;
+import net.sourceforge.plantuml.sequencediagram.Notes;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEngloberContexted;
+import net.sourceforge.plantuml.sequencediagram.ParticipantType;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Skin;
+
+class DrawableSetInitializer {
+
+ private ComponentType defaultLineType;
+ private final DrawableSet drawableSet;
+ private final boolean showTail;
+
+ private double freeX = 0;
+ private Frontier freeY2 = null;
+ private Frontier lastFreeY2 = null;
+
+ private final double autonewpage;
+
+ private ConstraintSet constraintSet;
+
+ public DrawableSetInitializer(Skin skin, ISkinParam skinParam, boolean showTail, double autonewpage) {
+ this.drawableSet = new DrawableSet(skin, skinParam);
+ this.showTail = showTail;
+ this.autonewpage = autonewpage;
+
+ }
+
+ private boolean useContinueLineBecauseOfDelay() {
+ final String strategy = drawableSet.getSkinParam().getValue("lifelineStrategy");
+ if ("nosolid".equalsIgnoreCase(strategy)) {
+ return false;
+ }
+ if ("solid".equalsIgnoreCase(strategy)) {
+ return true;
+ }
+ for (Event ev : drawableSet.getAllEvents()) {
+ if (ev instanceof Delay) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private ParticipantRange getFullParticipantRange() {
+ return new ParticipantRange(0, drawableSet.getAllParticipants().size());
+ }
+
+ private ParticipantRange getParticipantRange(Event ev) {
+ return getFullParticipantRange();
+ }
+
+ // private int getParticipantRangeIndex(Participant participant) {
+ // int r = 0;
+ // for (Participant p : drawableSet.getAllParticipants()) {
+ // r++;
+ // if (p == participant) {
+ // return r;
+ // }
+ // }
+ // throw new IllegalArgumentException();
+ // }
+
+ public DrawableSet createDrawableSet(StringBounder stringBounder) {
+ if (freeY2 != null) {
+ throw new IllegalStateException();
+ }
+
+ this.defaultLineType = useContinueLineBecauseOfDelay() ? ComponentType.CONTINUE_LINE
+ : ComponentType.PARTICIPANT_LINE;
+
+ for (Participant p : drawableSet.getAllParticipants()) {
+ prepareParticipant(stringBounder, p);
+ }
+
+ this.freeY2 = new FrontierStackImpl(drawableSet.getHeadHeight(stringBounder), drawableSet.getAllParticipants()
+ .size());
+
+ this.lastFreeY2 = this.freeY2;
+
+ drawableSet.setTopStartingY(this.freeY2.getFreeY(getFullParticipantRange()));
+
+ for (Participant p : drawableSet.getAllParticipants()) {
+ final LivingParticipantBox living = drawableSet.getLivingParticipantBox(p);
+ for (int i = 0; i < p.getInitialLife(); i++) {
+ living.getLifeLine().addSegmentVariation(LifeSegmentVariation.LARGER,
+ freeY2.getFreeY(getFullParticipantRange()), p.getLiveSpecificBackColor());
+ }
+ }
+
+ final List<ParticipantBox> col = new ArrayList<ParticipantBox>();
+ for (LivingParticipantBox livingParticipantBox : drawableSet.getAllLivingParticipantBox()) {
+ col.add(livingParticipantBox.getParticipantBox());
+ }
+
+ constraintSet = new ConstraintSet(col, freeX);
+
+ for (Event ev : new ArrayList<Event>(drawableSet.getAllEvents())) {
+ final ParticipantRange range = getParticipantRange(ev);
+ final double diffY = freeY2.getFreeY(range) - lastFreeY2.getFreeY(range);
+ // final double diffY = freeY2.diff(lastFreeY2);
+ if (autonewpage > 0 && diffY > 0 && diffY + getTotalHeight(0, stringBounder) > autonewpage) {
+ prepareNewpageSpecial(stringBounder, new Newpage(null), ev, range);
+ }
+ if (ev instanceof MessageExo) {
+ prepareMessageExo(stringBounder, (MessageExo) ev, range);
+ } else if (ev instanceof Message) {
+ prepareMessage(stringBounder, (Message) ev, range);
+ } else if (ev instanceof Note) {
+ prepareNote(stringBounder, (Note) ev, range);
+ } else if (ev instanceof Notes) {
+ prepareNotes(stringBounder, (Notes) ev, range);
+ } else if (ev instanceof LifeEvent) {
+ prepareLiveEvent(stringBounder, (LifeEvent) ev, range);
+ } else if (ev instanceof GroupingLeaf) {
+ prepareGroupingLeaf(stringBounder, (GroupingLeaf) ev, range);
+ } else if (ev instanceof GroupingStart) {
+ prepareGroupingStart(stringBounder, (GroupingStart) ev, range);
+ } else if (ev instanceof Newpage) {
+ prepareNewpage(stringBounder, (Newpage) ev, range);
+ } else if (ev instanceof Divider) {
+ prepareDivider(stringBounder, (Divider) ev, range);
+ } else if (ev instanceof HSpace) {
+ prepareHSpace(stringBounder, (HSpace) ev, range);
+ } else if (ev instanceof Delay) {
+ prepareDelay(stringBounder, (Delay) ev, col, range);
+ } else if (ev instanceof Reference) {
+ prepareReference(stringBounder, (Reference) ev, range);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ constraintSet.takeConstraintIntoAccount(stringBounder);
+ takeParticipantEngloberTitleWidth3(stringBounder);
+
+ prepareMissingSpace(stringBounder);
+
+ drawableSet.setDimension(new Dimension2DDouble(freeX, getTotalHeight(
+ freeY2.getFreeY(getFullParticipantRange()), stringBounder)));
+ return drawableSet;
+ }
+
+ private void takeParticipantEngloberTitleWidth3(StringBounder stringBounder) {
+ for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober()) {
+ final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder,
+ pe.getParticipantEnglober());
+ final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2()).getParticipantBox();
+ final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2()).getParticipantBox();
+ final double x1 = drawableSet.getX1(pe);
+ final double x2 = drawableSet.getX2(stringBounder, pe);
+ final double missing = preferredWidth - (x2 - x1);
+ if (missing > 0) {
+ constraintSet.pushToLeftParticipantBox(missing / 2, first, true);
+ constraintSet.pushToLeftParticipantBox(missing / 2, last, false);
+ }
+ }
+ }
+
+ private double getTotalHeight(double y, StringBounder stringBounder) {
+ final double signature = 0;
+ return y + drawableSet.getTailHeight(stringBounder, showTail) + signature;
+ }
+
+ public double getYposition(StringBounder stringBounder, Newpage newpage) {
+ if (newpage == null) {
+ throw new IllegalArgumentException();
+ }
+ final GraphicalNewpage graphicalNewpage = (GraphicalNewpage) drawableSet.getEvent(newpage);
+ return graphicalNewpage.getStartingY();
+ }
+
+ private void prepareMissingSpace(StringBounder stringBounder) {
+ freeX = constraintSet.getMaxX();
+
+ double missingSpace1 = 0;
+ double missingSpace2 = 0;
+
+ for (GraphicalElement ev : drawableSet.getAllGraphicalElements()) {
+ if (ev instanceof GraphicalDelayText) {
+ final double missing = ev.getPreferredWidth(stringBounder) - freeX;
+ if (missing > 0) {
+ missingSpace1 = Math.max(missingSpace1, missing / 2);
+ missingSpace2 = Math.max(missingSpace2, missing / 2);
+ }
+ continue;
+ }
+ final double startX = ev.getStartingX(stringBounder);
+ final double delta1 = -startX;
+ if (delta1 > missingSpace1) {
+ missingSpace1 = delta1;
+ }
+ if (ev instanceof Arrow) {
+ final Arrow a = (Arrow) ev;
+ a.setMaxX(freeX);
+ }
+ double width = ev.getPreferredWidth(stringBounder);
+ if (ev instanceof Arrow) {
+ final Arrow a = (Arrow) ev;
+ if (width < a.getActualWidth(stringBounder)) {
+ width = a.getActualWidth(stringBounder);
+ }
+ }
+ if (ev instanceof GroupingGraphicalElementHeader) {
+ final GroupingGraphicalElementHeader gh = (GroupingGraphicalElementHeader) ev;
+ if (width < gh.getActualWidth(stringBounder)) {
+ width = gh.getActualWidth(stringBounder);
+ }
+ }
+ final double endX = startX + width;
+ final double delta2 = endX - freeX;
+ if (delta2 > missingSpace2) {
+ missingSpace2 = delta2;
+ }
+ }
+
+ if (missingSpace1 > 0) {
+ constraintSet.pushToLeft(missingSpace1);
+ }
+ freeX = constraintSet.getMaxX() + missingSpace2;
+ }
+
+ private void prepareNewpage(StringBounder stringBounder, Newpage newpage, ParticipantRange range) {
+ final GraphicalNewpage graphicalNewpage = new GraphicalNewpage(freeY2.getFreeY(range), drawableSet.getSkin()
+ .createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), null));
+ this.lastFreeY2 = freeY2;
+ freeY2 = freeY2.add(graphicalNewpage.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(newpage, graphicalNewpage);
+ }
+
+ private void prepareNewpageSpecial(StringBounder stringBounder, Newpage newpage, Event justBefore,
+ ParticipantRange range) {
+ final GraphicalNewpage graphicalNewpage = new GraphicalNewpage(freeY2.getFreeY(range), drawableSet.getSkin()
+ .createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), null));
+ this.lastFreeY2 = freeY2;
+ freeY2 = freeY2.add(graphicalNewpage.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(newpage, graphicalNewpage, justBefore);
+ }
+
+ private void prepareDivider(StringBounder stringBounder, Divider divider, ParticipantRange range) {
+ final GraphicalDivider graphicalDivider = new GraphicalDivider(freeY2.getFreeY(range), drawableSet.getSkin()
+ .createComponent(ComponentType.DIVIDER, null, drawableSet.getSkinParam(), divider.getText()));
+ freeY2 = freeY2.add(graphicalDivider.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(divider, graphicalDivider);
+ }
+
+ private void prepareHSpace(StringBounder stringBounder, HSpace hspace, ParticipantRange range) {
+ final GraphicalHSpace graphicalHSpace = new GraphicalHSpace(freeY2.getFreeY(range), hspace.getPixel());
+ freeY2 = freeY2.add(graphicalHSpace.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(hspace, graphicalHSpace);
+ }
+
+ private void prepareDelay(StringBounder stringBounder, Delay delay, List<ParticipantBox> participants,
+ ParticipantRange range) {
+ final Component compText = drawableSet.getSkin().createComponent(ComponentType.DELAY_TEXT, null,
+ drawableSet.getSkinParam(), delay.getText());
+ final ParticipantBox first = participants.get(0);
+ final ParticipantBox last = participants.get(participants.size() - 1);
+ final GraphicalDelayText graphicalDivider = new GraphicalDelayText(freeY2.getFreeY(range), compText, first,
+ last);
+ for (ParticipantBox p : participants) {
+ p.addDelay(graphicalDivider);
+ }
+ freeY2 = freeY2.add(graphicalDivider.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(delay, graphicalDivider);
+ }
+
+ final private InGroupablesStack inGroupableStack = new InGroupablesStack();
+
+ private void prepareGroupingStart(StringBounder stringBounder, GroupingStart m, ParticipantRange range) {
+ if (m.getType() != GroupingType.START) {
+ throw new IllegalStateException();
+ }
+ final ISkinParam skinParam = new SkinParamBackcolored(drawableSet.getSkinParam(), m.getBackColorElement(),
+ m.getBackColorGeneral());
+
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.GROUPING_SPACE, null, skinParam,
+ Display.create(m.getComment()));
+ final double preferredHeight = comp.getPreferredHeight(stringBounder);
+ freeY2 = freeY2.add(preferredHeight, range);
+
+ final Display strings = m.getTitle().equals("group") ? Display.create(m.getComment()) : Display.create(
+ m.getTitle(), m.getComment());
+ final Component header = drawableSet.getSkin().createComponent(ComponentType.GROUPING_HEADER, null, skinParam,
+ strings);
+ final ParticipantBox veryfirst = drawableSet.getVeryfirst();
+ final InGroupableList inGroupableList = new InGroupableList(veryfirst, m, freeY2.getFreeY(range));
+ inGroupableStack.addList(inGroupableList);
+
+ final GraphicalElement element = new GroupingGraphicalElementHeader(freeY2.getFreeY(range), header,
+ inGroupableList, m.isParallel());
+ inGroupableList.setMinWidth(element.getPreferredWidth(stringBounder));
+ freeY2 = freeY2.add(element.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(m, element);
+ if (m.isParallel()) {
+ freeY2 = ((FrontierStack) freeY2).openBar();
+ }
+
+ }
+
+ private void prepareGroupingLeaf(StringBounder stringBounder, final GroupingLeaf m, ParticipantRange range) {
+ final GraphicalElement element;
+ final ISkinParam skinParam = new SkinParamBackcolored(drawableSet.getSkinParam(), null, m.getBackColorGeneral());
+ if (m.getType() == GroupingType.ELSE) {
+ if (m.isParallel()) {
+ freeY2 = ((FrontierStack) freeY2).restore();
+ }
+ final Component compElse = drawableSet.getSkin().createComponent(ComponentType.GROUPING_ELSE, null,
+ skinParam, Display.create(m.getComment()));
+ final Lazy lazy = new Lazy() {
+ public double getNow() {
+ final GraphicalElement after = drawableSet.getEvent(m.getJustAfter());
+ if (after == null) {
+ return 0;
+ }
+ return after.getStartingY();
+ }
+ };
+ element = new GroupingGraphicalElementElse(freeY2.getFreeY(range), compElse,
+ inGroupableStack.getTopGroupingStructure(), m.isParallel(), lazy);
+ final double preferredHeight = element.getPreferredHeight(stringBounder);
+ freeY2 = freeY2.add(preferredHeight, range);
+ // MODIF42
+ inGroupableStack.addElement((GroupingGraphicalElementElse) element);
+ } else if (m.getType() == GroupingType.END) {
+ if (m.isParallel()) {
+ freeY2 = ((FrontierStack) freeY2).closeBar();
+ }
+ final GroupingGraphicalElementHeader groupingHeaderStart = (GroupingGraphicalElementHeader) drawableSet
+ .getEvent(m.getGroupingStart());
+ if (groupingHeaderStart != null) {
+ groupingHeaderStart.setEndY(freeY2.getFreeY(range));
+ }
+ element = new GroupingGraphicalElementTail(freeY2.getFreeY(range),
+ inGroupableStack.getTopGroupingStructure(), m.isParallel());
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.GROUPING_SPACE, null, skinParam,
+ Display.create(m.getComment()));
+ final double preferredHeight = comp.getPreferredHeight(stringBounder);
+ freeY2 = freeY2.add(preferredHeight, range);
+ inGroupableStack.pop();
+ } else {
+ throw new IllegalStateException();
+ }
+ drawableSet.addEvent(m, element);
+
+ }
+
+ private void prepareNote(StringBounder stringBounder, Note n, ParticipantRange range) {
+ final NoteBox noteBox = createNoteBox(stringBounder, n, range);
+ inGroupableStack.addElement(noteBox);
+
+ drawableSet.addEvent(n, noteBox);
+ freeY2 = freeY2.add(noteBox.getPreferredHeight(stringBounder), range);
+ }
+
+ private NoteBox createNoteBox(StringBounder stringBounder, Note n, ParticipantRange range) {
+ LivingParticipantBox p1 = drawableSet.getLivingParticipantBox(n.getParticipant());
+ LivingParticipantBox p2;
+ if (n.getParticipant2() == null) {
+ p2 = null;
+ } else {
+ p2 = drawableSet.getLivingParticipantBox(n.getParticipant2());
+ if (p1.getParticipantBox().getCenterX(stringBounder) > p2.getParticipantBox().getCenterX(stringBounder)) {
+ final LivingParticipantBox tmp = p1;
+ p1 = p2;
+ p2 = tmp;
+ }
+ }
+ final ISkinParam skinParam = n.getSkinParamBackcolored(drawableSet.getSkinParam());
+ final ComponentType type = getNoteComponentType(n.getStyle());
+ final NoteBox noteBox = new NoteBox(freeY2.getFreeY(range), drawableSet.getSkin().createComponent(type, null,
+ skinParam, n.getStrings()), p1, p2, n.getPosition(), n.getUrl());
+ return noteBox;
+ }
+
+ private void prepareNotes(StringBounder stringBounder, Notes notes, ParticipantRange range) {
+ final NotesBoxes notesBoxes = new NotesBoxes(freeY2.getFreeY(range));
+ for (Note n : notes) {
+ final NoteBox noteBox = createNoteBox(stringBounder, n, range);
+ final ParticipantBox p1 = drawableSet.getLivingParticipantBox(n.getParticipant()).getParticipantBox();
+ final ParticipantBox p2 = n.getParticipant2() == null ? null : drawableSet.getLivingParticipantBox(
+ n.getParticipant2()).getParticipantBox();
+ notesBoxes.add(noteBox, p1, p2);
+ }
+ notesBoxes.ensureConstraints(stringBounder, constraintSet);
+ inGroupableStack.addElement(notesBoxes);
+
+ drawableSet.addEvent(notes, notesBoxes);
+ freeY2 = freeY2.add(notesBoxes.getPreferredHeight(stringBounder), range);
+ }
+
+ private ComponentType getNoteComponentType(NoteStyle noteStyle) {
+ if (noteStyle == NoteStyle.HEXAGONAL) {
+ return ComponentType.NOTE_HEXAGONAL;
+ }
+ if (noteStyle == NoteStyle.BOX) {
+ return ComponentType.NOTE_BOX;
+ }
+ return ComponentType.NOTE;
+ }
+
+ private void prepareLiveEvent(StringBounder stringBounder, LifeEvent lifeEvent, ParticipantRange range) {
+ final double y = freeY2.getFreeY(range);
+ final AbstractMessage message = lifeEvent.getMessage();
+ if (lifeEvent.getType() == LifeEventType.ACTIVATE) {
+ double pos = 0;
+ if (message != null) {
+ int delta1 = 0;
+ if (message.isCreate()) {
+ delta1 += 10;
+ } else if (OptionFlags.STRICT_SELFMESSAGE_POSITION && message.isSelfMessage()) {
+ delta1 += 8;
+ }
+ pos = message.getPosYstartLevel() + delta1;
+ }
+ final LifeLine line1 = drawableSet.getLivingParticipantBox(lifeEvent.getParticipant()).getLifeLine();
+ line1.addSegmentVariation(LifeSegmentVariation.LARGER, pos, lifeEvent.getSpecificBackColor());
+ } else if (lifeEvent.getType() == LifeEventType.DESTROY || lifeEvent.getType() == LifeEventType.DEACTIVATE) {
+ double delta = 0;
+ if (OptionFlags.STRICT_SELFMESSAGE_POSITION && message != null && message.isSelfMessage()) {
+ delta += 7;
+ }
+ final Participant p = lifeEvent.getParticipant();
+ final LifeLine line = drawableSet.getLivingParticipantBox(p).getLifeLine();
+ double pos2 = y;
+ if (message != null) {
+ pos2 = message.getPosYendLevel() - delta;
+ }
+ line.addSegmentVariation(LifeSegmentVariation.SMALLER, pos2, lifeEvent.getSpecificBackColor());
+ }
+
+ if (lifeEvent.getType() == LifeEventType.DESTROY) {
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.DESTROY, null,
+ drawableSet.getSkinParam(), null);
+ final double delta = comp.getPreferredHeight(stringBounder) / 2;
+ final LivingParticipantBox livingParticipantBox = drawableSet.getLivingParticipantBox(lifeEvent
+ .getParticipant());
+ final LifeDestroy destroy = new LifeDestroy(lifeEvent.getMessage().getPosYendLevel() - delta,
+ livingParticipantBox.getParticipantBox(), comp);
+ drawableSet.addEvent(lifeEvent, destroy);
+ } else {
+ drawableSet.addEvent(lifeEvent, new GraphicalElementLiveEvent(y));
+ }
+
+ }
+
+ private void prepareMessageExo(StringBounder stringBounder, MessageExo m, ParticipantRange range) {
+ final Step1MessageExo step1Message = new Step1MessageExo(range, stringBounder, m, drawableSet, freeY2);
+ freeY2 = step1Message.prepareMessage(constraintSet, inGroupableStack);
+ }
+
+ private void prepareMessage(StringBounder stringBounder, Message m, ParticipantRange range) {
+ final Step1Message step1Message = new Step1Message(range, stringBounder, m, drawableSet, freeY2);
+ freeY2 = step1Message.prepareMessage(constraintSet, inGroupableStack);
+ }
+
+ private void prepareReference(StringBounder stringBounder, Reference reference, ParticipantRange range) {
+ final LivingParticipantBox p1 = drawableSet.getLivingParticipantBox(drawableSet.getFirst(reference
+ .getParticipant()));
+ final LivingParticipantBox p2 = drawableSet.getLivingParticipantBox(drawableSet.getLast(reference
+ .getParticipant()));
+ final ISkinParam skinParam = new SkinParamBackcoloredReference(drawableSet.getSkinParam(),
+ reference.getBackColorElement(), reference.getBackColorGeneral());
+
+ Display strings = Display.empty();
+ strings = strings.add("ref");
+ strings = strings.addAll(reference.getStrings());
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.REFERENCE, null, skinParam, strings);
+ final GraphicalReference graphicalReference = new GraphicalReference(freeY2.getFreeY(range), comp, p1, p2,
+ reference.getUrl());
+
+ final ParticipantBox pbox1 = p1.getParticipantBox();
+ final ParticipantBox pbox2 = p2.getParticipantBox();
+ final double width = graphicalReference.getPreferredWidth(stringBounder)
+ - pbox1.getPreferredWidth(stringBounder) / 2 - pbox2.getPreferredWidth(stringBounder) / 2;
+
+ final Constraint constraint;
+ if (p1 == p2) {
+ constraint = constraintSet.getConstraintAfter(pbox1);
+ } else {
+ constraint = constraintSet.getConstraint(pbox1, pbox2);
+ }
+ constraint.ensureValue(width);
+
+ inGroupableStack.addElement(graphicalReference);
+ inGroupableStack.addElement(p1);
+ if (p1 != p2) {
+ inGroupableStack.addElement(p2);
+ }
+
+ freeY2 = freeY2.add(graphicalReference.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(reference, graphicalReference);
+ }
+
+ private void prepareParticipant(StringBounder stringBounder, Participant p) {
+ final ComponentType headType;
+ final ComponentType tailType;
+ if (p.getType() == ParticipantType.PARTICIPANT) {
+ headType = ComponentType.PARTICIPANT_HEAD;
+ tailType = ComponentType.PARTICIPANT_TAIL;
+ } else if (p.getType() == ParticipantType.ACTOR) {
+ headType = ComponentType.ACTOR_HEAD;
+ tailType = ComponentType.ACTOR_TAIL;
+ } else if (p.getType() == ParticipantType.BOUNDARY) {
+ headType = ComponentType.BOUNDARY_HEAD;
+ tailType = ComponentType.BOUNDARY_TAIL;
+ } else if (p.getType() == ParticipantType.CONTROL) {
+ headType = ComponentType.CONTROL_HEAD;
+ tailType = ComponentType.CONTROL_TAIL;
+ } else if (p.getType() == ParticipantType.ENTITY) {
+ headType = ComponentType.ENTITY_HEAD;
+ tailType = ComponentType.ENTITY_TAIL;
+ } else if (p.getType() == ParticipantType.DATABASE) {
+ headType = ComponentType.DATABASE_HEAD;
+ tailType = ComponentType.DATABASE_TAIL;
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ final ISkinParam skinParam = p.getSkinParamBackcolored(drawableSet.getSkinParam());
+ final Display participantDisplay = p.getDisplay(skinParam.forceSequenceParticipantUnderlined());
+ final Component head = drawableSet.getSkin().createComponent(headType, null, skinParam, participantDisplay);
+ final Component tail = drawableSet.getSkin().createComponent(tailType, null, skinParam, participantDisplay);
+ final Component line = drawableSet.getSkin().createComponent(this.defaultLineType, null,
+ drawableSet.getSkinParam(), participantDisplay);
+ final Component delayLine = drawableSet.getSkin().createComponent(ComponentType.DELAY_LINE, null,
+ drawableSet.getSkinParam(), participantDisplay);
+ final ParticipantBox box = new ParticipantBox(head, line, tail, delayLine, this.freeX);
+
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null,
+ drawableSet.getSkinParam(), null);
+
+ final LifeLine lifeLine = new LifeLine(box, comp.getPreferredWidth(stringBounder), drawableSet.getSkinParam()
+ .shadowing());
+ drawableSet.setLivingParticipantBox(p, new LivingParticipantBox(box, lifeLine));
+
+ this.freeX = box.getMaxX(stringBounder);
+ }
+
+ public void addParticipant(Participant p, ParticipantEnglober participantEnglober) {
+ drawableSet.addParticipant(p, participantEnglober);
+ }
+
+ public void addEvent(Event event) {
+ drawableSet.addEvent(event, null);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java
new file mode 100644
index 0000000..8fb5a18
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.core.ImageData;
+
+public interface FileMaker {
+
+ ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException;
+
+ public int getNbPages();
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java
new file mode 100644
index 0000000..3a9d38b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.sequencediagram.Event;
+
+interface FreeYStrategy {
+
+ double peekPosition(Event event, ParticipantRange range);
+
+ void addElement(Event event, ParticipantRange range, double height);
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java
new file mode 100644
index 0000000..0d3ceca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.sequencediagram.Event;
+
+class FreeYStrategyBasic implements FreeYStrategy {
+
+ public double peekPosition(Event event, ParticipantRange range) {
+ return 0;
+ }
+
+ public void addElement(Event event, ParticipantRange range, double height) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java
new file mode 100644
index 0000000..09d1a1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+
+interface Frontier {
+
+ double getFreeY(ParticipantRange range);
+
+ Frontier add(double delta, ParticipantRange range);
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java
new file mode 100644
index 0000000..1602d17
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.Arrays;
+
+class FrontierComplex implements Frontier {
+
+ private final double freeY[];
+
+ public FrontierComplex(double freeY, int rangeEnd) {
+ this.freeY = new double[rangeEnd + 1];
+ for (int i = 0; i <= rangeEnd; i++) {
+ this.freeY[i] = freeY;
+ }
+ }
+
+ private FrontierComplex(double freeY[]) {
+ this.freeY = freeY;
+ }
+
+ private FrontierComplex(double freeY[], double delta, ParticipantRange range) {
+ this(freeY.clone());
+ final double newV = getFreeY(range) + delta;
+ for (int i = range.start(); i <= range.end(); i++) {
+ this.freeY[i] = newV;
+ }
+ }
+
+ public double getFreeY(ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ double result = freeY[range.start()];
+ for (int i = range.start(); i <= range.end(); i++) {
+ if (freeY[i] > result) {
+ result = freeY[i];
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return Arrays.toString(freeY);
+ }
+
+ public FrontierComplex add(double delta, ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ return new FrontierComplex(freeY, delta, range);
+ }
+
+ FrontierComplex copy() {
+ return new FrontierComplex(freeY.clone());
+ }
+
+ FrontierComplex mergeMax(FrontierComplex other) {
+ if (this.freeY.length != other.freeY.length) {
+ throw new IllegalArgumentException();
+ }
+ final FrontierComplex result = new FrontierComplex(new double[freeY.length]);
+ for (int i=0; i<freeY.length; i++) {
+ result.freeY[i] = Math.max(this.freeY[i], other.freeY[i]);
+ }
+ return result;
+ }
+
+ // public double diff(Frontier other) {
+ // return freeY - other.freeY;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java
new file mode 100644
index 0000000..03546f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+
+class FrontierSimple implements Frontier {
+
+ private final double freeY;
+
+ public FrontierSimple(double freeY) {
+ this.freeY = freeY;
+ }
+
+ public double getFreeY(ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ return freeY;
+ }
+
+ public FrontierSimple add(double delta, ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ return new FrontierSimple(freeY + delta);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java
new file mode 100644
index 0000000..a58ed13
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+interface FrontierStack extends Frontier {
+
+ FrontierStack openBar();
+
+ FrontierStack restore();
+
+ FrontierStack closeBar();
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java
new file mode 100644
index 0000000..ed5e97e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+class FrontierStackImpl implements FrontierStack {
+
+ class Stack {
+ final private FrontierComplex current;
+ final private FrontierComplex envelop;
+
+ Stack(FrontierComplex current) {
+ this(current, null);
+ }
+
+ private Stack(FrontierComplex current, FrontierComplex envelop) {
+ this.current = current;
+ this.envelop = envelop;
+ }
+
+ Stack addEnvelop(FrontierComplex env) {
+ if (this.envelop == null) {
+ return new Stack(this.current, env);
+ }
+ return new Stack(this.current, this.envelop.mergeMax(env));
+ }
+ }
+
+ final private List<Stack> all;
+
+ public FrontierStackImpl(double freeY, int rangeEnd) {
+ final Stack s = new Stack(new FrontierComplex(freeY, rangeEnd));
+ all = Collections.singletonList(s);
+ }
+
+ private FrontierStackImpl(List<Stack> all) {
+ this.all = Collections.unmodifiableList(all);
+ }
+
+ private FrontierComplex getLast() {
+ return all.get(all.size() - 1).current;
+ }
+
+ public double getFreeY(ParticipantRange range) {
+ return getLast().getFreeY(range);
+ }
+
+ public FrontierStackImpl add(double delta, ParticipantRange range) {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack s = new Stack(getLast().add(delta, range));
+ result.set(result.size() - 1, s);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStack openBar() {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack s = new Stack(getLast().copy());
+ result.add(s);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStack restore() {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack openedBar = result.get(result.size() - 2);
+ final Stack lastStack = result.get(result.size() - 1);
+ result.set(result.size() - 2, openedBar.addEnvelop(lastStack.current));
+ result.remove(result.size() - 1);
+ final Stack s = new Stack(openedBar.current.copy());
+ result.add(s);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStack closeBar() {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack openedBar = result.get(result.size() - 2);
+ final Stack lastStack = result.get(result.size() - 1);
+ final Stack merge = openedBar.addEnvelop(lastStack.current);
+ result.set(result.size() - 2, new Stack(merge.envelop));
+ result.remove(result.size() - 1);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStackImpl copy() {
+ // return new FrontierStackImpl(all);
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String toString() {
+ return "nb=" + all.size() + " " + getLast().toString();
+ }
+
+}
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 0000000..1dbd01a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+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.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalDelayText extends GraphicalElement {
+
+ private final Component compText;
+
+ private final ParticipantBox p1;
+ private final ParticipantBox p2;
+
+ public GraphicalDelayText(double startingY, Component compText, ParticipantBox first, ParticipantBox last) {
+ super(startingY);
+ this.compText = compText;
+ this.p1 = first;
+ this.p2 = last;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = p1.getCenterX(stringBounder);
+ final double x2 = p2.getCenterX(stringBounder);
+ final double middle = (x1 + x2) / 2;
+ final double textWidth = compText.getPreferredWidth(stringBounder);
+ ug = ug.apply(new UTranslate(middle - textWidth / 2, getStartingY()));
+ // ug.translate(x1, getStartingY());
+ final Dimension2D dim = new Dimension2DDouble(textWidth, compText.getPreferredHeight(stringBounder));
+ compText.drawU(ug, new Area(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
new file mode 100644
index 0000000..95cee65
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+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.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalDivider extends GraphicalElement {
+
+ private final Component comp;
+
+ public GraphicalDivider(double startingY, Component comp) {
+ super(startingY);
+ this.comp = comp;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ ug = ug.apply(new UTranslate(0, getStartingY()));
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = new Dimension2DDouble(maxX, comp.getPreferredHeight(stringBounder));
+ comp.drawU(ug, new Area(dim), context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java
new file mode 100644
index 0000000..38e6f7f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+abstract class GraphicalElement {
+
+ private double startingY;
+
+ GraphicalElement(double startingY) {
+ this.startingY = startingY;
+ }
+
+ void pushToDown(double delta) {
+ startingY += delta;
+ }
+
+ protected final double getStartingY() {
+ return startingY;
+ }
+
+ public final void drawU(UGraphic ug, double maxX, Context2D context) {
+ // bugnewway
+ drawInternalU(ug, maxX, context);
+ }
+
+ protected abstract void drawInternalU(UGraphic ug, double maxX, Context2D context);
+
+ public abstract double getStartingX(StringBounder stringBounder);
+
+ public abstract double getPreferredWidth(StringBounder stringBounder);
+
+ public abstract double getPreferredHeight(StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java
new file mode 100644
index 0000000..5062308
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class GraphicalElementLiveEvent extends GraphicalElement {
+
+ public GraphicalElementLiveEvent(double startingY) {
+ super(startingY);
+ }
+
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ }
+
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java
new file mode 100644
index 0000000..7648a24
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+class GraphicalHSpace extends GraphicalElement {
+
+ private final int size;
+
+ public GraphicalHSpace(double startingY, int size) {
+ super(startingY);
+ this.size = size;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return size;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java
new file mode 100644
index 0000000..b97c674
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+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.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalNewpage extends GraphicalElement {
+
+ private final Component comp;
+
+ public GraphicalNewpage(double startingY, Component comp) {
+ super(startingY);
+ this.comp = comp;
+ }
+
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ //final double x = ug.getTranslateX();
+ ug = ug.apply(new UTranslate(0, getStartingY()));
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = new Dimension2DDouble(maxX, comp.getPreferredHeight(stringBounder));
+ comp.drawU(ug, new Area(dim), context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java
new file mode 100644
index 0000000..86291d4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalReference extends GraphicalElement implements InGroupable {
+
+ private final Component comp;
+ private final LivingParticipantBox livingParticipantBox1;
+ private final LivingParticipantBox livingParticipantBox2;
+ private final Url url;
+
+ public GraphicalReference(double startingY, Component comp, LivingParticipantBox livingParticipantBox1,
+ LivingParticipantBox livingParticipantBox2, Url url) {
+ super(startingY);
+ if (livingParticipantBox1 == null || livingParticipantBox2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.url = url;
+ this.comp = comp;
+ this.livingParticipantBox1 = livingParticipantBox1;
+ this.livingParticipantBox2 = livingParticipantBox2;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double posX = getMinX(stringBounder);
+
+ ug = ug.apply(new UTranslate(posX, getStartingY()));
+ final double preferredWidth = comp.getPreferredWidth(stringBounder);
+ final double w = getMaxX(stringBounder) - getMinX(stringBounder);
+
+ final double width = Math.max(preferredWidth, w);
+
+ final Dimension2D dim = new Dimension2DDouble(width, comp.getPreferredHeight(stringBounder));
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ comp.drawU(ug, new Area(dim), context);
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return getMinX(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return Math.max(livingParticipantBox1.getMaxX(stringBounder), livingParticipantBox2.getMaxX(stringBounder));
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return Math.min(livingParticipantBox1.getMinX(stringBounder), livingParticipantBox2.getMinX(stringBounder));
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java
new file mode 100644
index 0000000..eeb7a09
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+
+abstract class GroupingGraphicalElement extends GraphicalElement {
+
+ private final InGroupableList inGroupableList;
+
+ public GroupingGraphicalElement(double currentY, InGroupableList inGroupableList) {
+ super(currentY);
+ this.inGroupableList = inGroupableList;
+ if (inGroupableList == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ final public double getActualWidth(StringBounder stringBounder) {
+ return Math.max(getPreferredWidth(stringBounder), inGroupableList.getMaxX(stringBounder)
+ - inGroupableList.getMinX(stringBounder) + 2 * InGroupableList.MARGIN10);
+ }
+
+ @Override
+ final public double getStartingX(StringBounder stringBounder) {
+ return inGroupableList.getMinX(stringBounder) - InGroupableList.MARGIN10;
+ }
+
+ protected final InGroupableList getInGroupableList() {
+ return inGroupableList;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java
new file mode 100644
index 0000000..8a8531b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+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.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GroupingGraphicalElementElse extends GroupingGraphicalElement implements InGroupable {
+
+ private final Component compElse;
+ private final Lazy afterY;
+ private final boolean parallel;
+
+ public GroupingGraphicalElementElse(double startingY, Component compElse, InGroupableList inGroupableList,
+ boolean parallel, Lazy afterY) {
+ super(startingY, inGroupableList);
+ this.parallel = parallel;
+ this.compElse = compElse;
+ this.afterY = afterY;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = getInGroupableList().getMinX(stringBounder);
+ final double x2 = getInGroupableList().getMaxX(stringBounder);
+ ug = ug.apply(new UTranslate(x1, getStartingY()));
+
+ final double height = afterY.getNow() - getStartingY();
+ if (height <= 0) {
+ return;
+ }
+ final Dimension2D dim = new Dimension2DDouble(x2 - x1, height);
+
+ if (parallel == false) {
+ compElse.drawU(ug, new Area(dim), context);
+ }
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ if (parallel) {
+ return 0;
+ }
+ return compElse.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return compElse.getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getMinX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java
new file mode 100644
index 0000000..0b7bac4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+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.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GroupingGraphicalElementHeader extends GroupingGraphicalElement {
+
+ private final Component comp;
+ private double endY;
+ private final boolean isParallel;
+
+ public GroupingGraphicalElementHeader(double currentY, Component comp, InGroupableList inGroupableList, boolean isParallel) {
+ super(currentY, inGroupableList);
+ this.comp = comp;
+ this.isParallel = isParallel;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + (getInGroupableList() == null ? "no" : getInGroupableList().toString());
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder) + 5;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ if (isParallel) {
+ return;
+ }
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = getInGroupableList().getMinX(stringBounder);
+ final double x2 = getInGroupableList().getMaxX(stringBounder);
+ ug = ug.apply(new UTranslate(x1, getStartingY()));
+ double height = comp.getPreferredHeight(stringBounder);
+ if (endY > 0) {
+ height = endY - getStartingY();
+ } else {
+ // assert false;
+ return;
+ }
+ final Dimension2D dim = new Dimension2DDouble(x2 - x1, height);
+ comp.drawU(ug, new Area(dim), context);
+ }
+
+ public void setEndY(double y) {
+ this.endY = y;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java
new file mode 100644
index 0000000..017b0ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+class GroupingGraphicalElementTail extends GroupingGraphicalElement {
+
+ public GroupingGraphicalElementTail(double currentY, InGroupableList inGroupableList, boolean parallel) {
+ super(currentY, inGroupableList);
+ }
+
+ //
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java
new file mode 100644
index 0000000..bd34413
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+
+class InGroupablesStack {
+
+ final private List<InGroupableList> inGroupableStack = new ArrayList<InGroupableList>();
+
+ public void addList(InGroupableList inGroupableList) {
+ for (InGroupableList other : inGroupableStack) {
+ other.addInGroupable(inGroupableList);
+ }
+ inGroupableStack.add(inGroupableList);
+
+ }
+
+ public void pop() {
+ final int idx = inGroupableStack.size() - 1;
+ inGroupableStack.remove(idx);
+ }
+
+ public void addElement(InGroupable inGroupable) {
+ for (InGroupableList groupingStructure : inGroupableStack) {
+ groupingStructure.addInGroupable(inGroupable);
+ }
+ }
+
+ public InGroupableList getTopGroupingStructure() {
+ if (inGroupableStack.size() == 0) {
+ return null;
+ }
+ return inGroupableStack.get(inGroupableStack.size() - 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java
new file mode 100644
index 0000000..1010887
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+
+interface Lazy {
+ public double getNow();
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java
new file mode 100644
index 0000000..166dcbf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LifeDestroy extends GraphicalElement {
+
+ private final ParticipantBox participant;
+
+ private final Component comp;
+
+ public LifeDestroy(double startingY, ParticipantBox participant, Component comp) {
+ super(startingY);
+ this.participant = participant;
+ this.comp = comp;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), getStartingY()));
+ comp.drawU(ug, null, context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return participant.getCenterX(stringBounder) - getPreferredWidth(stringBounder) / 2.0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java
new file mode 100644
index 0000000..3401aa4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java
@@ -0,0 +1,242 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LifeLine {
+
+ static class Variation {
+ final private LifeSegmentVariation type;
+ final private HtmlColor backcolor;
+ final private double y;
+
+ Variation(LifeSegmentVariation type, double y, HtmlColor backcolor) {
+ this.type = type;
+ this.y = y;
+ this.backcolor = backcolor;
+ }
+
+ @Override
+ public String toString() {
+ return type + " " + y;
+ }
+ }
+
+ private final Pushable participant;
+ private final double nominalPreferredWidth;
+
+ private final List<Variation> events = new ArrayList<Variation>();
+ private final Stairs stairs = new Stairs();
+ private int maxLevel = 0;
+ private final boolean shadowing;
+
+ public LifeLine(Pushable participant, double nominalPreferredWidth, boolean shadowing) {
+ this.participant = participant;
+ this.nominalPreferredWidth = nominalPreferredWidth;
+ this.shadowing = shadowing;
+ }
+
+ public void addSegmentVariation(LifeSegmentVariation type, double y, HtmlColor backcolor) {
+ if (events.size() > 0) {
+ final Variation last = events.get(events.size() - 1);
+ if (y < last.y) {
+ return;
+ // throw new IllegalArgumentException();
+ }
+ if (y == last.y && type != last.type) {
+ return;
+ // throw new IllegalArgumentException();
+ }
+ }
+ events.add(new Variation(type, y, backcolor));
+ final int currentLevel = type.apply(stairs.getLastValue());
+ stairs.addStep(y, currentLevel);
+ assert getLevel(y) == stairs.getValue(y);
+ assert currentLevel == stairs.getValue(y);
+ assert getLevel(y) == currentLevel;
+ maxLevel = Math.max(getLevel(y), maxLevel);
+ }
+
+ public void finish(double y) {
+ final int missingClose = getMissingClose();
+ for (int i = 0; i < missingClose; i++) {
+ addSegmentVariation(LifeSegmentVariation.SMALLER, y, null);
+ }
+ }
+
+ int getMissingClose() {
+ int level = 0;
+ for (Variation ev : events) {
+ if (ev.type == LifeSegmentVariation.LARGER) {
+ level++;
+ } else {
+ level--;
+ }
+ }
+ return level;
+ }
+
+ int getLevel(double y) {
+ return stairs.getValue(y);
+ }
+
+ public int getMaxLevel() {
+ return maxLevel;
+ }
+
+ public double getRightShift(double y) {
+ return getRightShiftAtLevel(getLevel(y));
+ }
+
+ public double getLeftShift(double y) {
+ return getLeftShiftAtLevel(getLevel(y));
+ }
+
+ public double getMaxRightShift() {
+ return getRightShiftAtLevel(getMaxLevel());
+ }
+
+ public double getMaxLeftShift() {
+ return getLeftShiftAtLevel(getMaxLevel());
+ }
+
+ private double getRightShiftAtLevel(int level) {
+ if (level == 0) {
+ return 0;
+ }
+ return level * (nominalPreferredWidth / 2.0);
+ }
+
+ private double getLeftShiftAtLevel(int level) {
+ if (level == 0) {
+ return 0;
+ }
+ return nominalPreferredWidth / 2.0;
+ }
+
+ private double getStartingX(StringBounder stringBounder) {
+ final double delta = participant.getCenterX(stringBounder) - nominalPreferredWidth / 2.0;
+ return delta;
+ }
+
+ private SegmentColored getSegment(int i) {
+ if (events.get(i).type != LifeSegmentVariation.LARGER) {
+ return null;
+ }
+ int level = 1;
+ for (int j = i + 1; j < events.size(); j++) {
+ if (events.get(j).type == LifeSegmentVariation.LARGER) {
+ level++;
+ } else {
+ level--;
+ }
+ if (level == 0) {
+ final double y1 = events.get(i).y;
+ final double y2 = events.get(j).y;
+ return new SegmentColored(y1, y2, events.get(i).backcolor, shadowing);
+ }
+ }
+ return new SegmentColored(events.get(i).y, events.get(events.size() - 1).y, events.get(i).backcolor, shadowing);
+ }
+
+ private Collection<SegmentColored> getSegmentsCutted(StringBounder stringBounder, int i) {
+ final SegmentColored seg = getSegment(i);
+ if (seg != null) {
+ return seg.cutSegmentIfNeed(participant.getDelays(stringBounder));
+ }
+ return Collections.emptyList();
+ }
+
+ public void drawU(UGraphic ug, Skin skin, ISkinParam skinParam) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), 0));
+
+ for (int i = 0; i < events.size(); i++) {
+ ComponentType type = ComponentType.ALIVE_BOX_CLOSE_OPEN;
+ for (final Iterator<SegmentColored> it = getSegmentsCutted(stringBounder, i).iterator(); it.hasNext();) {
+ final SegmentColored seg = it.next();
+ final ISkinParam skinParam2 = new SkinParamBackcolored(skinParam, seg.getSpecificBackColor());
+ if (it.hasNext() == false) {
+ type = type == ComponentType.ALIVE_BOX_CLOSE_OPEN ? ComponentType.ALIVE_BOX_CLOSE_CLOSE
+ : ComponentType.ALIVE_BOX_OPEN_CLOSE;
+ }
+ final Component compAliveBox = skin.createComponent(type, null, skinParam2, null);
+ type = ComponentType.ALIVE_BOX_OPEN_OPEN;
+ final int currentLevel = getLevel(seg.getPos1Initial());
+ seg.drawU(ug, compAliveBox, currentLevel);
+ }
+ }
+ }
+
+ private double create = 0;
+
+ // private double destroy = 0;
+
+ public final void setCreate(double create) {
+ this.create = create;
+ }
+
+ public final double getCreate() {
+ return create;
+ }
+
+ public final double getDestroy() {
+ return 0;
+ }
+
+ // public final void setDestroy(double destroy) {
+ // this.destroy = destroy;
+ // }
+
+ public final boolean shadowing() {
+ return shadowing;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java
new file mode 100644
index 0000000..aaa9ce6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+public enum LifeSegmentVariation {
+ LARGER, SMALLER;
+
+ public int apply(int v) {
+ if (this == LARGER) {
+ return v + 1;
+ }
+ assert this == SMALLER;
+ if (v == 0) {
+ return 0;
+ }
+ return v - 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java
new file mode 100644
index 0000000..322f116
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java
@@ -0,0 +1,122 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class LivingParticipantBox implements InGroupable {
+
+ private final ParticipantBox participantBox;
+ private final LifeLine lifeLine;
+
+ public LivingParticipantBox(ParticipantBox participantBox, LifeLine lifeLine) {
+ this.participantBox = participantBox;
+ this.lifeLine = lifeLine;
+ }
+
+ /**
+ * @deprecated a virer
+ */
+ public ParticipantBox getParticipantBox() {
+ return participantBox;
+ }
+
+ /**
+ * @deprecated a virer
+ */
+ public LifeLine getLifeLine() {
+ return lifeLine;
+ }
+
+ public SegmentColored getLiveThicknessAt(StringBounder stringBounder, double y) {
+ final double left = lifeLine.getLeftShift(y);
+ assert left >= 0;
+ final double right = lifeLine.getRightShift(y);
+ assert right >= 0 : "right=" + right;
+ final double centerX = participantBox.getCenterX(stringBounder);
+ // Log.println("AZERTY " + y + " centerX=" + centerX + " left=" + left + " right=" + right);
+ // Log.println("Attention, null for segment");
+ return new SegmentColored(centerX - left, centerX + right, null, lifeLine.shadowing());
+ }
+
+ public void drawLineUTOBEREMOVED_4243(UGraphic ug, double startingY, double endingY, boolean showTail, double myDelta) {
+ if (endingY <= startingY) {
+ return;
+ }
+ final double destroy = lifeLine.getDestroy();
+ if (destroy != 0 && destroy > startingY && destroy < endingY) {
+ endingY = destroy;
+ }
+ participantBox.drawLineUTOBEREMOVED_4243(ug, startingY, endingY, showTail, myDelta);
+ }
+
+ public void drawLineU22(UGraphic ug, double startingY, double endingY, boolean showTail, double myDelta) {
+ if (endingY <= startingY) {
+ return;
+ }
+ final double destroy = lifeLine.getDestroy();
+ if (destroy != 0 && destroy > startingY && destroy < endingY) {
+ endingY = destroy;
+ }
+ participantBox.drawLineU22(ug, startingY, endingY, showTail, myDelta);
+ }
+
+ public double magicMargin(StringBounder stringBounder) {
+ return participantBox.magicMargin(stringBounder);
+ }
+
+ public void create(double ypos) {
+ lifeLine.setCreate(ypos);
+ }
+
+ public double getCreate() {
+ return lifeLine.getCreate();
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return participantBox.getMaxX(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return participantBox.getStartingX();
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java
new file mode 100644
index 0000000..73a9774
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java
@@ -0,0 +1,190 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class MessageArrow extends Arrow {
+
+ private final LivingParticipantBox p1;
+ private final LivingParticipantBox p2;
+ private final Component compAliveBox;
+
+ public MessageArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p1, LivingParticipantBox p2,
+ Url url, Component compAliveBox) {
+ super(startingY, skin, arrow, url);
+
+ if (p1 == p2) {
+ throw new IllegalArgumentException();
+ }
+ if (p1 == null || p2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.p1 = p1;
+ this.p2 = p2;
+ this.compAliveBox = compAliveBox;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ final double r = getRightEndInternal(stringBounder) - getLeftStartInternal(stringBounder);
+ assert r > 0;
+ return r;
+ }
+
+ private double getLeftStartInternal(StringBounder stringBounder) {
+ return getParticipantAt(stringBounder, NotePosition.LEFT)
+ .getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2();
+ }
+
+ private double getRightEndInternalOld(StringBounder stringBounder) {
+ return getParticipantAt(stringBounder, NotePosition.RIGHT).getLiveThicknessAt(stringBounder,
+ getArrowYStartLevel(stringBounder)).getSegment().getPos1();
+ }
+
+
+ private double getRightEndInternal(StringBounder stringBounder) {
+ final Segment segment = getParticipantAt(stringBounder, NotePosition.RIGHT).getLiveThicknessAt(stringBounder,
+ getArrowYStartLevel(stringBounder)).getSegment();
+ if (segment.getLength() == 0) {
+ return segment.getPos1();
+ }
+ final double rectWidth = compAliveBox.getPreferredWidth(stringBounder);
+ return segment.getPos2() - rectWidth;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ final double x1 = p1.getParticipantBox().getCenterX(stringBounder);
+ final double x2 = p2.getParticipantBox().getCenterX(stringBounder);
+ if (x1 < x2) {
+ return 1;
+ }
+ return -1;
+ }
+
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ final int direction = getDirection(stringBounder);
+ if (direction == 1 && position == NotePosition.RIGHT) {
+ return p2;
+ }
+ if (direction == 1 && position == NotePosition.LEFT) {
+ return p1;
+ }
+ if (direction == -1 && position == NotePosition.RIGHT) {
+ return p1;
+ }
+ if (direction == -1 && position == NotePosition.LEFT) {
+ return p2;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), getStartingY()));
+ startUrl(ug);
+ getArrowComponent().drawU(ug, new Area(getActualDimension(stringBounder)), context);
+ endUrl(ug);
+ }
+
+ private Dimension2D getActualDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(getActualWidth(stringBounder) - getPaddingArrowHead(), getArrowComponent()
+ .getPreferredHeight(stringBounder));
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
+ }
+ return getStartingY();
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();
+ }
+ return getStartingY() + getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getRightEndInternal(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return getMinX(stringBounder) + "-" + getMaxX(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java
new file mode 100644
index 0000000..18d500f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java
@@ -0,0 +1,210 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseArrow;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class MessageExoArrow extends Arrow {
+
+ private final LivingParticipantBox p;
+ private final MessageExoType type;
+ private final boolean shortArrow;
+ private final ArrowConfiguration arrowConfiguration;
+
+ public MessageExoArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p, MessageExoType type,
+ Url url, boolean shortArrow, ArrowConfiguration arrowConfiguration) {
+ super(startingY, skin, arrow, url);
+ this.p = p;
+ this.type = type;
+ this.shortArrow = shortArrow;
+ this.arrowConfiguration = arrowConfiguration;
+ }
+
+ double getActualWidth(StringBounder stringBounder, double maxX) {
+ final double r = getRightEndInternal(stringBounder, maxX) - getLeftStartInternal(stringBounder);
+ assert r > 0;
+ return r;
+ }
+
+ private double getLeftStartInternal(StringBounder stringBounder) {
+ if (type == MessageExoType.FROM_LEFT || type == MessageExoType.TO_LEFT) {
+ if (shortArrow) {
+ return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2()
+ - getPreferredWidth(stringBounder);
+ } else {
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_LEFT) {
+ return ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_LEFT) {
+ return ComponentRoseArrow.diamCircle;
+ }
+ return 0;
+ }
+ }
+ return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2();
+ }
+
+ private double getRightEndInternal(StringBounder stringBounder, double maxX) {
+ if (type == MessageExoType.FROM_LEFT || type == MessageExoType.TO_LEFT) {
+ return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos1();
+ }
+ if (shortArrow) {
+ return getLeftStartInternal(stringBounder) + getPreferredWidth(stringBounder);
+ }
+ double result = Math.max(maxX, getLeftStartInternal(stringBounder) + getPreferredWidth(stringBounder));
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_RIGHT) {
+ result -= ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_RIGHT) {
+ result -= ComponentRoseArrow.diamCircle;
+ }
+ return result;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return type.getDirection();
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ double result = getArrowComponent().getPreferredWidth(stringBounder);
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_RIGHT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_RIGHT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_LEFT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_LEFT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = getStartingX(stringBounder);
+ final double x2 = maxX;
+ ug = ug.apply(new UTranslate(x1, getStartingY()));
+ startUrl(ug);
+ getArrowComponent().drawU(ug, new Area(getActualDimension(stringBounder, x2)), context);
+ endUrl(ug);
+ }
+
+ private Dimension2D getActualDimension(StringBounder stringBounder, double maxX) {
+ return new Dimension2DDouble(getActualWidth(stringBounder, maxX), getArrowComponent().getPreferredHeight(
+ stringBounder));
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
+ }
+ return getStartingY();
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();
+ }
+ return getStartingY() + getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getRightEndInternal(stringBounder, 0);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return getMinX(stringBounder) + "-" + getMaxX(stringBounder);
+ }
+
+ public final MessageExoType getType() {
+ return type;
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return p;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return getActualWidth(stringBounder, getMaxX());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java
new file mode 100644
index 0000000..6b92ece
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java
@@ -0,0 +1,147 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class MessageSelfArrow extends Arrow {
+
+ private final LivingParticipantBox p1;
+ private final double deltaX;
+ private final double deltaY;
+
+ public MessageSelfArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p1, double deltaY,
+ Url url, double deltaX) {
+ super(startingY, skin, arrow, url);
+ this.p1 = p1;
+ this.deltaY = deltaY;
+ this.deltaX = deltaX;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), getStartingY() + deltaY));
+ final Area area = new Area(new Dimension2DDouble(getPreferredWidth(stringBounder),
+ getPreferredHeight(stringBounder)));
+ area.setDeltaX1(deltaY);
+ startUrl(ug);
+ getArrowComponent().drawU(ug, area, context);
+ endUrl(ug);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ // if (OptionFlags.STRICT_SELFMESSAGE_POSITION) {
+ // final double pos1 = p1.getLiveThicknessAt(stringBounder, getArrowYEndLevel(stringBounder)).getSegment()
+ // .getPos2();
+ // return pos1;
+ // }
+ final double pos2 = p1.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment()
+ .getPos2();
+ return pos2 + deltaX;
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return 1;
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
+ }
+ return getStartingY();
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();
+ }
+ return getStartingY() + getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getStartingX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return super.toString();
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return p1;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return getPreferredWidth(stringBounder);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java
new file mode 100644
index 0000000..ca08c3d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+final class NoteBox extends GraphicalElement implements InGroupable {
+
+ private final NotePosition position;
+ private final Url url;
+
+ private final LivingParticipantBox p1;
+ private final LivingParticipantBox p2;
+
+ private final Component comp;
+
+ private double delta = 0;
+
+ public NoteBox(double startingY, Component comp, LivingParticipantBox p1, LivingParticipantBox p2,
+ NotePosition position, Url url) {
+ super(startingY);
+ if (p1 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (p2 != null ^ position == NotePosition.OVER_SEVERAL) {
+ throw new IllegalArgumentException();
+ }
+ this.p1 = p1;
+ this.p2 = p2;
+ this.position = position;
+ this.url = url;
+ this.comp = comp;
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double preferredWidth = comp.getPreferredWidth(stringBounder);
+ if (position == NotePosition.OVER_SEVERAL) {
+ assert p1 != p2;
+ final double diff1 = p2.getParticipantBox().getMaxX(stringBounder) - p1.getParticipantBox().getMinX();
+ if (diff1 > preferredWidth) {
+ return diff1;
+ }
+
+ }
+ return preferredWidth;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double xStart = getStartingX(stringBounder);
+ ug = ug.apply(new UTranslate(xStart, getStartingY()));
+ final Dimension2D dimensionToUse = new Dimension2DDouble(getPreferredWidth(stringBounder), comp
+ .getPreferredHeight(stringBounder));
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ comp.drawU(ug, new Area(dimensionToUse), context);
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ final SegmentColored segment = getSegment(stringBounder);
+ final int xStart;
+ if (position == NotePosition.LEFT) {
+ xStart = (int) (segment.getSegment().getPos1() - getPreferredWidth(stringBounder));
+ } else if (position == NotePosition.RIGHT) {
+ xStart = (int) (segment.getSegment().getPos2());
+ } else if (position == NotePosition.OVER) {
+ xStart = (int) (p1.getParticipantBox().getCenterX(stringBounder) - getPreferredWidth(stringBounder) / 2);
+ } else if (position == NotePosition.OVER_SEVERAL) {
+ final double centre = (p1.getParticipantBox().getCenterX(stringBounder) + p2.getParticipantBox()
+ .getCenterX(stringBounder)) / 2.0;
+ xStart = (int) (centre - getPreferredWidth(stringBounder) / 2.0);
+ } else {
+ throw new IllegalStateException();
+ }
+ return xStart + delta;
+ }
+
+ private SegmentColored getSegment(StringBounder stringBounder) {
+ final SegmentColored segment = p1.getLiveThicknessAt(stringBounder, getStartingY());
+ final SegmentColored segment2 = p1.getLiveThicknessAt(stringBounder, getStartingY()
+ + comp.getPreferredHeight(stringBounder));
+ return segment.merge(segment2);
+ }
+
+ public void pushToRight(double x) {
+ this.delta += x;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getStartingX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+ public final Url getUrl() {
+ return url;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java
new file mode 100644
index 0000000..1800e36
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java
@@ -0,0 +1,149 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+final class NotesBoxes extends GraphicalElement implements InGroupable {
+
+ private final List<NoteBox> notes = new ArrayList<NoteBox>();
+ private final List<ParticipantBox> participants1 = new ArrayList<ParticipantBox>();
+ private final List<ParticipantBox> participants2 = new ArrayList<ParticipantBox>();
+
+ NotesBoxes(double startingY) {
+ super(startingY);
+ }
+
+ public void add(NoteBox noteBox, ParticipantBox participantBox1, ParticipantBox participantBox2) {
+ notes.add(noteBox);
+ participants1.add(participantBox1);
+ if (participantBox2 == null) {
+ participants2.add(participantBox1);
+ } else {
+ participants2.add(participantBox2);
+ }
+ }
+
+ public void ensureConstraints(StringBounder stringBounder, ConstraintSet constraintSet) {
+ for (int i = 0; i < notes.size(); i++) {
+ final NoteBox noteBox = notes.get(i);
+ final ParticipantBox participantBox1 = participants1.get(i);
+ final ParticipantBox participantBox2 = participants2.get(i);
+ final double width = noteBox.getPreferredWidth(stringBounder);
+ // System.err.println("i=" + i);
+ // System.err.println("width=" + width);
+ // System.err.println("participantBox1=" + participantBox1);
+ // System.err.println("participantBox2=" + participantBox2);
+ constraintSet.getConstraintBefore(participantBox1).ensureValue(width / 2);
+ constraintSet.getConstraintAfter(participantBox2).ensureValue(width / 2);
+ for (int j = i + 1; j < notes.size(); j++) {
+ final NoteBox noteBox2 = notes.get(j);
+ final ParticipantBox otherParticipantBox1 = participants1.get(j);
+ final double width2 = noteBox2.getPreferredWidth(stringBounder);
+ constraintSet.getConstraint(participantBox2, otherParticipantBox1).ensureValue((width + width2) / 2);
+ }
+ }
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ double result = Double.MAX_VALUE;
+ for (NoteBox n : notes) {
+ final double m = n.getMinX(stringBounder);
+ if (m < result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ double result = -Double.MAX_VALUE;
+ for (NoteBox n : notes) {
+ final double m = n.getMaxX(stringBounder);
+ if (m > result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ for (NoteBox n : notes) {
+ n.drawInternalU(ug, maxX, context);
+ }
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ double result = Double.MAX_VALUE;
+ for (NoteBox n : notes) {
+ final double m = n.getStartingX(stringBounder);
+ if (m < result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final double result = getMaxX(stringBounder) - getMinX(stringBounder);
+ return result;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ double result = 0;
+ for (NoteBox n : notes) {
+ final double m = n.getPreferredHeight(stringBounder);
+ if (m > result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java
new file mode 100644
index 0000000..dcaba0a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java
@@ -0,0 +1,122 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public final class Page {
+
+ private final double headerHeight;
+ private final double newpage1;
+ private final double newpage2;
+ private final double tailHeight;
+ private final double signatureHeight;
+ private final Display title;
+
+ @Override
+ public String toString() {
+ return "headerHeight=" + headerHeight + " newpage1=" + newpage1 + " newpage2=" + newpage2;
+ }
+
+ public Page(double headerHeight, double newpage1, double newpage2, double tailHeight,
+ double signatureHeight, Display title) {
+ if (headerHeight < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (tailHeight < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (signatureHeight < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (newpage1 > newpage2) {
+ throw new IllegalArgumentException();
+ }
+ this.headerHeight = headerHeight;
+ this.newpage1 = newpage1;
+ this.newpage2 = newpage2;
+ this.tailHeight = tailHeight;
+ this.signatureHeight = signatureHeight;
+ this.title = title;
+ }
+
+ public double getHeight() {
+ return headerHeight + getBodyHeight() + tailHeight + signatureHeight;
+ }
+
+ public double getHeaderRelativePosition() {
+ return 0;
+ }
+
+ public double getBodyRelativePosition() {
+ return getHeaderRelativePosition() + headerHeight;
+ }
+
+ public double getBodyHeight() {
+ return newpage2 - newpage1;
+ }
+
+ public double getTailRelativePosition() {
+ return getBodyRelativePosition() + getBodyHeight();
+ }
+
+ public double getSignatureRelativePosition() {
+ if (displaySignature() == false) {
+ return -1;
+ }
+ return getTailRelativePosition() + tailHeight;
+ }
+
+ public boolean displaySignature() {
+ return signatureHeight > 0;
+ }
+
+ public double getNewpage1() {
+ return newpage1;
+ }
+
+ public double getNewpage2() {
+ return newpage2;
+ }
+
+ public double getHeaderHeight() {
+ return headerHeight;
+ }
+
+ public final Display getTitle() {
+ return title;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java
new file mode 100644
index 0000000..83488e3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.Newpage;
+
+class PageSplitter {
+
+ private final double fullHeight;
+ private final List<Double> positions;
+ private final List<Display> titles;
+ private final double headerHeight;
+ private final double tailHeight;
+ private final double signatureHeight;
+ private final double newpageHeight;
+ private final Display diagramTitle;
+
+ PageSplitter(double fullHeight, double headerHeight, Map<Newpage, Double> newpages, double tailHeight,
+ double signatureHeight, double newpageHeight, Display diagramTitle) {
+ this.fullHeight = fullHeight;
+ this.diagramTitle = diagramTitle;
+ this.titles = new ArrayList<Display>();
+ this.positions = new ArrayList<Double>();
+
+ for (Map.Entry<Newpage, Double> ent : newpages.entrySet()) {
+ titles.add(ent.getKey().getTitle());
+ positions.add(ent.getValue());
+ }
+
+ this.headerHeight = headerHeight;
+ this.tailHeight = tailHeight;
+ this.signatureHeight = signatureHeight;
+ this.newpageHeight = newpageHeight;
+ }
+
+ public List<Page> getPages() {
+
+ if (positions.size() == 0) {
+ return Arrays.asList(onePage());
+ }
+ final List<Page> result = new ArrayList<Page>();
+
+ result.add(firstPage());
+ for (int i = 0; i < positions.size() - 1; i++) {
+ result.add(createPage(i));
+ }
+ result.add(lastPage());
+
+ return result;
+ }
+
+ private Page lastPage() {
+ final double newpage1 = positions.get(positions.size() - 1) - this.newpageHeight;
+ final double newpage2 = this.fullHeight - this.tailHeight - this.signatureHeight;
+ final Display title = titles.get(positions.size() - 1);
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, signatureHeight, title);
+ }
+
+ private Page firstPage() {
+ final double newpage1 = this.headerHeight;
+ final double newpage2 = positions.get(0) + this.newpageHeight;
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, 0, diagramTitle);
+ }
+
+ private Page onePage() {
+ final double newpage1 = this.headerHeight;
+ final double newpage2 = this.fullHeight - this.tailHeight - this.signatureHeight;
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, signatureHeight, diagramTitle);
+ }
+
+ private Page createPage(int i) {
+ final double newpage1 = positions.get(i) - this.newpageHeight;
+ final double newpage2 = positions.get(i + 1) + this.newpageHeight;
+ final Display title = titles.get(i);
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, 0, title);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java
new file mode 100644
index 0000000..3fa95f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java
@@ -0,0 +1,255 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.AbstractCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ParticipantBox implements Pushable {
+
+ private static int CPT = 0;
+
+ private final int outMargin = 5;
+
+ private double startingX;
+
+ 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, Component delayLine, double startingX) {
+ this.startingX = startingX;
+ this.head = head;
+ this.line = line;
+ this.tail = tail;
+ this.delayLine = delayLine;
+ }
+
+ @Override
+ public String toString() {
+ return "PB" + cpt;
+ }
+
+ public double getMinX() {
+ return startingX + outMargin;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return startingX + head.getPreferredWidth(stringBounder) + 2 * outMargin;
+ }
+
+ public double getCenterX(StringBounder stringBounder) {
+ return startingX + head.getPreferredWidth(stringBounder) / 2.0 + outMargin;
+ }
+
+ public double getHeadHeight(StringBounder stringBounder) {
+ return head.getPreferredHeight(stringBounder) + line.getPreferredHeight(stringBounder) / 2.0;
+ }
+
+ public double getHeadHeightOnly(StringBounder stringBounder) {
+ return head.getPreferredHeight(stringBounder);
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return head.getPreferredWidth(stringBounder);
+ }
+
+ public double getTailHeight(StringBounder stringBounder) {
+ return tail.getPreferredHeight(stringBounder) + line.getPreferredHeight(stringBounder) / 2.0;
+ }
+
+ public void pushToLeft(double deltaX) {
+ startingX += deltaX;
+ }
+
+ public void drawHeadTailU(UGraphic ug, double topStartingY, boolean showHead, double positionTail) {
+ if (topStartingY == 0) {
+ throw new IllegalStateException("setTopStartingY cannot be zero");
+ }
+
+ // final double atX = ug.getTranslateX();
+ // final double atY = ug.getTranslateY();
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ if (showHead) {
+ final double y1 = topStartingY - head.getPreferredHeight(stringBounder)
+ - line.getPreferredHeight(stringBounder) / 2;
+ head.drawU(
+ ug.apply(new UTranslate(getMinX(), y1)),
+ new Area(new Dimension2DDouble(head.getPreferredWidth(stringBounder), head
+ .getPreferredHeight(stringBounder))), new SimpleContext2D(false));
+ // ug.setTranslate(atX, atY);
+ }
+
+ if (positionTail > 0) {
+ // final double y2 = positionTail - topStartingY +
+ // line.getPreferredHeight(stringBounder) / 2 - 1;
+ positionTail += line.getPreferredHeight(stringBounder) / 2 - 1;
+ // if (y2 != y22) {
+ // throw new IllegalStateException();
+ // }
+ ug = ug.apply(new UTranslate(getMinX(), positionTail));
+ tail.drawU(
+ ug,
+ new Area(new Dimension2DDouble(tail.getPreferredWidth(stringBounder), tail
+ .getPreferredHeight(stringBounder))), new SimpleContext2D(false));
+ // ug.setTranslate(atX, atY);
+ }
+ }
+
+ public void drawParticipantHead(UGraphic ug) {
+ // ug.translate(outMargin, 0);
+ final StringBounder stringBounder = ug.getStringBounder();
+ head.drawU(
+ ug.apply(new UTranslate(outMargin, 0)),
+ new Area(new Dimension2DDouble(head.getPreferredWidth(stringBounder), head
+ .getPreferredHeight(stringBounder))), new SimpleContext2D(false));
+ // ug.translate(-outMargin, 0);
+ }
+
+ public void drawLineUTOBEREMOVED_4243(UGraphic ug, double startingY, double endingY, boolean showTail, double myDelta) {
+ throw new UnsupportedOperationException();
+// ug = ug.apply(new UTranslate(startingX, 0));
+// if (delays.size() > 0) {
+// final StringBounder stringBounder = ug.getStringBounder();
+// for (GraphicalDelayText delay : delays) {
+// if (delay.getStartingY() - myDelta >= startingY) {
+// drawLine(ug, startingY, delay.getStartingY() - myDelta, line);
+// drawLine(ug, delay.getStartingY() - myDelta, delay.getEndingY(stringBounder) - myDelta, delayLine);
+// startingY = delay.getEndingY(stringBounder) - myDelta;
+// }
+// }
+// if (delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta > startingY) {
+// startingY = delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta;
+// }
+// }
+// drawLine(ug, startingY, endingY, line);
+ }
+
+ public void drawLineU22(UGraphic ug, double startingY, final double endingY, boolean showTail, double myDelta) {
+ ug = ug.apply(new UTranslate(startingX, 0));
+ if (delays.size() > 0) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (GraphicalDelayText delay : delays) {
+ if (delay.getStartingY() - myDelta >= startingY) {
+ drawLineIfLowerThan(ug, startingY, delay.getStartingY() - myDelta, line, endingY);
+ drawLineIfLowerThan(ug, delay.getStartingY() - myDelta, delay.getEndingY(stringBounder) - myDelta,
+ delayLine, endingY);
+ startingY = delay.getEndingY(stringBounder) - myDelta;
+ }
+ }
+ if (delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta > startingY) {
+ startingY = delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta;
+ }
+ }
+ drawLineIfLowerThan(ug, startingY, endingY, line, endingY);
+ }
+
+ private void drawLineIfLowerThan(UGraphic ug, double startingY, double endingY, Component comp, double limitY) {
+ startingY = Math.min(startingY, limitY);
+ endingY = Math.min(endingY, limitY);
+ if (startingY < limitY || endingY < limitY) {
+ drawLine(ug, startingY, endingY, comp);
+ }
+
+ }
+
+ private void drawLine(UGraphic ug, double startingY, double endingY, Component comp) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ comp.drawU(ug.apply(new UTranslate(0, startingY)),
+ new Area(new Dimension2DDouble(head.getPreferredWidth(stringBounder) + outMargin * 2, endingY
+ - startingY)), new SimpleContext2D(false));
+ }
+
+ public double magicMargin(StringBounder stringBounder) {
+ return line.getPreferredHeight(stringBounder) / 2;
+ }
+
+ public double getStartingX() {
+ return startingX;
+ }
+
+ private final List<GraphicalDelayText> delays = new ArrayList<GraphicalDelayText>();
+
+ public void addDelay(GraphicalDelayText delay) {
+ this.delays.add(delay);
+ }
+
+ public Collection<Segment> getDelays(final StringBounder stringBounder) {
+ return new AbstractCollection<Segment>() {
+
+ @Override
+ public Iterator<Segment> iterator() {
+ return new Iterator<Segment>() {
+
+ private final Iterator<GraphicalDelayText> it = delays.iterator();
+
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ public Segment next() {
+ final GraphicalDelayText d = it.next();
+ return new Segment(d.getStartingY(), d.getEndingY(stringBounder));
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ @Override
+ public int size() {
+ return delays.size();
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java
new file mode 100644
index 0000000..c16f259
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class ParticipantBoxSimple implements Pushable {
+
+ private double pos = 0;
+ private final String name;
+
+ public ParticipantBoxSimple(double pos) {
+ this(pos, null);
+ }
+
+ public ParticipantBoxSimple(double pos, String name) {
+ this.pos = pos;
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name == null ? super.toString() : name;
+ }
+
+ public double getCenterX(StringBounder stringBounder) {
+ return pos;
+ }
+
+ public void pushToLeft(double deltaX) {
+ pos += deltaX;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public Collection<Segment> getDelays(StringBounder stringBounder) {
+ return Collections.emptyList();
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java
new file mode 100644
index 0000000..e76233d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+class ParticipantRange {
+
+ private final int start;
+ private final int end;
+
+ public ParticipantRange(int start, int end) {
+ if (start > end) {
+ throw new IllegalArgumentException();
+ }
+ this.start = start;
+ this.end = end;
+ }
+
+ public int start() {
+ return start;
+ }
+
+ public int end() {
+ return end;
+ }
+
+ public ParticipantRange merge(ParticipantRange other) {
+ return new ParticipantRange(this.start, other.end);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java
new file mode 100644
index 0000000..e2fbff3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.Collection;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface Pushable {
+
+ double getPreferredWidth(StringBounder stringBounder);
+
+ double getCenterX(StringBounder stringBounder);
+
+ void pushToLeft(double deltaX);
+
+ public Collection<Segment> getDelays(StringBounder stringBounder);
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java
new file mode 100644
index 0000000..27ec32d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class Segment {
+
+ final private double pos1;
+ final private double pos2;
+
+ Segment(double pos1, double pos2) {
+ this.pos1 = pos1;
+ this.pos2 = pos2;
+ if (pos2 < pos1) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Segment this2 = (Segment) obj;
+ return pos1 == this2.pos1 && pos2 == this2.pos2;
+ }
+
+ @Override
+ public int hashCode() {
+ return new Double(pos1).hashCode() + new Double(pos2).hashCode();
+ }
+
+ final public boolean contains(double y) {
+ return y >= pos1 && y <= pos2;
+ }
+
+ final public boolean contains(Segment other) {
+ return contains(other.pos1) && contains(other.pos2);
+ }
+
+ @Override
+ public String toString() {
+ return "" + pos1 + " - " + pos2;
+ }
+
+ final public double getLength() {
+ return pos2 - pos1;
+ }
+
+ final public double getPos1() {
+ return pos1;
+ }
+
+ final public double getPos2() {
+ return pos2;
+ }
+
+ public Segment merge(Segment this2) {
+ return new Segment(Math.min(this.pos1, this2.pos1), Math.max(this.pos2, this2.pos2));
+ }
+
+ public Collection<Segment> cutSegmentIfNeed(Collection<Segment> allDelays) {
+ final List<Segment> sortedDelay = new ArrayList<Segment>(allDelays);
+ Collections.sort(sortedDelay, new SortPos1());
+ final List<Segment> result2 = new ArrayList<Segment>();
+ double pendingStart = pos1;
+ for (Segment d : sortedDelay) {
+ if (d.pos1 <= pendingStart) {
+ continue;
+ }
+ if (d.pos1 > this.pos2) {
+ result2.add(new Segment(pendingStart, this.pos2));
+ return Collections.unmodifiableCollection(result2);
+ }
+ if (this.contains(d) == false) {
+ throw new IllegalStateException();
+ }
+ result2.add(new Segment(pendingStart, d.pos1));
+ pendingStart = d.pos2;
+ }
+ result2.add(new Segment(pendingStart, this.pos2));
+ return Collections.unmodifiableCollection(result2);
+ }
+
+ static class SortPos1 implements Comparator<Segment> {
+ public int compare(Segment segA, Segment segB) {
+ return (int) Math.signum(segA.pos1 - segB.pos1);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java
new file mode 100644
index 0000000..341aad9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class SegmentColored {
+
+ final private Segment segment;
+ final private HtmlColor backcolor;
+ final private boolean shadowing;
+ final private double pos1Initial;
+
+ SegmentColored(double pos1, double pos2, HtmlColor backcolor, boolean shadowing) {
+ this(new Segment(pos1, pos2), backcolor, shadowing, pos1);
+ }
+
+ private SegmentColored(Segment segment, HtmlColor backcolor, boolean shadowing, double pos1Initial) {
+ this.segment = segment;
+ this.backcolor = backcolor;
+ this.shadowing = shadowing;
+ this.pos1Initial = pos1Initial;
+ }
+
+ public HtmlColor getSpecificBackColor() {
+ return backcolor;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final SegmentColored this2 = (SegmentColored) obj;
+ return this.segment.equals(this2.segment);
+ }
+
+ @Override
+ public int hashCode() {
+ return this.segment.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return this.segment.toString();
+ }
+
+ public void drawU(UGraphic ug, Component compAliveBox, int level) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate((level - 1) * compAliveBox.getPreferredWidth(stringBounder) / 2, segment.getPos1()));
+ final Dimension2D dim = new Dimension2DDouble(compAliveBox.getPreferredWidth(stringBounder), segment.getPos2()
+ - segment.getPos1());
+ compAliveBox.drawU(ug, new Area(dim), new SimpleContext2D(false));
+ }
+
+ public Collection<SegmentColored> cutSegmentIfNeed(Collection<Segment> allDelays) {
+ return new Coll2(segment.cutSegmentIfNeed(allDelays), segment.getPos1());
+ }
+
+ public double getPos1Initial() {
+ return pos1Initial;
+ }
+
+ public SegmentColored merge(SegmentColored this2) {
+ final Segment merge = this.segment.merge(this2.segment);
+ return new SegmentColored(merge, backcolor, shadowing, merge.getPos1());
+ }
+
+ public final Segment getSegment() {
+ return segment;
+ }
+
+ class Iterator2 implements Iterator<SegmentColored> {
+
+ private final Iterator<Segment> it;
+ private final double pos1Initial;
+
+ public Iterator2(Iterator<Segment> it, double pos1Initial) {
+ this.it = it;
+ this.pos1Initial = pos1Initial;
+ }
+
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ public SegmentColored next() {
+ return new SegmentColored(it.next(), backcolor, shadowing, pos1Initial);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ class Coll2 extends AbstractCollection<SegmentColored> {
+
+ private final Collection<Segment> col;
+ private final double pos1Initial;
+
+ public Coll2(Collection<Segment> col, double pos1Initial) {
+ this.col = col;
+ this.pos1Initial = pos1Initial;
+ }
+
+ @Override
+ public Iterator<SegmentColored> iterator() {
+ return new Iterator2(col.iterator(), pos1Initial);
+ }
+
+ @Override
+ public int size() {
+ return col.size();
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java
new file mode 100644
index 0000000..abcc008
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class SequenceDiagramArea {
+
+ private final double sequenceWidth;
+ private final double sequenceHeight;
+
+ private double headerWidth;
+ private double headerHeight;
+ private double headerMargin;
+
+ private double titleWidth;
+ private double titleHeight;
+
+ private double footerWidth;
+ private double footerHeight;
+ private double footerMargin;
+
+ public SequenceDiagramArea(double width, double height) {
+ this.sequenceWidth = width;
+ this.sequenceHeight = height;
+ }
+
+ public void setTitleArea(double titleWidth, double titleHeight) {
+ this.titleWidth = titleWidth;
+ this.titleHeight = titleHeight;
+ }
+
+ public void setHeaderArea(double headerWidth, double headerHeight, double headerMargin) {
+ this.headerWidth = headerWidth;
+ this.headerHeight = headerHeight;
+ this.headerMargin = headerMargin;
+ }
+
+ public void setFooterArea(double footerWidth, double footerHeight, double footerMargin) {
+ this.footerWidth = footerWidth;
+ this.footerHeight = footerHeight;
+ this.footerMargin = footerMargin;
+ }
+
+ public double getWidth() {
+ double result = sequenceWidth;
+ if (headerWidth > result) {
+ result = headerWidth;
+ }
+ if (titleWidth > result) {
+ result = titleWidth;
+ }
+ if (footerWidth > result) {
+ result = footerWidth;
+ }
+ return result;
+ }
+
+ public double getHeight() {
+ return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin + footerHeight;
+ }
+
+ public double getTitleX() {
+ return (getWidth() - titleWidth) / 2;
+ }
+
+ public double getTitleY() {
+ return headerHeight + headerMargin;
+ }
+
+ public double getSequenceAreaX() {
+ return (getWidth() - sequenceWidth) / 2;
+ }
+
+ public double getSequenceAreaY() {
+ return getTitleY() + titleHeight;
+ }
+
+ public double getHeaderY() {
+ return 0;
+ }
+
+ public double getFooterY() {
+ return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin;
+ }
+
+ public double getFooterX(HorizontalAlignment align) {
+ if (align == HorizontalAlignment.LEFT) {
+ return 0;
+ }
+ if (align == HorizontalAlignment.RIGHT) {
+ return getWidth() - footerWidth;
+ }
+ if (align == HorizontalAlignment.CENTER) {
+ return (getWidth() - footerWidth) / 2;
+ }
+ throw new IllegalStateException();
+ }
+
+ public double getHeaderX(HorizontalAlignment align) {
+ if (align == HorizontalAlignment.LEFT) {
+ return 0;
+ }
+ if (align == HorizontalAlignment.RIGHT) {
+ return getWidth() - headerWidth;
+ }
+ if (align == HorizontalAlignment.CENTER) {
+ return (getWidth() - headerWidth) / 2;
+ }
+ throw new IllegalStateException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java
new file mode 100644
index 0000000..d79a8ea
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java
@@ -0,0 +1,315 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+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 net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
+import net.sourceforge.plantuml.core.ImageData;
+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.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.png.PngTitler;
+import net.sourceforge.plantuml.sequencediagram.Event;
+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.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class SequenceDiagramFileMakerPuma2 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 double scale;
+
+ public SequenceDiagramFileMakerPuma2(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) {
+ 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.create(""))
+ .getPreferredHeight(dummyStringBounder);
+
+ return new PageSplitter(fullDimension.getHeight(), headerHeight, positions, tailHeight, signatureHeight,
+ newpageHeight, title);
+ }
+
+ public ImageData createOne(OutputStream os, final int index, boolean isWithMetadata) throws IOException {
+
+ final Page page = pages.get(index);
+ final SequenceDiagramArea area = new SequenceDiagramArea(fullDimension.getWidth(), page.getHeight());
+
+ final Component compTitle;
+ if (page.getTitle() == null) {
+ compTitle = null;
+ } else {
+ compTitle = drawableSet.getSkin().createComponent(ComponentType.TITLE, null, drawableSet.getSkinParam(),
+ page.getTitle());
+ area.setTitleArea(compTitle.getPreferredWidth(dummyStringBounder),
+ compTitle.getPreferredHeight(dummyStringBounder));
+ }
+ addFooter2(area);
+ addHeader2(area);
+
+ // final FileFormat fileFormat = fileFormatOption.getFileFormat();
+
+ 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());
+
+ final double dpiFactor = diagram.getDpiFactor(fileFormatOption);
+ // System.err.println("dpiFactor=" + dpiFactor);
+ // System.err.println("scale=" + scale);
+
+ final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam().getColorMapper(), oneOf(scale,
+ dpiFactor), diagram.getSkinParam().getBackgroundColor(), null, null, 3, 10, diagram.getAnimation(),
+ diagram.getSkinParam().handwritten());
+
+ imageBuilder.addUDrawable(new UDrawable() {
+ public void drawU(UGraphic ug) {
+
+ double delta = 0;
+ if (index > 0) {
+ delta = page.getNewpage1() - page.getHeaderHeight();
+ }
+ if (delta < 0) {
+ delta = 0;
+ }
+
+ double legendYdelta = 0;
+ if (compTitle != null) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double h = compTitle.getPreferredHeight(stringBounder);
+ legendYdelta += h;
+ 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));
+ }
+
+ final double delta1 = Math.max(0, dimLegend.getWidth() - area.getWidth());
+
+ final boolean legendTop = legend != null
+ && diagram.getLegendVerticalAlignment() == VerticalAlignment.TOP;
+
+ double sequenceAreaY = area.getSequenceAreaY();
+ if (legendTop) {
+ sequenceAreaY += legendBlock.calculateDimension(ug.getStringBounder()).getHeight();
+ }
+ drawableSet.drawU22(ug.apply(new UTranslate(area.getSequenceAreaX() + delta1 / 2, sequenceAreaY)),
+ delta, fullDimension.getWidth(), page, diagram.isShowFootbox());
+
+ addHeader3(area, ug);
+ addFooter3(area, ug);
+
+ 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, legendTop ? legendYdelta : legendYdelta
+ + area.getHeight())));
+ }
+
+ }
+ });
+ return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
+ }
+
+ private double oneOf(double a, double b) {
+ if (a == 1) {
+ return b;
+ }
+ return a;
+ }
+
+ private double getImageWidth(SequenceDiagramArea area, double dpiFactor, double legendWidth) {
+ final int minsize = diagram.getMinwidth();
+ final double w = Math.max(area.getWidth() * getScale(area.getWidth(), area.getHeight()) * 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 void addFooter2(SequenceDiagramArea area) {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
+ diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder);
+ if (dim != null) {
+ area.setFooterArea(dim.getWidth(), dim.getHeight(), 3);
+ }
+ }
+
+ private void addHeader2(SequenceDiagramArea area) {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
+ diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ 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 hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
+ diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ 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 hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
+ diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ final TextBlock text = pngTitler.getTextBlock();
+ if (text == null) {
+ return;
+ }
+ text.drawU(ug.apply(new UTranslate(area.getHeaderX(diagram.getHeaderAlignment()), area.getHeaderY())));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java
new file mode 100644
index 0000000..b978489
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.asciiart.TextSkin;
+import net.sourceforge.plantuml.asciiart.TextStringBounder;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.StringBounder;
+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.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class SequenceDiagramTxtMaker implements FileMaker {
+
+ private final SequenceDiagram diagram;
+ private final DrawableSet drawableSet;
+ private final Dimension2D fullDimension;
+ private final StringBounder dummyStringBounder = new TextStringBounder();
+ private final UGraphicTxt ug = new UGraphicTxt();
+ private final FileFormat fileFormat;
+ private final Skin skin;
+
+ public SequenceDiagramTxtMaker(SequenceDiagram sequenceDiagram, FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+ this.diagram = sequenceDiagram;
+ this.skin = new TextSkin(fileFormat);
+
+ final DrawableSetInitializer initializer = new DrawableSetInitializer(skin, sequenceDiagram.getSkinParam(),
+ sequenceDiagram.isShowFootbox(), sequenceDiagram.getAutonewpage());
+
+ for (Participant p : sequenceDiagram.participants().values()) {
+ initializer.addParticipant(p, null);
+ }
+ 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 double headerHeight = drawableSet.getHeadHeight(dummyStringBounder);
+ final double tailHeight = drawableSet.getTailHeight(dummyStringBounder, diagram.isShowFootbox());
+ final double newpage2 = fullDimension.getHeight() - (diagram.isShowFootbox() ? tailHeight : 0) - headerHeight;
+ final Page page = new Page(headerHeight, 0, newpage2, tailHeight, 0, null);
+ //drawableSet.drawU_REMOVEDME_4243(ug, 0, fullDimension.getWidth(), page, diagram.isShowFootbox());
+ drawableSet.drawU22(ug, 0, fullDimension.getWidth(), page, diagram.isShowFootbox());
+ }
+
+
+ public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
+ if (fileFormat == FileFormat.UTXT) {
+ final PrintStream ps = new PrintStream(os, true, "UTF-8");
+ ug.getCharArea().print(ps);
+ } else {
+ final PrintStream ps = new PrintStream(os);
+ ug.getCharArea().print(ps);
+ }
+ return new ImageDataSimple(1, 1);
+ }
+
+ public int getNbPages() {
+ return 1;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java
new file mode 100644
index 0000000..3330fe4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Stairs {
+
+ private final List<Double> ys = new ArrayList<Double>();
+ private final List<Integer> values = new ArrayList<Integer>();
+ private final Map<Double, Integer> cache = new HashMap<Double, Integer>();
+
+ @Override
+ public String toString() {
+ final List<Double> copy = new ArrayList<Double>(ys);
+ Collections.sort(copy);
+ final StringBuilder sb = new StringBuilder("[");
+ for (Double y : copy) {
+ sb.append(y + "=" + getValue(y) + " ");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public void addStep(double y, int value) {
+ assert ys.size() == values.size();
+ if (ys.size() > 0) {
+ final double lastY = ys.get(ys.size() - 1);
+ if (y < lastY) {
+ throw new IllegalArgumentException();
+ }
+ if (lastY == y) {
+ values.set(ys.size() - 1, value);
+ cache.clear();
+ return;
+ }
+ }
+ ys.add(y);
+ values.add(value);
+ cache.clear();
+ }
+
+ public int getMaxValue() {
+ int max = Integer.MIN_VALUE;
+ for (Integer v : values) {
+ if (v > max) {
+ max = v;
+ }
+ }
+ return max;
+ }
+
+ public List<Double> getYs() {
+ return Collections.unmodifiableList(ys);
+ }
+
+ private double getLastY() {
+ if (ys.size() == 0) {
+ return 0;
+ }
+ return ys.get(ys.size() - 1);
+ }
+
+ public int getValue(double y) {
+ Integer result = cache.get(y);
+ if (result == null) {
+ result = getValueSlow(y);
+ cache.put(y, result);
+ }
+ return result;
+ }
+
+ private int getValueSlow(double y) {
+ final int idx = Collections.binarySearch(ys, y);
+ if (idx >= 0) {
+ return values.get(idx);
+ }
+ final int insertPoint = -idx - 1;
+ if (insertPoint == 0) {
+ return 0;
+ }
+ return values.get(insertPoint - 1);
+ }
+
+ public int getLastValue() {
+ final int size = values.size();
+ if (size == 0) {
+ return 0;
+ }
+ return values.get(size - 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java
new file mode 100644
index 0000000..369c5d9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java
@@ -0,0 +1,151 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.MessageNumber;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+
+abstract class Step1Abstract {
+
+ private final StringBounder stringBounder;
+
+ private final DrawableSet drawingSet;
+
+ private final AbstractMessage message;
+
+ private Frontier freeY2;
+
+ // private ComponentType type;
+ private ArrowConfiguration config;
+
+ private Component note;
+
+ private ParticipantRange range;
+
+ Step1Abstract(ParticipantRange range, StringBounder stringBounder, AbstractMessage message, DrawableSet drawingSet,
+ Frontier freeY2) {
+ if (freeY2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.range = range;
+ this.stringBounder = stringBounder;
+ this.message = message;
+ this.freeY2 = freeY2;
+ this.drawingSet = drawingSet;
+ }
+
+ protected final ParticipantRange getParticipantRange() {
+ return range;
+ }
+
+ abstract Frontier prepareMessage(ConstraintSet constraintSet, InGroupablesStack groupingStructures);
+
+ protected final Display getLabelOfMessage(AbstractMessage message) {
+ if (message.getMessageNumber() == null) {
+ return message.getLabel();
+ }
+ Display result = Display.empty();
+ result = result.add(new MessageNumber(message.getMessageNumber()));
+ result = result.addAll(message.getLabel());
+ return result;
+ }
+
+
+ protected final ArrowConfiguration getConfig() {
+ return config;
+ }
+
+ protected final void setConfig(ArrowConfiguration config) {
+ this.config = config;
+ }
+
+ protected final Component getNote() {
+ return note;
+ }
+
+ protected final void setNote(Component note) {
+ this.note = note;
+ }
+
+ protected final StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ protected final AbstractMessage getMessage() {
+ return message;
+ }
+
+ protected final DrawableSet getDrawingSet() {
+ return drawingSet;
+ }
+
+ protected final Frontier getFreeY() {
+ return freeY2;
+ }
+
+ protected final void incFreeY(double v) {
+ freeY2 = freeY2.add(v, range);
+ }
+
+ protected final NoteBox createNoteBox(StringBounder stringBounder, Arrow arrow, Component noteComp,
+ NotePosition notePosition, Url url) {
+ final LivingParticipantBox p = arrow.getParticipantAt(stringBounder, notePosition);
+ final NoteBox noteBox = new NoteBox(arrow.getStartingY(), noteComp, p, null, notePosition, url);
+
+ if (arrow instanceof MessageSelfArrow && notePosition == NotePosition.RIGHT) {
+ noteBox.pushToRight(arrow.getPreferredWidth(stringBounder));
+ }
+ // if (arrow instanceof MessageExoArrow) {
+ // final MessageExoType type = ((MessageExoArrow) arrow).getType();
+ // if (type.isRightBorder()) {
+ // final double width = noteBox.getPreferredWidth(stringBounder);
+ // noteBox.pushToRight(-width);
+ // }
+ // }
+
+ return noteBox;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java
new file mode 100644
index 0000000..3d5d1ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java
@@ -0,0 +1,251 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+
+class Step1Message extends Step1Abstract {
+
+ private final MessageArrow messageArrow;
+
+ Step1Message(ParticipantRange range, StringBounder stringBounder, Message message, DrawableSet drawingSet,
+ Frontier freeY) {
+ super(range, stringBounder, message, drawingSet, freeY);
+
+ final double x1 = getParticipantBox1().getCenterX(stringBounder);
+ final double x2 = getParticipantBox2().getCenterX(stringBounder);
+
+ this.setConfig(isSelfMessage() ? getSelfArrowType(message) : getArrowType(message, x1, x2));
+
+ if (isSelfMessage()) {
+ this.messageArrow = null;
+ } else {
+ final Component comp = drawingSet.getSkin().createComponent(ComponentType.ARROW, getConfig(),
+ drawingSet.getSkinParam(), getLabelOfMessage(message));
+ final Component compAliveBox = drawingSet.getSkin().createComponent(ComponentType.ALIVE_BOX_OPEN_OPEN,
+ null, drawingSet.getSkinParam(), null);
+
+ this.messageArrow = new MessageArrow(freeY.getFreeY(range), drawingSet.getSkin(), comp,
+ getLivingParticipantBox1(), getLivingParticipantBox2(), message.getUrl(), compAliveBox);
+ }
+
+ if (message.getNote() != null) {
+ final ISkinParam skinParam = message.getSkinParamNoteBackcolored(drawingSet.getSkinParam());
+ setNote(drawingSet.getSkin().createComponent(ComponentType.NOTE, null, skinParam, message.getNote()));
+ }
+
+ }
+
+ Frontier prepareMessage(ConstraintSet constraintSet, InGroupablesStack inGroupablesStack) {
+ final Arrow graphic = createArrow();
+ final double arrowYStartLevel = graphic.getArrowYStartLevel(getStringBounder());
+ final double arrowYEndLevel = graphic.getArrowYEndLevel(getStringBounder());
+
+ // final double delta1 = isSelfMessage() ? 4 : 0;
+ final double delta1 = 0;
+ getMessage().setPosYstartLevel(arrowYStartLevel + delta1);
+
+ final double length;
+ if (isSelfMessage()) {
+ length = graphic.getArrowOnlyWidth(getStringBounder())
+ + getLivingParticipantBox1().getLiveThicknessAt(getStringBounder(), arrowYStartLevel).getSegment()
+ .getLength();
+ } else {
+ length = graphic.getArrowOnlyWidth(getStringBounder())
+ + getLivingParticipantBox(NotePosition.LEFT).getLifeLine().getRightShift(arrowYStartLevel)
+ + getLivingParticipantBox(NotePosition.RIGHT).getLifeLine().getLeftShift(arrowYStartLevel);
+ }
+
+ incFreeY(graphic.getPreferredHeight(getStringBounder()));
+ double marginActivateAndDeactive = 0;
+ if (getMessage().isActivateAndDeactive()) {
+ marginActivateAndDeactive = 30;
+ incFreeY(marginActivateAndDeactive);
+ }
+ getDrawingSet().addEvent(getMessage(), graphic);
+
+ if (isSelfMessage()) {
+ constraintSet.getConstraintAfter(getParticipantBox1()).ensureValue(length);
+ } else {
+ constraintSet.getConstraint(getParticipantBox1(), getParticipantBox2()).ensureValue(length);
+ }
+
+ final double posYendLevel = arrowYEndLevel + marginActivateAndDeactive - delta1;
+ getMessage().setPosYendLevel(posYendLevel);
+
+ assert graphic instanceof InGroupable;
+ if (graphic instanceof InGroupable) {
+ inGroupablesStack.addElement((InGroupable) graphic);
+ inGroupablesStack.addElement(getLivingParticipantBox1());
+ if (isSelfMessage() == false) {
+ inGroupablesStack.addElement(getLivingParticipantBox2());
+ }
+ }
+
+ return getFreeY();
+ }
+
+ private boolean isSelfMessage() {
+ return getParticipantBox1().equals(getParticipantBox2());
+ }
+
+ private ParticipantBox getParticipantBox1() {
+ return getLivingParticipantBox1().getParticipantBox();
+ }
+
+ private ParticipantBox getParticipantBox2() {
+ return getLivingParticipantBox2().getParticipantBox();
+ }
+
+ private LivingParticipantBox getLivingParticipantBox1() {
+ return getDrawingSet().getLivingParticipantBox(((Message) getMessage()).getParticipant1());
+ }
+
+ private LivingParticipantBox getLivingParticipantBox2() {
+ return getDrawingSet().getLivingParticipantBox(((Message) getMessage()).getParticipant2());
+ }
+
+ private LivingParticipantBox getLivingParticipantBox(NotePosition position) {
+ if (isSelfMessage()) {
+ throw new IllegalStateException();
+ }
+ return messageArrow.getParticipantAt(getStringBounder(), position);
+ }
+
+ private Arrow createArrow() {
+ if (getMessage().isCreate()) {
+ return createArrowCreate();
+ }
+ if (getMessage().getNote() != null && isSelfMessage()) {
+ final MessageSelfArrow messageSelfArrow = createMessageSelfArrow();
+ final NoteBox noteBox = createNoteBox(getStringBounder(), messageSelfArrow, getNote(), getMessage()
+ .getNotePosition(), getMessage().getUrlNote());
+ return new ArrowAndNoteBox(getStringBounder(), messageSelfArrow, noteBox);
+ } else if (getMessage().getNote() != null) {
+ final NoteBox noteBox = createNoteBox(getStringBounder(), messageArrow, getNote(), getMessage()
+ .getNotePosition(), getMessage().getUrlNote());
+ return new ArrowAndNoteBox(getStringBounder(), messageArrow, noteBox);
+ } else if (isSelfMessage()) {
+ return createMessageSelfArrow();
+ } else {
+ return messageArrow;
+ }
+ }
+
+ private MessageSelfArrow createMessageSelfArrow() {
+ final double posY = getFreeY().getFreeY(getParticipantRange());
+ double deltaY = 0;
+ double deltaX = 0;
+ if (getMessage().isActivate()) {
+ deltaY -= getHalfLifeWidth();
+ if (OptionFlags.STRICT_SELFMESSAGE_POSITION) {
+ deltaX += 5;
+ }
+ }
+ if (getMessage().isDeactivate()) {
+ deltaY += getHalfLifeWidth();
+ }
+
+ return new MessageSelfArrow(posY, getDrawingSet().getSkin(), getDrawingSet().getSkin().createComponent(
+ ComponentType.ARROW, getConfig(), getDrawingSet().getSkinParam(), getLabelOfMessage(getMessage())),
+ getLivingParticipantBox1(), deltaY, getMessage().getUrl(), deltaX);
+ }
+
+ private double getHalfLifeWidth() {
+ return getDrawingSet()
+ .getSkin()
+ .createComponent(ComponentType.ALIVE_BOX_OPEN_OPEN, null, getDrawingSet().getSkinParam(),
+ Display.create("")).getPreferredWidth(null) / 2;
+ }
+
+ private Arrow createArrowCreate() {
+ if (messageArrow == null) {
+ throw new IllegalStateException();
+ }
+ Arrow result = new ArrowAndParticipant(getStringBounder(), messageArrow, getParticipantBox2());
+ if (getMessage().getNote() != null) {
+ final NoteBox noteBox = createNoteBox(getStringBounder(), result, getNote(),
+ getMessage().getNotePosition(), getMessage().getUrlNote());
+ if (getMessage().getNotePosition() == NotePosition.RIGHT) {
+ noteBox.pushToRight(getParticipantBox2().getPreferredWidth(getStringBounder()) / 2);
+ }
+ result = new ArrowAndNoteBox(getStringBounder(), result, noteBox);
+ }
+ getLivingParticipantBox2().create(
+ getFreeY().getFreeY(getParticipantRange()) + result.getPreferredHeight(getStringBounder()) / 2);
+ return result;
+ }
+
+ private ArrowConfiguration getSelfArrowType(Message m) {
+ // return m.getArrowConfiguration().self();
+ ArrowConfiguration result = ArrowConfiguration.withDirectionSelf();
+ if (m.getArrowConfiguration().isDotted()) {
+ result = result.withDotted();
+ }
+ if (m.getArrowConfiguration().isAsync()) {
+ result = result.withHead(ArrowHead.ASYNC);
+ }
+ if (m.getArrowConfiguration().getDressing2().getHead() == ArrowHead.CROSSX) {
+ result = result.withHead2(m.getArrowConfiguration().getDressing2().getHead());
+ System.err.println("WARNING : CROSSX");
+ // assert false;
+ }
+ result = result.withPart(m.getArrowConfiguration().getPart());
+ result = result.withColor(m.getArrowConfiguration().getColor());
+ result = result.withDecoration1(m.getArrowConfiguration().getDecoration1());
+ result = result.withDecoration2(m.getArrowConfiguration().getDecoration2());
+
+ return result;
+ }
+
+ private ArrowConfiguration getArrowType(Message m, final double x1, final double x2) {
+ if (x2 > x1) {
+ return m.getArrowConfiguration();
+ }
+ return m.getArrowConfiguration().reverse();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java
new file mode 100644
index 0000000..08b1df9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+import net.sourceforge.plantuml.sequencediagram.MessageNumber;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ComponentType;
+
+class Step1MessageExo extends Step1Abstract {
+
+ private final MessageExoArrow messageArrow;
+
+ Step1MessageExo(ParticipantRange range, StringBounder stringBounder, MessageExo message, DrawableSet drawingSet,
+ Frontier freeY) {
+ super(range, stringBounder, message, drawingSet, freeY);
+
+ setConfig(getArrowType(message));
+
+ this.messageArrow = new MessageExoArrow(freeY.getFreeY(range), drawingSet.getSkin(), drawingSet.getSkin()
+ .createComponent(ComponentType.ARROW, getConfig(), drawingSet.getSkinParam(),
+ getLabelOfMessage(message)), getLivingParticipantBox(), message.getType(), message.getUrl(),
+ message.isShortArrow(), message.getArrowConfiguration());
+
+ if (message.getNote() != null) {
+ final ISkinParam skinParam = message.getSkinParamNoteBackcolored(drawingSet.getSkinParam());
+ setNote(drawingSet.getSkin().createComponent(ComponentType.NOTE, null, skinParam, message.getNote()));
+ // throw new UnsupportedOperationException();
+ }
+
+ }
+
+ Frontier prepareMessage(ConstraintSet constraintSet, InGroupablesStack inGroupablesStack) {
+ final Arrow graphic = createArrow();
+ final double arrowYStartLevel = graphic.getArrowYStartLevel(getStringBounder());
+ final double arrowYEndLevel = graphic.getArrowYEndLevel(getStringBounder());
+
+ getMessage().setPosYstartLevel(arrowYStartLevel);
+
+ final double length = graphic.getArrowOnlyWidth(getStringBounder());
+ incFreeY(graphic.getPreferredHeight(getStringBounder()));
+ double marginActivateAndDeactive = 0;
+ if (getMessage().isActivateAndDeactive()) {
+ marginActivateAndDeactive = 30;
+ incFreeY(marginActivateAndDeactive);
+ }
+ getDrawingSet().addEvent(getMessage(), graphic);
+
+ final LivingParticipantBox livingParticipantBox = getLivingParticipantBox();
+ if (messageArrow.getType().isRightBorder()) {
+ constraintSet.getConstraint(livingParticipantBox.getParticipantBox(), constraintSet.getLastborder())
+ .ensureValue(length);
+ } else {
+ constraintSet.getConstraint(constraintSet.getFirstBorder(), livingParticipantBox.getParticipantBox())
+ .ensureValue(length);
+ }
+
+ final double posYendLevel = arrowYEndLevel + marginActivateAndDeactive;
+ getMessage().setPosYendLevel(posYendLevel);
+
+ assert graphic instanceof InGroupable;
+ if (graphic instanceof InGroupable) {
+ inGroupablesStack.addElement((InGroupable) graphic);
+ inGroupablesStack.addElement(livingParticipantBox);
+ }
+
+ return getFreeY();
+ }
+
+ private LivingParticipantBox getLivingParticipantBox() {
+ return getDrawingSet().getLivingParticipantBox(((MessageExo) getMessage()).getParticipant());
+ }
+
+ private Display getLabelOfMessage(MessageExo message) {
+ if (message.getMessageNumber() == null) {
+ return message.getLabel();
+ }
+ Display result = Display.empty();
+ result = result.add(new MessageNumber(message.getMessageNumber()));
+ result = result.addAll(message.getLabel());
+ return result;
+ }
+
+ private Arrow createArrow() {
+ if (getMessage().getNote() == null) {
+ return messageArrow;
+ }
+ final NoteBox toto = createNoteBox(getStringBounder(), messageArrow, getNote(), getMessage().getNotePosition(),
+ getMessage().getUrlNote());
+ return new ArrowAndNoteBox(getStringBounder(), messageArrow, toto);
+ }
+
+ private ArrowConfiguration getArrowType(MessageExo m) {
+ final MessageExoType type = m.getType();
+ ArrowConfiguration result = null;
+
+ if (type.getDirection() == 1) {
+ result = m.getArrowConfiguration();
+ } else {
+ result = m.getArrowConfiguration().reverse();
+ }
+ result = result.withDecoration1(m.getArrowConfiguration().getDecoration1());
+ result = result.withDecoration2(m.getArrowConfiguration().getDecoration2());
+ return result;
+ // ArrowConfiguration result = null;
+ // if (type.getDirection() == 1) {
+ // result = ArrowConfiguration.withDirectionNormal();
+ // } else {
+ // result = ArrowConfiguration.withDirectionReverse();
+ // }
+ // if (m.getArrowConfiguration().isDotted()) {
+ // result = result.withDotted();
+ // }
+ // if (m.getArrowConfiguration().isAsync()) {
+ // result = result.withHead(ArrowHead.ASYNC);
+ // }
+ // result = result.withPart(m.getArrowConfiguration().getPart());
+ // return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java b/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java
new file mode 100644
index 0000000..16b69f8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public class FixedLink {
+
+ final private SegmentPosition segmentPosition1;
+ final private SegmentPosition segmentPosition2;
+
+ public FixedLink(SegmentPosition segmentPosition1, SegmentPosition segmentPosition2) {
+ this.segmentPosition1 = segmentPosition1;
+ this.segmentPosition2 = segmentPosition2;
+ }
+
+ public boolean pushIfNeed() {
+ final double p1 = segmentPosition1.getPosition();
+ final double p2 = segmentPosition2.getPosition();
+ if (p1 == p2) {
+ return false;
+ }
+ final double diff = p1 - p2;
+ segmentPosition2.getSegment().push(diff);
+ assert segmentPosition1.getPosition() == segmentPosition2.getPosition();
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java
new file mode 100644
index 0000000..b66f949
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public class PSegment {
+
+ private final double minsize;
+ private double startx;
+ private double endx;
+
+ public PSegment(double minsize) {
+ this.minsize = minsize;
+ this.startx = 0;
+ this.endx = minsize;
+ }
+
+ public double getMinsize() {
+ return minsize;
+ }
+
+ public void push(double delta) {
+ this.startx += delta;
+ this.endx += delta;
+ }
+
+ public String getDebugPosition() {
+ return "" + ((int) startx) + "-" + ((int) endx);
+ }
+
+ public double getPosition(double position) {
+ if (position == 0) {
+ return startx;
+ }
+ if (position == 1) {
+ return endx;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java
new file mode 100644
index 0000000..fbcb1a2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class PUnivers {
+
+ private final Collection<PSegment> all = new ArrayList<PSegment>();
+ private final Collection<FixedLink> links = new ArrayList<FixedLink>();
+
+ public PSegment createPSegment(double minsize) {
+ final PSegment result = new PSegment(minsize);
+ all.add(result);
+ return result;
+ }
+
+ public void addFixedLink(PSegment segment1, double position1, PSegment segment2, double position2) {
+ final FixedLink link = new FixedLink(new SegmentPosition(segment1, position1), new SegmentPosition(segment2,
+ position2));
+ links.add(link);
+
+ }
+
+ public void solve() {
+ boolean changed = false;
+ do {
+ changed = false;
+ for (FixedLink link : links) {
+ if (link.pushIfNeed()) {
+ changed = true;
+ }
+ }
+ } while (changed);
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java
new file mode 100644
index 0000000..ef2bf1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public enum PushDirection {
+
+ TOLEFT, TORIGHT
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java
new file mode 100644
index 0000000..4577f22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public enum PushSide {
+
+ START, END
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java
new file mode 100644
index 0000000..fb2e07f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public enum PushStrategy {
+
+ MOVE, ENLARGE
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java b/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java
new file mode 100644
index 0000000..5850de1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public class SegmentPosition {
+
+ final private PSegment segment;
+ final private double position;
+
+ public SegmentPosition(PSegment segment, double position) {
+ this.segment = segment;
+ this.position = position;
+ }
+
+ public double getPosition() {
+ return segment.getPosition(position);
+ }
+
+ public PSegment getSegment() {
+ return segment;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java
new file mode 100644
index 0000000..c1b9c86
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java
@@ -0,0 +1,149 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationExoTile implements TileWithUpdateStairs {
+
+ private final LivingSpace livingSpace;
+ private final MessageExo message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Real alpha;
+ private final Real omega;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationExoTile(LivingSpace livingSpace, MessageExo message, Skin skin, ISkinParam skinParam,
+ Real alpha, Real omega) {
+ this.livingSpace = livingSpace;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.alpha = alpha;
+ this.omega = omega;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
+ if (message.getType().getDirection() == -1) {
+ arrowConfiguration = arrowConfiguration.reverse();
+ }
+ final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam,
+ message.getLabel());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double x1 = getPoint1(stringBounder).getCurrentValue();
+ final double x2 = getPoint2(stringBounder).getCurrentValue();
+ final Area area = new Area(x2 - x1, dim.getHeight());
+ ug = ug.apply(new UTranslate(x1, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+
+ final Real point1 = getPoint1(stringBounder);
+ final Real point2 = getPoint2(stringBounder);
+ if (point1.getCurrentValue() < point2.getCurrentValue()) {
+ point2.ensureBiggerThan(point1.addFixed(width));
+ } else {
+ point1.ensureBiggerThan(point2.addFixed(width));
+ }
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double arrowY = comp.getStartPoint(stringBounder, dim).getY();
+
+ livingSpace.addStepForLivebox(getEvent(), y + arrowY);
+
+ }
+
+ private Real getPoint1(final StringBounder stringBounder) {
+ if (message.getType().isRightBorder()) {
+ return livingSpace.getPosC(stringBounder);
+ }
+ return alpha;
+ }
+
+ private Real getPoint2(final StringBounder stringBounder) {
+ if (message.getType().isRightBorder()) {
+ return omega;
+ }
+ return livingSpace.getPosC(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getPoint1(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return getPoint2(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java
new file mode 100644
index 0000000..9e70eb3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java
@@ -0,0 +1,214 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTile implements TileWithUpdateStairs {
+
+ private final LivingSpace livingSpace1;
+ private final LivingSpace livingSpace2;
+ private final Message message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Message message, Skin skin,
+ ISkinParam skinParam) {
+ if (livingSpace1 == livingSpace2) {
+ throw new IllegalArgumentException();
+ }
+ this.livingSpace1 = livingSpace1;
+ this.livingSpace2 = livingSpace2;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ // for (LifeEvent lifeEvent : message.getLiveEvents()) {
+ // System.err.println("lifeEvent = " + lifeEvent);
+ // // livingSpace1.addLifeEvent(this, lifeEvent);
+ // // livingSpace2.addLifeEvent(this, lifeEvent);
+ // }
+ }
+
+ public boolean isReverse(StringBounder stringBounder) {
+ final Real point1 = livingSpace1.getPosC(stringBounder);
+ final Real point2 = livingSpace2.getPosC(stringBounder);
+ if (point1.getCurrentValue() > point2.getCurrentValue()) {
+ return true;
+ }
+ return false;
+
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
+ /*
+ * if (isSelf()) { arrowConfiguration = arrowConfiguration.self(); } else
+ */
+ if (isReverse(stringBounder)) {
+ arrowConfiguration = arrowConfiguration.reverse();
+ }
+ final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam,
+ message.getLabel());
+ return comp;
+ }
+
+ public static final double LIVE_DELTA_SIZE = 5;
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final Point2D p2 = comp.getEndPoint(stringBounder, dim);
+ // System.err.println("CommunicationTile::updateStairs y=" + y + " p1=" + p1 + " p2=" + p2 + " dim=" + dim);
+ final double arrowY = comp.getStartPoint(stringBounder, dim).getY();
+
+ livingSpace1.addStepForLivebox(getEvent(), y + arrowY);
+ livingSpace2.addStepForLivebox(getEvent(), y + arrowY);
+
+ // System.err.println("CommunicationTile::updateStairs msg=" + message + " y=" + y + " arrowY=" + arrowY);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ double x1 = getPoint1(stringBounder).getCurrentValue();
+ double x2 = getPoint2(stringBounder).getCurrentValue();
+
+ final int level1 = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
+ final int level2 = livingSpace2.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
+ // System.err.println("CommunicationTile::draw msg=" + message + " level1=" + level1 + " level2=" + level2);
+
+ final Area area;
+ if (isReverse(stringBounder)) {
+ System.err.println("isreverse!");
+ // x1 -= LIVE_DELTA_SIZE * level1;
+ x2 += LIVE_DELTA_SIZE * level2;
+ area = new Area(x1 - x2, dim.getHeight());
+ ug = ug.apply(new UTranslate(x2, 0));
+ } else {
+ x1 += LIVE_DELTA_SIZE * level1;
+ x2 -= LIVE_DELTA_SIZE * level2;
+ area = new Area(x2 - x1, dim.getHeight());
+ ug = ug.apply(new UTranslate(x1, 0));
+ }
+ comp.drawU(ug, area, (Context2D) ug);
+ // ug.draw(new ULine(x2 - x1, 0));
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+
+ // if (isSelf()) {
+ // final LivingSpace next = livingSpace1.getNext();
+ // if (next != null) {
+ // next.getPosB().ensureBiggerThan(getMaxX(stringBounder));
+ // }
+ // } else {
+ final Real point1 = getPoint1(stringBounder);
+ final Real point2 = getPoint2(stringBounder);
+ if (point1.getCurrentValue() < point2.getCurrentValue()) {
+ point2.ensureBiggerThan(point1.addFixed(width));
+ } else {
+ point1.ensureBiggerThan(point2.addFixed(width));
+ // }
+ }
+ }
+
+ // private boolean isSelf() {
+ // return livingSpace1 == livingSpace2;
+ // }
+
+ private Real getPoint1(final StringBounder stringBounder) {
+ return livingSpace1.getPosC(stringBounder);
+ }
+
+ private Real getPoint2(final StringBounder stringBounder) {
+ if (message.isCreate()) {
+ if (isReverse(stringBounder)) {
+ return livingSpace2.getPosD(stringBounder);
+ }
+ return livingSpace2.getPosB();
+ }
+ return livingSpace2.getPosC(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ if (isReverse(stringBounder)) {
+ return getPoint2(stringBounder);
+ }
+ return getPoint1(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ // if (isSelf()) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ // return livingSpace1.getPosC(stringBounder).addFixed(width);
+ // }
+ if (isReverse(stringBounder)) {
+ return getPoint1(stringBounder);
+ }
+ return getPoint2(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java
new file mode 100644
index 0000000..cdf0d64
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileNoteLeft implements TileWithUpdateStairs {
+
+ private final TileWithUpdateStairs tile;
+ private final AbstractMessage message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display notes;
+ // private final NotePosition notePosition;
+ private final LivingSpace livingSpace;
+
+ public Event getEvent() {
+ return message;
+ }
+
+
+ public CommunicationTileNoteLeft(TileWithUpdateStairs tile, AbstractMessage message, Skin skin, ISkinParam skinParam,
+ LivingSpace livingSpace) {
+ this.tile = tile;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.notes = message.getNote();
+ // this.notePosition = message.getNotePosition();
+ this.livingSpace = livingSpace;
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ tile.updateStairs(stringBounder, y);
+ }
+
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null, message.getSkinParamNoteBackcolored(skinParam), notes);
+ return comp;
+ }
+
+ private Real getNotePosition(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return livingSpace.getPosC(stringBounder).addFixed(-dim.getWidth());
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ tile.drawU(ug);
+ final Real p = getNotePosition(stringBounder);
+
+ comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight());
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getNotePosition(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return tile.getMaxX(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java
new file mode 100644
index 0000000..87a6508
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileNoteRight implements TileWithUpdateStairs {
+
+ private final TileWithUpdateStairs tile;
+ private final AbstractMessage message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display notes;
+ // private final NotePosition notePosition;
+ private final LivingSpace livingSpace;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationTileNoteRight(TileWithUpdateStairs tile, AbstractMessage message, Skin skin,
+ ISkinParam skinParam, LivingSpace livingSpace) {
+ this.tile = tile;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.notes = message.getNote();
+ // this.notePosition = message.getNotePosition();
+ this.livingSpace = livingSpace;
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ tile.updateStairs(stringBounder, y);
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null,
+ message.getSkinParamNoteBackcolored(skinParam), notes);
+ return comp;
+ }
+
+ private Real getNotePosition(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return livingSpace.getPosC(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ tile.drawU(ug);
+ final Real p = getNotePosition(stringBounder);
+
+ comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight());
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tile.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return getNotePosition(stringBounder).addFixed(dim.getWidth());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java
new file mode 100644
index 0000000..a846280
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java
@@ -0,0 +1,189 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Iterator;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileSelf implements TileWithUpdateStairs {
+
+ private final LivingSpace livingSpace1;
+ private final Message message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final LivingSpaces livingSpaces;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationTileSelf(LivingSpace livingSpace1, Message message, Skin skin, ISkinParam skinParam,
+ LivingSpaces livingSpaces) {
+ this.livingSpace1 = livingSpace1;
+ this.livingSpaces = livingSpaces;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ // private boolean isReverse(StringBounder stringBounder) {
+ // final Real point1 = livingSpace1.getPosC(stringBounder);
+ // final Real point2 = livingSpace2.getPosC(stringBounder);
+ // if (point1.getCurrentValue() > point2.getCurrentValue()) {
+ // return true;
+ // }
+ // return false;
+ //
+ // }
+
+ private Component getComponent(StringBounder stringBounder) {
+ ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
+ arrowConfiguration = arrowConfiguration.self();
+ final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam,
+ message.getLabel());
+ return comp;
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Point2D p1 = comp.getStartPoint(stringBounder, dim);
+ final Point2D p2 = comp.getEndPoint(stringBounder, dim);
+
+ if (message.isActivate()) {
+ livingSpace1.addStepForLivebox(getEvent(), y + p2.getY());
+ System.err.println("CommunicationTileSelf::updateStairs activate y=" + (y + p2.getY()) + " " + message);
+ } else if (message.isDeactivate()) {
+ livingSpace1.addStepForLivebox(getEvent(), y + p1.getY());
+ System.err.println("CommunicationTileSelf::updateStairs deactivate y=" + (y + p1.getY()) + " " + message);
+ }
+
+ // livingSpace1.addStep(y + arrowY, level1);
+ // livingSpace1.addStep(y + dim.getHeight(), level1);
+ // final int level2 = livingSpace2.getLevelAt(this);
+ // livingSpace2.addStep(y + arrowY, level2);
+ // livingSpace2.addStep(y + dim.getHeight(), level2);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ double x1 = getPoint1(stringBounder).getCurrentValue();
+ final int levelIgnore = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_ACTIVATE);
+ final int levelConsidere = livingSpace1.getLevelAt(this, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE);
+ System.err.println("CommunicationTileSelf::drawU levelIgnore=" + levelIgnore + " levelConsidere="
+ + levelConsidere);
+ x1 += CommunicationTile.LIVE_DELTA_SIZE * levelIgnore;
+ if (levelIgnore < levelConsidere) {
+ x1 += CommunicationTile.LIVE_DELTA_SIZE;
+ }
+
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ // if (message.isActivate()) {
+ // area.setDeltaX1(CommunicationTile.LIVE_DELTA_SIZE);
+ // } else if (message.isDeactivate()) {
+ // // area.setDeltaX1(CommunicationTile.LIVE_DELTA_SIZE);
+ // // x1 += CommunicationTile.LIVE_DELTA_SIZE * levelConsidere;
+ // }
+ area.setDeltaX1((levelIgnore - levelConsidere) * CommunicationTile.LIVE_DELTA_SIZE);
+ ug = ug.apply(new UTranslate(x1, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+
+ final LivingSpace next = getNext();
+ if (next != null) {
+ next.getPosB().ensureBiggerThan(getMaxX(stringBounder));
+ }
+ }
+
+ // private boolean isSelf() {
+ // return livingSpace1 == livingSpace2;
+ // }
+
+ private LivingSpace getNext() {
+ for (Iterator<LivingSpace> it = livingSpaces.values().iterator(); it.hasNext();) {
+ final LivingSpace current = it.next();
+ if (current == livingSpace1 && it.hasNext()) {
+ return it.next();
+ }
+ }
+ return null;
+ }
+
+ private Real getPoint1(final StringBounder stringBounder) {
+ return livingSpace1.getPosC(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getPoint1(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+ return livingSpace1.getPosC(stringBounder).addFixed(width);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java
new file mode 100644
index 0000000..ec561b7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileSelfNoteRight implements TileWithUpdateStairs {
+
+ private final CommunicationTileSelf tile;
+ private final Message message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display notes;
+
+ // private final NotePosition notePosition;
+ // private final LivingSpace livingSpace;
+
+ public Event getEvent() {
+ return message;
+ }
+
+
+ public CommunicationTileSelfNoteRight(CommunicationTileSelf tile, Message message, Skin skin, ISkinParam skinParam) {
+ this.tile = tile;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.notes = message.getNote();
+ // this.notePosition = message.getNotePosition();
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ tile.updateStairs(stringBounder, y);
+ }
+
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null, message.getSkinParamNoteBackcolored(skinParam), notes);
+ return comp;
+ }
+
+ private Real getNotePosition(StringBounder stringBounder) {
+ return tile.getMaxX(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ tile.drawU(ug);
+ final Real p = getNotePosition(stringBounder);
+
+ comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight());
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tile.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return getNotePosition(stringBounder).addFixed(dim.getWidth());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java
new file mode 100644
index 0000000..e685861
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java
@@ -0,0 +1,126 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class DelayTile implements Tile {
+
+ private final Delay delay;
+ private final TileArguments tileArguments;
+ private Real first;
+ private Real last;
+
+ public Event getEvent() {
+ return delay;
+ }
+
+
+ public DelayTile(Delay delay, TileArguments tileArguments) {
+ this.delay = delay;
+ this.tileArguments = tileArguments;
+ }
+
+ private void init(StringBounder stringBounder) {
+ if (first != null) {
+ return;
+ }
+ this.first = tileArguments.getFirstLivingSpace().getPosC(stringBounder);
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ this.last = tileArguments.getLastLivingSpace().getPosC(stringBounder).addAtLeast(0);
+ this.last.ensureBiggerThan(this.first.addFixed(dim.getWidth()));
+
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = tileArguments.getSkin().createComponent(ComponentType.DELAY_TEXT, null,
+ tileArguments.getSkinParam(), delay.getText());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ init(stringBounder);
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(last.getCurrentValue() - first.getCurrentValue(), dim.getHeight());
+
+ ug = ug.apply(new UTranslate(first.getCurrentValue(), 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.first;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.last;
+ }
+
+// private double startingY;
+//
+// public void setStartingY(double startingY) {
+// this.startingY = startingY;
+// }
+//
+// public double getStartingY() {
+// return startingY;
+// }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java
new file mode 100644
index 0000000..d01f7af
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Divider;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class DividerTile implements Tile {
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Divider divider;
+ private final Real origin;
+ private final Real omega;
+
+ public Event getEvent() {
+ return divider;
+ }
+
+
+ public DividerTile(Divider divider, Skin skin, ISkinParam skinParam, Real origin, Real omega) {
+ this.divider = divider;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.origin = origin;
+ this.omega = omega;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.DIVIDER, null, skinParam, divider.getText());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(omega.getCurrentValue() - origin.getCurrentValue(), dim.getHeight());
+
+ // ug = ug.apply(new UTranslate(x, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return origin;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return omega;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java
new file mode 100644
index 0000000..8032c36
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElseTile implements Tile {
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final GroupingLeaf anElse;
+ private final Tile parent;
+
+ public Event getEvent() {
+ return anElse;
+ }
+
+
+ public ElseTile(GroupingLeaf anElse, Skin skin, ISkinParam skinParam, Tile parent) {
+ this.anElse = anElse;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.parent = parent;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Display display = Display.create(anElse.getTitle());
+ final Component comp = skin.createComponent(ComponentType.GROUPING_ELSE, null, skinParam, display);
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Real min = getMinX(stringBounder);
+ final Real max = getMaxX(stringBounder);
+ final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), dim.getHeight());
+ ug = ug.apply(new UTranslate(min.getCurrentValue(), 0));
+ // ug = ug.apply(new UTranslate(x, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return parent.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return parent.getMaxX(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java
new file mode 100644
index 0000000..4b566e1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java
@@ -0,0 +1,186 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+
+public class EventsHistory {
+
+ private final Participant p;
+ private final List<Event> events;
+ private final Map<Event, Double> ys3 = new HashMap<Event, Double>();
+
+ public EventsHistory(Participant p, List<Event> events) {
+ this.p = p;
+ this.events = events;
+ }
+
+ public void addStepForLivebox(Event event, double y) {
+ ys3.put(event, y);
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+ public int getLevelAt(Event event, EventsHistoryMode mode) {
+ final int result = getLevelAtInternal(event, mode);
+ // System.err.println("EventsHistory::getLevelAt " + mode + " " + result + " " + event);
+ return result;
+ }
+
+ private int getLevelAtInternal(Event event, EventsHistoryMode mode) {
+ int level = 0; // p.getInitialLife();
+ // System.err.println("--->EventsHistory for " + p + " " + event);
+ for (Iterator<Event> it = events.iterator(); it.hasNext();) {
+ final Event current = it.next();
+ if (current instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) current;
+ if (le.getParticipant() == p && le.isActivate()) {
+ level++;
+ }
+ if (le.getParticipant() == p && le.isDeactivateOrDestroy()) {
+ level--;
+ }
+ }
+ if (event == current) {
+ if (current instanceof Message) {
+ final Event next = nextButSkippingNotes(it);
+ if (next instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) next;
+ final Message msg = (Message) current;
+ if (mode != EventsHistoryMode.IGNORE_FUTURE_ACTIVATE && le.isActivate() && msg.dealWith(p)
+ && le.getParticipant() == p) {
+ level++;
+ }
+ if (mode == EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE && le.isDeactivateOrDestroy()
+ && msg.dealWith(p) && le.getParticipant() == p) {
+ level--;
+ }
+ // System.err.println("Warning, this is message " + current + " next=" + next);
+ }
+
+ }
+ // System.err.println("<-result1 is " + level);
+ return level;
+ }
+ }
+ throw new IllegalArgumentException();
+ // return level;
+ }
+
+ private boolean isNextEventADestroy(Event event) {
+ for (Iterator<Event> it = events.iterator(); it.hasNext();) {
+ final Event current = it.next();
+ if (event != current) {
+ continue;
+ }
+ if (current instanceof Message) {
+ final Event next = nextButSkippingNotes(it);
+ if (next instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) next;
+ return le.isDestroy();
+ }
+ }
+ return false;
+ }
+ return false;
+ }
+
+ private HtmlColor getActivateColor(Event event) {
+ for (Iterator<Event> it = events.iterator(); it.hasNext();) {
+ final Event current = it.next();
+ if (event != current) {
+ continue;
+ }
+ if (current instanceof Message) {
+ final Event next = nextButSkippingNotes(it);
+ if (next instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) next;
+ if (le.isActivate()) {
+ return le.getSpecificBackColor();
+ }
+ return null;
+ }
+ }
+ return null;
+ }
+ return null;
+ }
+
+ private Event nextButSkippingNotes(Iterator<Event> it) {
+ while (true) {
+ if (it.hasNext() == false) {
+ return null;
+ }
+ final Event next = it.next();
+ if (next instanceof Note) {
+ continue;
+ }
+ // System.err.println("nextButSkippingNotes=" + next);
+ return next;
+ }
+ }
+
+ public Stairs2 getStairs(double totalHeight) {
+ System.err.println("EventsHistory::getStairs totalHeight=" + totalHeight);
+ final Stairs2 result = new Stairs2();
+ int value = 0;
+ for (Event event : events) {
+ final Double position = ys3.get(event);
+ System.err.println("EventsHistory::getStairs event=" + event + " position=" + position);
+ if (position != null) {
+ assert position <= totalHeight : "position=" + position + " totalHeight=" + totalHeight;
+ value = getLevelAt(event, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE);
+ result.addStep(new StairsPosition(position, isNextEventADestroy(event)), value, getActivateColor(event));
+ }
+ }
+ System.err.println("EventsHistory::getStairs finishing totalHeight=" + totalHeight);
+ result.addStep(new StairsPosition(totalHeight, false), value, null);
+ // System.err.println("EventsHistory::getStairs " + p + " result=" + result);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java
new file mode 100644
index 0000000..b265bb8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+public enum EventsHistoryMode {
+ IGNORE_FUTURE_DEACTIVATE, IGNORE_FUTURE_ACTIVATE, CONSIDERE_FUTURE_DEACTIVATE;
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java
new file mode 100644
index 0000000..8ba04c1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java
@@ -0,0 +1,166 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealMax;
+import net.sourceforge.plantuml.real.RealMin;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Grouping;
+import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
+import net.sourceforge.plantuml.sequencediagram.GroupingStart;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GroupingTile implements Tile {
+
+ private static final int MARGINX = 16;
+ private static final int MARGINY = 10;
+ private final List<Tile> tiles = new ArrayList<Tile>();
+ private final RealMin min = new RealMin();
+ private final RealMax max = new RealMax();
+ private final GroupingStart start;
+
+ // private final double marginX = 20;
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display display;
+
+ private double bodyHeight;
+
+ public Event getEvent() {
+ return start;
+ }
+
+ public GroupingTile(Iterator<Event> it, GroupingStart start, TileArguments tileArgumentsBachColorChanged,
+ TileArguments tileArgumentsOriginal) {
+ final StringBounder stringBounder = tileArgumentsOriginal.getStringBounder();
+ this.start = start;
+ this.display = start.getTitle().equals("group") ? Display.create(start.getComment()) : Display.create(
+ start.getTitle(), start.getComment());
+ this.skin = tileArgumentsOriginal.getSkin();
+ this.skinParam = tileArgumentsBachColorChanged.getSkinParam();
+ // this.max = min.addAtLeast(dim1.getWidth());
+
+ while (it.hasNext()) {
+ final Event ev = it.next();
+ System.err.println("GroupingTile::ev=" + ev);
+ if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) {
+ break;
+ }
+ final Tile tile = TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this);
+ if (tile != null) {
+ tiles.add(tile);
+ min.put(tile.getMinX(stringBounder).addFixed(-MARGINX));
+ final Real m = tile.getMaxX(stringBounder);
+ max.put(m == tileArgumentsOriginal.getOmega() ? m : m.addFixed(MARGINX));
+ bodyHeight += tile.getPreferredHeight(stringBounder);
+ }
+ }
+ final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
+ final double width = dim1.getWidth();
+ System.err.println("width=" + width);
+ if (min.size() == 0) {
+ min.put(tileArgumentsOriginal.getOrigin());
+ max.put(tileArgumentsOriginal.getOmega());
+ }
+ // max.ensureBiggerThan(min.addFixed(width));
+ this.max.ensureBiggerThan(getMinX(stringBounder).addFixed(width + 16));
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.GROUPING_HEADER, null, skinParam, display);
+ return comp;
+ }
+
+ public Dimension2D getPreferredDimensionIfEmpty(StringBounder stringBounder) {
+ return getComponent(stringBounder).getPreferredDimension(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
+ final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), bodyHeight + dim1.getHeight()
+ + MARGINY / 2);
+
+ if (ug instanceof LiveBoxFinder == false) {
+ comp.drawU(ug.apply(new UTranslate(min.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+ // ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).draw(new URectangle(area.getDimensionToUse()));
+
+ double h = dim1.getHeight() + MARGINY / 2;
+ for (Tile tile : tiles) {
+ ug.apply(new UTranslate(0, h)).draw(tile);
+ h += tile.getPreferredHeight(stringBounder);
+ }
+
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
+ return dim1.getHeight() + bodyHeight + MARGINY;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ for (Tile tile : tiles) {
+ tile.addConstraints(stringBounder);
+ }
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return min;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return max;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java
new file mode 100644
index 0000000..19da327
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class IntegerColored {
+
+ private final int value;
+ private final HtmlColor color;
+
+ public IntegerColored(int value, HtmlColor color) {
+ this.value = value;
+ this.color = color;
+ }
+
+ @Override
+ public String toString() {
+ return "" + value + " " + color;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java
new file mode 100644
index 0000000..a7430d6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class LifeEventTile implements TileWithUpdateStairs {
+
+ private final LifeEvent lifeEvent;
+ private final TileArguments tileArguments;
+ private final LivingSpace livingSpace;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ System.err.println("LifeEventTile::updateStairs " + lifeEvent + " " + livingSpace.getParticipant() + " y=" + y);
+ livingSpace.addStepForLivebox(getEvent(), y);
+ }
+
+ public Event getEvent() {
+ return lifeEvent;
+ }
+
+ public LifeEventTile(LifeEvent lifeEvent, TileArguments tileArguments, LivingSpace livingSpace, Skin skin,
+ ISkinParam skinParam) {
+ this.lifeEvent = lifeEvent;
+ this.tileArguments = tileArguments;
+ this.livingSpace = livingSpace;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ if (lifeEvent.isActivate()) {
+ return 20;
+ }
+ return 0;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosB();
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosD(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java
new file mode 100644
index 0000000..93c943b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UParamNull;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LiveBoxFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new LiveBoxFinder(stringBounder, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new LiveBoxFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new LiveBoxFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new LiveBoxFinder(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+
+ public LiveBoxFinder(StringBounder stringBounder) {
+ this(stringBounder, new UTranslate());
+ }
+
+ private LiveBoxFinder(StringBounder stringBounder, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.translate = translate;
+ }
+
+ private LiveBoxFinder(LiveBoxFinder other) {
+ this(other.stringBounder, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof GroupingTile) {
+ ((GroupingTile) shape).drawU(this);
+ } else if (shape instanceof TileWithUpdateStairs) {
+ ((TileWithUpdateStairs) shape).updateStairs(stringBounder, y);
+ } else if (shape instanceof Tile) {
+ System.err.println("OtherTile " + shape);
+ } else {
+ throw new UnsupportedOperationException(shape.getClass().getName());
+ }
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java
new file mode 100644
index 0000000..c174374
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.Iterator;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LiveBoxes implements UDrawable {
+
+ private final EventsHistory eventsHistory;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final double totalHeight;
+ private final Context2D context;
+
+ public LiveBoxes(EventsHistory eventsHistory, Skin skin, ISkinParam skinParam, double totalHeight, Context2D context) {
+ this.eventsHistory = eventsHistory;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.totalHeight = totalHeight;
+ this.context = context;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Stairs2 stairs = eventsHistory.getStairs(totalHeight);
+ final int max = stairs.getMaxValue();
+ for (int i = 1; i <= max; i++) {
+ drawOneLevel(ug, i, stairs, context);
+ }
+ }
+
+ private void drawOneLevel(UGraphic ug, int levelToDraw, Stairs2 stairs, Context2D context) {
+ final Component comp1 = skin.createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam, null);
+ final Component cross = skin.createComponent(ComponentType.DESTROY, null, skinParam, null);
+ final Dimension2D dimCross = cross.getPreferredDimension(ug.getStringBounder());
+ final double width = comp1.getPreferredWidth(ug.getStringBounder());
+ ug = ug.apply(new UTranslate((levelToDraw - 1) * width / 2.0, 0));
+
+ double y1 = Double.MAX_VALUE;
+ HtmlColor color = null;
+ for (Iterator<StairsPosition> it = stairs.getYs().iterator(); it.hasNext();) {
+ final StairsPosition yposition = it.next();
+ System.err.println("LiveBoxes::drawOneLevel " + levelToDraw + " " + yposition);
+ final IntegerColored integerColored = stairs.getValue(yposition.getValue());
+ System.err.println("integerColored=" + integerColored);
+ final int level = integerColored.getValue();
+ if (y1 == Double.MAX_VALUE && level == levelToDraw) {
+ y1 = yposition.getValue();
+ color = integerColored.getColor();
+ } else if (y1 != Double.MAX_VALUE && (it.hasNext() == false || level < levelToDraw)) {
+ final double y2 = yposition.getValue();
+ final Area area = new Area(width, y2 - y1);
+
+ final ISkinParam skinParam2 = new SkinParamBackcolored(skinParam, color);
+ final Component comp = skin
+ .createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam2, null);
+
+ comp.drawU(ug.apply(new UTranslate(-width / 2, y1)), area, context);
+ System.err.println("LiveBoxes::drawOneLevel one block " + y1 + " " + y2);
+ if (yposition.isDestroy()) {
+ System.err.println("LiveBoxes::drawOneLevel DESTROY " + yposition);
+ cross.drawU(ug.apply(new UTranslate(-dimCross.getWidth() / 2, y2 - dimCross.getHeight() / 2)),
+ null, context);
+ } else {
+ System.err.println("LiveBoxes::drawOneLevel NOTDESTROY " + yposition);
+ }
+ y1 = Double.MAX_VALUE;
+ }
+ }
+ }
+
+ private UGraphic withColor(UGraphic ug) {
+ return ug;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java
new file mode 100644
index 0000000..462a35b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java
@@ -0,0 +1,205 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober;
+import net.sourceforge.plantuml.sequencediagram.ParticipantType;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class LivingSpace {
+
+ private final Participant p;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final ComponentType headType;
+ private final ComponentType tailType;
+ private final boolean useContinueLineBecauseOfDelay;
+ private final MutingLine mutingLine;
+ private final Rose rose = new Rose();
+
+ // private final LivingSpaceImpl previous;
+ // private LivingSpace next;
+
+ private final Real posB;
+ private Real posC;
+ private Real posD;
+
+ private final EventsHistory eventsHistory;
+
+ public int getLevelAt(Tile tile, EventsHistoryMode mode) {
+ // assert mode == EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE;
+ return eventsHistory.getLevelAt(tile.getEvent(), mode);
+ }
+
+ public void addStepForLivebox(Event event, double y) {
+ eventsHistory.addStepForLivebox(event, y);
+ }
+
+ @Override
+ public String toString() {
+ return p.getCode() + " B=" + posB.getCurrentValue() + "/C=" + currentValue(posC) + "/D=" + currentValue(posD);
+ }
+
+ private static String currentValue(Real pos) {
+ if (pos == null) {
+ return null;
+ }
+ return "" + pos.getCurrentValue();
+ }
+
+ public LivingSpace(Participant p, ParticipantEnglober englober, Skin skin, ISkinParam skinParam, Real position,
+ List<Event> events) {
+ this.eventsHistory = new EventsHistory(p, events);
+ this.p = p;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.posB = position;
+ if (p.getType() == ParticipantType.PARTICIPANT) {
+ headType = ComponentType.PARTICIPANT_HEAD;
+ tailType = ComponentType.PARTICIPANT_TAIL;
+ } else if (p.getType() == ParticipantType.ACTOR) {
+ headType = ComponentType.ACTOR_HEAD;
+ tailType = ComponentType.ACTOR_TAIL;
+ } else if (p.getType() == ParticipantType.BOUNDARY) {
+ headType = ComponentType.BOUNDARY_HEAD;
+ tailType = ComponentType.BOUNDARY_TAIL;
+ } else if (p.getType() == ParticipantType.CONTROL) {
+ headType = ComponentType.CONTROL_HEAD;
+ tailType = ComponentType.CONTROL_TAIL;
+ } else if (p.getType() == ParticipantType.ENTITY) {
+ headType = ComponentType.ENTITY_HEAD;
+ tailType = ComponentType.ENTITY_TAIL;
+ } else if (p.getType() == ParticipantType.DATABASE) {
+ headType = ComponentType.DATABASE_HEAD;
+ tailType = ComponentType.DATABASE_TAIL;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ // this.stairs2.addStep2(0, p.getInitialLife());
+ // this.stairs2.addStep2(0, 0);
+ this.useContinueLineBecauseOfDelay = useContinueLineBecauseOfDelay(events);
+ this.mutingLine = new MutingLine(skin, skinParam, events);
+
+ }
+
+ private boolean useContinueLineBecauseOfDelay(List<Event> events) {
+ final String strategy = skinParam.getValue("lifelineStrategy");
+ if ("nosolid".equalsIgnoreCase(strategy)) {
+ return false;
+ }
+ for (Event ev : events) {
+ if (ev instanceof Delay) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void drawLineAndLiveBoxes(UGraphic ug, double height, Context2D context) {
+
+ mutingLine.drawLine(ug, height, context);
+ // final ComponentType defaultLineType = useContinueLineBecauseOfDelay ? ComponentType.CONTINUE_LINE
+ // : ComponentType.PARTICIPANT_LINE;
+ // final Component comp = skin.createComponent(defaultLineType, null, skinParam, p.getDisplay(false));
+ // final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder());
+ // final Area area = new Area(dim.getWidth(), height);
+ // comp.drawU(ug, area, new SimpleContext2D(false));
+
+ final LiveBoxes liveBoxes = new LiveBoxes(eventsHistory, skin, skinParam, height, context);
+ liveBoxes.drawU(ug);
+ }
+
+ // public void addDelayTile(DelayTile tile) {
+ // System.err.println("addDelayTile " + this + " " + tile);
+ // }
+
+ public void drawHead(UGraphic ug, Context2D context) {
+ // final Component comp = skin.createComponent(headType, null, skinParam, p.getDisplay(false));
+ final Component comp = rose.createComponent(headType, null, p.getSkinParamBackcolored(skinParam),
+ p.getDisplay(false));
+ final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder());
+ final Area area = new Area(dim);
+ comp.drawU(ug, area, context);
+ }
+
+ public Dimension2D getHeadPreferredDimension(StringBounder stringBounder) {
+ // final Component comp = skin.createComponent(headType, null, skinParam, p.getDisplay(false));
+ final Component comp = rose.createComponent(headType, null, skinParam, p.getDisplay(false));
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim;
+ }
+
+ private double getPreferredWidth(StringBounder stringBounder) {
+ return getHeadPreferredDimension(stringBounder).getWidth();
+ }
+
+ public Real getPosC(StringBounder stringBounder) {
+ if (posC == null) {
+ this.posC = posB.addFixed(this.getPreferredWidth(stringBounder) / 2);
+ }
+ return posC;
+ }
+
+ public Real getPosD(StringBounder stringBounder) {
+ if (posD == null) {
+ this.posD = posB.addFixed(this.getPreferredWidth(stringBounder));
+ }
+ return posD;
+ }
+
+ public Real getPosB() {
+ return posB;
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java
new file mode 100644
index 0000000..db9823f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LivingSpaces {
+
+ private final Map<Participant, LivingSpace> all = new LinkedHashMap<Participant, LivingSpace>();
+
+ public Collection<LivingSpace> values() {
+ return all.values();
+ }
+
+ public void put(Participant participant, LivingSpace livingSpace) {
+ all.put(participant, livingSpace);
+ }
+
+ public LivingSpace get(Participant participant) {
+ return all.get(participant);
+ }
+
+ public void drawHeads(final UGraphic ug, Context2D context, VerticalAlignment verticalAlignment) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double headHeight = getHeadHeight(stringBounder);
+ for (LivingSpace livingSpace : values()) {
+ final double x = livingSpace.getPosB().getCurrentValue();
+ double y = 0;
+ if (verticalAlignment == VerticalAlignment.BOTTOM) {
+ final Dimension2D dimHead = livingSpace.getHeadPreferredDimension(stringBounder);
+ y = headHeight - dimHead.getHeight();
+ }
+ livingSpace.drawHead(ug.apply(new UTranslate(x, y)), context);
+ }
+ }
+
+ public double getHeadHeight(StringBounder stringBounder) {
+ double headHeight = 0;
+ for (LivingSpace livingSpace : values()) {
+ final Dimension2D headDim = livingSpace.getHeadPreferredDimension(stringBounder);
+ headHeight = Math.max(headHeight, headDim.getHeight());
+ }
+ return headHeight;
+ }
+
+ public void drawLifeLines(final UGraphic ug, double height, Context2D context) {
+ int i = 0;
+ for (LivingSpace livingSpace : values()) {
+ // if (i++ == 0) {
+ // System.err.println("TEMPORARY SKIPPING OTHERS");
+ // continue;
+ // }
+ // System.err.println("drawing lines " + livingSpace);
+ final double x = livingSpace.getPosC(ug.getStringBounder()).getCurrentValue();
+ livingSpace.drawLineAndLiveBoxes(ug.apply(new UTranslate(x, 0)), height, context);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java
new file mode 100644
index 0000000..1153f8f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java
@@ -0,0 +1,144 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealMax;
+import net.sourceforge.plantuml.real.RealMin;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.LimitFinder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class MainTile implements Tile {
+
+ private final RealMin min = new RealMin();
+ private final RealMax max = new RealMax();
+ // private double height;
+
+ private final List<Tile> tiles = new ArrayList<Tile>();
+
+ public MainTile(SequenceDiagram diagram, Skin skin, Real omega, LivingSpaces livingSpaces, Real origin) {
+
+ min.put(origin);
+ max.put(omega);
+
+ final ISkinParam skinParam = diagram.getSkinParam();
+ final StringBounder stringBounder = TextBlockUtils.getDummyStringBounder();
+
+ final TileArguments tileArguments = new TileArguments(stringBounder, omega, livingSpaces, skin, skinParam,
+ origin);
+
+ tiles.addAll(TileBuilder.buildSeveral(diagram.events().iterator(), tileArguments, null));
+
+ for (Tile tile : tiles) {
+ // height += tile.getPreferredHeight(stringBounder);
+ min.put(tile.getMinX(stringBounder));
+ max.put(tile.getMaxX(stringBounder));
+ }
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final LiveBoxFinder liveBoxFinder = new LiveBoxFinder(stringBounder);
+
+ drawUInternal(liveBoxFinder, false);
+ final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, true);
+ drawUInternal(interceptor, false);
+ }
+
+ public void drawForeground(UGraphic ug) {
+ final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, false);
+ drawUInternal(interceptor, false);
+ }
+
+ private double drawUInternal(UGraphic ug, boolean trace) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ double y = 0;
+ double lastY = 0;
+ final List<YPositionedTile> positionedTiles = new ArrayList<YPositionedTile>();
+ for (Tile tile : tiles) {
+ if (tile.getEvent().isParallel()) {
+ y = lastY;
+ }
+ if (trace) {
+ System.err.println("MainTile::drawUInternal tile=" + tile + " y=" + y);
+ }
+ positionedTiles.add(new YPositionedTile(tile, y));
+ lastY = y;
+ y += tile.getPreferredHeight(stringBounder);
+ }
+ for (YPositionedTile tile : positionedTiles) {
+ tile.drawU(ug);
+ }
+ System.err.println("MainTile::drawUInternal finalY=" + y);
+ return y;
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final LimitFinder limitFinder = new LimitFinder(stringBounder, true);
+ final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(limitFinder, false);
+ final double finalY = drawUInternal(interceptor, true);
+ final double result = Math.max(limitFinder.getMinMax().getDimension().getHeight(), finalY) + 10;
+ System.err.println("MainTile::getPreferredHeight=" + result);
+ return result;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ for (Tile tile : tiles) {
+ tile.addConstraints(stringBounder);
+ }
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return min;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return max;
+ }
+
+ public Event getEvent() {
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java
new file mode 100644
index 0000000..47a80e6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class MutingLine {
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final boolean useContinueLineBecauseOfDelay;
+
+ public MutingLine(Skin skin, ISkinParam skinParam, List<Event> events) {
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.useContinueLineBecauseOfDelay = useContinueLineBecauseOfDelay(events);
+ }
+
+ private boolean useContinueLineBecauseOfDelay(List<Event> events) {
+ final String strategy = skinParam.getValue("lifelineStrategy");
+ if ("nosolid".equalsIgnoreCase(strategy)) {
+ return false;
+ }
+ for (Event ev : events) {
+ if (ev instanceof Delay) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void drawLine(UGraphic ug, double height, Context2D context) {
+ final ComponentType defaultLineType = useContinueLineBecauseOfDelay ? ComponentType.CONTINUE_LINE
+ : ComponentType.PARTICIPANT_LINE;
+ final Component comp = skin.createComponent(defaultLineType, null, skinParam, null);
+ final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder());
+ final Area area = new Area(dim.getWidth(), height);
+ comp.drawU(ug, area, context);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java
new file mode 100644
index 0000000..e639907
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java
@@ -0,0 +1,148 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealUtils;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class NoteTile implements Tile {
+
+ private final LivingSpace livingSpace1;
+ private final LivingSpace livingSpace2;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Note note;
+
+ public Event getEvent() {
+ return note;
+ }
+
+ public NoteTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Note note, Skin skin, ISkinParam skinParam) {
+ this.livingSpace1 = livingSpace1;
+ this.livingSpace2 = livingSpace2;
+ this.note = note;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null, note.getSkinParamBackcolored(skinParam),
+ note.getStrings());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double x = getX(stringBounder).getCurrentValue();
+ final Area area = new Area(getUsedWidth(stringBounder), dim.getHeight());
+
+ ug = ug.apply(new UTranslate(x, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ // ug.draw(new ULine(x2 - x1, 0));
+ }
+
+ private double getUsedWidth(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+ if (note.getPosition() == NotePosition.OVER_SEVERAL) {
+ final double x1 = livingSpace1.getPosB().getCurrentValue();
+ final double x2 = livingSpace2.getPosD(stringBounder).getCurrentValue();
+ final double w = x2 - x1;
+ if (width < w) {
+ return w;
+ }
+ }
+ return width;
+ }
+
+ private Real getX(StringBounder stringBounder) {
+ final NotePosition position = note.getPosition();
+ final double width = getUsedWidth(stringBounder);
+ if (position == NotePosition.LEFT) {
+ return livingSpace1.getPosC(stringBounder).addFixed(-width);
+ } else if (position == NotePosition.RIGHT) {
+ final int level = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
+ final double dx = level * CommunicationTile.LIVE_DELTA_SIZE;
+ return livingSpace1.getPosC(stringBounder).addFixed(dx);
+ } else if (position == NotePosition.OVER_SEVERAL) {
+ final Real x1 = livingSpace1.getPosC(stringBounder);
+ final Real x2 = livingSpace2.getPosC(stringBounder);
+ return RealUtils.middle(x1, x2).addFixed(-width / 2);
+ } else if (position == NotePosition.OVER) {
+ return livingSpace1.getPosC(stringBounder).addFixed(-width / 2);
+ } else {
+ throw new UnsupportedOperationException(position.toString());
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return getX(stringBounder).addFixed(getUsedWidth(stringBounder));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java
new file mode 100644
index 0000000..5e88e7b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ReferenceTile implements Tile {
+
+ private final Reference reference;
+ private final TileArguments tileArguments;
+ private Real first;
+ private Real last;
+
+ public Event getEvent() {
+ return reference;
+ }
+
+
+ public ReferenceTile(Reference reference, TileArguments tileArguments) {
+ this.reference = reference;
+ this.tileArguments = tileArguments;
+ }
+
+ private void init(StringBounder stringBounder) {
+ if (first != null) {
+ return;
+ }
+ for (Participant p : reference.getParticipant()) {
+ final LivingSpace livingSpace = tileArguments.getLivingSpace(p);
+ final Real pos = livingSpace.getPosC(stringBounder);
+ if (first == null || pos.getCurrentValue() < first.getCurrentValue()) {
+ this.first = pos;
+ }
+ if (last == null || pos.getCurrentValue() > last.getCurrentValue()) {
+ this.last = pos;
+ }
+ }
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ this.last = this.last.addAtLeast(0);
+ this.last.ensureBiggerThan(this.first.addFixed(dim.getWidth()));
+
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ Display strings = Display.empty();
+ strings = strings.add("ref");
+ strings = strings.addAll(reference.getStrings());
+
+ final Component comp = tileArguments.getSkin().createComponent(ComponentType.REFERENCE, null,
+ tileArguments.getSkinParam(), strings);
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ init(stringBounder);
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(last.getCurrentValue() - first.getCurrentValue(), dim.getHeight());
+
+ ug = ug.apply(new UTranslate(first.getCurrentValue(), 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.first;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.last;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java
new file mode 100644
index 0000000..7699637
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java
@@ -0,0 +1,243 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+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.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.png.PngTitler;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealUtils;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten;
+import net.sourceforge.plantuml.utils.MathUtils;
+
+public class SequenceDiagramFileMakerTeoz implements FileMaker {
+
+ private final SequenceDiagram diagram;
+ private final FileFormatOption fileFormatOption;
+ private final Skin skin;
+
+ public SequenceDiagramFileMakerTeoz(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) {
+ this.diagram = sequenceDiagram;
+ this.fileFormatOption = fileFormatOption;
+ this.skin = skin;
+
+ }
+
+ public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
+ StringBounder stringBounder = TextBlockUtils.getDummyStringBounder();
+
+ final ISkinParam skinParam = diagram.getSkinParam();
+
+ final Real origin = RealUtils.createOrigin();
+ Real currentPos = origin.addAtLeast(0);
+ LivingSpace last = null;
+ LivingSpaces livingSpaces = new LivingSpaces();
+ for (Participant p : diagram.participants().values()) {
+ final LivingSpace livingSpace = new LivingSpace(p, diagram.getEnglober(p), skin, skinParam, currentPos,
+ diagram.events());
+ last = livingSpace;
+ ((LivingSpaces) livingSpaces).put(p, livingSpace);
+ currentPos = livingSpace.getPosD(stringBounder).addAtLeast(0);
+ }
+
+ final MainTile mainTile = new MainTile(diagram, skin, last.getPosD(stringBounder).addAtLeast(0), livingSpaces,
+ origin);
+ mainTile.addConstraints(stringBounder);
+ origin.compile();
+
+ final double mainHeight = mainTile.getPreferredHeight(stringBounder) + 2
+ * livingSpaces.getHeadHeight(stringBounder);
+
+ final Real min1 = mainTile.getMinX(stringBounder);
+ final Real max1 = mainTile.getMaxX(stringBounder);
+ // System.err.println("min1=" + min1.getCurrentValue());
+ // System.err.println("max1=" + max1.getCurrentValue());
+
+ final Component compTitle = getCompTitle();
+
+ final double mainWidth = max1.getCurrentValue() - min1.getCurrentValue();
+
+ Dimension2D dimTitle = new Dimension2DDouble(0, 0);
+ if (compTitle != null) {
+ dimTitle = compTitle.getPreferredDimension(stringBounder);
+ }
+
+ final PngTitler footer = getFooter();
+ Dimension2D dimFooter = new Dimension2DDouble(0, 0);
+ if (footer != null && footer.getTextBlock() != null) {
+ dimFooter = footer.getTextBlock().calculateDimension(stringBounder);
+ }
+
+ final PngTitler header = getHeader();
+ Dimension2D dimHeader = new Dimension2DDouble(0, 0);
+ if (header != null && header.getTextBlock() != null) {
+ dimHeader = header.getTextBlock().calculateDimension(stringBounder);
+ }
+
+ final double totalWidth = MathUtils.max(mainWidth, dimTitle.getWidth(), dimFooter.getWidth(),
+ dimHeader.getWidth());
+ final double totalHeight = mainHeight + dimTitle.getHeight() + dimHeader.getHeight() + dimFooter.getHeight();
+ final Dimension2D dim = new Dimension2DDouble(totalWidth, totalHeight);
+ final UGraphic2 ug2 = (UGraphic2) fileFormatOption.createUGraphic(skinParam.getColorMapper(),
+ diagram.getDpiFactor(fileFormatOption), dim, skinParam.getBackgroundColor(), false).apply(
+ new UTranslate(-min1.getCurrentValue(), 0));
+
+ UGraphic ug = diagram.getSkinParam().handwritten() ? new UGraphicHandwritten(ug2) : ug2;
+
+ if (footer != null && footer.getTextBlock() != null) {
+ double dx = 0;
+ if (diagram.getFooterAlignment() == HorizontalAlignment.RIGHT) {
+ dx = totalWidth - dimFooter.getWidth();
+ } else if (diagram.getFooterAlignment() == HorizontalAlignment.CENTER) {
+ dx = (totalWidth - dimFooter.getWidth()) / 2;
+ }
+ footer.getTextBlock().drawU(
+ ug.apply(new UTranslate(dx, mainHeight + dimTitle.getHeight() + dimHeader.getHeight())));
+ }
+ if (header != null && header.getTextBlock() != null) {
+ double dx = 0;
+ if (diagram.getHeaderAlignment() == HorizontalAlignment.RIGHT) {
+ dx = totalWidth - dimHeader.getWidth();
+ } else if (diagram.getHeaderAlignment() == HorizontalAlignment.CENTER) {
+ dx = (totalWidth - dimHeader.getWidth()) / 2;
+ }
+ header.getTextBlock().drawU(ug.apply(new UTranslate(dx, 0)));
+ }
+ if (compTitle != null) {
+ compTitle.drawU(ug.apply(new UTranslate((totalWidth - dimTitle.getWidth()) / 2, 0)), new Area(dimTitle),
+ new SimpleContext2D(false));
+ ug = ug.apply(new UTranslate((totalWidth - mainWidth) / 2, dimTitle.getHeight() + dimHeader.getHeight()));
+ }
+
+ drawMainTile(ug, mainTile, livingSpaces);
+
+ ug2.writeImageTOBEMOVED(os, isWithMetadata ? diagram.getMetadata() : null, diagram.getDpi(fileFormatOption));
+ final Dimension2D info = new Dimension2DDouble(dim.getWidth(), dim.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 Component getCompTitle() {
+ final Display title = diagram.getTitle();
+
+ final Component compTitle;
+ if (title == null) {
+ compTitle = null;
+ } else {
+ compTitle = skin.createComponent(ComponentType.TITLE, null, diagram.getSkinParam(), title);
+ }
+ return compTitle;
+ }
+
+ private PngTitler getFooter() {
+ if (diagram.getFooter() == null) {
+ return null;
+ }
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
+ diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ return pngTitler;
+ }
+
+ private PngTitler getHeader() {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
+ diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ return pngTitler;
+ }
+
+ private void drawMainTile(final UGraphic ug, final MainTile mainTile, LivingSpaces livingSpaces) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Context2D context = new SimpleContext2D(false);
+ livingSpaces.drawHeads(ug, context, VerticalAlignment.BOTTOM);
+
+ final double headHeight = livingSpaces.getHeadHeight(stringBounder);
+
+ mainTile.drawU(ug.apply(new UTranslate(0, headHeight)));
+ livingSpaces.drawLifeLines(ug.apply(new UTranslate(0, headHeight)), mainTile.getPreferredHeight(stringBounder),
+ context);
+ livingSpaces.drawHeads(ug.apply(new UTranslate(0, mainTile.getPreferredHeight(stringBounder) + headHeight)),
+ context, VerticalAlignment.TOP);
+ mainTile.drawForeground(ug.apply(new UTranslate(0, headHeight)));
+ }
+
+ public int getNbPages() {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java
new file mode 100644
index 0000000..f6cdcc3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Stairs2 {
+
+ private final List<StairsPosition> ys = new ArrayList<StairsPosition>();
+ private final List<IntegerColored> values = new ArrayList<IntegerColored>();
+ private final Map<Double, IntegerColored> cache = new HashMap<Double, IntegerColored>();
+
+ public void addStep(StairsPosition position, int value, HtmlColor color) {
+ System.err.println("Stairs2::addStep " + position + " " + value + " color=" + color);
+ assert ys.size() == values.size();
+ if (ys.size() > 0) {
+ final double lastY = ys.get(ys.size() - 1).getValue();
+ if (position.getValue() < lastY) {
+ throw new IllegalArgumentException();
+ }
+ if (lastY == position.getValue()) {
+ values.set(ys.size() - 1, new IntegerColored(value, color));
+ cache.clear();
+ return;
+ }
+ }
+ ys.add(position);
+ values.add(new IntegerColored(value, color));
+ cache.clear();
+ }
+
+ public int getMaxValue() {
+ int max = Integer.MIN_VALUE;
+ for (IntegerColored vc : values) {
+ final int v = vc.getValue();
+ if (v > max) {
+ max = v;
+ }
+ }
+ return max;
+ }
+
+ public List<StairsPosition> getYs() {
+ return Collections.unmodifiableList(ys);
+ }
+
+ public IntegerColored getValue(double y) {
+ IntegerColored resultc = cache.get(y);
+ if (resultc == null) {
+ resultc = getValueSlow(new StairsPosition(y, false));
+ cache.put(y, resultc);
+ }
+ return resultc;
+ }
+
+ private IntegerColored getValueSlow(StairsPosition y) {
+ final int idx = Collections.binarySearch(ys, y);
+ if (idx >= 0) {
+ return values.get(idx);
+ }
+ final int insertPoint = -idx - 1;
+ if (insertPoint == 0) {
+ return new IntegerColored(0, null);
+ }
+ return values.get(insertPoint - 1);
+ }
+
+ public int getLastValue() {
+ final int size = values.size();
+ if (size == 0) {
+ return 0;
+ }
+ return values.get(size - 1).getValue();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java
new file mode 100644
index 0000000..cf4e0f8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+
+public class StairsPosition implements Comparable<StairsPosition> {
+
+ private final double value;
+ private final boolean destroy;
+
+ public StairsPosition(double value, boolean destroy) {
+ this.value = value;
+ this.destroy = destroy;
+ }
+
+ @Override
+ public String toString() {
+ return "" + value + "-(" + destroy + ")";
+ }
+
+ public double getValue() {
+ return value;
+ }
+
+ public int compareTo(StairsPosition other) {
+ if (this.value > other.value) {
+ return 1;
+ }
+ if (this.value < other.value) {
+ return -1;
+ }
+ return 0;
+ }
+
+ public boolean isDestroy() {
+ return destroy;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java
new file mode 100644
index 0000000..1a106fe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public interface Tile extends UDrawable, UShape {
+
+ public double getPreferredHeight(StringBounder stringBounder);
+
+ public void addConstraints(StringBounder stringBounder);
+
+ public Real getMinX(StringBounder stringBounder);
+
+ public Real getMaxX(StringBounder stringBounder);
+
+ public Event getEvent();
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java
new file mode 100644
index 0000000..4edee7e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SkinParamBackcoloredReference;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Skin;
+
+public class TileArguments {
+ private final StringBounder stringBounder;
+ private final Real omega;
+ private final Real origin;
+ private final LivingSpaces livingSpaces;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+
+ public TileArguments(StringBounder stringBounder, Real omega, LivingSpaces livingSpaces, Skin skin,
+ ISkinParam skinParam, Real origin) {
+ this.stringBounder = stringBounder;
+ this.origin = origin;
+ this.omega = omega;
+ this.livingSpaces = livingSpaces;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ public TileArguments withBackColorGeneral(HtmlColor backColorElement, HtmlColor backColorGeneral) {
+ return new TileArguments(stringBounder, omega, livingSpaces, skin, new SkinParamBackcolored(skinParam,
+ backColorElement, backColorGeneral), origin);
+ }
+
+ public TileArguments withBackColor(Reference reference) {
+ final ISkinParam newSkinParam = new SkinParamBackcoloredReference(skinParam, reference.getBackColorElement(),
+ reference.getBackColorGeneral());
+ return new TileArguments(stringBounder, omega, livingSpaces, skin, newSkinParam, origin);
+ }
+
+ public final StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public final Real getOmega() {
+ return omega;
+ }
+
+ public final Real getOrigin() {
+ return origin;
+ }
+
+ public final LivingSpaces getLivingSpaces() {
+ return livingSpaces;
+ }
+
+ public final Skin getSkin() {
+ return skin;
+ }
+
+ public final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ public LivingSpace getLivingSpace(Participant p) {
+ return livingSpaces.get(p);
+ }
+
+ public LivingSpace getFirstLivingSpace() {
+ return livingSpaces.values().iterator().next();
+ }
+
+ public LivingSpace getLastLivingSpace() {
+ LivingSpace result = null;
+ for (LivingSpace v : livingSpaces.values()) {
+ result = v;
+ }
+ return result;
+ }
+
+ // public void ensure(Tile tile) {
+ // getAlpha().ensureLowerThan(tile.getMinX(getStringBounder()));
+ // getOmega().ensureBiggerThan(tile.getMaxX(getStringBounder()));
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java
new file mode 100644
index 0000000..7a46663
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java
@@ -0,0 +1,155 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcoloredReference;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+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;
+import net.sourceforge.plantuml.sequencediagram.GroupingStart;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Skin;
+
+public class TileBuilder {
+
+ public static List<Tile> buildSeveral(Iterator<Event> it, TileArguments tileArguments, Tile parent) {
+ final List<Tile> tiles = new ArrayList<Tile>();
+ while (it.hasNext()) {
+ final Event ev = it.next();
+ final Tile tile = TileBuilder.buildOne(it, tileArguments, ev, parent);
+ if (tile != null) {
+ tiles.add(tile);
+ tileArguments.getOmega().ensureBiggerThan(tile.getMaxX(tileArguments.getStringBounder()));
+ }
+ }
+ return Collections.unmodifiableList(tiles);
+ }
+
+ public static Tile buildOne(Iterator<Event> it, TileArguments tileArguments, final Event ev, Tile parent) {
+
+ final StringBounder stringBounder = tileArguments.getStringBounder();
+ final Skin skin = tileArguments.getSkin();
+ final ISkinParam skinParam = tileArguments.getSkinParam();
+ final LivingSpaces livingSpaces = tileArguments.getLivingSpaces();
+
+ Tile tile = null;
+ // System.err.println("TileBuilder::buildOne " + ev);
+ if (ev instanceof Message) {
+ final Message msg = (Message) ev;
+ final LivingSpace livingSpace1 = livingSpaces.get(msg.getParticipant1());
+ final LivingSpace livingSpace2 = livingSpaces.get(msg.getParticipant2());
+ boolean reverse = false;
+ if (msg.isSelfMessage()) {
+ tile = new CommunicationTileSelf(livingSpace1, msg, skin, skinParam, livingSpaces);
+ } else {
+ // System.err.println("msg=" + msg);
+ tile = new CommunicationTile(livingSpace1, livingSpace2, msg, skin, skinParam);
+ reverse = ((CommunicationTile) tile).isReverse(stringBounder);
+ }
+ if (msg.getNote() != null) {
+ final NotePosition notePosition = msg.getNotePosition();
+ if (notePosition == NotePosition.LEFT) {
+ tile = new CommunicationTileNoteLeft((TileWithUpdateStairs) tile, msg, skin, skinParam,
+ reverse ? livingSpace2 : livingSpace1);
+ } else if (notePosition == NotePosition.RIGHT && msg.isSelfMessage()) {
+ tile = new CommunicationTileSelfNoteRight((CommunicationTileSelf) tile, msg, skin, skinParam);
+ } else if (notePosition == NotePosition.RIGHT) {
+ tile = new CommunicationTileNoteRight((TileWithUpdateStairs) tile, msg, skin, skinParam,
+ reverse ? livingSpace1 : livingSpace2);
+ }
+ }
+ } else if (ev instanceof MessageExo) {
+ final MessageExo exo = (MessageExo) ev;
+ final LivingSpace livingSpace1 = livingSpaces.get(exo.getParticipant());
+ tile = new CommunicationExoTile(livingSpace1, exo, skin, skinParam, tileArguments.getOrigin(),
+ tileArguments.getOmega());
+ if (exo.getNote() != null) {
+ final NotePosition notePosition = exo.getNotePosition();
+ if (notePosition == NotePosition.LEFT) {
+ tile = new CommunicationTileNoteLeft((TileWithUpdateStairs) tile, exo, skin, skinParam,
+ livingSpace1);
+ } else if (notePosition == NotePosition.RIGHT) {
+ tile = new CommunicationTileNoteRight((TileWithUpdateStairs) tile, exo, skin, skinParam,
+ livingSpace1);
+ }
+ }
+ } else if (ev instanceof Note) {
+ final Note note = (Note) ev;
+ final LivingSpace livingSpace1 = livingSpaces.get(note.getParticipant());
+ final LivingSpace livingSpace2 = note.getParticipant2() == null ? null : livingSpaces.get(note
+ .getParticipant2());
+ tile = new NoteTile(livingSpace1, livingSpace2, note, skin, skinParam);
+ } else if (ev instanceof Divider) {
+ final Divider divider = (Divider) ev;
+ tile = new DividerTile(divider, skin, skinParam, tileArguments.getOrigin(), tileArguments.getOmega());
+ } else if (ev instanceof GroupingStart) {
+ final GroupingStart start = (GroupingStart) ev;
+ tile = new GroupingTile(it, start, tileArguments.withBackColorGeneral(start.getBackColorElement(),
+ start.getBackColorGeneral()), tileArguments);
+ // tile = TileUtils.withMargin(tile, 10, 10, 10, 10);
+ } else if (ev instanceof GroupingLeaf && ((GroupingLeaf) ev).getType() == GroupingType.ELSE) {
+ final GroupingLeaf anElse = (GroupingLeaf) ev;
+ tile = new ElseTile(anElse, skin, skinParam, parent);
+ } else if (ev instanceof Reference) {
+ final Reference ref = (Reference) ev;
+ tile = new ReferenceTile(ref, tileArguments.withBackColor(ref));
+ } else if (ev instanceof Delay) {
+ final Delay delay = (Delay) ev;
+ tile = new DelayTile(delay, tileArguments);
+ } else if (ev instanceof LifeEvent) {
+ final LifeEvent lifeEvent = (LifeEvent) ev;
+ final LivingSpace livingSpace = livingSpaces.get(lifeEvent.getParticipant());
+ tile = new LifeEventTile(lifeEvent, tileArguments, livingSpace, skin, skinParam);
+ } else {
+ System.err.println("TileBuilder::Ignoring " + ev.getClass());
+ }
+ return tile;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java
new file mode 100644
index 0000000..b9f698d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TileMarged implements Tile {
+
+ private final Tile tile;
+ private final double x1;
+ private final double x2;
+ private final double y1;
+ private final double y2;
+
+ public TileMarged(Tile tile, double x1, double x2, double y1, double y2) {
+ this.tile = tile;
+ this.x1 = x1;
+ this.x2 = x2;
+ this.y1 = y1;
+ this.y2 = y2;
+ }
+
+ public void drawU(UGraphic ug) {
+ tile.drawU(ug.apply(new UTranslate(x1, y1)));
+
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return tile.getPreferredHeight(stringBounder) + y1 + y2;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tile.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return tile.getMaxX(stringBounder).addFixed(x1 + x2);
+ }
+
+ public Event getEvent() {
+ return tile.getEvent();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java
new file mode 100644
index 0000000..2307fa9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+public class TileUtils {
+
+ private static Tile withMargin(Tile tile, double x1, double x2, double y1, double y2) {
+ return new TileMarged(tile, x1, x2, y1, y2);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java
new file mode 100644
index 0000000..ebb7266
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface TileWithUpdateStairs extends Tile {
+
+ public void updateStairs(StringBounder stringBounder, double y);
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java
new file mode 100644
index 0000000..2a13a9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorTile extends UGraphicDelegator implements Context2D {
+
+ private final boolean isBackground;
+
+ public UGraphicInterceptorTile(UGraphic ug, boolean isBackground) {
+ super(ug);
+ this.isBackground = isBackground;
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof Tile) {
+ final Tile drawable = (Tile) shape;
+ drawable.drawU(this);
+ } else {
+ getUg().draw(shape);
+ }
+
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorTile(getUg().apply(change), isBackground);
+ }
+
+ public boolean isBackground() {
+ return isBackground;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java
new file mode 100644
index 0000000..a9aaf6c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class YPositionedTile implements UDrawable {
+
+ private final Tile tile;
+ private final double y;
+
+ public YPositionedTile(Tile tile, double y) {
+ this.tile = tile;
+ this.y = y;
+ }
+
+ public void drawU(UGraphic ug) {
+ // System.err.println("YPositionedTile::drawU y=" + y + " " + tile);
+ ug.apply(new UTranslate(0, y)).draw(tile);
+ }
+
+}