| 1 |
% Manual of pgf-umlcd.sty, a convenient set of macros for drawing UML |
| 2 |
% class diagrams. |
| 3 |
% Written by Xu Yuan <[email protected]> |
| 4 |
% This file is part of pgf-umlcd |
| 5 |
% you may get it at http://code.google.com/p/pgf-umlcd/ |
| 6 |
|
| 7 |
\documentclass{article} |
| 8 |
\usepackage[margin=12mm]{geometry} |
| 9 |
\usepackage{hyperref} |
| 10 |
|
| 11 |
\usepackage[ |
| 12 |
% school, |
| 13 |
% simplified |
| 14 |
]{pgf-umlcd} |
| 15 |
|
| 16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 17 |
\usepackage{listings} |
| 18 |
\usepackage{color} |
| 19 |
\definecolor{listinggray}{gray}{0.92} |
| 20 |
\lstset{ % |
| 21 |
language=[LaTeX]TeX, |
| 22 |
breaklines=true, |
| 23 |
frame=single, |
| 24 |
% frameround=tttt, |
| 25 |
basicstyle=\footnotesize\ttfamily, |
| 26 |
backgroundcolor=\color{listinggray}, |
| 27 |
keywordstyle=\color{blue} |
| 28 |
} |
| 29 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 30 |
|
| 31 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 32 |
\hypersetup{ |
| 33 |
colorlinks=true, |
| 34 |
linkcolor=blue, |
| 35 |
anchorcolor=black, |
| 36 |
citecolor=olive, |
| 37 |
filecolor=magenta, |
| 38 |
menucolor=red, |
| 39 |
urlcolor=blue |
| 40 |
} |
| 41 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 42 |
|
| 43 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 44 |
\newcommand{\demo}[2][1]{ |
| 45 |
\begin{minipage}{.49\linewidth} |
| 46 |
\centering |
| 47 |
\resizebox{#1\linewidth}{!}{ |
| 48 |
\input{demo/#2} |
| 49 |
} |
| 50 |
\end{minipage} |
| 51 |
\hspace{0.01\linewidth} |
| 52 |
\begin{minipage}{.5\linewidth} |
| 53 |
\lstinputlisting{demo/#2} |
| 54 |
\end{minipage} |
| 55 |
} |
| 56 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 57 |
|
| 58 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 59 |
\newcommand{\example}[1]{ |
| 60 |
\resizebox{\linewidth}{!}{ |
| 61 |
\input{demo/#1} |
| 62 |
} |
| 63 |
\lstinputlisting{demo/#1} |
| 64 |
} |
| 65 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 66 |
|
| 67 |
\begin{document} |
| 68 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 69 |
\title{Drawing UML Class Diagram by using \texttt{pgf-umlcd}} |
| 70 |
\author{\href{mailto:[email protected]}{Yuan Xu}} |
| 71 |
\date{\today{}~(v0.3)} |
| 72 |
\maketitle |
| 73 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 74 |
|
| 75 |
\begin{abstract} |
| 76 |
\texttt{pgf-umlcd} is a LaTeX package for drawing UML Class |
| 77 |
Diagrams. As stated by its name, it is based on a very popular |
| 78 |
graphic package \texttt{PGF/TikZ}. This document presents the usage |
| 79 |
of \texttt{pgf-umlcd} and collects some UML class diagrams as |
| 80 |
examples. \texttt{pgf-umlcd} can be downloaded from |
| 81 |
\href{http://code.google.com/p/pgf-umlcd/}{http://code.google.com/p/pgf-umlcd/}. |
| 82 |
\end{abstract} |
| 83 |
|
| 84 |
\tableofcontents |
| 85 |
|
| 86 |
\section{Basics} |
| 87 |
\subsection{Class with attributes and operations} |
| 88 |
Note: If you don't want to show empty parts in the diagrams, please |
| 89 |
use \texttt{simplified} option, e.g. \lstinline|\usepackage[simplified]{pgf-umlcd}|.\\ |
| 90 |
\demo{class} |
| 91 |
|
| 92 |
\subsubsection{Visibility of attributes and operations} |
| 93 |
\demo[0.8]{visibility} |
| 94 |
|
| 95 |
\subsubsection{Abstract class and interface} |
| 96 |
\demo[0.5]{abstract-class} |
| 97 |
\demo[0.5]{interface} |
| 98 |
|
| 99 |
\subsubsection{Object} |
| 100 |
\demo[0.7]{object} |
| 101 |
Note: Object with rounded corners and methods are used in German school for didactic reasons. You get the rounded corners with \lstinline|\usepackage[school]{pgf-umlcd}|. If you need both in one document you can switch it with \lstinline|\switchUmlcdSchool| \\ |
| 102 |
\switchUmlcdSchool |
| 103 |
\demo[0.7]{object} |
| 104 |
\demo[0.7]{object-include-methods} |
| 105 |
|
| 106 |
\subsubsection{Note} |
| 107 |
The \lstinline|\umlnote| use the same syntax as tikz command |
| 108 |
\lstinline|\node|, e.g. \lstinline|\umlnote[style] (name) at (coordinate) {text};| |
| 109 |
|
| 110 |
\demo[0.7]{note} |
| 111 |
|
| 112 |
\subsection{Inheritance and implement} |
| 113 |
\subsubsection{Inheritance} |
| 114 |
\demo{inheritance} |
| 115 |
\subsubsection{Multiple Inheritance} |
| 116 |
\demo{multiple-inheritance} |
| 117 |
|
| 118 |
\subsubsection{Implement an interface} |
| 119 |
\demo{implement-interface} |
| 120 |
|
| 121 |
\subsection{Association, Aggregation and Composition} |
| 122 |
\subsubsection{Association} |
| 123 |
\demo{association} |
| 124 |
|
| 125 |
\subsubsection{Unidirectional association} |
| 126 |
\demo{unidirectional-association} |
| 127 |
|
| 128 |
\subsubsection{Aggregation} |
| 129 |
\demo{aggregation} |
| 130 |
|
| 131 |
\subsubsection{Composition} |
| 132 |
\demo{composition} |
| 133 |
|
| 134 |
\subsection{Package} |
| 135 |
\demo{package} |
| 136 |
|
| 137 |
\section{Customization} |
| 138 |
\subsection{Color settings} |
| 139 |
The color of digram is defined by \lstinline|\umltextcolor|, \lstinline|\umldrawcolor| and \lstinline|\umlfillcolor|, such as: |
| 140 |
|
| 141 |
\demo{color} |
| 142 |
|
| 143 |
|
| 144 |
\section{Examples} |
| 145 |
\subsection{Abstract Factory} |
| 146 |
\example{abstract-factory} |
| 147 |
|
| 148 |
\section{Acknowledgements} |
| 149 |
Many people contributed to \texttt{pgf-umlcd} by reporting problems, |
| 150 |
suggesting various improvements or submitting code. Here is a list of |
| 151 |
these people: \href{mailto:[email protected]}{Martin Quinson}, |
| 152 |
\href{mailto:[email protected]}{Johannes Pieper}, |
| 153 |
\href{mailto:[email protected]}{sh w}, |
| 154 |
and \href{mailto:[email protected]}{Maarten van Dessel}. |
| 155 |
|
| 156 |
\end{document} |
| 157 |
%%% Local Variables: |
| 158 |
%%% mode: Tex-PDF |
| 159 |
%%% TeX-master: t |
| 160 |
%%% End: |