summaryrefslogtreecommitdiff
path: root/chart2/source/view/inc/ScaleAutomatism.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/view/inc/ScaleAutomatism.hxx')
-rw-r--r--chart2/source/view/inc/ScaleAutomatism.hxx119
1 files changed, 119 insertions, 0 deletions
diff --git a/chart2/source/view/inc/ScaleAutomatism.hxx b/chart2/source/view/inc/ScaleAutomatism.hxx
new file mode 100644
index 000000000000..4440ad26ac5a
--- /dev/null
+++ b/chart2/source/view/inc/ScaleAutomatism.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CHART2_SCALEAUTOMATISM_HXX
+#define _CHART2_SCALEAUTOMATISM_HXX
+
+#include <com/sun/star/chart2/ExplicitIncrementData.hpp>
+#include <com/sun/star/chart2/ExplicitScaleData.hpp>
+#include <com/sun/star/chart2/ScaleData.hpp>
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+//-----------------------------------------------------------------------------
+
+/** This class implements the calculation of automatic axis limits.
+*/
+class ScaleAutomatism
+{
+public:
+ explicit ScaleAutomatism(
+ const ::com::sun::star::chart2::ScaleData& rSourceScale );
+ virtual ~ScaleAutomatism();
+
+ /** Expands own value range with the passed minimum and maximum. */
+ void expandValueRange( double fMinimum, double fMaximum );
+
+ /** Sets additional auto scaling options.
+ @param bExpandBorderToIncrementRhythm If true, expands automatic
+ borders to the fixed or calculated increment rhythm.
+ @param bExpandIfValuesCloseToBorder If true, expands automatic borders
+ if values are too close (closer than 1/21 of visible area).
+ @param 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.
+ @param 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). */
+ void setAutoScalingOptions(
+ bool bExpandBorderToIncrementRhythm,
+ bool bExpandIfValuesCloseToBorder,
+ bool bExpandWideValuesToZero,
+ bool bExpandNarrowValuesTowardZero );
+
+ /** 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. */
+ void setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMainIncrementCount );
+
+ /** Fills the passed scale data and increment data according to the own settings. */
+ void calculateExplicitScaleAndIncrement(
+ ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
+ ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement ) const;
+
+ ::com::sun::star::chart2::ScaleData getScale() const;
+
+private:
+ /** Fills the passed scale data and increment data for category scaling. */
+ void calculateExplicitIncrementAndScaleForCategory(
+ ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
+ ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement,
+ bool bAutoMinimum, bool bAutoMaximum ) const;
+
+ /** Fills the passed scale data and increment data for logarithmic scaling. */
+ void calculateExplicitIncrementAndScaleForLogarithmic(
+ ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
+ ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement,
+ bool bAutoMinimum, bool bAutoMaximum ) const;
+
+ /** Fills the passed scale data and increment data for linear scaling. */
+ void calculateExplicitIncrementAndScaleForLinear(
+ ::com::sun::star::chart2::ExplicitScaleData& rExplicitScale,
+ ::com::sun::star::chart2::ExplicitIncrementData& rExplicitIncrement,
+ bool bAutoMinimum, bool bAutoMaximum ) const;
+
+private:
+ ::com::sun::star::chart2::ScaleData m_aSourceScale;
+
+ double m_fValueMinimum; /// Minimum of all source values.
+ double m_fValueMaximum; /// Maximum of all source values.
+ sal_Int32 m_nMaximumAutoMainIncrementCount; /// Maximum number of automatic main increments.
+ bool m_bExpandBorderToIncrementRhythm; /// true = Expand to main increments.
+ bool m_bExpandIfValuesCloseToBorder; /// true = Expand if values are too close to the borders.
+ bool m_bExpandWideValuesToZero; /// true = Expand wide spread values to zero.
+ bool m_bExpandNarrowValuesTowardZero; /// true = Expand narrow range toward zero (add half of range).
+};
+
+//.............................................................................
+} //namespace chart
+//.............................................................................
+#endif