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

#include <genesis/utils/tools/color/norm_boundary.hpp>

Inherits ColorNormalization.

Detailed Description

Color normalization that maps to discrete intervals.

The normalization takes a set of boundaries, which define the edges of intervals. Values falling within an interval are mapped to a value within [ 0.0, 1.0 ] that corresponds to the index of the interval. For example, with boundaries 3.0, 4.0, 5.0, 6.0, we get three intervals. Valus outside of these boundaries are mapped to -1.0 or 2.0. Hence, values are mapped as follows:

< 3.0        : -1.0
[ 3.0, 4.0 ) :  0.0
[ 4.0, 5.0 ) :  0.5
[ 5.0, 6.0 ] :  1.0
> 6.0        :  2.0

Thus, this normalization can immediately be used with a ColorMap. Furthermore, the function interval() offers to retrieve the interval index for a given value. For the example above, these would be values between 0 and 2 for valid values.

Definition at line 75 of file norm_boundary.hpp.

Public Member Functions

 ColorNormalizationBoundary ()=default
 
 ColorNormalizationBoundary (std::vector< double > const &boundaries)
 
 ColorNormalizationBoundary (double min, double max, size_t intervals)
 
 ColorNormalizationBoundary (ColorNormalizationBoundary const &)=default
 
 ColorNormalizationBoundary (ColorNormalizationBoundary &&)=default
 
virtual ~ColorNormalizationBoundary ()=default
 
ColorNormalizationBoundaryautoscale (std::vector< double > const &values, size_t intervals)
 Set the boundaries similar to scale(), but use the given vector of values to determine min and max first. More...
 
template<class ForwardIterator >
ColorNormalizationBoundaryautoscale (ForwardIterator first, ForwardIterator last, size_t intervals)
 Set the boundaries similar to scale(), but use the given range to determine min and max first. More...
 
std::vector< double > const & boundaries () const
 Return the boundaries currently set. More...
 
ColorNormalizationBoundaryboundaries (std::vector< double > const &values)
 Explicitly set the boundaries to the given values. Have to be sorted. More...
 
int interval (double value) const
 Return the interval index of a value. More...
 
virtual bool is_valid_ () const override
 Return whether the boundaries are correct. More...
 
ColorNormalizationBoundaryoperator= (ColorNormalizationBoundary const &)=default
 
ColorNormalizationBoundaryoperator= (ColorNormalizationBoundary &&)=default
 
ColorNormalizationBoundaryscale (double min, double max, size_t intervals)
 Set the boundaries to equal-sizes intervals between min and max, using interval many steps. More...
 
- Public Member Functions inherited from ColorNormalization
 ColorNormalization ()=default
 
 ColorNormalization (ColorNormalization const &)=default
 
 ColorNormalization (ColorNormalization &&)=default
 
virtual ~ColorNormalization ()=default
 
bool is_valid () const
 Return whether ranges and other values are correct. More...
 
double mask_value () const
 Mask value that identifies invalid values. More...
 
ColorNormalizationmask_value (double value)
 Mask value that identifies invalid values. More...
 
double operator() (double value) const
 Normalize a value into range [ 0.0, 1.0 ]. More...
 
std::vector< double > operator() (std::vector< double > const &values) const
 Return the normalized values for a vector of values. More...
 
template<class ForwardIterator >
std::vector< double > operator() (ForwardIterator first, ForwardIterator last) const
 Return the normalized values for a range of values. More...
 
ColorNormalizationoperator= (ColorNormalization const &)=default
 
ColorNormalizationoperator= (ColorNormalization &&)=default
 

Protected Member Functions

virtual void is_valid_or_throw_ () const
 Throw if the boundaries are incorrect. More...
 
virtual double normalize_ (double value) const override
 Normalization function. More...
 

Constructor & Destructor Documentation

ColorNormalizationBoundary ( std::vector< double > const &  boundaries)
inline

Definition at line 92 of file norm_boundary.hpp.

ColorNormalizationBoundary ( double  min,
double  max,
size_t  intervals 
)
inline

Definition at line 98 of file norm_boundary.hpp.

virtual ~ColorNormalizationBoundary ( )
virtualdefault

Member Function Documentation

ColorNormalizationBoundary& autoscale ( std::vector< double > const &  values,
size_t  intervals 
)
inline

Set the boundaries similar to scale(), but use the given vector of values to determine min and max first.

Definition at line 199 of file norm_boundary.hpp.

ColorNormalizationBoundary& autoscale ( ForwardIterator  first,
ForwardIterator  last,
size_t  intervals 
)
inline

Set the boundaries similar to scale(), but use the given range to determine min and max first.

Definition at line 209 of file norm_boundary.hpp.

std::vector<double> const& boundaries ( ) const
inline

Return the boundaries currently set.

Definition at line 118 of file norm_boundary.hpp.

ColorNormalizationBoundary& boundaries ( std::vector< double > const &  values)
inline

Explicitly set the boundaries to the given values. Have to be sorted.

Definition at line 169 of file norm_boundary.hpp.

int interval ( double  value) const
inline

Return the interval index of a value.

Definition at line 126 of file norm_boundary.hpp.

virtual bool is_valid_ ( ) const
inlineoverridevirtual

Return whether the boundaries are correct.

Implements ColorNormalization.

Definition at line 248 of file norm_boundary.hpp.

virtual void is_valid_or_throw_ ( ) const
inlineprotectedvirtual

Throw if the boundaries are incorrect.

Definition at line 258 of file norm_boundary.hpp.

virtual double normalize_ ( double  value) const
inlineoverrideprotectedvirtual

Normalization function.

Implements ColorNormalization.

Definition at line 271 of file norm_boundary.hpp.

ColorNormalizationBoundary& operator= ( ColorNormalizationBoundary const &  )
default
ColorNormalizationBoundary& scale ( double  min,
double  max,
size_t  intervals 
)
inline

Set the boundaries to equal-sizes intervals between min and max, using interval many steps.

Definition at line 180 of file norm_boundary.hpp.


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