TextLegendProperties.cc 1.94 KB
/*
 * 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) :
		_text(),
		_position(TextLegendPosition::POS_RIGHT),
		_color(Color(0,0,0)),
		_font("sans-serif", 12),
		_offset(0),
		_drawn(false)
{
}

TextLegendProperties::~TextLegendProperties(void) {
}

void TextLegendProperties::resetPlot(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 */