1 #ifndef GENESIS_TREE_FORMATS_PHYLOXML_COLOR_WRITER_PLUGIN_H_
2 #define GENESIS_TREE_FORMATS_PHYLOXML_COLOR_WRITER_PLUGIN_H_
100 throw std::length_error(
101 "Color vector does not have as many elements as the tree has edges."
139 void set_color_(
utils::XmlElement& element,
unsigned char r,
unsigned char g,
unsigned char b )
const
149 auto re = utils::make_unique< utils::XmlElement >(
"red");
152 auto ge = utils::make_unique< utils::XmlElement >(
"green");
155 auto be = utils::make_unique< utils::XmlElement >(
"blue");
158 auto color = utils::make_unique< utils::XmlElement >(
"color");
159 color->content.push_back(std::move(re));
160 color->content.push_back(std::move(ge));
161 color->content.push_back(std::move(be));
163 element.
content.push_back(std::move(color));
166 void set_color_( utils::XmlElement& element, utils::Color color )
const
168 set_color_( element, color.r_byte(), color.g_byte(), color.b_byte() );
176 #endif // include guard
bool use_ignored_color() const
Return whether currently an ignored color is used.
bool enable_color() const
Returns whether colors tags are written to the output.
size_t index() const
Return the index of this Edge.
std::vector< utils::Color > const & edge_colors() const
Return the edge colors that are currently set.
PhyloxmlColorWriterPlugin()=default
void register_with(PhyloxmlWriter &writer) const
Plugin class for PhyloXML output that allows coloring of edges.
Write a Tree to Phyloxml format.
std::string to_string(T const &v)
Return a string representation of a given value.
utils::Color ignored_color() const
Return the currently set ignored color. See the setter for more information.
std::vector< prepare_writing_function > prepare_writing_plugins
Collect all functions to be called before starting the actual tree writing.
Class for representing phylogenetic trees.
Base class for creating plugin classes that allow coloring of Tree edges.
virtual ~PhyloxmlColorWriterPlugin()=default
void edge_to_element(TreeEdge const &edge, utils::XmlElement &element) const
A collection of classes for working with XML documents. See XmlDocument for more. ...
PhyloxmlColorWriterPlugin & operator=(PhyloxmlColorWriterPlugin const &)=default
size_t edge_count() const
Return the number of TreeEdges of the Tree.
std::vector< std::unique_ptr< XmlValue > > content
void prepare_writing(Tree const &tree, utils::XmlDocument &xml) const
std::vector< edge_to_element_function > edge_to_element_plugins
Collect all functions to be called for each TreeEdge in order to translate it to a Phyloxml represent...