\documentclass[a4paper]{article}
\usepackage{pgfuml}
\usepackage{doc-macros}
\usepackage[a4paper,textwidth=17.5cm,textheight=24.5cm,bmargin=2cm]{geometry}

\begin{document}

\section{Test of basic associations}

\subsection{Horizontal and vertical}
\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m](6,0){}
  \umlclass[name=P,label=p](6,3){}
  \umlasso[arity start=as,arity end=ae,name start=ns,name end=ne,name=name,nav start,inv route](n)(m)
  \umlasso[arity start=as,arity end=ae,name start=ns,name end=ne,name=name,nav end,compo](m)(p)
\end{tikzpicture}
\end{codeexample}

\subsection{With a line break}

\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m](4,3){}
  \umlclass[name=P,label=p](8,0){}
  \umlasso[arity start=as,arity end=ae,dashed,name start=ns,name end=ne,name=name](n)(m)
  \umlasso[arity start=as,arity end=ae,name start=ns,name end=ne,name=name,name pos=left](m)(p)
  \umlasso[arity start=as,arity end=ae,name start=ns,name end=ne,name=name,inv route](m)(p)
\end{tikzpicture}
\end{codeexample}

\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m](4,3){}
  \umlclass[name=P,label=p](8,0){}
  \umlasso[nav start,inv route,end shift=-8mm](n)(m)
  \umlasso[nav end,compo,start shift=8mm](m)(p)
\end{tikzpicture}
\end{codeexample}


\section{Test of complex associations}

\begin{codeexample}[]
\begin{tikzpicture}[font=\scriptsize,
  /pgfuml/asso/asso/.style={name=nom,arity end=ae,arity start=as,name end=ne,name start=ns}]
  \umlclass[name=Class,label=class,width=1cm](2,6.5){
    - name : String
    \separator
    \underline{+ forName(String) : Class}\\
    + get(String) : Member\\
    + newInstance() : Object\\
    + isInstance(Object) : boolean
  }
  \umlclass[name=Member,label=mem](8,6.5){
    - name : String
  }
  \umlclass[name=Member2,label=mem2](-4,6.5){
    - name : String
  }
  \umlclass[name=Field1,label=f,width=1cm](6.5,2.5){
    + get(Object) : Object\\
    + set(Object,Object)
  }
  \umlclass[name=Field2,label=f2,width=1cm](6.5,10.5){
    + get(Object) : Object\\
    + set(Object,Object)
  }
  \umlclass[name=Field3,label=f3,width=1cm](-2.5,2.5){
    + get(Object) : Object\\
    + set(Object,Object)
  }
  \umlclass[name=Field4,label=f4,width=1cm](-2.5,10.5){
    + get(Object) : Object\\
    + set(Object,Object)
  }
  \umlclass[name=Constructor,label=c,width=1.4cm](2,0.5){
    + invoke(Object,Object[])
  }
  \umlclass[name=Constructor2,label=c2,width=1.4cm](2,12.5){
    + invoke(Object,Object[])
  }
  \umlasso[asso](mem)(class)
  \umlasso[asso](mem2)(class)
  \umlasso[asso,inv route](c)(class)
  \umlasso[asso,inv route](c2)(class)
  \umlasso[asso,inv route,end shift=15mm](f)(class)
  \umlasso[asso,end shift=-10mm](f)(class)
  \umlasso[asso,inv route,end shift=15mm](f2)(class)
  \umlasso[asso,end shift=10mm](f2)(class)
  \umlasso[asso,inv route,end shift=-15mm](f3)(class)
  \umlasso[asso,end shift=-10mm](f3)(class)
  \umlasso[asso,inv route,end shift=-15mm](f4)(class)
  \umlasso[asso,end shift=10mm](f4)(class)
\end{tikzpicture}%
\end{codeexample}

\begin{codeexample}
\begin{tikzpicture}[font=\footnotesize, 
  /pgfuml/asso/asso/.style={name=nom,arity end=ae,arity start=as,name end=ne,name start=ns}]
  \umlclass[name=Class,label=class,width=1cm](2,6.5){
    - name\,:\,String
    \separator
    \underline{+ forName(String)\,:\,Class}\\
    + get(String)\,:\,Member\\
    + newInstance()\,:\,Object\\
    + isInstance(Object)\,:\,boolean
  }
  \umlclass[name=Member,label=mem](8,6.5){
    - name\,:\,String
  }
  \umlclass[name=Member2,label=mem2](-4,6.5){
    - name\,:\,String
  }
  \umlclass[name=Field1,label=f,width=1cm](6.5,2.5){
    + get(Object)\,:\,Object\\
    + set(Object,Object)
  }
  \umlclass[name=Field2,label=f2,width=1cm](6.5,10.5){
    + get(Object)\,:\,Object\\
    + set(Object,Object)
  }
  \umlclass[name=Field3,label=f3,width=1cm](-2.5,2.5){
    + get(Object)\,:\,Object\\
    + set(Object,Object)
  }
  \umlclass[name=Field4,label=f4,width=1cm](-2.5,10.5){
    + get(Object)\,:\,Object\\
    + set(Object,Object)
  }
  \umlclass[name=Constructor,label=c,width=1.4cm](2,0.5){
    + invoke(Object,Object[])
  }
  \umlclass[name=Constructor2,label=c2,width=1.4cm](2,12.5){
    + invoke(Object,Object[])
  }
  \umlasso[asso](class)(mem)
  \umlasso[asso](class)(mem2)
  \umlasso[asso,inv route](class)(c)
  \umlasso[asso,inv route](class)(c2)
  \umlasso[asso,start shift=15mm](class)(f)
  \umlasso[asso,inv route,start shift=-10mm](class)(f)
  \umlasso[asso,start shift=15mm](class)(f2)
  \umlasso[asso,inv route,start shift=10mm](class)(f2)
  \umlasso[asso,start shift=-15mm](class)(f3)
  \umlasso[asso,inv route,start shift=-10mm](class)(f3)
  \umlasso[asso,start shift=-15mm](class)(f4)
  \umlasso[asso,inv route,start shift=10mm](class)(f4)
\end{tikzpicture}%
\end{codeexample}

\section{Test of S associations}
\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m,name height=2cm](4,3){}
  \umlclass[name=P,label=p](8,0){}
  \umlasso[S,arity start=as,arity end=ae,dashed,name start=ns,name end=ne,name=name](n)(m)
  \umlasso[S,arity start=as,arity end=ae,name start=ns,name end=ne,name=name,name pos=left](m)(p)
\end{tikzpicture}
\end{codeexample}

\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m,name height=2cm](4,3){}
  \umlasso[S,inv route,arity start=as,arity end=ae,dashed,name start=ns,name end=ne,name=name](n)(m)
  \umlasso[S,arity start=as,arity end=ae,name start=ns,name end=ne,name=name](n)(m)
\end{tikzpicture}
\end{codeexample}

\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m](4,3){}
  \umlclass[name=P,label=p](8,0){}
  \umlasso[S,nav start,inv route](n)(m)
  \umlasso[S,nav end,compo](m)(p)
\end{tikzpicture}
\end{codeexample}

\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m](4,3){}
  \umlclass[name=P,label=p](8,0){}
  \umlasso[S,nav start,inv route,start shift=8mm](n)(m)
  \umlasso[S,nav end,compo](m)(p)
\end{tikzpicture}
\end{codeexample}

\section{Test of C associations}
\begin{codeexample}[]
\begin{tikzpicture}
  \umlclass[name=N,label=n](0,0){}
  \umlclass[name=M,label=m,name height=2cm](0,3){}
  \umlclass[name=P,label=p](0,6){}
  \umlasso[arity start=as,arity end=ae,dashed,name start=ns,name end=ne,name=name](n)(m)
  \umlasso[arity start=as,arity end=ae,name start=ns,name end=ne,name=name,name pos=left](m)(p)
  \umlasso[CV,arity start=as,arity end=ae,name start=ns,name end=ne,name=name,name pos=left](n)(p)
  \umlasso[CV,C sep=5cm,arity start=as,arity end=ae,name start=ns,name end=ne,name=name,name pos=left,inv route](n)(p)
\end{tikzpicture}
\end{codeexample}

\section{Test of shift}
\label{sec:test-shift}

\begin{tikzpicture}[font=\footnotesize]
  \umlclass[name=c1,label=c1](0,0){}
  \umlclass[name=c2,label=c21](1.5,3){}
  \umlclass[name=c2,label=c22](-1.5,3){}
  \umlclass[name=c2,label=c23](1.5,-3){}
  \umlclass[name=c2,label=c24](-1.5,-3){}
  \umlclass[name=c3,label=c31,name height=1cm](4,0.5){}
  \umlclass[name=c3,label=c32,name height=1cm](-4,0.5){}
  \umlclass[name=c3,label=c33,name height=1cm](4,-0.5){}
  \umlclass[name=c3,label=c34,name height=1cm](-4,-0.5){}

  \umlasso[D](c1)(c21)

  \umlasso[start shift=0.75cm,end shift=-0.75cm](c1)(c21)
  \umlasso[start shift=-0.75cm,end shift=0.75cm](c1)(c22)
  \umlasso[start shift=0.75cm,end shift=-0.75cm](c1)(c23)
  \umlasso[start shift=-0.75cm,end shift=0.75cm](c1)(c24)
  \umlasso[start shift=0.1cm,end shift=-0.4cm](c1)(c31)
  \umlasso[start shift=0.1cm,end shift=-0.4cm](c1)(c32)
  \umlasso[start shift=-0.1cm,end shift=0.4cm](c1)(c33)
  \umlasso[start shift=-0.1cm,end shift=0.4cm](c1)(c34)
\end{tikzpicture}

\begin{tikzpicture}[font=\footnotesize]
  \umlclass[name=c1,label=c1](0,0){}
  \umlclass[name=c2,label=c21](1.5,3){}
  \umlclass[name=c2,label=c22](-1.5,3){}
  \umlclass[name=c2,label=c23](1.5,-3){}
  \umlclass[name=c2,label=c24](-1.5,-3){}
  \umlclass[name=c3,label=c31,name height=1cm](4,0.5){}
  \umlclass[name=c3,label=c32,name height=1cm](-4,0.5){}
  \umlclass[name=c3,label=c33,name height=1cm](4,-0.5){}
  \umlclass[name=c3,label=c34,name height=1cm](-4,-0.5){}

  \umlimplem[D](c1)(c21)

  \umlimplem[start shift=0.75cm,end shift=-0.75cm](c1)(c21)
  \umlimplem[start shift=-0.75cm,end shift=0.75cm](c1)(c22)
  \umlimplem[start shift=0.75cm,end shift=-0.75cm](c1)(c23)
  \umlimplem[start shift=-0.75cm,end shift=0.75cm](c1)(c24)
  \umlimplem[start shift=0.1cm,end shift=-0.4cm](c1)(c31)
  \umlimplem[start shift=0.1cm,end shift=-0.4cm](c1)(c32)
  \umlimplem[start shift=-0.1cm,end shift=0.4cm](c1)(c33)
  \umlimplem[start shift=-0.1cm,end shift=0.4cm](c1)(c34)
\end{tikzpicture}

\section{O associations}
\label{sec:o-associations}

\begin{tikzpicture}[font=\footnotesize,
  /pgfuml/asso/extremities/.style={arity end=ae,arity start=as,name end=ne,name start=ns},
  /pgfuml/asso/asso/.style={arity end=0..1,nav end,name= code of,extremities}]
  \umlclass[name=Info,label=i,parts=2,width=4cm,name height=1cm](-5.5,12){name\\ value}
  \umlasso[O,shift=6mm,asso](i)(i)
  \begin{scope}[red]
    \umlasso[asso,O,O anchor=south west,O sep=1.3cm,shift=-6mm](i)(i)
  \end{scope}
  \begin{scope}[blue]
    \umlasso[asso,O,O anchor=south east,start shift=-6mm,end shift=6mm](i)(i)
  \end{scope}
  \begin{scope}[green]
    \umlasso[asso,O,O anchor=north west,O sep=8mm,end shift=-6mm,start shift=6mm](i)(i)
  \end{scope}
\end{tikzpicture}%


\end{document}
