-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent.tex
283 lines (221 loc) · 7.08 KB
/
component.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
% ========================================================================
% 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{Component Diagram}
% ========================================================================
\subsection{Components}
\begin{description}
\item Components must be bracketed.
\item You can also use the \texttt{component} keyword to defines a component.
\item And you can define an alias, using the \texttt{as} keyword.
\item This alias will be used latter, when defining relations.
\end{description}
\begin{lstlisting}
@startuml
[First component]
[Another component] as Comp2
component Comp3
component [Last\ncomponent] as Comp4
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=125mm]{component.png}
\end{center}
% ========================================================================
\newpage \subsection{Interfaces}
\begin{description}
\item Interface can be defined using the "\texttt{()}" symbol (because this
looks like a circle).
\item You can also use the \texttt{interface} keyword to defines a usecase.
\item And you can define an alias, using the \texttt{as} keyword.
\item This alias will be used latter, when defining relations.
\item We will see latter that interface declaration is optional.
\end{description}
\begin{lstlisting}
@startuml
() "First Interface"
() "Another interface" as Interf2
interface Interf3
interface "Last\ninterface" as Interf4
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=105mm]{component_001.png}
\end{center}
% ========================================================================
\newpage \subsection{Basic example}
Links between elements are made using combinaisons of dotted line
"\texttt{..}", straight line "\texttt{--}", and arrows "\texttt{-->}" symbols.
\begin{lstlisting}
@startuml
DataAccess - [First Component]
[First Component] ..> HTTP : use
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=65mm]{component_002.png}
\end{center}
% ========================================================================
\newpage \subsection{Using notes}
You can use the
\begin{itemize}
\item \texttt{note left of},
\item \texttt{note right of},
\item \texttt{note top of},
\item \texttt{note bottom of},
\end{itemize}
keywords to define notes related to a single object.
A note can also be defined alone with the \texttt{note} keywords, then linked
to other objects using the "\texttt{..}" symbol.
\begin{lstlisting}
@startuml
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
note left of HTTP : Web Service only
note right of [First Component]
A note can also
be on several lines
end note
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=105mm]{component_003.png}
\end{center}
% ========================================================================
\newpage \subsection{Grouping Components}
You can use the \texttt{package} keyword to group components and interfaces
together.
\begin{lstlisting}
@startuml
package "Some Group" {
HTTP - [First Component]
[Another Component]
}
package "Other Groups" {
FTP - [Second Component]
[First Component] --> FTP
}
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=120mm]{component_004.png}
\end{center}
% ========================================================================
\newpage \subsection{Changing arrows direction}
By default, links between classes have two dashes \texttt{--}
and are verticaly oriented. It is possible to use horizontal link by putting a
single dash (or dot) like this:
\begin{lstlisting}
@startuml
[Component] --> Interface1
[Component] -> Interface2
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=50mm]{component_005.png}
\end{center}
You can also change directions by reversing the link:
\begin{lstlisting}
@startuml
Interface1 <-- [Component]
Interface2 <- [Component]
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=50mm]{component_006.png}
\end{center}
It is also possible to change arrow direction by adding \texttt{left},
\texttt{right}, \texttt{up} or \texttt{down} keywords inside the arrow:
\begin{lstlisting}
@startuml
[Component] -left-> left
[Component] -right-> right
[Component] -up-> up
[Component] -down-> down
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=75mm]{component_007.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.
% ========================================================================
\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 Very simple component\ndiagram
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=70mm]{component_008.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 component {
FontSize 13
InterfaceBackgroundColor RosyBrown
InterfaceBorderColor orange
BackgroundColor<< Apache >> Red
BorderColor<< Apache >> #FF6655
FontName Courier
BorderColor black
BackgroundColor gold
ArrowFontName Impact
ArrowColor #FF6655
ArrowFontColor #777777
}
() "Data Access" as DA
DA - [First Component]
[First Component] ..> () HTTP : use
HTTP - [Web Server] << Apache >>
@enduml
\end{lstlisting}
\begin{center}
\includegraphics[width=75mm]{component_009.png}
\end{center}