123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Start of pgf-umlcd.sty
- %
- % Some macros for UML Class Diagrams.
- % Home page of project: http://pgf-umlcd.googlecode.com/
- % Author: Xu Yuan <xu@informatik.hu-berlin.de>, Humboldt University, Berlin
- % Style from: http://www.ibm.com/developerworks/cn/rational/r-uml/
- % Fixed by Martin Quinson (martin.quinson@loria.fr) in nov 2010 to compile with pgf 2.00
- % Fixed by Jean-Christophe Bach (jeanchristophe.bach@inria.fr) in apr 2011 to have enum
- \tikzstyle{help lines}+=[blue!50,very thin,dashed]
- \newcommand{\umltextcolor}{black}
- \newcommand{\umldrawcolor}{black}
- \newcommand{\umlfillcolor}{yellow!20}
- \tikzstyle{umlcolor}=[color=\umldrawcolor,fill=\umlfillcolor,text=\umltextcolor]
- \tikzstyle{umlcd style}=[umlcolor, >=angle 90]
- \tikzstyle{package}=[matrix, column sep=1mm, row sep=1cm, node distance=2cm]
- \tikzstyle{packagename}=[rectangle, minimum height=2em]
- \tikzstyle{umlcd style implement line}=[color=\umldrawcolor, open triangle 45-,dashed]
- \tikzstyle{objectline}=[color=\umldrawcolor, diamond->]
- \tikzstyle{umlcd style inherit line}=[color=\umldrawcolor, open triangle 45-]
- \tikzstyle{splitline}=[color=\umldrawcolor, dotted,font=\itshape]
- \tikzstyle{umlcd style class}=[rectangle split, rectangle split parts=3, every
- text node part/.style={text centered}, draw, minimum height=2em, umlcolor,
- minimum width=2cm, minimum height=1cm, node distance=2cm]
- %text width=3cm,
- \tikzstyle{umlcd style enum}=[rectangle split, rectangle split parts=2,
- every text node part/.style={text centered},
- %every text node part/.style={text ragged left,color=red},
- draw, minimum height=2em, umlcolor, minimum width=2cm, text width=4cm,
- minimum height=1cm, node distance=2cm]
- % declare layers
- \pgfdeclarelayer{background}
- \pgfdeclarelayer{connectionlayers}
- \pgfsetlayers{background,connectionlayers,main}
- \newcounter{umlcdClassAttributesNum}
- \newcounter{umlcdClassOperationsNum}
- \newcounter{umlcdClassAbstractClassNum}
- \newcounter{umlcdClassInterfaceNum}
- \def\umlcdPackageFit{}
- \newenvironment{class}[3][]%
- {
- \begin{classAndInterfaceCommon}{#1}{#2}{#3}
- }%
- {\node[this umlcd style, anchor=north] (\umlcdClassName) at (\umlcdClassPos)
- {\textbf{\umlcdClassName}
- \nodepart{second}
- \umlcdClassAttributes
- \nodepart{third}
- \umlcdClassOperations
- };
- \end{classAndInterfaceCommon}
- }
- \newenvironment{abstractclass}[3][]%
- {
- \begin{classAndInterfaceCommon}{#1}{#2}{#3}
- }%
- {\node[this umlcd style, anchor=north] (\umlcdClassName) at (\umlcdClassPos)
- {\textit{\textbf{\umlcdClassName}}
- \nodepart{second}
- \umlcdClassAttributes
- \nodepart{third}
- \umlcdClassOperations
- };
- \end{classAndInterfaceCommon}
- }
- \newenvironment{interface}[3][]%
- {
- \begin{classAndInterfaceCommon}{#1}{#2}{#3}
- }%
- {\node[this umlcd style, anchor=north] (\umlcdClassName) at (\umlcdClassPos)
- {$<<$interface$>>$ \\ \textbf{\umlcdClassName}
- \nodepart{second}
- \umlcdClassAttributes
- \nodepart{third}
- \umlcdClassOperations
- };
- \end{classAndInterfaceCommon}
- }
- %perso
- \newenvironment{enum}[3][]%
- {
- \begin{classAndInterfaceCommon}{#1}{#2}{#3}
- }%
- {\node[umlcd style enum, anchor=north] (\umlcdClassName) at (\umlcdClassPos)
- {$<<$enumeration$>>$ \\ \textbf{\umlcdClassName}
- \nodepart{second}
- \umlcdClassAttributes
- };
- %\begin{tabular}{c}
- %\end{tabular}
- %\begin{tabular}{l}
- %\end{tabular}
- \end{classAndInterfaceCommon}
- }
- %/perso
- \newenvironment*{classAndInterfaceCommon}[3]
- {
- \def\umlcdClassName{#2}%
- \def\umlcdClassPos{#3}
- \def\umlcdClassAttributes{}%
- \def\umlcdClassOperations{}%
- \def\umlcdClassAbstractClass{}%
- \def\umlcdClassInterface{}%
- \setcounter{umlcdClassAttributesNum}{0}%
- \setcounter{umlcdClassOperationsNum}{0}%
- \setcounter{umlcdClassAbstractClassNum}{0}%
- \setcounter{umlcdClassInterfaceNum}{0}%
- \tikzstyle{this umlcd style}=[umlcd style class, #1]
- }%
- {
- %% connections
- \begin{pgfonlayer}{connectionlayers}
- \ifnum\c@umlcdClassAbstractClassNum>0
- \foreach \c in {\umlcdClassAbstractClass}{
- \draw [umlcd style inherit line] (\c) -- (\umlcdClassName);
- }
- \fi
- \ifnum\c@umlcdClassInterfaceNum>0
- \foreach \c in {\umlcdClassInterface}{
- \draw [umlcd style implement line] (\c) -- (\umlcdClassName);
- }
- \fi
- \end{pgfonlayer}
- %% add to fit
- \let\umlcdPackageFitOld\umlcdPackageFit
- \protected@xdef\umlcdPackageFit{\umlcdPackageFitOld (\umlcdClassName)}
- }
- \newcommand{\attribute}[1]{%
- \ifnum\c@umlcdClassAttributesNum=0
- \protected@xdef\umlcdClassAttributes{#1}
- \else
- \let\umlcdClassAttributesOld\umlcdClassAttributes
- \protected@xdef\umlcdClassAttributes{\umlcdClassAttributesOld \ \newline %\\
- #1}
- \fi
- \stepcounter{umlcdClassAttributesNum}
- }
- \newcommand{\operation}[2][1]{%
- \stepcounter{umlcdClassOperationsNum}
- \def\virtualoperation{#2}
- \ifnum0=#1
- \def\virtualoperation{\textit{#2}}
- \fi
- \ifnum\c@umlcdClassOperationsNum=1
- \protected@xdef\umlcdClassOperations{\virtualoperation}
- \else
- \let\umlcdClassOperationsOld\umlcdClassOperations
- \protected@xdef\umlcdClassOperations{\umlcdClassOperationsOld \ \newline
- \virtualoperation}
- \fi
- }
- \newcommand{\inherit}[1]
- {
- \stepcounter{umlcdClassAbstractClassNum}
- \ifnum\c@umlcdClassAbstractClassNum=1
- \protected@xdef\umlcdClassAbstractClass{#1}
- \else
- \let\umlcdClassAbstractClassOld\umlcdClassAbstractClass
- \protected@xdef\umlcdClassAbstractClass{\umlcdClassAbstractClassOld,
- #1}
- \fi
- }
- \newcommand{\implement}[1]
- {
- \stepcounter{umlcdClassInterfaceNum}
- \ifnum\c@umlcdClassInterfaceNum=1
- \protected@xdef\umlcdClassInterface{#1}
- \else
- \let\umlcdClassInterfaceOld\umlcdClassInterface
- \protected@xdef\umlcdClassInterface{\umlcdClassInterfaceOld,
- #1}
- \fi
- }
- \newcommand{\association}[6]{
- \draw [umlcd style] (#1) -- (#4)
- node[near start, above]{#2}
- node[near start, below]{#3}
- node[near end, above]{#5}
- node[near end, below]{#6};
- }
- % 0 -> up
- % 1 -> down
- % 2 -> left
- % 3 -> right
- \newcommand{\myassociation}[8]{
- %\node({#7}){}; %[draw=white,fill=white]
- \ifnum0=#8
- \draw [umlcd style, fill=white] (#1) --
- node[near start, above, anchor=210]{#2}
- node[near start, below, anchor=150]{#3}
- (#7) -- (#4)
- node[near end, below]{#5}
- node[near end, above]{#6};
- \fi
- \ifnum1=#8
- \draw [umlcd style, fill=white] (#1) --
- node[near start, below, anchor=150]{#2}
- node[near start, above, anchor=210]{#3}
- (#7) -- (#4)
- node[near end, above]{#5}
- node[near end, below]{#6};
- \fi
- }
- \newcommand{\myassociationtwo}[8]{
- %\node({#7}){}; %[draw=white,fill=white]
- \draw [umlcd style, fill=white] (#1) --
- node[near start, left]{#2}
- node[near start, right]{#3}
- (#7) -- (#8) -- (#4)
- node[near end, left]{#5}
- node[near end, right]{#6};
- }
- \newcommand{\myassociationthree}[8]{
- %\node({#7}){}; %[draw=white,fill=white]
- \draw [umlcd style, fill=white] (#1) --
- node[near start, left]{#2}
- node[near start, below, xshift=-0.5cm]{#3}
- (#7) -- (#8) -- (#4)
- node[near end, below, xshift=0.5cm]{#5}
- node[near end, right]{#6};
- }
- %%%
- \newcommand{\unidirectionalAssociation}[4]{
- \draw [umlcd style, ->] (#1) -- (#4)
- node[near end, above]{#2}
- node[near end, below]{#3};
- }
- \newcommand{\aggregation}[4]
- {
- \draw[umlcd style, open diamond->] (#1) -- (#4)
- node[near end, above]{#2}
- node[near end, below]{#3};
- }
- \newcommand{\composition}[4]
- {
- \draw[umlcd style, fill=\umldrawcolor, diamond->] (#1) -- (#4)
- node[near end, above]{#2}
- node[near end, below]{#3};
- }
- \newenvironment{package}[1]{
- \def\umlcdPackageFit{}
- \def\umlcdPackageName{#1}
- }{
- \begin{pgfonlayer}{background}
- \node[umlcd style, draw, inner sep=0.5cm, fit = \umlcdPackageFit] (\umlcdPackageName) {};
- \node[umlcd style, draw, outer ysep=-0.5, anchor=south west] (\umlcdPackageName caption) at
- (\umlcdPackageName.north west) {\umlcdPackageName};
- \end{pgfonlayer}
- }
- %%% End of pgf-umlcd.sty
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|