Stroke.h
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/se/Stroke.h
22 
23  \brief A Stroke specifies the appearance of a linear geometry.
24 */
25 
26 #ifndef __TERRALIB_SE_INTERNAL_STROKE_H
27 #define __TERRALIB_SE_INTERNAL_STROKE_H
28 
29 // TerraLib
30 #include "Config.h"
31 
32 // STL
33 #include <map>
34 #include <string>
35 
36 // Boost
37 #include <boost/noncopyable.hpp>
38 
39 namespace te
40 {
41  namespace se
42  {
43 // Forward declarations
44  class Graphic;
45  class GraphicStroke;
46  class SvgParameter;
47 
48  /*!
49  \class Stroke
50 
51  \brief A Stroke specifies the appearance of a linear geometry.
52 
53  It is defined in parallel with SVG strokes.
54  There are three basic types of strokes:
55  <ul>
56  <li>solid-color</li>
57  <li>GraphicFill (stipple)</li>
58  <li>repeated linear GraphicStroke</li>
59  </ul>
60  If neither a GraphicFill nor GraphicStroke element
61  is given, then the line Symbolizer will render a solid color.
62 
63  \ingroup se
64 
65  \sa LineSymbolizer, Graphic, GraphicStroke, Mark
66  */
67  class TESEEXPORT Stroke : public boost::noncopyable
68  {
69  public:
70 
71  /** @name Initializer Methods
72  * Methods related to instantiation and destruction.
73  */
74  //@{
75 
76  /*! \brief It initializes a new Stroke. */
77  Stroke();
78 
79  /*! \brief Destructor. */
80  ~Stroke();
81 
82  //@}
83 
84  /** @name Accessor methods
85  * Methods used to get or set properties.
86  */
87  //@{
88 
89  /*!
90  \brief Sets the GraphicFill element to this Stroke.
91  GraphicFill defines that the pixels of the line will be drawn repeating an area-fill pattern.
92 
93  \note The Stroke object will take the ownership of the informed fill pointer.
94  */
95  void setGraphicFill(Graphic* fill);
96 
97  /*!
98  \brief Gets the GraphicFill element associate to this Stroke.
99 
100  \return The GraphicFill element.
101  */
102  const Graphic* getGraphicFill() const;
103 
104  /*!
105  \brief Sets the GraphicStroke element to this Stroke.
106  GraphicStroke defines that a repeated linear graphic is plotted linearly
107  and has its graphic bent around the curves of the line string.
108 
109  \note The Stroke object will take the ownership of the informed stroke pointer.
110  */
111  void setGraphicStroke(GraphicStroke* stroke);
112 
113  /*!
114  \brief Gets the GraphicStroke element associate to this Stroke.
115 
116  \return The GraphicStroke element.
117  */
118  const GraphicStroke* getGraphicStroke() const;
119 
120  /*!
121  \brief Add a SvgParameter to this Stroke.
122 
123  \note If there is already a SvgParamater with the same name it will be overrided.
124  \note The Stroke object will take the ownership of the informed p pointer.
125  */
126  void add(SvgParameter* p);
127 
128  void setColor(const std::string& color);
129 
130  void setOpacity(const std::string& opacity);
131 
132  void setWidth(const std::string& width);
133 
134  void setLineJoin(const std::string& join);
135 
136  void setLineCap(const std::string& cap);
137 
138  void setDashArray(const std::string& dasharray);
139 
140  void setDashOffset(const std::string& offset);
141 
142  const SvgParameter* getColor() const;
143 
144  const SvgParameter* getOpacity() const;
145 
146  const SvgParameter* getWidth() const;
147 
148  const SvgParameter* getLineJoin() const;
149 
150  const SvgParameter* getLineCap() const;
151 
152  const SvgParameter* getDashArray() const;
153 
154  const SvgParameter* setDashOffset() const;
155 
156  //@}
157 
158  /*! \brief It creates a new copy of this object. */
159  Stroke* clone() const;
160 
161  private:
162 
163  void setParameter(const std::string& name, const std::string& value);
164 
165  const SvgParameter* getParameter(const std::string& name) const;
166 
167  private:
168 
169  Graphic* m_fill; //!< The GraphicFill both indicates that a stipple-fill repeated graphic will be used and specifies the fill graphic. (Optional)
170  GraphicStroke* m_stroke; //!< The GraphicStroke both indicates that a repeated-linear-graphic stroke type will be used. (Optional)
171  std::map<std::string, SvgParameter*> m_svgParams; //!< If neither a GraphicFill nor GraphicStroke is given, then the line Symbolizer will render a solid color. (Optional)
172 
173  static const std::string sm_stroke; //!< SVG/CSS "stroke" parameter.
174  static const std::string sm_opacity; //!< SVG/CSS "stroke-opacity parameter.
175  static const std::string sm_width; //!< SVG/CSS "stroke-width" parameter.
176  static const std::string sm_linejoin; //!< SVG/CSS "stroke-linejoin" parameter.
177  static const std::string sm_linecap; //!< SVG/CSS "stroke-linecap" parameter.
178  static const std::string sm_dasharray; //!< SVG/CSS "stroke-dasharray" parameter.
179  static const std::string sm_dashoffset; //!< SVG/CSS "stroke-dashoffset" parameter.
180  };
181 
182  } // end namespace se
183 } // end namespace te
184 
185 #endif // __TERRALIB_SE_INTERNAL_STROKE_H
186 
static const std::string sm_opacity
SVG/CSS "stroke-opacity parameter.
Definition: Stroke.h:174
static const std::string sm_linejoin
SVG/CSS "stroke-linejoin" parameter.
Definition: Stroke.h:176
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
static const std::string sm_width
SVG/CSS "stroke-width" parameter.
Definition: Stroke.h:175
URI C++ Library.
static const std::string sm_dashoffset
SVG/CSS "stroke-dashoffset" parameter.
Definition: Stroke.h:179
#define TESEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:187
Configuration flags for the Symbology Encoding support of TerraLib.
GraphicStroke * m_stroke
The GraphicStroke both indicates that a repeated-linear-graphic stroke type will be used...
Definition: Stroke.h:170
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
static const std::string sm_stroke
SVG/CSS "stroke" parameter.
Definition: Stroke.h:173
A SvgParameter refers to an SVG/CSS graphical-formatting parameter.
Definition: SvgParameter.h:48
std::map< std::string, SvgParameter * > m_svgParams
If neither a GraphicFill nor GraphicStroke is given, then the line Symbolizer will render a solid col...
Definition: Stroke.h:171
static const std::string sm_linecap
SVG/CSS "stroke-linecap" parameter.
Definition: Stroke.h:177
Graphic * m_fill
The GraphicFill both indicates that a stipple-fill repeated graphic will be used and specifies the fi...
Definition: Stroke.h:169
A GraphicStroke defines a repeated-linear graphic pattern to be used for stroking a line...
Definition: GraphicStroke.h:50
static const std::string sm_dasharray
SVG/CSS "stroke-dasharray" parameter.
Definition: Stroke.h:178