%%%%%%%%%%%%%%%%%%%%%
%%%%% NOTE SHAPE %%%%%
%%%%%%%%%%%%%%%%%%%%%
\pgfdeclareshape{uml note}
{
  \inheritsavedanchors[from=rectangle] % this is nearly a rectangle
  \inheritanchorborder[from=rectangle]
  \inheritanchor[from=rectangle]{north}
  \inheritanchor[from=rectangle]{north west}
  \inheritanchor[from=rectangle]{north east}
  \inheritanchor[from=rectangle]{center}
  \inheritanchor[from=rectangle]{west}
  \inheritanchor[from=rectangle]{east}
  \inheritanchor[from=rectangle]{mid}
  \inheritanchor[from=rectangle]{mid west}
  \inheritanchor[from=rectangle]{mid east}
  \inheritanchor[from=rectangle]{base}
  \inheritanchor[from=rectangle]{base west}
  \inheritanchor[from=rectangle]{base east}
  \inheritanchor[from=rectangle]{south}
  \inheritanchor[from=rectangle]{south west}
  \inheritanchor[from=rectangle]{south east}
  \foregroundpath{
    % store lower right in xa/ya and upper right in xb/yb
    \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
    \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
    \pgfutil@tempdima=\pgf@xb%
    \pgfutil@tempdimb=\pgf@yb%
    \advance\pgfutil@tempdima by-2mm%
    \advance\pgfutil@tempdimb by-2mm%
    \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}
    \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}
    \pgfpathlineto{\pgfqpoint{\pgfutil@tempdima}{\pgf@yb}}
    \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgfutil@tempdimb}}
    \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}
    \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@ya}}
    \pgfpathmoveto{\pgfqpoint{\pgfutil@tempdima}{\pgf@yb}}
    \pgfpathlineto{\pgfqpoint{\pgfutil@tempdima}{\pgfutil@tempdimb}}
    \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgfutil@tempdimb}}
 }
}

%%%%%%%%%%%%%%%%%%%%%
%%%%% CLASS SHAPE %%%%%
%%%%%%%%%%%%%%%%%%%%%
% Highly inspired from rectangle split shape from pgf standard library
\pgfkeys{/tikz/class parts/.code={%
	\pgfkeys{/pgfuml/class shape/parts=#1}%
	}%
}
\pgfkeys{/tikz/class use custom fill/.code={%
	\pgfkeys{/pgfuml/class shape/use custom fill=#1}%
	\pgfkeys{/tikz/fill=none}}%
}
\pgfkeys{/tikz/class part align/.code={%
		\pgfkeys{/pgfuml/class shape/part align={#1}}%
	}%
}%
\pgfkeys{/tikz/class part fill/.code={%
		\pgfkeys{/pgfuml/class shape/part fill={#1}}%
	}%
}%

\newif\ifpgfrectanglesplitusecustomfill
\pgfrectanglesplitusecustomfillfalse

\pgfkeys{/pgfuml/class shape/.cd,
	parts/.initial=3,
	empty part height/.initial=1ex,
	%
	part align/.code=\pgf@lib@shapes@rectanglesplit@assigntoparts{#1}{align},
	text part align/.initial=center,
	attribute part align/.initial=left,
	method part align/.initial=left,
	extra part align/.initial=left,
	%
	use custom fill/.is if=pgfrectanglesplitusecustomfill,
	part fill/.code={%
		\pgfrectanglesplitusecustomfilltrue%
		\pgf@lib@shapes@rectanglesplit@assigntoparts{#1}{fill}%
	},
	text part fill/.initial=white,
	attribute part fill/.initial=white,
	method part fill/.initial=white,
	extra part fill/.initial=white
}

% Internal macros for the class shape shape.
%
\def\pgf@lib@shapes@rectanglesplit@left{left}
\def\pgf@lib@shapes@rectanglesplit@right{right}

\def\pgf@lib@shapes@rectanglesplit@assigntoparts#1#2{%
	\expandafter\pgf@lib@shapes@rectanglesplit@@assigntoparts#1,\@@,\@@,\@@,\@@,\pgf@lib#2\pgf@lib}
\def\pgf@lib@shapes@rectanglesplit@@assigntoparts#1,#2,#3,#4,#5\pgf@lib#6\pgf@lib{%
	\pgfkeys{/pgfuml/class shape/.cd,%
		text part #6=#1,
		attribute part #6=#1,
		method part #6=#1,
		extra part #6=#1
	}%
	\ifx#2\@@\else%
	\pgfkeys{/pgfuml/class shape/.cd,%
			attribute part #6=#2,
			method part #6=#2,
			extra part #6=#2
		}%
	\fi%
	\ifx#3\@@\else%
		\pgfkeys{/pgfuml/class shape/.cd,%
			method part #6=#3,
			extra part #6=#3
		}%
	\fi%
	\ifx#4\@@\else%
		\pgfkeys{/pgfuml/class shape/extra part #6=#4}%
	\fi%
}%

\newbox\pgfnodepartattributebox
\newbox\pgfnodepartmethodbox
\newbox\pgfnodepartextrabox
\newdimen\pgf@xd


%%%%%% MODIFS
%%%%%% - name of the part more UML like
%%%%%% - take care of minimum height for the first part (become a true rectangle when only one part)
%%%%%% - take care of the minimum width for text alignement (for me it is a rectangle split bug)
%%%%%% - follow rectangle strategy and do not take care of line width

\pgfdeclareshape{class shape}{%
	\nodeparts{text,attribute,method,extra} %%MODIF the boxname are modified
	\savedmacro\getrectanglesplitparameters{%
		%
		% If the height+depth of any box is 0pt use the default empty height.
		%
		\pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgfuml/class shape/empty part height}}
		\pgf@y\ht\pgfnodeparttextbox%
		\advance\pgf@y\dp\pgfnodeparttextbox%
		\ifdim\pgf@y=0pt\relax%
			\setbox\pgfnodeparttextbox=\hbox{%				
				\vrule width0pt height\the\pgfutil@tempdima depth0pt%
			}%
		\fi%
		\pgf@y\ht\pgfnodepartattributebox%
		\advance\pgf@y\dp\pgfnodepartattributebox%
		\ifdim\pgf@y=0pt\relax%
			\setbox\pgfnodepartattributebox=\hbox{%
				\vrule width0pt height\the\pgfutil@tempdima depth0pt%
			}%
		\fi%
		\pgf@y\ht\pgfnodepartmethodbox%
		\advance\pgf@y\dp\pgfnodepartmethodbox%
		\ifdim\pgf@y=0pt\relax%
			\setbox\pgfnodepartmethodbox=\hbox{%
				\vrule width0pt height\the\pgfutil@tempdima depth0pt%
			}%
		\fi%
		\pgf@y\ht\pgfnodepartextrabox%
		\advance\pgf@y\dp\pgfnodepartextrabox%
		\ifdim\pgf@y=0pt\relax%
			\setbox\pgfnodepartextrabox=\hbox{%
					\vrule width0pt height\the\pgfutil@tempdima depth0pt%
			}%
		\fi%
		%
		% Empty boxes (without voiding them) if they are not used.
		%
		\pgfmathtruncatemacro\parts{\pgfkeysvalueof{/pgfuml/class shape/parts}}%
	  \addtosavedmacro{\parts}%
%%
          % If just one part, take care of height
%	  \ifnum\parts<2\relax%
                 %%FROM rectangle shape
                 % First, is height+depth < minimum height?
                 \pgf@y=\ht\pgfnodeparttextbox%
                 \advance\pgf@y by\dp\pgfnodeparttextbox%
                 \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}%
                 \pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/inner ysep}}%
                 \advance\pgf@yb by -2\pgf@yc%
                 \ifdim\pgf@y<\pgf@yb%
                 % yes, too small. Enlarge...
                        \pgf@yb=0.5\pgf@yb%
                        \pgf@y=\pgf@yb%
                        \pgfmathsetlength\pgf@yc{.5ex}%
                        %depth
                        \advance\pgf@y by -\pgf@yc%
                        %height
                        \advance\pgf@yb by \pgf@yc%
			\setbox\pgfnodeparttextbox=\hbox{%				
				\vrule width0pt height\the\pgf@yb depth\the\pgf@y%
                                \box\pgfnodeparttextbox
			}%
                  \fi%
%	  \fi%
%%
	  \ifnum\parts<2\relax%
	  	\setbox\pgfnodepartattributebox=\hbox{}%
	  \fi%
	  \ifnum\parts<3\relax%
	  	\setbox\pgfnodepartmethodbox=\hbox{}%
	  \fi%
	  \ifnum\parts<4\relax%
	  	\setbox\pgfnodepartextrabox=\hbox{}%
	  \fi%	  
	  %
		% Save the line width.
		%
		\pgfmathsetlength\pgf@x{\pgflinewidth}
		\edef\linewidth{\the\pgf@x}%
	  \addtosavedmacro{\linewidth}%
	  %
	  \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
  	\edef\innerysep{\the\pgf@y}%
  	%
	  \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
  	\edef\innerxsep{\the\pgf@x}%
  	%
  	% Get the widths.
  	%
  	\pgf@x.5\wd\pgfnodeparttextbox%
  	\pgf@xa.5\wd\pgfnodepartattributebox%
  	\pgf@xb.5\wd\pgfnodepartmethodbox%
  	\pgf@xc.5\wd\pgfnodepartextrabox%
  	%
  	% Find the maximum width%
  	%
%%MODIF
%%  	\pgfutil@tempdima\pgf@x%
%%
  	\pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/minimum width}}%
        \pgfutil@tempdima.5\pgfutil@tempdima%
        \pgfmathaddtolength\pgfutil@tempdima{-\pgfkeysvalueof{/pgf/inner xsep}}%
  	\ifdim\pgfutil@tempdima<\pgf@x%
  		\pgfutil@tempdima\pgf@x%
  	\fi%
%%MODIF
  	\ifdim\pgfutil@tempdima<\pgf@xa%
  		\pgfutil@tempdima\pgf@xa%
  	\fi%
  	\ifdim\pgfutil@tempdima<\pgf@xb%
  		\pgfutil@tempdima\pgf@xb%
  	\fi%
  	\ifdim\pgfutil@tempdima<\pgf@xc%
  		\pgfutil@tempdima\pgf@xc%
  	\fi%
%%MODIF
\pgf@xd-\pgfutil@tempdima
%%MODIF
  	%
  	% Adjust for alignment.
	  %
	  \edef\pgf@lib@temp{\pgfkeysvalueof{/pgfuml/class shape/text part align}}%
	  \ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left%
  		\pgf@x-\pgfutil@tempdima%
	  \else%
	  	\ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right%
	  		\pgf@x-2.0\pgf@x%
  			\advance\pgf@x\pgfutil@tempdima%	  		
	  	\else%
	  		\pgf@x-\pgf@x%
  		\fi%
	  \fi%
  	%
  	\edef\pgf@lib@temp{\pgfkeysvalueof{/pgfuml/class shape/attribute part align}}%
  	\ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left%
  		\pgf@xa-\pgfutil@tempdima%
	  \else%
	  	\ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right%
	  		\pgf@xa-2.0\pgf@xa%
  			\advance\pgf@xa\pgfutil@tempdima%
	  	\else%
  			\pgf@xa-\pgf@xa%
  		\fi%
	  \fi%
  	%
  	\edef\pgf@lib@temp{\pgfkeysvalueof{/pgfuml/class shape/method part align}}%
  	\ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left%
  		\pgf@xb-\pgfutil@tempdima%
	  \else%
	  	\ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right%
	  		\pgf@xb-2.0\pgf@xb%
	  		\advance\pgf@xb\pgfutil@tempdima%
	  	\else%
	  		\pgf@xb-\pgf@xb%
	  	\fi%
	  \fi%
  	%
  	\edef\pgf@lib@temp{\pgfkeysvalueof{/pgfuml/class shape/extra part align}}%
  	\ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@left%
  		\pgf@xc-\pgfutil@tempdima%
	  \else%
	  	\ifx\pgf@lib@temp\pgf@lib@shapes@rectanglesplit@right%
	  		\pgf@xc-2.0\pgf@xc%
	  		\advance\pgf@xc\pgfutil@tempdima%
	  	\else%
	  		\pgf@xc-\pgf@xc%
	  	\fi%
	  \fi%
  	%
  	% Make relative to x.
  	%
  	\advance\pgf@xa-\pgf@x%
  	\advance\pgf@xb-\pgf@x%
  	\advance\pgf@xc-\pgf@x%
%%MODIF
  	\advance\pgf@xd-\pgf@x%
%%MODIF
  	\pgf@x0pt%
  	%
  	% Find the minimum.
  	%
  	\pgfutil@tempdimb\pgf@x%
  	\ifdim\pgfutil@tempdimb>\pgf@xa%
  		\pgfutil@tempdimb\pgf@xa%
  	\fi%
  	\ifdim\pgfutil@tempdimb>\pgf@xb%
  		\pgfutil@tempdimb\pgf@xb%
  	\fi%
  	\ifdim\pgfutil@tempdimb>\pgf@xc%
  		\pgfutil@tempdimb\pgf@xc%
  	\fi%
%%MODIF
  	\ifdim\pgfutil@tempdimb>\pgf@xd%
  		\pgfutil@tempdimb\pgf@xd%
  	\fi%
%%MODIF
  	%
  	% Anchor for the text box is (0pt, 0pt)
  	%
  	\pgfsavepgf@process\textanchor{\pgfqpoint{0pt}{0pt}}%
  	%
  	% Anchor for attribute box.
  	%
  	\pgfsavepgf@process\lowestanchor{\pgfqpoint{0pt}{0pt}}%
  	\let\lowestbox\pgfnodeparttextbox%
  	\ifnum\parts>1\relax%
  	  \pgfsavepgf@process\attributeanchor{%
  	  	\pgf@x\pgf@xa%
	  		\pgf@y-\dp\pgfnodeparttextbox%
	  		\advance\pgf@y-\innerysep\relax%
	  		\advance\pgf@y-\pgflinewidth%
	  		\advance\pgf@y-\innerysep\relax%
	  		\advance\pgf@y-\ht\pgfnodepartattributebox%
	  	}%
	  	\let\lowestanchor\attributeanchor%
	  	\let\lowestbox\pgfnodepartattributebox%
  	\else%
  		\let\attributeanchor\textanchor%
  	\fi%
  	%
  	% Anchor for method box.
  	%
  	\ifnum\parts>2\relax%
  	  \pgfsavepgf@process\methodanchor{%
  	  	\lowestanchor%
  	  	\pgf@x\pgf@xb%
	  		\advance\pgf@y-\dp\pgfnodepartattributebox%
	  		\advance\pgf@y-\innerysep\relax%
	  		\advance\pgf@y-\pgflinewidth%
	  		\advance\pgf@y-\innerysep\relax%
	  		\advance\pgf@y-\ht\pgfnodepartmethodbox%
	  	}%
	  	\let\lowestanchor\methodanchor%
	  	\let\lowestbox\pgfnodepartmethodbox%
  	\else%
  		\let\methodanchor\attributeanchor%
  	\fi%
  	%
  	% Anchor for extra box.
  	%
  	\ifnum\parts>3\relax%
  		\pgfsavepgf@process\extraanchor{%
  			\lowestanchor%
  	  	\pgf@x\pgf@xc%
  	  	\advance\pgf@y-\dp\lowestbox%
	  		\advance\pgf@y-\innerysep\relax%
	  		\advance\pgf@y-\pgflinewidth%
	  		\advance\pgf@y-\innerysep\relax%
	  		\advance\pgf@y-\ht\pgfnodepartextrabox%
	  	}%
	  	\let\lowestanchor\extraanchor%
	  	\let\lowestbox\pgfnodepartextrabox%
	  \else%
  		\let\extraanchor\methodanchor%
  	\fi%
  	%
  	\addtosavedmacro{\textanchor}%
	  \addtosavedmacro{\attributeanchor}%
	  \addtosavedmacro{\methodanchor}%
	  \addtosavedmacro{\extraanchor}%
	  %
	  % Adjust the boxwidth for minimum width
	  %
%%MODIF
%	  \pgfmathaddtolength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/inner xsep}}%
%   	\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/minimum width}}%
%   	\ifdim\pgfutil@tempdima<.5\pgf@x%
%   		\pgfutil@tempdima.5\pgf@x%
%   	\fi%
%  	\pgfmathaddtolength\pgfutil@tempdima{-\pgfkeysvalueof{/pgf/inner xsep}}%
  	%
  	% Get some important points.
  	%
  	\pgfsavepgf@process\southwest{%
  		\lowestanchor%
  		\pgf@x\pgfutil@tempdimb%
  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/inner xsep}}%
  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
%%MODIF  		\pgf@ya\linewidth\relax%
%%MODIF  		\advance\pgf@x-.5\pgf@ya%
  		\advance\pgf@y-\dp\lowestbox%
%%MODIF  		\advance\pgf@y-.5\pgf@ya%
  		\pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/inner ysep}}%
  		\pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}%
  	}%
  	\pgfsavepgf@process\northeast{%
  		\pgf@x\pgfutil@tempdimb%
  		\advance\pgf@x2.0\pgfutil@tempdima%
  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
%%MODIF  		\pgf@ya\linewidth\relax%
%%MODIF  		\advance\pgf@x.5\pgf@ya%
  		\pgf@y\ht\pgfnodeparttextbox%
%%MODIF  		\advance\pgf@y.5\pgf@ya%
  		\pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
  		\pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
  	}%
  	\addtosavedmacro{\northeast}%
  	\addtosavedmacro{\southwest}%  	
  	\pgfsavepgf@process\centerpoint{%
  	  \pgfpointadd{\southwest}{%
  			\pgfpointdiff{\southwest}{\northeast}%
  			\pgf@x.5\pgf@x%
  			\pgf@y.5\pgf@y%
  		}%
  	}%
  	\addtosavedmacro{\centerpoint}%  
  	\pgfsavepgf@process\south{%
  		\centerpoint%
  		\pgf@xa\pgf@x%
  		\southwest%
  		\pgf@x\pgf@xa%
  	}%
  	%
  	% Get the split points.
  	%
  	\let\lastsplit\south%
  	\ifnum\parts>1\relax%
	  	\pgfsavepgf@process\textsplit{%
	  		\pgf@x\pgfutil@tempdimb%
	  		\advance\pgf@x\pgfutil@tempdima%
	  		\pgf@y-\dp\pgfnodeparttextbox%
	  		\advance\pgf@y-\innerysep%
	  		\advance\pgf@y-.5\pgflinewidth%
	  	}%
	  \else%
	  	\let\textsplit\south%
	  \fi%
  	\addtosavedmacro{\textsplit}%
  	\pgfsavepgf@process\textspliteast{%
  		\textsplit%
  		\pgf@ya\pgf@y%
  		\northeast%
  		\pgf@y\pgf@ya%
  	}%
  	\addtosavedmacro{\textspliteast}%
  	\pgfsavepgf@process\textsplitwest{%
  		\textsplit%
  		\pgf@ya\pgf@y%
  		\southwest%
  		\pgf@y\pgf@ya%
  	}%
  	\addtosavedmacro{\textsplitwest}%
  	\ifnum\parts>2\relax%
  		\pgfsavepgf@process\attributesplit{%
  		  \attributeanchor%
  			\pgf@x\pgfutil@tempdimb%
  			\advance\pgf@x\pgfutil@tempdima%
  			\advance\pgf@y-\dp\pgfnodepartattributebox%
  			\advance\pgf@y-\innerysep%
  			\advance\pgf@y-.5\pgflinewidth%
  		}%
  	\else%
  		\let\attributesplit\south%
  	\fi%
  	\addtosavedmacro{\attributesplit}%
  	\pgfsavepgf@process\attributespliteast{%
  		\attributesplit%
  		\pgf@ya\pgf@y%
  		\northeast%
  		\pgf@y\pgf@ya%
  	}%
  	\addtosavedmacro{\attributespliteast}%
  	\pgfsavepgf@process\attributesplitwest{%
  		\attributesplit%
  		\pgf@ya\pgf@y%
  		\southwest%
  		\pgf@y\pgf@ya%
  	}%
  	\addtosavedmacro{\attributesplitwest}%
  	\ifnum\parts>3\relax%
  		\pgfsavepgf@process\methodsplit{%
  		  \methodanchor%
  			\pgf@x\pgfutil@tempdimb%
  			\advance\pgf@x\pgfutil@tempdima%
  			\advance\pgf@y-\dp\pgfnodepartmethodbox%
  			\advance\pgf@y-\innerysep%
  			\advance\pgf@y-.5\pgflinewidth%
  		}%
  		\let\lastsplit\methodsplit%
  	\else%
  		\let\methodsplit\south%
  	\fi%
  	\addtosavedmacro{\methodsplit}%
  	\pgfsavepgf@process\methodspliteast{%
  		\methodsplit%
  		\pgf@ya\pgf@y%
  		\northeast%
  		\pgf@y\pgf@ya%
  	}%
  	\addtosavedmacro{\methodspliteast}%
  	\pgfsavepgf@process\methodsplitwest{%
  		\methodsplit%
  		\pgf@ya\pgf@y%
  		\southwest%
  		\pgf@y\pgf@ya%
  	}%
  	\addtosavedmacro{\methodsplitwest}%
	}%
	\savedanchor\basepoint{%
		\pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
		\pgfmathsetlength\pgf@y{+.5\ht\pgfnodeparttextbox}%
		\pgf@y0pt\relax%
	}%
	\savedanchor\midpoint{%
		\pgfmathsetlength\pgf@x{+.5\wd\pgfnodeparttextbox}%
		\pgfmathsetlength\pgf@y{+.5ex}%
	}%
	\anchor{center}{\getrectanglesplitparameters\centerpoint}%
	\anchor{base}{\basepoint}%
	\anchor{mid}{\midpoint}%
	\anchor{attribute}{\getrectanglesplitparameters\attributeanchor}%
	\anchor{method}{\getrectanglesplitparameters\methodanchor}%
	\anchor{extra}{\getrectanglesplitparameters\extraanchor}%
	\anchor{north east}{\getrectanglesplitparameters\northeast}
	\anchor{south west}{\getrectanglesplitparameters\southwest}
	\anchor{south east}{%
		\getrectanglesplitparameters%
		\northeast%
		\pgf@xa\pgf@x%
		\southwest%
		\pgf@x\pgf@xa}
	\anchor{north west}{%
		\getrectanglesplitparameters%
		\northeast%
		\pgf@ya\pgf@y%
		\southwest%
		\pgf@y\pgf@ya}
	\anchor{south}{%
		\getrectanglesplitparameters%
		\centerpoint%
		\pgf@xa\pgf@x%
		\southwest%
		\pgf@x\pgf@xa}
	\anchor{north}{%
		\getrectanglesplitparameters%
		\centerpoint%
		\pgf@xa\pgf@x%
		\northeast%
		\pgf@x\pgf@xa}
	\anchor{west}{%
		\getrectanglesplitparameters%
		\centerpoint%
		\pgf@ya\pgf@y%
		\southwest%
		\pgf@y\pgf@ya}
	\anchor{east}{%
		\getrectanglesplitparameters%
		\centerpoint%
		\pgf@ya\pgf@y%
		\northeast%
		\pgf@y\pgf@ya}
	\anchor{text split}{\getrectanglesplitparameters\textsplit}
	\anchor{text split east}{\getrectanglesplitparameters\textspliteast}
	\anchor{text split west}{\getrectanglesplitparameters\textsplitwest}
	\anchor{attribute split}{\getrectanglesplitparameters\attributesplit}
	\anchor{attribute split east}{\getrectanglesplitparameters\attributespliteast}
	\anchor{attribute split west}{\getrectanglesplitparameters\attributesplitwest}
	\anchor{method split}{\getrectanglesplitparameters\methodsplit}
	\anchor{method split east}{\getrectanglesplitparameters\methodspliteast}
	\anchor{method split west}{\getrectanglesplitparameters\methodsplitwest}	
	\anchor{text east}{%
		\getrectanglesplitparameters%
		\ifnum\parts>1\relax%
			\textsplit%
			\pgf@ya\pgf@y
			\northeast%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@ya\linewidth\relax%
			\advance\pgf@y-.25\pgf@ya%
		\else%
			\centerpoint%
			\pgf@ya\pgf@y%
			\northeast%
			\pgf@y\pgf@ya%
		\fi%
	}
	\anchor{text west}{%
		\getrectanglesplitparameters%
		\ifnum\parts>1\relax%
			\textsplit%
			\pgf@ya\pgf@y
			\southwest%
			\pgf@xa\pgf@x%
			\northeast%
			\pgf@x\pgf@xa%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@ya\linewidth\relax%
			\advance\pgf@y-.25\pgf@ya%
		\else%
			\centerpoint%
			\pgf@ya\pgf@y%
			\southwest%
			\pgf@y\pgf@ya%
		\fi%
	}
	\anchor{attribute east}{%
		\getrectanglesplitparameters%
		\ifnum\parts>1\relax%
			\northeast%
			\pgf@xa\pgf@x%
			\attributesplit%
			\pgf@ya\pgf@y
			\textsplit%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@x\pgf@xa%
		\else%
			\southwest%
			\pgf@ya\pgf@y%
			\northeast%
			\pgf@y\pgf@ya%
		\fi%
	}
	\anchor{attribute west}{%
		\getrectanglesplitparameters%
		\ifnum\parts>1\relax%
			\southwest%
			\pgf@xa\pgf@x%
			\attributesplit%
			\pgf@ya\pgf@y
			\textsplit%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@x\pgf@xa%
		\else%
			\southwest%
		\fi%
	}
	\anchor{method east}{%
		\getrectanglesplitparameters%
		\ifnum\parts>2\relax%
			\northeast%
			\pgf@xa\pgf@x%
			\methodsplit%
			\pgf@ya\pgf@y
			\attributesplit%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@x\pgf@xa%
		\else%
			\southwest%
			\pgf@ya\pgf@y%
			\northeast%
			\pgf@y\pgf@ya%
		\fi%
	}
	\anchor{method west}{%
		\getrectanglesplitparameters%
		\ifnum\parts>2\relax%
			\southwest%
			\pgf@xa\pgf@x%
			\methodsplit%
			\pgf@ya\pgf@y
			\attributesplit%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@x\pgf@xa%
		\else%
			\southwest
		\fi%
	}
	\anchor{extra east}{%
		\getrectanglesplitparameters%
		\ifnum\parts>3\relax%
			\northeast%
			\pgf@xa\pgf@x%
			\southwest%
			\pgf@ya\linewidth\relax%
			\pgf@ya.5\pgf@ya%
			\advance\pgf@ya\pgf@y%
			\methodsplit%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@x\pgf@xa%
		\else%
			\northeast%
			\pgf@xa\pgf@x%
			\southwest%
			\pgf@x\pgf@xa%
		\fi%
	}
	\anchor{extra west}{%
		\getrectanglesplitparameters%
		\ifnum\parts>3\relax%
			\southwest%
			\pgf@xa\pgf@x%
			\pgf@ya\linewidth\relax%
			\pgf@ya.5\pgf@ya%
			\advance\pgf@ya\pgf@y%
			\methodsplit%
			\advance\pgf@y\pgf@ya%
			\pgf@y.5\pgf@y%
			\pgf@x\pgf@xa%
		\else%
			\southwest%
		\fi%
	}
	\backgroundpath{%
		\getrectanglesplitparameters%
		%
		% Remove outer sep.
		%
		\pgfsavepgf@process\southwest{%
			\southwest%
  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
  		\pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
  	}%
  	\pgfsavepgf@process\northeast{%
			\northeast%
  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
  		\pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}%
  	}%
  	\pgfsavepgf@process\textsplit{%
			\textsplit%
  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
  	}%
  	\pgfsavepgf@process\attributesplit{%
			\attributesplit%
  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
  	}%
  	\pgfsavepgf@process\methodsplit{%
			\methodsplit%
  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
  	}%
  	\pgfpathrectangle{\southwest}{\pgfpointdiff{\southwest}{\northeast}}%
  	{%
  		\pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
  		\ifnum\parts>1\relax%
  			\pgfpathmoveto{\textsplit\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}%
  			\pgfpathlineto{\textsplit\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}%
  		\fi%
  		\ifnum\parts>2\relax%
  			\pgfpathmoveto{\attributesplit\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}%
  			\pgfpathlineto{\attributesplit\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}%
  		\fi%
  		\ifnum\parts>3\relax%
  			\pgfpathmoveto{\methodsplit\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}%
  			\pgfpathlineto{\methodsplit\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}%
  		\fi%
  	}%
  }
  \behindbackgroundpath{%
  	\ifpgfrectanglesplitusecustomfill%
  		%
			% Remove outer sep.
			%
			\getrectanglesplitparameters%
			\pgfsavepgf@process\southwest{%
				\southwest%
	  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
	  		\pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
	  	}%
	  	\pgfsavepgf@process\northeast{%
				\northeast%
	  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
	  		\pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}%
	  	}%
	  	\pgfsavepgf@process\textspliteast{%
				\textspliteast%
	  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
	  	}%
	  	\pgfsavepgf@process\textsplitwest{%
				\textsplitwest%
	  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
	  	}%
	  	\pgfsavepgf@process\attributespliteast{%
				\attributespliteast%
	  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
	  	}%
	  	\pgfsavepgf@process\attributesplitwest{%
				\attributesplitwest%
	  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
	  	}%
	  	\pgfsavepgf@process\methodspliteast{%
				\methodspliteast%
	  		\pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
	  	}%
	  	\pgfsavepgf@process\methodsplitwest{%
				\methodsplitwest%
	  		\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
	  	}%
	  	%
  		% Always fill the text box.
  		%
  		\pgfpathmoveto{\textsplitwest}%
  		\pgfpathlineto{\northeast\pgf@ya\pgf@y\southwest\pgf@y\pgf@ya}%
  		\pgfpathlineto{\northeast}%
  		\ifnum\parts>1\relax%
  			\bgroup%
  				\pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
  		\fi%  		
  		\pgfpathlineto{\textspliteast}%
  		\pgfpathclose%
  		\ifnum\parts>1\relax%
  			\egroup%
  		\fi% 
  		\pgfsetfillcolor{\pgfkeysvalueof{/pgfuml/class shape/text part fill}}%
  		\pgfusepath{fill}%
  		%
  		% Attribute box.
  		%
  		\ifnum\parts>1\relax%
  			\bgroup%
  				\pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
  				\pgfpathmoveto{\textsplitwest}%
  				\pgfpathlineto{\textspliteast}%
	  			\ifnum\parts=2\relax%
	  				\egroup%
	  			\fi%
  				\pgfpathlineto{\attributespliteast}%
  				\pgfpathlineto{\attributesplitwest}%
  				\ifnum\parts=2\relax%
	  				\bgroup%
	  				\pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
	  			\fi%
  				\pgfpathclose%
  				\pgfsetfillcolor{\pgfkeysvalueof{/pgfuml/class shape/attribute part fill}}%
  				\pgfusepath{fill}%
  			\egroup%
  		\fi%
  		%
  		% Method box.
  		%
  		\ifnum\parts>2\relax%
  			\bgroup%
  				\pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
  				\pgfpathmoveto{\attributesplitwest}%
  				\pgfpathlineto{\attributespliteast}%
  				\ifnum\parts=3\relax%
  					\egroup%
  				\fi%
  				\pgfpathlineto{\methodspliteast}%
  				\pgfpathlineto{\methodsplitwest}%
  				\ifnum\parts=3\relax%
  					\bgroup%
  					\pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
  				\fi%
  				\pgfpathclose%
  				\pgfsetfillcolor{\pgfkeysvalueof{/pgfuml/class shape/method part fill}}%
  				\pgfusepath{fill}%
  			\egroup%
  		\fi%
	  	%
			% And the extra box.
			%
			\ifnum\parts>3\relax%
				\pgfpathmoveto{\methodsplitwest}%
				\pgfpathlineto{\southwest}%
				\pgfpathlineto{\southwest\pgf@ya\pgf@y\northeast\pgf@y\pgf@ya}%
				\bgroup%
						\pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
						\pgfpathlineto{\methodspliteast}%
					\pgfpathclose%
				\egroup%
				\pgfsetfillcolor{\pgfkeysvalueof{/pgfuml/class shape/extra part fill}}%
				\pgfusepath{fill}%
			\fi%
		\fi%
  }
  \anchorborder{%
  	\pgfutil@tempdima\pgf@x%
  	\pgfutil@tempdimb\pgf@y%
  	\getrectanglesplitparameters%
  	\pgfpointdiff{\southwest}{\northeast}%
  	\pgf@x.5\pgf@x%
  	\pgf@y.5\pgf@y%
  	\edef\pgf@marshall{%
  		\noexpand\pgfpointborderrectangle{%
  				\noexpand\pgfqpoint{\the\pgfutil@tempdima}{\the\pgfutil@tempdimb}%
  			}%
      	{%
      		\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}%
      	}%
    }%
    \pgf@marshall%
    \pgf@xa\pgf@x%
    \pgf@ya\pgf@y%
    \centerpoint%
    \advance\pgf@x\pgf@xa%
    \advance\pgf@y\pgf@ya%
   }%
}
