Label.cc 1.26 KB
/*
 * 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);
	}

}