Label.hh
1.41 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Label.hh
*
* Created on: 25 nov. 2013
* Author: CS
*/
#ifndef LABEL_HH_
#define LABEL_HH_
#include "Font.hh"
#include "Color.hh"
#include <vector>
#include <boost/shared_ptr.hpp>
namespace plot {
typedef std::vector<std::string> LabelRowInfo;
class Label {
public:
static const std::string DELIMITER;
Label() :
_color(0, 0, 0), _font(Font("", 0)) {
}
Label(Font font) :
_color(0, 0, 0), _font(font) {
}
Label(Font font, Color color) :
_color(color), _font(font) {
}
Label(const Label& label) :
_text(label._text), _color(label._color), _font(label._font) {
}
virtual ~Label() {
}
const Font& getFont() const {
return _font;
}
void setFont(const Font& font) {
_font = font;
}
/**
* @brief Determine number of line that compose label.
*/
static LabelRowInfo getRowNumber(Label const& pLegend);
/**
* Label text.
*/
std::string _text;
/**
* Text color
*/
Color _color;
/**
* Dumps label properties, used for test.
*/
void dump(std::ostream& out, std::string& prefix);
private:
/**
* Label font name and size.
*/
Font _font;
};
inline std::ostream& operator <<(std::ostream& out, Label& label) {
out << "[LABEL]" << std::endl;
out << "label.text=" << label._text;
out << "label.color=" << label._color;
std::string prefix = "label";
Font font = label.getFont();
font.dump(out, prefix);
return out;
}
} /* namespace plot */
#endif /* LABEL_HH_ */