00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00023 #ifndef LABELLEGEND_INCLUDED
00024 #define LABELLEGEND_INCLUDED
00025
00026 #include "DrawingMetrics.h"
00027 #include "LabelSet.h"
00028 #include "DrawingLabelManager.h"
00029 #include "DrawingCanvas.h"
00030 #include "SVG.h"
00031 #include "Utf8String.h"
00032 #include "Legend.h"
00033
00034 class LabelLegend : public Legend{
00035
00036 private:
00037 const LabelSet * _labelSet;
00038
00039 public:
00040
00041 LabelLegend() {}
00042
00043 void setLabelSet(const LabelSet *const labelSet){
00044
00045 _labelSet = labelSet;
00046
00047 _width = DrawingMetrics::getIconInterval();
00048 _height = _labelSet->getNumberOfLabels()*DrawingMetrics::getLineHeight() + 2*DrawingMetrics::getLabelMargin();
00049
00050 }
00051
00052
00053
00054
00055 void draw(std::ostringstream& os,SVG* psvg,DrawingLabelManager* plm,const double x,const double y){
00056
00057
00058 double lineHeight = DrawingMetrics::getLineHeight();
00059 double labelMargin = DrawingMetrics::getLabelMargin();
00060 std::vector<UTF8String> labels = _labelSet->getLabelNameSet();
00061
00062
00063 double xstt = x - DrawingMetrics::getHorizontalInterval() + labelMargin;
00064 double ystt = y;
00065
00066
00067 psvg->startGroup(os,"legend");
00068 psvg->drawRectangle(os,xstt,ystt,_width-2*labelMargin,_height,"keyBox");
00069 ystt+= lineHeight;
00070 xstt+=DrawingMetrics::getHorizontalInterval() - labelMargin;
00071 for(unsigned i=0;i<labels.size();i++){
00072 psvg->drawText(os,xstt,ystt, plm->fitStringToLabelWidth( labels[i] ) );
00073 ystt+=lineHeight;
00074 }
00075 psvg->endGroup(os);
00076 }
00077
00078 };
00079
00080 #endif