A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColorWriterPlugin Class Reference

#include <genesis/tree/formats/color_writer_plugin.hpp>

Inherited by NewickColorWriterPlugin, and PhyloxmlColorWriterPlugin.

Detailed Description

Base class for creating plugin classes that allow coloring of Tree edges.

The effect of this class on the Tree output is that (if enabled) a color tag will be added to each edge.

There are two ways this plugin can be used:

  1. Use edge_color_vector() to set a vector of colors for each edge before calling the actual writing function. This can be done by client code that needs a particular coloring of the edges, but can also be used by superclasses to set all edge colors at once.
  2. Use set_color() in the superclass to set the color of individual edges. This is helpful within the edge_to_element() function of the superclass. This function is however not implemented in this base class, as it needs knowledge of the actual type of Tree output to work. Thus, this is a function that the plugin classes should provide.

If neither of this is done, no color tags will be written. Color tags can also be deactivated by client code using the enable_color() option.

Furthermore, with the ignored_color option, by default, all edged that are colored black (Color(0, 0, 0)) are ignored in the output, i.e., they produce no color tag. See ignored_color to set the value to a different color.

For the root node, there is no color tag written, for those reasons:

  • In unrooted trees, the color tags for the nodes next to the root will cover all edges anyway. In other words, there is no "root edge" that could get a color.
  • In rooted trees, the root node has two edges. Those two combined edges are usually interpreted as the one edge where the root is located. So again, there are actual edges that can be colored - no need for an extra root color. Caveat: It is possible to give different colors to those edges. What that means is up to the user.

This class is intended to be used as base for plugin classes that do actual tree output.

Definition at line 81 of file color_writer_plugin.hpp.

Public Member Functions

virtual ~ColorWriterPlugin ()
 
void edge_colors (std::vector< utils::Color > const &color_vector)
 Set the edge colors that shall be written to the output. More...
 
std::vector< utils::Color > const & edge_colors () const
 Return the edge colors that are currently set. More...
 
void enable_color (bool value)
 Set whether colors tags are written to the output. More...
 
bool enable_color () const
 Returns whether colors tags are written to the output. More...
 
void ignored_color (utils::Color value)
 Set a color that is used as marker for partially disabling the output of color tags. More...
 
utils::Color ignored_color () const
 Return the currently set ignored color. See the setter for more information. More...
 
void use_ignored_color (bool value)
 Set whether to use the ignored_color(). More...
 
bool use_ignored_color () const
 Return whether currently an ignored color is used. More...
 

Constructor & Destructor Documentation

virtual ~ColorWriterPlugin ( )
inlinevirtual

Definition at line 89 of file color_writer_plugin.hpp.

Member Function Documentation

void edge_colors ( std::vector< utils::Color > const &  color_vector)
inline

Set the edge colors that shall be written to the output.

If this function is called with a vector of size > 0, the edges in the output will be colored according to the values given as a parameter. The vector then needs to contain as many elements as the tree has edges. The elements need to be indexed using the edge.index() value.

If this function is called with an empty vector, the color printing is reset to not print the edge colors that might have been set before.

Definition at line 107 of file color_writer_plugin.hpp.

std::vector<utils::Color> const& edge_colors ( ) const
inline

Return the edge colors that are currently set.

Definition at line 115 of file color_writer_plugin.hpp.

void enable_color ( bool  value)
inline

Set whether colors tags are written to the output.

Definition at line 123 of file color_writer_plugin.hpp.

bool enable_color ( ) const
inline

Returns whether colors tags are written to the output.

Definition at line 131 of file color_writer_plugin.hpp.

void ignored_color ( utils::Color  value)
inline

Set a color that is used as marker for partially disabling the output of color tags.

All edges that have set a color equal to the ignored color will produce no color tag output. This is thus something like magic pink, where all parts of an image are rendered transparent when originially colored in pink.

By default, we do not use an ignored color. If this function is called (which sets a color), also use_ignored_color() is set to true, so that the color is actually used.

Definition at line 146 of file color_writer_plugin.hpp.

utils::Color ignored_color ( ) const
inline

Return the currently set ignored color. See the setter for more information.

Definition at line 155 of file color_writer_plugin.hpp.

void use_ignored_color ( bool  value)
inline

Set whether to use the ignored_color().

If this option is set to true, the color that is set via ignored_color() is not written as a color attribute to the output format.

Definition at line 166 of file color_writer_plugin.hpp.

bool use_ignored_color ( ) const
inline

Return whether currently an ignored color is used.

Definition at line 174 of file color_writer_plugin.hpp.


The documentation for this class was generated from the following file: