A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
text.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_FORMATS_SVG_TEXT_H_
2 #define GENESIS_UTILS_FORMATS_SVG_TEXT_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
36 
37 #include <iosfwd>
38 #include <string>
39 
40 namespace genesis {
41 namespace utils {
42 
43 // =================================================================================================
44 // Svg Text
45 // =================================================================================================
46 
47 struct SvgText
48 {
49 public:
50 
51  // -------------------------------------------------------------
52  // Typedefs and Enums
53  // -------------------------------------------------------------
54 
55  using self_type = SvgText;
56 
57  enum class Anchor
58  {
59  kNone,
60  kStart,
61  kMiddle,
62  kEnd
63  };
64 
65  // -------------------------------------------------------------
66  // Constructors and Rule of Five
67  // -------------------------------------------------------------
68 
69  SvgText(
70  std::string const& text = "",
71  SvgPoint const& position = SvgPoint(),
72  SvgFont const& font = SvgFont(),
73  SvgFill const& fill = SvgFill(),
75  );
76 
77  ~SvgText() = default;
78 
79  SvgText( SvgText const& ) = default;
80  SvgText( SvgText&& ) = default;
81 
82  SvgText& operator= ( SvgText const& ) = default;
83  SvgText& operator= ( SvgText&& ) = default;
84 
85  // -------------------------------------------------------------
86  // Drawing Function
87  // -------------------------------------------------------------
88 
89  SvgBox bounding_box() const;
90 
91  void write(
92  std::ostream& out,
93  size_t indent = 0,
94  SvgDrawingOptions const& options = SvgDrawingOptions()
95  ) const;
96 
97  // -------------------------------------------------------------
98  // Properties
99  // -------------------------------------------------------------
100 
101  std::string id;
102 
103  std::string text;
105 
109 
111 
112  double kerning;
114  double word_spacing;
115 
116  std::string dx;
117  std::string dy;
118 
120 
121 };
122 
123 } // namespace utils
124 } // namespace genesis
125 
126 #endif // include guard
std::string dy
Definition: text.hpp:117
SvgTransform transform
Definition: text.hpp:119
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
Definition: text.cpp:101
SvgBox bounding_box() const
Definition: text.cpp:71
std::string dx
Definition: text.hpp:116
std::string indent(std::string const &text, std::string const &indentation)
Indent each line of text with indentation and return the result.
Definition: string.cpp:158
std::string text
Definition: text.hpp:103
std::string id
Definition: text.hpp:101
SvgText(std::string const &text="", SvgPoint const &position=SvgPoint(), SvgFont const &font=SvgFont(), SvgFill const &fill=SvgFill(), SvgStroke const &stroke=SvgStroke(SvgStroke::Type::kOmit))
Definition: text.cpp:50
SvgText & operator=(SvgText const &)=default