Blame view

src/ParamOutputImpl/Plot/TextLegendProperties.cc 1.94 KB
fbe3c2bb   Benjamin Renard   First commit
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * TextLegendProperties.cc
 *
 *  Created on: 18 sep. 2014
 *      Author: AKKA
 */

#include <boost/regex.hpp>
#include <boost/algorithm/string/regex.hpp>

#include "TextLegendProperties.hh"

namespace plot
{

const std::string TextLegendProperties::DELIMITER = "/breakline/";

TextLegendProperties::TextLegendProperties(void) :
		_font("sans-serif", 12),
		_text(),
		_position(TextLegendPosition::POS_RIGHT),
		_color(Color(0,0,0)),
		_offset(0),
		_drawn(false)
{
}

TextLegendProperties::~TextLegendProperties(void) {
}

void TextLegendProperties::reset(void)
{
	_drawn = false;
}

void TextLegendProperties::setText(const std::string& text) {
	_text = text;
}

const std::string& TextLegendProperties::getText() const {
	return _text;
}

void TextLegendProperties::setPosition(TextLegendPosition position) {
	_position = position;
}

TextLegendPosition TextLegendProperties::getPosition(void) {
	return _position;
}

void TextLegendProperties::setColor(const Color& color) {
	_color = color;
}

Color& TextLegendProperties::getColor() {
	return _color;
}

void TextLegendProperties::setFont(Font font) {
	_font = font;
}

Font& TextLegendProperties::getFont(void) {
	return _font;
}

double TextLegendProperties::getOffset(void) {
	return _offset;
}

void TextLegendProperties::setOffset(double offset) {
	_offset = offset;
}

int TextLegendProperties::getTextLinesNb (void) {
	std::vector<std::string> textLines;

	if (_text.empty() == false) {
		boost::split_regex (textLines, _text, boost::regex(TextLegendProperties::DELIMITER));
	}

	return textLines.size();
}

std::vector<std::string> TextLegendProperties::getTextLines (void) {
	std::vector<std::string> textLines;

	if (_text.empty() == false) {
		boost::split_regex (textLines, _text, boost::regex(TextLegendProperties::DELIMITER));
	}

	return textLines;
}

bool TextLegendProperties::isDrawn(void)
{
	return _drawn;
}

void TextLegendProperties::setDrawn(bool drawn)
{
	_drawn = drawn;
}

} /* namespace plot */