A toolkit for working with phylogenetic data.
v0.19.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  enum class DominantBaseline
66  {
67  kNone,
68  kAuto,
69  kUseScript,
70  kNoChange,
71  kResetSize,
74  kHanging,
76  kCentral,
77  kMiddle,
80  kInherit
81  };
82 
83  enum class AlignmentBaseline
84  {
85  kNone,
86  kAuto,
87  kBaseline,
90  kMiddle,
91  kCentral,
92  kAfterEdge,
96  kHanging,
98  kInherit
99  };
100 
101  // -------------------------------------------------------------
102  // Constructors and Rule of Five
103  // -------------------------------------------------------------
104 
105  SvgText(
106  std::string const& text = "",
107  SvgPoint const& position = SvgPoint(),
108  SvgFont const& font = SvgFont(),
109  SvgFill const& fill = SvgFill(),
111  );
112 
113  ~SvgText() = default;
114 
115  SvgText( SvgText const& ) = default;
116  SvgText( SvgText&& ) = default;
117 
118  SvgText& operator= ( SvgText const& ) = default;
119  SvgText& operator= ( SvgText&& ) = default;
120 
121  // -------------------------------------------------------------
122  // Drawing Function
123  // -------------------------------------------------------------
124 
125  SvgBox bounding_box() const;
126 
127  void write(
128  std::ostream& out,
129  size_t indent = 0,
130  SvgDrawingOptions const& options = SvgDrawingOptions()
131  ) const;
132 
133  // -------------------------------------------------------------
134  // Helper Functions
135  // -------------------------------------------------------------
136 
137  static std::string anchor_to_string( Anchor value );
138  static std::string dominant_baseline_to_string( DominantBaseline value );
139  static std::string alignment_baseline_to_string( AlignmentBaseline value );
140 
141  // -------------------------------------------------------------
142  // Properties
143  // -------------------------------------------------------------
144 
145  std::string id;
146 
147  std::string text;
149 
153 
157 
158  double kerning;
160  double word_spacing;
161 
162  std::string dx;
163  std::string dy;
164 
166 
167 };
168 
169 } // namespace utils
170 } // namespace genesis
171 
172 #endif // include guard
std::string dy
Definition: text.hpp:163
SvgTransform transform
Definition: text.hpp:165
static std::string alignment_baseline_to_string(AlignmentBaseline value)
Definition: text.cpp:220
void write(std::ostream &out, size_t indent=0, SvgDrawingOptions const &options=SvgDrawingOptions()) const
Definition: text.cpp:102
SvgBox bounding_box() const
Definition: text.cpp:72
AlignmentBaseline alignment_baseline
Definition: text.hpp:156
std::string dx
Definition: text.hpp:162
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:231
std::string text
Definition: text.hpp:147
DominantBaseline dominant_baseline
Definition: text.hpp:155
std::string id
Definition: text.hpp:145
static std::string anchor_to_string(Anchor value)
Definition: text.cpp:166
static std::string dominant_baseline_to_string(DominantBaseline value)
Definition: text.cpp:182
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:51
SvgText & operator=(SvgText const &)=default