
% ----------------------------------------------------------------------------
% | keys for the legend
% ----------------------------------------------------------------------------

\define@key[NumericDataPlot]{Legend}{nrCols}[1]{\renewcommand{\nrLegendCols}{#1}}%
\define@key[NumericDataPlot]{Legend}{LegLineWidth}[20pt]{\setlength{\LegLineWidth}{#1}}%

\define@choicekey+[NumericDataPlot]{Legend}{LabelOrientation}[\val\nrLegOrient]
{r,l,c}{%
	\ifcase\nrLegOrient\relax%
		\setboolean{LegendOrientationLeft}{false}%
		\setboolean{LegendOrientationRight}{true}%
		\setboolean{LegendOrientationCenter}{false}%
    \or%
        \setboolean{LegendOrientationLeft}{true}%
		\setboolean{LegendOrientationRight}{false}%
		\setboolean{LegendOrientationCenter}{false}%
    \or%
    	\setboolean{LegendOrientationLeft}{false}%
		\setboolean{LegendOrientationRight}{false}%
		\setboolean{LegendOrientationCenter}{true}%
    \fi%
}{
	\PackageWarning{NumericPlots}{LabelOrientation #1 not defined. Use r, l or c}%
}


% ==============================================================================
% ||
% || legend
% ||
% ==============================================================================


\newcommand{\LegLineOld}[2][]{%
	\setkeys[NumericDataPlot]{Legend}{#1}
	%
	\centering\Rnode{lab#2}{}%
	\psline[style=#2,showpoints=false]([nodesep=0.5\LegLineWidth]lab#2)([nodesep=-0.5\LegLineWidth]lab#2)%
	\psline[style=#2](lab#2)(lab#2)%
}

% \newcommand{\LegLine}[2][]{%
% 	\setkeys[NumericDataPlot]{Legend}{#1}
% 	%
% 	\centering\Rnode{LegLineNode}{}%
% 	\psline[#2,showpoints=false]([nodesep=0.5\LegLineWidth]LegLineNode)([nodesep=-0.5\LegLineWidth]LegLineNode)%
% 	\psline[#2, linestyle=none](LegLineNode)(LegLineNode)
% }
% 
% 
% \newcommand{\LegendDefinition}[2][nrCols]{%
% 	\setkeys[NumericDataPlot]{Legend}{#1}%
% 	%
% 	\psframebox[style=LegendBoxStyle]{%
% 		\ifLegendOrientationLeft
% 			\begin{tabular}{*{\nrLegendCols}{p{\LegLineWidth}l}}%
% 				#2%
% 			\end{tabular}%
% 		\fi
% 		\ifLegendOrientationCenter
% 			\begin{tabular}{*{\nrLegendCols}{p{\LegLineWidth}c}}
% 				#2
% 			\end{tabular}
% 		\fi
% 		\ifLegendOrientationRight
% 			\begin{tabular}{*{\nrLegendCols}{p{\LegLineWidth}r}}
% 				#2
% 			\end{tabular}
% 		\fi
% 	}%psframebox
% }

\newcommand{\LegLine}[2][]{%
	\setkeys[NumericDataPlot]{Legend}{#1}%
	\parbox[t]{\LegLineWidth}{%	
	\centering\Rnode{LegLineNode}{}%
	\psline[#2,showpoints=false]([nodesep=0.5\LegLineWidth]LegLineNode)([nodesep=-0.5\LegLineWidth]LegLineNode)%	
	\psline[#2,linestyle=none](LegLineNode)(LegLineNode)%
	}
}

\newcommand{\LegDot}[2][]{%
	\setkeys[NumericDataPlot]{Legend}{#1}%
	\parbox[t]{\LegLineWidth}{%	
	\centering\Rnode{LegLineNode}{}%
	\psdots[#2](LegLineNode)%
	}
}

\newcommand{\LegendDefinition}[2][nrCols]{%
	\setkeys[NumericDataPlot]{Legend}{#1}%
	%
	\psframebox[style=LegendBoxStyle]{%
		\ifLegendOrientationLeft%
			\begin{tabular}{*{\nrLegendCols}{ll}}%
				#2%
			\end{tabular}%
		\fi
		\ifLegendOrientationCenter
			\begin{tabular}{*{\nrLegendCols}{cc}}
				#2
			\end{tabular}
		\fi
		\ifLegendOrientationRight
			\begin{tabular}{*{\nrLegendCols}{cr}}
				#2
			\end{tabular}
		\fi
	}%psframebox
}
