Label.cc
1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Label.cc
*
* Created on: 27 nov. 2013
* Author: CS
*/
#include "Label.hh"
#include <sstream>
#include <algorithm>
#include <boost/regex.hpp>
#include <boost/algorithm/string/regex.hpp>
namespace plot {
const std::string Label::DELIMITER = "/breakline/";
LabelRowInfo Label::getRowNumber(Label const& pLegend) {
LabelRowInfo lSplittedLegend(new std::vector<std::string>());
if (!pLegend._text.empty()) {
boost::split_regex(*lSplittedLegend.get(), pLegend._text,
boost::regex(Label::DELIMITER));
}
return lSplittedLegend;
}
void Label::dump(std::ostream& out, std::string& prefix) {
prefix += "label.";
out << prefix << "font.name=" << _font._name << std::endl;
out << prefix << "font.size=" << _font._size << std::endl;
out << prefix << "style=";
std::string styleStr;
for (size_t i = 0; i < _style.size(); ++i) {
Font::Style style = _style[i];
switch (style) {
case Font::Style::BOLD:
styleStr += "bold";
break;
case Font::Style::ITALIC:
styleStr += "italic";
break;
case Font::Style::NORMAL:
default:
styleStr += "normal";
}
if (i < _style.size() - 1) {
styleStr += ",";
}
}
out << styleStr << std::endl;
out << prefix << "text=" << _text << std::endl;
_color.dump(out, prefix);
}
}