summaryrefslogtreecommitdiff
path: root/chart2/source/tools/RegressionCurveModel.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-05-27 08:02:37 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-07-03 21:46:39 +0200
commite6a0cc2d6cb37bf4e04861173c7e55b307513778 (patch)
tree3569da62ea24a3fd4dce7216751692b1a5e79306 /chart2/source/tools/RegressionCurveModel.cxx
parentc63b74d22d360893bb9e1200f59099ffb7943705 (diff)
fdo#35712 polynomial and moving average regression lines
- added polynomial and moving average to the dialog - implemented moving average and polynomal RegressionCurveCalculator - added icon for polynomial regression curve - prepare icon for moving average regression curve - degree parameter for polynomial regression curve - period parameter for moving average regression curve - limit the curve to max and min x value - added extrapolation Change-Id: I4ebb8dc23a3aff285b999e115fdda20ab11910a5
Diffstat (limited to 'chart2/source/tools/RegressionCurveModel.cxx')
-rw-r--r--chart2/source/tools/RegressionCurveModel.cxx102
1 files changed, 102 insertions, 0 deletions
diff --git a/chart2/source/tools/RegressionCurveModel.cxx b/chart2/source/tools/RegressionCurveModel.cxx
index 2dd96ed2be86..cd9b143d7cc6 100644
--- a/chart2/source/tools/RegressionCurveModel.cxx
+++ b/chart2/source/tools/RegressionCurveModel.cxx
@@ -47,10 +47,54 @@ static const OUString lcl_aImplementationName_Exponential(
"com.sun.star.comp.chart2.ExponentialRegressionCurve" );
static const OUString lcl_aImplementationName_Potential(
"com.sun.star.comp.chart2.PotentialRegressionCurve" );
+static const OUString lcl_aImplementationName_Polynomial(
+ "com.sun.star.comp.chart2.PolynomialRegressionCurve" );
+static const OUString lcl_aImplementationName_MovingAverage(
+ "com.sun.star.comp.chart2.MovingAverageRegressionCurve" );
static const OUString lcl_aServiceName(
"com.sun.star.chart2.RegressionCurve" );
+enum
+{
+ PROPERTY_DEGREE,
+ PROPERTY_PERIOD,
+ PROPERTY_EXTRAPOLATE_FORWARD,
+ PROPERTY_EXTRAPOLATE_BACKWARD
+};
+
+void lcl_AddPropertiesToVector(
+ ::std::vector< Property > & rOutProperties )
+{
+ rOutProperties.push_back(
+ Property( "PolynomialDegree",
+ PROPERTY_DEGREE,
+ ::getCppuType( reinterpret_cast< const sal_Int32* >(0)),
+ beans::PropertyAttribute::BOUND |
+ beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( "MovingAveragePeriod",
+ PROPERTY_PERIOD,
+ ::getCppuType( reinterpret_cast< const sal_Int32* >(0)),
+ beans::PropertyAttribute::BOUND |
+ beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( "ExtrapolateForward",
+ PROPERTY_EXTRAPOLATE_FORWARD,
+ ::getCppuType( reinterpret_cast< const double* >(0) ),
+ beans::PropertyAttribute::BOUND |
+ beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( "ExtrapolateBackward",
+ PROPERTY_EXTRAPOLATE_BACKWARD,
+ ::getCppuType( reinterpret_cast< const double* >(0) ),
+ beans::PropertyAttribute::BOUND |
+ beans::PropertyAttribute::MAYBEDEFAULT ));
+}
+
struct StaticXXXDefaults_Initializer
{
::chart::tPropertyValueMap* operator()()
@@ -82,6 +126,7 @@ private:
uno::Sequence< Property > lcl_GetPropertySequence()
{
::std::vector< ::com::sun::star::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
::std::sort( aProperties.begin(), aProperties.end(),
@@ -189,6 +234,10 @@ OUString SAL_CALL RegressionCurveModel::getServiceName()
return OUString("com.sun.star.chart2.ExponentialRegressionCurve");
case CURVE_TYPE_POWER:
return OUString("com.sun.star.chart2.PotentialRegressionCurve");
+ case CURVE_TYPE_POLYNOMIAL:
+ return OUString("com.sun.star.chart2.PolynomialRegressionCurve");
+ case CURVE_TYPE_MOVING_AVERAGE:
+ return OUString("com.sun.star.chart2.MovingAverageRegressionCurve");
}
return OUString();
@@ -426,6 +475,59 @@ uno::Reference< util::XCloneable > SAL_CALL PotentialRegressionCurve::createClon
}
+PolynomialRegressionCurve::PolynomialRegressionCurve(
+ const uno::Reference< uno::XComponentContext > & xContext )
+ : RegressionCurveModel( xContext, RegressionCurveModel::CURVE_TYPE_POLYNOMIAL )
+{}
+PolynomialRegressionCurve::PolynomialRegressionCurve(
+ const PolynomialRegressionCurve & rOther ) :
+ RegressionCurveModel( rOther )
+{}
+PolynomialRegressionCurve::~PolynomialRegressionCurve()
+{}
+uno::Sequence< OUString > PolynomialRegressionCurve::getSupportedServiceNames_Static()
+{
+ uno::Sequence< OUString > aServices( 2 );
+ aServices[ 0 ] = lcl_aServiceName;
+ aServices[ 1 ] = "com.sun.star.chart2.PolynomialRegressionCurve";
+ return aServices;
+}
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( PolynomialRegressionCurve, lcl_aImplementationName_Polynomial );
+
+uno::Reference< util::XCloneable > SAL_CALL PolynomialRegressionCurve::createClone()
+ throw (uno::RuntimeException)
+{
+ return uno::Reference< util::XCloneable >( new PolynomialRegressionCurve( *this ));
+}
+
+MovingAverageRegressionCurve::MovingAverageRegressionCurve(
+ const uno::Reference< uno::XComponentContext > & xContext )
+ : RegressionCurveModel( xContext, RegressionCurveModel::CURVE_TYPE_MOVING_AVERAGE )
+{}
+MovingAverageRegressionCurve::MovingAverageRegressionCurve(
+ const MovingAverageRegressionCurve & rOther ) :
+ RegressionCurveModel( rOther )
+{}
+MovingAverageRegressionCurve::~MovingAverageRegressionCurve()
+{}
+uno::Sequence< OUString > MovingAverageRegressionCurve::getSupportedServiceNames_Static()
+{
+ uno::Sequence< OUString > aServices( 2 );
+ aServices[ 0 ] = lcl_aServiceName;
+ aServices[ 1 ] = "com.sun.star.chart2.MovingAverageRegressionCurve";
+ return aServices;
+}
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( MovingAverageRegressionCurve, lcl_aImplementationName_MovingAverage );
+
+uno::Reference< util::XCloneable > SAL_CALL MovingAverageRegressionCurve::createClone()
+ throw (uno::RuntimeException)
+{
+ return uno::Reference< util::XCloneable >( new MovingAverageRegressionCurve( *this ));
+}
+
+
} // namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */