-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivity.tex
436 lines (348 loc) · 10.1 KB
/
activity.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
% ========================================================================
% PlantUML : a free UML diagram generator
% ========================================================================
%
% (C) Copyright 2009, Arnaud Roques
%
% Project Info: http://plantuml.sourceforge.net
%
% This file is part of PlantUML.
%
% PlantUML is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% PlantUML distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
% License for more details.
%
% You should have received a copy of the GNU General Public
% License along with this library; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
% USA.
%
% [Java is a trademark or registered trademark of Sun Microsystems, Inc.
% in the United States and other countries.]
%
% Original Author: Arnaud Roques
%
\section{Activity Diagram}
% ========================================================================
\subsection{Simple Activity}
\begin{description}
\item
You can use \texttt{(*)} for the starting point and ending point of the activity
diagram.
\item
Use \texttt{-->} for arrows.
\end{description}
Example:
\begin{lstlisting}
@startuml
(*) --> "First Activity"
"First Activity" --> (*)
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=40mm]{activity.png}
\end{center}
% ========================================================================
\subsection{Label on arrows}
\begin{description}
\item By default, an arrow starts at the last used activity.
\item You can put a label on a arrow using brackets \texttt{[} and \texttt{]}
just after the arrow definition.
\end{description}
\begin{lstlisting}
@startuml
(*) --> "First Activity"
-->[You can put also labels] "Second Activity"
--> (*)
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=55mm]{activity_001.png}
\end{center}
% ========================================================================
\newpage \subsection{Changing arrow direction}
You can use \texttt{->} for horizontal arrows. It is possible to force arrow's
direction using the following syntax:
\begin{itemize}
\item \texttt{-down->} (default arrow)
\item \texttt{-right->} or \texttt{->}
\item \texttt{-left->}
\item \texttt{-up->}
\end{itemize}
\begin{lstlisting}
@startuml
(*) -up-> "First Activity"
-right-> "Second Activity"
--> "Third Activity"
-left-> (*)
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=80mm]{activity_002.png}
\end{center}
You can shorten the arrow by using only the first character of the direction
(for example, \texttt{-d-} instead of \texttt{-down-}) or the two first
characters (\texttt{-do-}).
Please note that you should not abuse this functionnality : \textit{GraphViz}
gives usually good results without tweaking.
% ========================================================================
\newpage \subsection{Branches}
\begin{description}
\item You can use \texttt{if/then/else} keywords to define branches.
\end{description}
\begin{lstlisting}
@startuml
(*) --> "Initialisation"
if "Some Test" then
-->[true] "Some Activity"
--> "Another activity"
-right-> (*)
else
->[false] "Something else"
-->[Ending process] (*)
endif
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=70mm]{activity_003.png}
\end{center}
% ========================================================================
\newpage \subsection{More on Branches}
\begin{description}
\item By default, a branch is connected to the last defined activity,
but it is possible to override this and to define a link with the
\texttt{if} keywords.
\item It is also possible to nest branches.
\end{description}
\begin{lstlisting}
@startuml
(*) --> if "Some Test" then
-->[true] "activity 1"
if "" then
-> "activity 3" as a3
else
if "Other test" then
-left-> "activity 5"
else
--> "activity 6"
endif
endif
else
->[false] "activity 2"
endif
a3 --> if "last test" then
--> "activity 7"
else
-> "activity 8"
endif
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=110mm]{activity_004.png}
\end{center}
% ========================================================================
\newpage \subsection{Synchronization}
You can use "\texttt{=== code ===}" to display synchronization bars.
\begin{lstlisting}
@startuml
(*) --> ===B1===
--> "Parallel Activity 1"
--> ===B2===
===B1=== --> "Parallel Activity 2"
--> ===B2===
--> (*)
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=90mm]{activity_005.png}
\end{center}
% ========================================================================
\newpage \subsection{Long activity description}
When you declare activities, you can span on several lines the description text.
You can also add \texttt{\textbackslash n } in the description.
It is also possible to use few html tags like :
\begin{itemize}
\item \texttt{$<$b$>$}
\item \texttt{$<$i$>$}
\item \texttt{$<$font size="nn"$>$} or \texttt{$<$size:nn$>$} to change font
size
\item \texttt{$<$font color="\#AAAAAA"$>$} or \texttt{$<$font
color="colorName"$>$}
\item \texttt{$<$color:\#AAAAAA$>$} or \texttt{$<$color:colorName$>$}
\item \texttt{$<$img:file.png$>$} to include an image
\end{itemize}
You can also give a short code to the activity with the as keyword.
This code can be used latter in the diagram description.
\begin{lstlisting}
@startuml
(*) -left-> "this <size:20>activity</size>
is <b>very</b> <color:red>long</color>
and defined on several lines
that contains many <i>text</i>" as A1
-up-> "Another activity\n on several lines"
A1 --> "Short activity <img:sourceforge.jpg>"
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=75mm]{activity_006.png}
\end{center}
% ========================================================================
\newpage \subsection{Notes}
You can add notes on a activity using the commands:
\begin{itemize}
\item \texttt{note left},
\item \texttt{note right},
\item \texttt{note top},
\item \texttt{note bottom},
\end{itemize}
just after the description of the activity you want to note.
If you want to put a note on the starting point, define the note at the very
beginning of the diagram description.
You can also have a note on several lines, using the \texttt{end note} keywords.
\begin{lstlisting}
@startuml
(*) --> "Some Activity"
note right: This activity has to be defined
"Some Activity" --> (*)
note left
This note is on
several lines
end note
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=90mm]{activity_007.png}
\end{center}
% ========================================================================
\newpage \subsection{Partition}
\begin{description}
\item You can define a partition using the \texttt{partition} keyword, and
optionally declare a background color for your partition (using a html color code or name).
\item When you declare activities, they are automatically put in the last used partition.
\end{description}
You can close the partition definition using the \texttt{end partition} keyword.
\begin{lstlisting}
@startuml
partition Conductor
(*) --> "Climbs on Platform"
--> === S1 ===
--> Bows
end partition
partition Audience #LightSkyBlue
=== S1 === --> Applauds
partition Conductor
Bows --> === S2 ===
--> WavesArmes
Applauds --> === S2 ===
end partition
partition Orchestra #CCCCEE
WavesArmes --> Introduction
--> "Play music"
end partition
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=80mm]{activity_008.png}
\end{center}
% ========================================================================
\newpage \subsection{Title the diagram}
The \texttt{title} keywords is used to put a title.
You can use \texttt{title} and \texttt{end title} keywords for a longer title,
as in sequence diagrams.
\begin{lstlisting}
@startuml
title Simple example\nof title
(*) --> "First activity"
--> (*)
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=40mm]{activity_009.png}
\end{center}
% ========================================================================
\newpage \subsection{Skinparam}
You can use the \texttt{skinparam} command to change colors and fonts for the
drawing. You can use this command :
\begin{itemize}
\item In the diagram definition, like any other commands,
\item In an included file,
\item In a configuration file, provided in the command line or the ANT task.
\end{itemize}
\begin{lstlisting}
@startuml
skinparam backgroundColor #AAFFFF
skinparam activity {
StartColor red
BarColor SaddleBrown
EndColor Silver
BackgroundColor Peru
BorderColor Peru
FontName Impact
}
(*) --> "Climbs on Platform"
--> === S1 ===
--> Bows
--> === S2 ===
--> WavesArmes
--> (*)
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=50mm]{activity_010.png}
\end{center}
% ========================================================================
\newpage \subsection{Complete example}
\begin{lstlisting}
@startuml
'http://click.sourceforge.net/images/activity-diagram-small.png
title Servlet Container
(*) --> "ClickServlet.handleRequest()"
--> "new Page"
if "Page.onSecurityCheck" then
->[true] "Page.onInit()"
if "isForward?" then
->[no] "Process controls"
if "continue processing?" then
-->[yes] ===RENDERING===
else
-->[no] ===REDIRECT_CHECK===
endif
else
-->[yes] ===RENDERING===
endif
if "is Post?" then
-->[yes] "Page.onPost()"
--> "Page.onRender()" as render
--> ===REDIRECT_CHECK===
else
-->[no] "Page.onGet()"
--> render
endif
else
-->[false] ===REDIRECT_CHECK===
endif
if "Do redirect?" then
->[yes] "redirect request"
--> ==BEFORE_DESTROY===
else
if "Do Forward?" then
-left->[yes] "Forward request"
--> ==BEFORE_DESTROY===
else
-right->[no] "Render page template"
--> ==BEFORE_DESTROY===
endif
endif
--> "Page.onDestroy()"
-->(*)
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=130mm]{activity_011.png}
\end{center}