A library for working with phylogenetic and population genetic data.
v0.32.0
ColorNormalizationBoundary Class Reference

#include <genesis/utils/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 (ColorNormalizationBoundary &&)=default
 
 ColorNormalizationBoundary (ColorNormalizationBoundary const &)=default
 
 ColorNormalizationBoundary (double min, double max, size_t intervals)
 
 ColorNormalizationBoundary (std::vector< double > const &boundaries)
 
virtual ~ColorNormalizationBoundary () override=default
 
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...
 
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...
 
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...
 
long interval (double value) const
 Return the interval index of a value. More...
 
ColorNormalizationBoundaryoperator= (ColorNormalizationBoundary &&)=default
 
ColorNormalizationBoundaryoperator= (ColorNormalizationBoundary const &)=default
 
ColorNormalizationBoundaryscale (double min, double max, size_t intervals)
 Set the boundaries to equal-sizes intervals between min and max, using intervals many steps. More...
 
- Public Member Functions inherited from ColorNormalization
 ColorNormalization ()=default
 
 ColorNormalization (ColorNormalization &&)=default
 
 ColorNormalization (ColorNormalization const &)=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...
 
template<class ForwardIterator >
std::vector< double > operator() (ForwardIterator first, ForwardIterator last) const
 Return the normalized values for a range of values. More...
 
std::vector< double > operator() (std::vector< double > const &values) const
 Return the normalized values for a vector of values. More...
 
ColorNormalizationoperator= (ColorNormalization &&)=default
 
ColorNormalizationoperator= (ColorNormalization const &)=default
 

Protected Member Functions

virtual bool is_valid_ () const override
 Return whether the boundaries are correct. More...
 
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() [1/5]

◆ ColorNormalizationBoundary() [2/5]

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

Definition at line 92 of file norm_boundary.hpp.

◆ ColorNormalizationBoundary() [3/5]

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

Definition at line 98 of file norm_boundary.hpp.

◆ ~ColorNormalizationBoundary()

virtual ~ColorNormalizationBoundary ( )
overridevirtualdefault

◆ ColorNormalizationBoundary() [4/5]

◆ ColorNormalizationBoundary() [5/5]

Member Function Documentation

◆ autoscale() [1/2]

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.

◆ autoscale() [2/2]

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.

◆ boundaries() [1/2]

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

Return the boundaries currently set.

Definition at line 118 of file norm_boundary.hpp.

◆ boundaries() [2/2]

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.

◆ interval()

long interval ( double  value) const
inline

Return the interval index of a value.

Definition at line 126 of file norm_boundary.hpp.

◆ is_valid_()

virtual bool is_valid_ ( ) const
inlineoverrideprotectedvirtual

Return whether the boundaries are correct.

Implements ColorNormalization.

Definition at line 251 of file norm_boundary.hpp.

◆ is_valid_or_throw_()

virtual void is_valid_or_throw_ ( ) const
inlineprotectedvirtual

Throw if the boundaries are incorrect.

Definition at line 259 of file norm_boundary.hpp.

◆ normalize_()

virtual double normalize_ ( double  value) const
inlineoverrideprotectedvirtual

Normalization function.

Implements ColorNormalization.

Definition at line 272 of file norm_boundary.hpp.

◆ operator=() [1/2]

◆ operator=() [2/2]

ColorNormalizationBoundary& operator= ( ColorNormalizationBoundary const &  )
default

◆ scale()

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

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

Definition at line 180 of file norm_boundary.hpp.


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