All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ChartRendererManager.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/maptools/ChartRendererManager.cpp
22 
23  \brief This is a singleton for managing chart renderer instance available in the system.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "AbstractChartRenderer.h"
29 #include "ChartRendererManager.h"
30 #include "Exception.h"
31 
32 // STL
33 #include <cassert>
34 
36  : m_renderer(0)
37 {
38 }
39 
41 {
42  delete m_renderer;
43 }
44 
45 te::color::RGBAColor** te::map::ChartRendererManager::render(const Chart* chart, const te::da::DataSet* dataset, std::size_t& width)
46 {
47  LockWrite l;
48 
49  if(m_renderer == 0)
50  throw Exception(TE_TR("There is not a chart renderer registered!"));
51 
52  return m_renderer->render(chart, dataset, width);
53 }
54 
55 te::color::RGBAColor** te::map::ChartRendererManager::render(const Chart* chart, const std::map<std::string, double>& chartValue, std::size_t& width)
56 {
57  LockWrite l;
58 
59  if(m_renderer == 0)
60  throw Exception(TE_TR("There is not a chart renderer registered!"));
61 
62  return m_renderer->render(chart, chartValue, width);
63 }
64 
66 {
67  delete m_renderer;
68  m_renderer = renderer;
69 }
te::color::RGBAColor ** render(const Chart *chart, const te::da::DataSet *dataset, std::size_t &width)
It generates the image pattern from the given chart and dataset.
This is the base class for chart renderers.
This is a singleton for managing chart renderer instance available in the system. ...
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
An exception class for the MapTools module.
This class represents the informations needed to build map charts.
Definition: Chart.h:51
~ChartRendererManager()
Singleton destructor.
ChartRendererManager()
It initializes the singleton instance of the chart renderer manager.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
void set(AbstractChartRenderer *renderer)
It sets the chart renderer to the manager.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
This is the base class for chart renderers.