All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TitleModel.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 TitleModel.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "TitleModel.h"
30 #include "../../geometry/Envelope.h"
31 #include "../../color/RGBAColor.h"
32 #include "../../maptools/Canvas.h"
33 #include "../core/enum/Enums.h"
34 #include "../core/property/Property.h"
35 #include "../core/property/Properties.h"
36 #include "../core/property/TextGridSettingsConfigProperties.h"
37 
39  m_textgridProperties(0),
40  m_title("Title"),
41  m_spacing(1),
42  m_padding(1),
43  m_width(100),
44  m_addRow(false),
45  m_rowNumber(2),
46  m_addColumn(false),
47  m_columnNumber(1),
48  m_columnWidth(100),
49  m_borderWidth(0.5)
50 
51 {
52 
53  m_type = Enums::getInstance().getEnumObjectType()->getTitleItem();
54 
55  m_box = te::gm::Envelope(0., 0., 190., 170.);
56 
57  m_tableColor.setColor(0,0,0,255);
58  m_borderGridColor.setColor(0,0,0,255);
59  m_headerHorizontalColor.setColor(255,255,255,0);
60  m_headerVerticalColor.setColor(192,192,192,255);
61 
63  m_text = "Text";
64 }
65 
67 {
68  if(m_textgridProperties)
69  {
70  delete m_textgridProperties;
71  m_textgridProperties = 0;
72  }
73 }
74 
76 {
78 
80 
81  Property pro_title(m_hashCode);
82  pro_title.setName(m_textgridProperties->getTitle());
83  pro_title.setValue(m_title, dataType->getDataTypeString());
84  pro_title.addSubProperty(pro_title);
85  m_properties->addProperty(pro_title);
86 
87  //------------------------------------------------------------------------
88 
89  Property pro_textGrid(m_hashCode);
90  pro_textGrid.setName(m_textgridProperties->getName());
91  std::string sValuePlanar = "Settings";
92  pro_textGrid.setMenu(true);
93  pro_textGrid.setValue(sValuePlanar, dataType->getDataTypeTextGridSettings());
94 
95  /* Subproperties of DataTypeGridSettings property */
96 
97  Property pro_spacing(m_hashCode);
98  pro_spacing.setName(m_textgridProperties->getSpacing());
99  pro_spacing.setValue(m_spacing, dataType->getDataTypeDouble());
100  pro_textGrid.addSubProperty(pro_spacing);
101 
102  Property pro_padding(m_hashCode);
103  pro_padding.setName(m_textgridProperties->getPadding());
104  pro_padding.setValue(m_padding, dataType->getDataTypeDouble());
105  pro_textGrid.addSubProperty(pro_padding);
106 
107  Property pro_tableColor(m_hashCode);
108  pro_tableColor.setName(m_textgridProperties->getTableColor());
109  pro_tableColor.setValue(m_tableColor, dataType->getDataTypeColor());
110  pro_textGrid.addSubProperty(pro_tableColor);
111 
112  Property pro_width(m_hashCode);
113  pro_width.setName(m_textgridProperties->getWidth());
114  pro_width.setValue(m_width, dataType->getDataTypeDouble());
115  pro_textGrid.addSubProperty(pro_width);
116 
117  Property pro_rowNumber(m_hashCode);
118  pro_rowNumber.setName(m_textgridProperties->getRowNumber());
119  pro_rowNumber.setValue(m_rowNumber, dataType->getDataTypeInt());
120  pro_textGrid.addSubProperty(pro_rowNumber);
121 
122  Property pro_evenRow(m_hashCode);
123  pro_evenRow.setName(m_textgridProperties->getEvenRow());
124  pro_evenRow.setValue(m_evenRow, dataType->getDataTypeColor());
125  pro_textGrid.addSubProperty(pro_evenRow);
126 
127  Property pro_oddRow(m_hashCode);
128  pro_oddRow.setName(m_textgridProperties->getOddRow());
129  pro_oddRow.setValue(m_oddRow, dataType->getDataTypeColor());
130  pro_textGrid.addSubProperty(pro_oddRow);
131 
132  Property pro_columnNumber(m_hashCode);
133  pro_columnNumber.setName(m_textgridProperties->getColumnNumber());
134  pro_columnNumber.setValue(m_columnNumber, dataType->getDataTypeInt());
135  pro_textGrid.addSubProperty(pro_columnNumber);
136 
137  Property pro_columnWidth(m_hashCode);
138  pro_columnWidth.setName(m_textgridProperties->getColumnWidth());
139  pro_columnWidth.setValue(m_columnWidth, dataType->getDataTypeDouble());
140  pro_textGrid.addSubProperty(pro_columnWidth);
141 
142  Property pro_borderWidth(m_hashCode);
143  pro_borderWidth.setName(m_textgridProperties->getBorderWidth());
144  pro_borderWidth.setValue(m_borderWidth, dataType->getDataTypeDouble());
145  pro_textGrid.addSubProperty(pro_borderWidth);
146 
147  Property pro_borderGridColor(m_hashCode);
148  pro_borderGridColor.setName(m_textgridProperties->getBorderGridColor());
149  pro_borderGridColor.setValue(m_borderGridColor, dataType->getDataTypeColor());
150  pro_textGrid.addSubProperty(pro_borderGridColor);
151 
152  Property pro_headerHorizontalColor(m_hashCode);
153  pro_headerHorizontalColor.setName(m_textgridProperties->getHeaderHorizontalColor());
154  pro_headerHorizontalColor.setValue(m_headerHorizontalColor, dataType->getDataTypeColor());
155  pro_textGrid.addSubProperty(pro_headerHorizontalColor);
156 
157  Property headerVerticalColor(m_hashCode);
158  headerVerticalColor.setName(m_textgridProperties->getHeaderVerticalColor());
159  headerVerticalColor.setValue(m_headerVerticalColor, dataType->getDataTypeColor());
160  pro_textGrid.addSubProperty(headerVerticalColor);
161 
162  m_properties->addProperty(pro_textGrid);
163 
164  //-------------------------------------------------------------------------
165 
166  return m_properties;
167 }
168 
170 {
171  TextModel::updateProperties(properties);
172 
173  Properties* vectorProps = const_cast<Properties*>(properties);
174 
175  Property pro_textGrid = vectorProps->contains(m_textgridProperties->getName());
176 
177  Property pro_spacing = pro_textGrid.containsSubProperty(m_textgridProperties->getSpacing());
178 
179  if(!pro_spacing.isNull())
180  {
181  m_spacing = pro_spacing.getValue().toDouble();
182  }
183 
184  Property pro_padding = pro_textGrid.containsSubProperty(m_textgridProperties->getPadding());
185 
186  if(!pro_padding.isNull())
187  {
188  m_padding = pro_padding.getValue().toDouble();
189  }
190 
191  Property pro_tableColor = pro_textGrid.containsSubProperty(m_textgridProperties->getTableColor());
192 
193  if(!pro_tableColor.isNull())
194  {
195  m_tableColor = pro_tableColor.getValue().toColor();
196  }
197 
198  Property pro_width = pro_textGrid.containsSubProperty(m_textgridProperties->getWidth());
199 
200  if(!pro_width.isNull())
201  {
202  m_width = pro_width.getValue().toDouble();
203  }
204 
205  Property pro_rowNumber = pro_textGrid.containsSubProperty(m_textgridProperties->getRowNumber());
206 
207  if(!pro_rowNumber.isNull())
208  {
209  m_rowNumber = pro_rowNumber.getValue().toInt();
210  }
211 
212  Property pro_evenRow = pro_textGrid.containsSubProperty(m_textgridProperties->getEvenRow());
213 
214  if(!pro_evenRow.isNull())
215  {
216  m_evenRow = pro_evenRow.getValue().toColor();
217  }
218 
219  Property pro_oddRow = pro_textGrid.containsSubProperty(m_textgridProperties->getOddRow());
220 
221  if(!pro_oddRow.isNull())
222  {
223  m_oddRow = pro_oddRow.getValue().toColor();
224  }
225 
226  Property pro_columnNumber = pro_textGrid.containsSubProperty(m_textgridProperties->getColumnNumber());
227 
228  if(!pro_columnNumber.isNull())
229  {
230  m_columnNumber = pro_columnNumber.getValue().toInt();
231  }
232 
233  Property pro_columnWidth = pro_textGrid.containsSubProperty(m_textgridProperties->getColumnWidth());
234 
235  if(!pro_columnWidth.isNull())
236  {
237  m_columnWidth = pro_columnWidth.getValue().toDouble();
238  }
239 
240  Property pro_borderWidth = pro_textGrid.containsSubProperty(m_textgridProperties->getBorderWidth());
241 
242  if(!pro_borderWidth.isNull())
243  {
244  m_borderWidth = pro_borderWidth.getValue().toDouble();
245  }
246 
247  Property pro_borderGridColor = pro_textGrid.containsSubProperty(m_textgridProperties->getBorderGridColor());
248 
249  if(!pro_borderGridColor.isNull())
250  {
251  m_borderGridColor = pro_borderGridColor.getValue().toColor();
252  }
253 
254  Property pro_headerHorizontalColor = pro_textGrid.containsSubProperty(m_textgridProperties->getHeaderHorizontalColor());
255 
256  if(!pro_headerHorizontalColor.isNull())
257  {
258  m_headerHorizontalColor = pro_headerHorizontalColor.getValue().toColor();
259  }
260 
261  Property pro_headerVerticalColor = pro_textGrid.containsSubProperty(m_textgridProperties->getHeaderVerticalColor());
262 
263  if(!pro_headerVerticalColor.isNull())
264  {
265  m_headerVerticalColor = pro_headerVerticalColor.getValue().toColor();
266  }
267 }
268 
269 void te::layout::TitleModel::setTitle( std::string title )
270 {
271  m_title = title;
272 }
273 
275 {
276  return m_title;
277 }
278 
280 {
281  m_spacing = value;
282 }
283 
285 {
286  return m_spacing;
287 }
288 
290 {
291  m_padding = value;
292 }
293 
295 {
296  return m_padding;
297 }
298 
300 {
301  m_columnNumber = value;
302 }
303 
305 {
306  return m_columnNumber;
307 }
308 
310 {
311  m_rowNumber = value;
312 }
313 
315 {
316  return m_rowNumber;
317 }
318 
320 {
321  m_tableColor = color;
322 }
323 
325 {
326  return m_tableColor;
327 }
328 
330 {
331  m_width = width;
332 }
333 
335 {
336  return m_width;
337 }
338 
340 {
341  m_evenRow = color;
342 }
343 
345 {
346  return m_evenRow;
347 }
348 
350 {
351  m_oddRow = color;
352 }
353 
355 {
356  return m_oddRow;
357 }
358 
360 {
361  m_columnWidth = width;
362 }
363 
365 {
366  return m_columnWidth;
367 }
368 
370 {
371  m_borderWidth = width;
372 }
373 
375 {
376  return m_borderWidth;
377 }
378 
380 {
381  m_borderGridColor = color;
382 }
383 
385 {
386  return m_borderGridColor;
387 }
388 
390 {
391  m_headerHorizontalColor = color;
392 }
393 
395 {
396  return m_headerHorizontalColor;
397 }
398 
400 {
401  m_headerVerticalColor = color;
402 }
403 
405 {
406  return m_headerVerticalColor;
407 }
virtual double getSpacing()
Definition: TitleModel.cpp:284
virtual double getBorderWidth()
Definition: TitleModel.cpp:374
virtual int getNumberColumns()
Definition: TitleModel.cpp:304
virtual te::color::RGBAColor getTableColor()
Definition: TitleModel.cpp:324
virtual te::color::RGBAColor getEvenRow()
Definition: TitleModel.cpp:344
Variant getValue()
Returns stored value.
Definition: Property.cpp:72
virtual EnumDataType * getEnumDataType()
Returns data type enumeration.
Definition: Enums.cpp:52
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
Definition: RGBAColor.h:329
void addSubProperty(Property property)
Definition: Property.cpp:124
virtual void setBorderWidth(double width)
Definition: TitleModel.cpp:369
virtual void setNumberRows(int value)
Definition: TitleModel.cpp:309
virtual EnumType * getDataTypeDouble() const
Returns value that represents type double belonging to enumeration.
virtual void setColumnWidth(double width)
Definition: TitleModel.cpp:359
virtual double getPadding()
Definition: TitleModel.cpp:294
bool isNull()
Returns true if no value has been set, false otherwise.
Definition: Property.cpp:146
virtual te::color::RGBAColor getOddRow()
Definition: TitleModel.cpp:354
virtual EnumType * getDataTypeInt() const
Returns value that represents type integer belonging to enumeration.
virtual void setPadding(double value)
Definition: TitleModel.cpp:289
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition: Properties.h:52
EnumType * m_type
type of the MVC component
virtual void setEvenRow(te::color::RGBAColor color)
Definition: TitleModel.cpp:339
virtual te::layout::Properties * getProperties() const
Reimplemented from Observable.
Definition: TitleModel.cpp:75
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: TextModel.cpp:78
virtual void setOddRow(te::color::RGBAColor color)
Definition: TitleModel.cpp:349
virtual te::color::RGBAColor getBorderGridColor()
Definition: TitleModel.cpp:384
te::color::RGBAColor m_tableColor
Definition: TitleModel.h:138
virtual void setNumberColumns(int value)
Definition: TitleModel.cpp:299
virtual void setTableColor(te::color::RGBAColor color)
Definition: TitleModel.cpp:319
Class that represents a "Model" part of Title MVC component. Its coordinate system is the same of sce...
virtual void setSpacing(double value)
Definition: TitleModel.cpp:279
virtual void setWidth(double width)
Definition: TitleModel.cpp:329
static Enums & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual void setHeaderVerticalColor(te::color::RGBAColor color)
Definition: TitleModel.cpp:399
Class to represent a data type enumeration. Ex.: int, double, bool, te::color::RGBAColor (color)...
Definition: EnumDataType.h:48
te::gm::Envelope m_box
bounding rectangle
std::string m_text
Definition: TextModel.h:86
te::color::RGBAColor m_headerHorizontalColor
Definition: TitleModel.h:164
te::color::RGBAColor m_borderGridColor
Definition: TitleModel.h:158
virtual EnumType * getDataTypeColor() const
Returns value that represents type te::color::RGBAColor** (color) belonging to enumeration.
virtual int getNumberRows()
Definition: TitleModel.cpp:314
TitleModel()
Constructor.
Definition: TitleModel.cpp:38
virtual void setTitle(std::string title)
Definition: TitleModel.cpp:269
virtual EnumType * getDataTypeTextGridSettings() const
Returns value that represents type TextGridSettings (string) belonging to enumeration.
double toDouble()
Returns the value of double type. (The setValue method received a double)
Definition: Variant.cpp:316
virtual bool containsSubProperty(Property subProperty)
Definition: Property.cpp:165
virtual te::color::RGBAColor getHeaderVerticalColor()
Definition: TitleModel.cpp:404
void setValue(ValueType value, EnumType *type)
Stores a copy of value.
Definition: Property.h:298
virtual std::string getTitle()
Definition: TitleModel.cpp:274
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
TextGridSettingsConfigProperties * m_textgridProperties
Definition: TitleModel.h:128
virtual double getWidth()
Definition: TitleModel.cpp:334
void setName(std::string name)
Sets the name of this property.
Definition: Property.cpp:62
virtual void setMenu(bool menu)
Sets true if property will be used in a menu, false otherwise.
Definition: Property.cpp:228
te::color::RGBAColor toColor()
Returns the value of te::color::RGBAColor type. (The setValue method received a te::color::RGBAColor)...
Definition: Variant.cpp:341
virtual te::layout::Properties * getProperties() const
Reimplemented from Observable.
Definition: TextModel.cpp:57
virtual EnumType * getDataTypeString() const
Returns value that represents type string belonging to enumeration.
virtual ~TitleModel()
Destructor.
Definition: TitleModel.cpp:66
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: TitleModel.cpp:169
virtual bool contains(Property property)
Checks if the property is contained within the set of properties.
Definition: Properties.h:251
A property acts like a attribute member of a object and stores the state of this attribute. A set of properties stores the state of an object. Any data type, not included in the convertValue method in the class te::layout::Variant, it will be by default "std::string" value.
Definition: Property.h:47
int toInt()
Returns the value of int type. (The setValue method received a int)
Definition: Variant.cpp:321
virtual te::color::RGBAColor getHeaderHorizontalColor()
Definition: TitleModel.cpp:394
virtual void setHeaderHorizontalColor(te::color::RGBAColor color)
Definition: TitleModel.cpp:389
te::color::RGBAColor m_headerVerticalColor
Definition: TitleModel.h:165
virtual void setBorderGridColor(te::color::RGBAColor color)
Definition: TitleModel.cpp:379
virtual double getColumnWidth()
Definition: TitleModel.cpp:364