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 "../core/translator/Translator.h"
28 #include "AbstractChartRenderer.h"
29 #include "ChartRendererManager.h"
30 #include "Exception.h"
31 
32 // STL
33 #include <cassert>
34 
36  : m_renderer(nullptr)
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 == nullptr)
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 == nullptr)
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.
An exception class for the MapTools module.
Base exception class for plugin module.
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:242
AbstractChartRenderer * m_renderer
The chart renderer in the manager.
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.
virtual te::color::RGBAColor ** render(const Chart *chart, const te::da::DataSet *dataset, std::size_t &width)=0
It generates the image pattern from the given chart and the current element of dataset.
A dataset is the unit of information manipulated by the data access module of TerraLib.
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.