summaryrefslogtreecommitdiff
path: root/chart2/source/tools
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2007-11-23 11:06:40 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2007-11-23 11:06:40 +0000
commit1a683d5053338b1fe9e9cd5d1bf2a99b7d4e73a8 (patch)
treec276637e5a63bb50a84280505903587b5cf0f9d0 /chart2/source/tools
parent7a7d5931873caa81eeb90ee2f5ee6c9d3f3c2d8c (diff)
INTEGRATION: CWS chart17 (1.5.110); FILE MERGED
2007/10/23 15:02:36 bm 1.5.110.2: #i82891# improve rendering of regression curves using XRegressionCurveCalculator::getCurveValues() 2007/10/12 12:35:09 bm 1.5.110.1: #i7998# equations for regression curves
Diffstat (limited to 'chart2/source/tools')
-rw-r--r--chart2/source/tools/ExponentialRegressionCurveCalculator.cxx55
-rw-r--r--chart2/source/tools/PotentialRegressionCurveCalculator.cxx48
2 files changed, 67 insertions, 36 deletions
diff --git a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx
index 451b14b22314..9481add6108d 100644
--- a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: ExponentialRegressionCurveCalculator.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: obo $ $Date: 2006-09-17 13:24:12 $
+ * last change: $Author: ihi $ $Date: 2007-11-23 12:05:27 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -39,12 +39,8 @@
#include "macros.hxx"
#include "RegressionCalculationHelper.hxx"
-#ifndef INCLUDED_RTL_MATH_HXX
#include <rtl/math.hxx>
-#endif
-#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
-#endif
using namespace ::com::sun::star;
@@ -56,12 +52,10 @@ namespace chart
ExponentialRegressionCurveCalculator::ExponentialRegressionCurveCalculator() :
m_fSlope( 0.0 ),
- m_fIntercept( 0.0 ),
- m_fCorrelationCoeffitient( 0.0 )
+ m_fIntercept( 0.0 )
{
::rtl::math::setNan( & m_fSlope );
::rtl::math::setNan( & m_fIntercept );
- ::rtl::math::setNan( & m_fCorrelationCoeffitient );
}
ExponentialRegressionCurveCalculator::~ExponentialRegressionCurveCalculator()
@@ -134,14 +128,35 @@ double SAL_CALL ExponentialRegressionCurveCalculator::getCurveValue( double x )
return fResult;
}
-double SAL_CALL ExponentialRegressionCurveCalculator::getCorrelationCoefficient()
- throw (uno::RuntimeException)
+uno::Sequence< geometry::RealPoint2D > SAL_CALL ExponentialRegressionCurveCalculator::getCurveValues(
+ double min, double max, ::sal_Int32 nPointCount,
+ const uno::Reference< chart2::XScaling >& xScalingX,
+ const uno::Reference< chart2::XScaling >& xScalingY,
+ ::sal_Bool bMaySkipPointsInCalculation )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
{
- return m_fCorrelationCoeffitient;
+ if( bMaySkipPointsInCalculation &&
+ isLinearScaling( xScalingX ) &&
+ isLogarithmicScaling( xScalingY ))
+ {
+ // optimize result
+ uno::Sequence< geometry::RealPoint2D > aResult( 2 );
+ aResult[0].X = min;
+ aResult[0].Y = this->getCurveValue( min );
+ aResult[1].X = max;
+ aResult[1].Y = this->getCurveValue( max );
+
+ return aResult;
+ }
+
+ return RegressionCurveCalculator::getCurveValues( min, max, nPointCount, xScalingX, xScalingY, bMaySkipPointsInCalculation );
}
-OUString SAL_CALL ExponentialRegressionCurveCalculator::getRepresentation()
- throw (uno::RuntimeException)
+
+OUString ExponentialRegressionCurveCalculator::ImplGetRepresentation(
+ const uno::Reference< util::XNumberFormatter >& xNumFormatter,
+ ::sal_Int32 nNumberFormatKey ) const
{
OUStringBuffer aBuf( C2U( "f(x) = " ));
@@ -152,19 +167,21 @@ OUString SAL_CALL ExponentialRegressionCurveCalculator::getRepresentation()
}
else if( rtl::math::approxEqual( m_fSlope, 1.0 ) )
{
- aBuf.append( NUMBER_TO_STR( m_fIntercept ));
+ aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fIntercept ));
}
else
{
if( ! rtl::math::approxEqual( m_fIntercept, 1.0 ) )
{
- aBuf.append( NUMBER_TO_STR( m_fIntercept ));
- aBuf.append( sal_Unicode( ' ' ));
+ aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fIntercept ));
aBuf.append( sal_Unicode( 0x00b7 ));
- aBuf.append( sal_Unicode( ' ' ));
}
- aBuf.append( NUMBER_TO_STR( m_fSlope ));
+ if( m_fSlope < 0.0 )
+ aBuf.append( sal_Unicode( '(' ));
+ aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fSlope ));
+ if( m_fSlope < 0.0 )
+ aBuf.append( sal_Unicode( ')' ));
aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "^x" ));
}
diff --git a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
index 9fdf6de033e9..1b43c4294dcf 100644
--- a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: PotentialRegressionCurveCalculator.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: obo $ $Date: 2006-09-17 13:28:18 $
+ * last change: $Author: ihi $ $Date: 2007-11-23 12:06:40 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -39,9 +39,8 @@
#include "macros.hxx"
#include "RegressionCalculationHelper.hxx"
-#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx>
-#endif
using namespace ::com::sun::star;
@@ -53,12 +52,10 @@ namespace chart
PotentialRegressionCurveCalculator::PotentialRegressionCurveCalculator() :
m_fSlope( 0.0 ),
- m_fIntercept( 0.0 ),
- m_fCorrelationCoeffitient( 0.0 )
+ m_fIntercept( 0.0 )
{
::rtl::math::setNan( & m_fSlope );
::rtl::math::setNan( & m_fIntercept );
- ::rtl::math::setNan( & m_fCorrelationCoeffitient );
}
PotentialRegressionCurveCalculator::~PotentialRegressionCurveCalculator()
@@ -130,14 +127,33 @@ double SAL_CALL PotentialRegressionCurveCalculator::getCurveValue( double x )
return fResult;
}
-double SAL_CALL PotentialRegressionCurveCalculator::getCorrelationCoefficient()
- throw (uno::RuntimeException)
+uno::Sequence< geometry::RealPoint2D > SAL_CALL PotentialRegressionCurveCalculator::getCurveValues(
+ double min, double max, ::sal_Int32 nPointCount,
+ const uno::Reference< chart2::XScaling >& xScalingX,
+ const uno::Reference< chart2::XScaling >& xScalingY,
+ ::sal_Bool bMaySkipPointsInCalculation )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
{
- return m_fCorrelationCoeffitient;
+ if( bMaySkipPointsInCalculation &&
+ isLogarithmicScaling( xScalingX ) &&
+ isLogarithmicScaling( xScalingY ))
+ {
+ // optimize result
+ uno::Sequence< geometry::RealPoint2D > aResult( 2 );
+ aResult[0].X = min;
+ aResult[0].Y = this->getCurveValue( min );
+ aResult[1].X = max;
+ aResult[1].Y = this->getCurveValue( max );
+
+ return aResult;
+ }
+ return RegressionCurveCalculator::getCurveValues( min, max, nPointCount, xScalingX, xScalingY, bMaySkipPointsInCalculation );
}
-OUString SAL_CALL PotentialRegressionCurveCalculator::getRepresentation()
- throw (uno::RuntimeException)
+OUString PotentialRegressionCurveCalculator::ImplGetRepresentation(
+ const uno::Reference< util::XNumberFormatter >& xNumFormatter,
+ ::sal_Int32 nNumberFormatKey ) const
{
OUStringBuffer aBuf( C2U( "f(x) = " ));
@@ -147,21 +163,19 @@ OUString SAL_CALL PotentialRegressionCurveCalculator::getRepresentation()
}
else if( m_fSlope == 0.0 )
{
- aBuf.append( NUMBER_TO_STR( m_fIntercept ));
+ aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fIntercept ));
}
else
{
if( ! rtl::math::approxEqual( m_fIntercept, 1.0 ) )
{
- aBuf.append( NUMBER_TO_STR( m_fIntercept ));
- aBuf.append( sal_Unicode( ' ' ));
- aBuf.append( sal_Unicode( 0x00b7 ));
+ aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fIntercept ));
aBuf.append( sal_Unicode( ' ' ));
}
if( m_fSlope != 0.0 )
{
aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "x^" ));
- aBuf.append( NUMBER_TO_STR( m_fSlope ));
+ aBuf.append( getFormattedString( xNumFormatter, nNumberFormatKey, m_fSlope ));
}
}