LibreOffice Module chart2 (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
chart::ScaleAutomatism Class Reference

This class implements the calculation of automatic axis limits. More...

#include <ScaleAutomatism.hxx>

Collaboration diagram for chart::ScaleAutomatism:
[legend]

Public Member Functions

 ScaleAutomatism (const css::chart2::ScaleData &rSourceScale, const Date &rNullDate)
 
void expandValueRange (double fMinimum, double fMaximum)
 Expands own value range with the passed minimum and maximum. More...
 
void resetValueRange ()
 
void setAutoScalingOptions (bool bExpandBorderToIncrementRhythm, bool bExpandIfValuesCloseToBorder, bool bExpandWideValuesToZero, bool bExpandNarrowValuesTowardZero)
 Sets additional auto scaling options. More...
 
void setMaximumAutoMainIncrementCount (sal_Int32 nMaximumAutoMainIncrementCount)
 Sets the maximum allowed number of automatic main increments. More...
 
void setAutomaticTimeResolution (sal_Int32 nTimeResolution)
 Sets the time resolution to be used in case it is not set explicitly within the scale. More...
 
void calculateExplicitScaleAndIncrement (ExplicitScaleData &rExplicitScale, ExplicitIncrementData &rExplicitIncrement) const
 Fills the passed scale data and increment data according to the own settings. More...
 
const css::chart2::ScaleData & getScale () const
 
const DategetNullDate () const
 

Private Member Functions

void calculateExplicitIncrementAndScaleForCategory (ExplicitScaleData &rExplicitScale, ExplicitIncrementData &rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum) const
 Fills the passed scale data and increment data for category scaling. More...
 
void calculateExplicitIncrementAndScaleForLogarithmic (ExplicitScaleData &rExplicitScale, ExplicitIncrementData &rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum) const
 Fills the passed scale data and increment data for logarithmic scaling. More...
 
void calculateExplicitIncrementAndScaleForLinear (ExplicitScaleData &rExplicitScale, ExplicitIncrementData &rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum) const
 Fills the passed scale data and increment data for linear scaling. More...
 
void calculateExplicitIncrementAndScaleForDateTimeAxis (ExplicitScaleData &rExplicitScale, ExplicitIncrementData &rExplicitIncrement, bool bAutoMinimum, bool bAutoMaximum) const
 Fills the passed scale data and increment data for date-time axis. More...
 

Private Attributes

css::chart2::ScaleData m_aSourceScale
 
double m_fValueMinimum
 
double m_fValueMaximum
 Minimum of all source values. More...
 
sal_Int32 m_nMaximumAutoMainIncrementCount
 Maximum of all source values. More...
 
bool m_bExpandBorderToIncrementRhythm
 Maximum number of automatic main increments. More...
 
bool m_bExpandIfValuesCloseToBorder
 true = Expand to main increments. More...
 
bool m_bExpandWideValuesToZero
 true = Expand if values are too close to the borders. More...
 
bool m_bExpandNarrowValuesTowardZero
 true = Expand wide spread values to zero. More...
 
sal_Int32 m_nTimeResolution
 true = Expand narrow range toward zero (add half of range). More...
 
Date m_aNullDate
 

Detailed Description

This class implements the calculation of automatic axis limits.

This class is used for calculating axis scales and increments in the form of instances of ExplicitScaleData and ExplicitIncrementData classes. When a ScaleAutomatism instance is created a ScaleData object is passed to the constructor. Objects of ScaleData type are initialized by the createCoordinateSystem method of some chart type (e.g. the PieChartType class) and belong to some Axis object, they can be accessed through the XAxis interface (XAxis::getScaleData).

Definition at line 41 of file ScaleAutomatism.hxx.

Constructor & Destructor Documentation

◆ ScaleAutomatism()

chart::ScaleAutomatism::ScaleAutomatism ( const css::chart2::ScaleData &  rSourceScale,
const Date rNullDate 
)
explicit

Definition at line 89 of file ScaleAutomatism.cxx.

References DAY, expandValueRange(), m_aSourceScale, and resetValueRange().

Member Function Documentation

◆ calculateExplicitIncrementAndScaleForCategory()

void chart::ScaleAutomatism::calculateExplicitIncrementAndScaleForCategory ( ExplicitScaleData rExplicitScale,
ExplicitIncrementData rExplicitIncrement,
bool  bAutoMinimum,
bool  bAutoMaximum 
) const
private

◆ calculateExplicitIncrementAndScaleForDateTimeAxis()

void chart::ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis ( ExplicitScaleData rExplicitScale,
ExplicitIncrementData rExplicitIncrement,
bool  bAutoMinimum,
bool  bAutoMaximum 
) const
private

◆ calculateExplicitIncrementAndScaleForLinear()

void chart::ScaleAutomatism::calculateExplicitIncrementAndScaleForLinear ( ExplicitScaleData rExplicitScale,
ExplicitIncrementData rExplicitIncrement,
bool  bAutoMinimum,
bool  bAutoMaximum 
) const
private

◆ calculateExplicitIncrementAndScaleForLogarithmic()

void chart::ScaleAutomatism::calculateExplicitIncrementAndScaleForLogarithmic ( ExplicitScaleData rExplicitScale,
ExplicitIncrementData rExplicitIncrement,
bool  bAutoMinimum,
bool  bAutoMaximum 
) const
private

◆ calculateExplicitScaleAndIncrement()

void chart::ScaleAutomatism::calculateExplicitScaleAndIncrement ( ExplicitScaleData rExplicitScale,
ExplicitIncrementData rExplicitIncrement 
) const

Fills the passed scale data and increment data according to the own settings.

It performs the initialization of the passed explicit scale and explicit increment parameters, mainly the initialization is achieved by using the ScaleData object as data source. However other parameters which affect the behavior of this method can be set through the setAutoScalingOptions and the expandValueRange methods.

Definition at line 158 of file ScaleAutomatism.cxx.

References chart::ExplicitScaleData::AxisType, calculateExplicitIncrementAndScaleForCategory(), calculateExplicitIncrementAndScaleForDateTimeAxis(), calculateExplicitIncrementAndScaleForLinear(), calculateExplicitIncrementAndScaleForLogarithmic(), chart::AxisHelper::isLogarithmic(), m_aNullDate, m_aSourceScale, chart::ExplicitScaleData::m_bShiftedCategoryPosition, m_fValueMaximum, m_fValueMinimum, chart::ExplicitScaleData::Maximum, chart::ExplicitScaleData::Minimum, chart::ExplicitScaleData::NullDate, chart::ExplicitScaleData::Orientation, chart::ExplicitScaleData::Origin, and chart::ExplicitScaleData::Scaling.

◆ expandValueRange()

void chart::ScaleAutomatism::expandValueRange ( double  fMinimum,
double  fMaximum 
)

Expands own value range with the passed minimum and maximum.

It allows to set up the m_fValueMinimum and the m_fValueMaximum parameters which are used by the calculateExplicitScaleAndIncrement method for initializing the Minimum and Maximum properties of the explicit scale when the same properties of the ScaleData object are undefined (that is empty uno::Any objects).

Definition at line 114 of file ScaleAutomatism.cxx.

References m_fValueMaximum, m_fValueMinimum, and resetValueRange().

Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling(), and ScaleAutomatism().

◆ getNullDate()

const Date & chart::ScaleAutomatism::getNullDate ( ) const
inline

Definition at line 100 of file ScaleAutomatism.hxx.

References m_aNullDate.

Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling().

◆ getScale()

const css::chart2::ScaleData & chart::ScaleAutomatism::getScale ( ) const
inline

Definition at line 99 of file ScaleAutomatism.hxx.

References m_aSourceScale.

Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling().

◆ resetValueRange()

void chart::ScaleAutomatism::resetValueRange ( )

Definition at line 108 of file ScaleAutomatism.cxx.

References m_fValueMaximum, and m_fValueMinimum.

Referenced by expandValueRange(), and ScaleAutomatism().

◆ setAutomaticTimeResolution()

void chart::ScaleAutomatism::setAutomaticTimeResolution ( sal_Int32  nTimeResolution)

Sets the time resolution to be used in case it is not set explicitly within the scale.

Definition at line 153 of file ScaleAutomatism.cxx.

References m_nTimeResolution.

Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling().

◆ setAutoScalingOptions()

void chart::ScaleAutomatism::setAutoScalingOptions ( bool  bExpandBorderToIncrementRhythm,
bool  bExpandIfValuesCloseToBorder,
bool  bExpandWideValuesToZero,
bool  bExpandNarrowValuesTowardZero 
)

Sets additional auto scaling options.

Parameters
bExpandBorderToIncrementRhythmIf true, expands automatic borders to the fixed or calculated increment rhythm.
bExpandIfValuesCloseToBorderIf true, expands automatic borders if values are too close (closer than 1/21 of visible area).
bExpandWideValuesToZeroIf true, expands automatic border to zero, if source values are positive only or negative only, and if the absolute values are wide spread (at least one value is less than 5/6 of absolute maximum), or if all values are equal.
bExpandNarrowValuesTowardZeroIf true, expands automatic border toward zero (50% of the visible range), if source values are positive only or negative only, and if the absolute values are close to the absolute maximum (no value is less than 5/6 of absolute maximum).

Definition at line 127 of file ScaleAutomatism.cxx.

References m_aSourceScale, m_bExpandBorderToIncrementRhythm, m_bExpandIfValuesCloseToBorder, m_bExpandNarrowValuesTowardZero, and m_bExpandWideValuesToZero.

Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling().

◆ setMaximumAutoMainIncrementCount()

void chart::ScaleAutomatism::setMaximumAutoMainIncrementCount ( sal_Int32  nMaximumAutoMainIncrementCount)

Sets the maximum allowed number of automatic main increments.

@descr The number of main increments may be limited e.g. by the length of the axis and the font size of the axis caption text.

Definition at line 143 of file ScaleAutomatism.cxx.

References chart::lcl_getMaximumAutoIncrementCount(), m_aSourceScale, and m_nMaximumAutoMainIncrementCount.

Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling().

Member Data Documentation

◆ m_aNullDate

Date chart::ScaleAutomatism::m_aNullDate
private

◆ m_aSourceScale

css::chart2::ScaleData chart::ScaleAutomatism::m_aSourceScale
private

◆ m_bExpandBorderToIncrementRhythm

bool chart::ScaleAutomatism::m_bExpandBorderToIncrementRhythm
private

◆ m_bExpandIfValuesCloseToBorder

bool chart::ScaleAutomatism::m_bExpandIfValuesCloseToBorder
private

true = Expand to main increments.

Definition at line 134 of file ScaleAutomatism.hxx.

Referenced by calculateExplicitIncrementAndScaleForLinear(), and setAutoScalingOptions().

◆ m_bExpandNarrowValuesTowardZero

bool chart::ScaleAutomatism::m_bExpandNarrowValuesTowardZero
private

true = Expand wide spread values to zero.

Definition at line 136 of file ScaleAutomatism.hxx.

Referenced by calculateExplicitIncrementAndScaleForLinear(), calculateExplicitIncrementAndScaleForLogarithmic(), and setAutoScalingOptions().

◆ m_bExpandWideValuesToZero

bool chart::ScaleAutomatism::m_bExpandWideValuesToZero
private

true = Expand if values are too close to the borders.

Definition at line 135 of file ScaleAutomatism.hxx.

Referenced by calculateExplicitIncrementAndScaleForLinear(), and setAutoScalingOptions().

◆ m_fValueMaximum

double chart::ScaleAutomatism::m_fValueMaximum
private

Minimum of all source values.

Definition at line 131 of file ScaleAutomatism.hxx.

Referenced by calculateExplicitScaleAndIncrement(), expandValueRange(), and resetValueRange().

◆ m_fValueMinimum

double chart::ScaleAutomatism::m_fValueMinimum
private

◆ m_nMaximumAutoMainIncrementCount

sal_Int32 chart::ScaleAutomatism::m_nMaximumAutoMainIncrementCount
private

◆ m_nTimeResolution

sal_Int32 chart::ScaleAutomatism::m_nTimeResolution
private

true = Expand narrow range toward zero (add half of range).

Definition at line 137 of file ScaleAutomatism.hxx.

Referenced by calculateExplicitIncrementAndScaleForDateTimeAxis(), and setAutomaticTimeResolution().


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