LibreOffice Module chart2 (master) 1
|
This class implements the calculation of automatic axis limits. More...
#include <ScaleAutomatism.hxx>
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 Date & | getNullDate () 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 |
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.
|
explicit |
Definition at line 89 of file ScaleAutomatism.cxx.
References DAY, expandValueRange(), m_aSourceScale, and resetValueRange().
|
private |
Fills the passed scale data and increment data for category scaling.
Definition at line 237 of file ScaleAutomatism.cxx.
References chart::ExplicitIncrementData::BaseValue, chart::ExplicitIncrementData::Distance, chart::EquidistantTickFactory::getMaximumAtIncrement(), chart::EquidistantTickFactory::getMinimumAtIncrement(), chart::ExplicitSubIncrement::IntervalCount, m_aSourceScale, m_bExpandBorderToIncrementRhythm, chart::ExplicitScaleData::m_bShiftedCategoryPosition, chart::ExplicitScaleData::Maximum, chart::MAXIMUM_MANUAL_INCREMENT_COUNT, chart::ExplicitScaleData::Minimum, chart::ExplicitSubIncrement::PostEquidistant, chart::ExplicitIncrementData::PostEquidistant, chart::ExplicitScaleData::Scaling, and chart::ExplicitIncrementData::SubIncrements.
Referenced by calculateExplicitScaleAndIncrement().
|
private |
Fills the passed scale data and increment data for date-time axis.
Definition at line 545 of file ScaleAutomatism.cxx.
References Date::AddDays(), DAY, chart::DateHelper::GetDateSomeMonthsAway(), chart::DateHelper::GetDateSomeYearsAway(), chart::DateHelper::IsLessThanOneMonthAway(), chart::DateHelper::IsLessThanOneYearAway(), m_aNullDate, m_aSourceScale, chart::ExplicitScaleData::m_bShiftedCategoryPosition, m_nMaximumAutoMainIncrementCount, m_nTimeResolution, chart::ExplicitIncrementData::MajorTimeInterval, chart::ExplicitScaleData::Maximum, chart::MAXIMUM_MANUAL_INCREMENT_COUNT, chart::ExplicitScaleData::Minimum, chart::ExplicitIncrementData::MinorTimeInterval, MONTH, chart::ExplicitIncrementData::PostEquidistant, chart::ExplicitScaleData::Scaling, Date::SetDay(), Date::SetMonth(), chart::ExplicitScaleData::TimeResolution, and YEAR.
Referenced by calculateExplicitScaleAndIncrement().
|
private |
Fills the passed scale data and increment data for linear scaling.
Definition at line 737 of file ScaleAutomatism.cxx.
References chart::ExplicitIncrementData::BaseValue, chart::ExplicitIncrementData::Distance, chart::EquidistantTickFactory::getMaximumAtIncrement(), chart::EquidistantTickFactory::getMinimumAtIncrement(), chart::ExplicitSubIncrement::IntervalCount, m_aSourceScale, m_bExpandBorderToIncrementRhythm, m_bExpandIfValuesCloseToBorder, m_bExpandNarrowValuesTowardZero, m_bExpandWideValuesToZero, m_nMaximumAutoMainIncrementCount, chart::ExplicitScaleData::Maximum, chart::MAXIMUM_MANUAL_INCREMENT_COUNT, chart::ExplicitScaleData::Minimum, chart::ExplicitSubIncrement::PostEquidistant, chart::ExplicitIncrementData::PostEquidistant, and chart::ExplicitIncrementData::SubIncrements.
Referenced by calculateExplicitScaleAndIncrement().
|
private |
Fills the passed scale data and increment data for logarithmic scaling.
Definition at line 294 of file ScaleAutomatism.cxx.
References chart::ExplicitIncrementData::BaseValue, chart::AxisHelper::createLogarithmicScaling(), chart::ExplicitIncrementData::Distance, chart::EquidistantTickFactory::getMaximumAtIncrement(), chart::EquidistantTickFactory::getMinimumAtIncrement(), chart::ExplicitSubIncrement::IntervalCount, m_aSourceScale, m_bExpandBorderToIncrementRhythm, m_bExpandNarrowValuesTowardZero, m_nMaximumAutoMainIncrementCount, chart::ExplicitScaleData::Maximum, chart::MAXIMUM_MANUAL_INCREMENT_COUNT, chart::ExplicitScaleData::Minimum, chart::ExplicitSubIncrement::PostEquidistant, chart::ExplicitIncrementData::PostEquidistant, chart::ExplicitScaleData::Scaling, and chart::ExplicitIncrementData::SubIncrements.
Referenced by 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.
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().
|
inline |
Definition at line 100 of file ScaleAutomatism.hxx.
References m_aNullDate.
Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling().
|
inline |
Definition at line 99 of file ScaleAutomatism.hxx.
References m_aSourceScale.
Referenced by chart::VCoordinateSystem::prepareAutomaticAxisScaling().
void chart::ScaleAutomatism::resetValueRange | ( | ) |
Definition at line 108 of file ScaleAutomatism.cxx.
References m_fValueMaximum, and m_fValueMinimum.
Referenced by expandValueRange(), and ScaleAutomatism().
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().
void chart::ScaleAutomatism::setAutoScalingOptions | ( | bool | bExpandBorderToIncrementRhythm, |
bool | bExpandIfValuesCloseToBorder, | ||
bool | bExpandWideValuesToZero, | ||
bool | bExpandNarrowValuesTowardZero | ||
) |
Sets additional auto scaling options.
bExpandBorderToIncrementRhythm | If true, expands automatic borders to the fixed or calculated increment rhythm. |
bExpandIfValuesCloseToBorder | If true, expands automatic borders if values are too close (closer than 1/21 of visible area). |
bExpandWideValuesToZero | If 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. |
bExpandNarrowValuesTowardZero | If 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().
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().
|
private |
Definition at line 139 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForDateTimeAxis(), calculateExplicitScaleAndIncrement(), and getNullDate().
|
private |
Definition at line 128 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForCategory(), calculateExplicitIncrementAndScaleForDateTimeAxis(), calculateExplicitIncrementAndScaleForLinear(), calculateExplicitIncrementAndScaleForLogarithmic(), calculateExplicitScaleAndIncrement(), getScale(), ScaleAutomatism(), setAutoScalingOptions(), and setMaximumAutoMainIncrementCount().
|
private |
Maximum number of automatic main increments.
Definition at line 133 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForCategory(), calculateExplicitIncrementAndScaleForLinear(), calculateExplicitIncrementAndScaleForLogarithmic(), and setAutoScalingOptions().
|
private |
true = Expand to main increments.
Definition at line 134 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForLinear(), and setAutoScalingOptions().
|
private |
true = Expand wide spread values to zero.
Definition at line 136 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForLinear(), calculateExplicitIncrementAndScaleForLogarithmic(), and setAutoScalingOptions().
|
private |
true = Expand if values are too close to the borders.
Definition at line 135 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForLinear(), and setAutoScalingOptions().
|
private |
Minimum of all source values.
Definition at line 131 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitScaleAndIncrement(), expandValueRange(), and resetValueRange().
|
private |
Definition at line 130 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitScaleAndIncrement(), expandValueRange(), and resetValueRange().
|
private |
Maximum of all source values.
Definition at line 132 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForDateTimeAxis(), calculateExplicitIncrementAndScaleForLinear(), calculateExplicitIncrementAndScaleForLogarithmic(), and setMaximumAutoMainIncrementCount().
|
private |
true = Expand narrow range toward zero (add half of range).
Definition at line 137 of file ScaleAutomatism.hxx.
Referenced by calculateExplicitIncrementAndScaleForDateTimeAxis(), and setAutomaticTimeResolution().