Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

LabelLegend.h

Go to the documentation of this file.
00001 
00002 //
00003 // This file is part of the MADELINE 2 program 
00004 // written by Edward H. Trager and Ritu Khanna
00005 // Copyright (c) 2005 by the
00006 // Regents of the University of Michigan.
00007 // All Rights Reserved.
00008 // 
00009 // The latest version of this program is available from:
00010 // 
00011 //   http://eyegene.ophthy.med.umich.edu/madeline/
00012 //   
00013 // Released under the GNU General Public License.
00014 // A copy of the GPL is included in the distribution
00015 // package of this software, or see:
00016 // 
00017 //   http://www.gnu.org/copyleft/
00018 //   
00019 // ... for licensing details.
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                 //_width  = DrawingMetrics::getIconInterval()  + 2*DrawingMetrics::getLabelMargin();
00047                 _width = DrawingMetrics::getIconInterval(); 
00048                 _height = _labelSet->getNumberOfLabels()*DrawingMetrics::getLineHeight() + 2*DrawingMetrics::getLabelMargin();
00049                 
00050         }
00051         
00052         
00053         
00054         //void draw(std::ostringstream& os,SVG* psvg,DrawingLabelManager* plm,const double x,const double y);
00055         void draw(std::ostringstream& os,SVG* psvg,DrawingLabelManager* plm,const double x,const double y){
00056                 
00057                 // lineHeight:
00058                 double lineHeight = DrawingMetrics::getLineHeight();
00059                 double labelMargin = DrawingMetrics::getLabelMargin();
00060                 std::vector<UTF8String> labels = _labelSet->getLabelNameSet();
00061                 
00062                 // Determine a starting point to draw the key:
00063                 double xstt = x - DrawingMetrics::getHorizontalInterval() + labelMargin;
00064                 double ystt = y; 
00065                 
00066                 // Wrap labels in a group:
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

Generated on Fri Nov 18 16:24:39 2011 for MADELINE by  doxygen 1.4.4