LCOV - code coverage report
Current view: top level - chart2/source/view/charttypes - CategoryPositionHelper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 31 35 88.6 %
Date: 2014-04-11 Functions: 8 9 88.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "CategoryPositionHelper.hxx"
      21             : 
      22             : namespace chart
      23             : {
      24             : 
      25         553 : CategoryPositionHelper::CategoryPositionHelper( double fSeriesCount, double fCategoryWidth )
      26             :     : m_fSeriesCount(fSeriesCount)
      27             :     , m_fCategoryWidth(fCategoryWidth)
      28             :     , m_fInnerDistance(0.0)
      29         553 :     , m_fOuterDistance(1.0)
      30             : {
      31         553 : }
      32             : 
      33           1 : CategoryPositionHelper::CategoryPositionHelper( const CategoryPositionHelper& rSource )
      34             :     : m_fSeriesCount( rSource.m_fSeriesCount )
      35             :     , m_fCategoryWidth( rSource.m_fCategoryWidth )
      36             :     , m_fInnerDistance( rSource.m_fInnerDistance )
      37           1 :     , m_fOuterDistance( rSource.m_fOuterDistance )
      38             : {
      39           1 : }
      40             : 
      41         554 : CategoryPositionHelper::~CategoryPositionHelper()
      42             : {
      43         554 : }
      44             : 
      45       20805 : double CategoryPositionHelper::getScaledSlotWidth() const
      46             : {
      47       20805 :     double fWidth = m_fCategoryWidth /
      48             :                 (  m_fSeriesCount
      49       20805 :                  + m_fOuterDistance
      50       20805 :                  + m_fInnerDistance*( m_fSeriesCount - 1.0) );
      51       20805 :     return fWidth;
      52             : }
      53             : 
      54        6943 : double CategoryPositionHelper::getScaledSlotPos( double fScaledXPos, double fSeriesNumber ) const
      55             : {
      56             :     //the returned position is in the middle of the rect
      57             :     //fSeriesNumber 0...n-1
      58             :     double fPos = fScaledXPos
      59        6943 :            - (m_fCategoryWidth/2.0)
      60        6943 :            + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getScaledSlotWidth()
      61        6943 :            + getScaledSlotWidth()/2.0;
      62        6943 :     return fPos;
      63             : }
      64             : 
      65        6884 : void CategoryPositionHelper::setInnerDistance( double fInnerDistance )
      66             : {
      67        6884 :     if( fInnerDistance < -1.0 )
      68           0 :         fInnerDistance = -1.0;
      69        6884 :     if( fInnerDistance > 1.0 )
      70           0 :         fInnerDistance = 1.0;
      71        6884 :     m_fInnerDistance = fInnerDistance;
      72        6884 : }
      73             : 
      74        6884 : void CategoryPositionHelper::setOuterDistance( double fOuterDistance )
      75             : {
      76        6884 :     if( fOuterDistance < 0.0 )
      77           0 :         fOuterDistance = 0.0;
      78        6884 :     if( fOuterDistance > 6.0 )
      79           0 :         fOuterDistance = 6.0;
      80        6884 :     m_fOuterDistance = fOuterDistance;
      81        6884 : }
      82             : 
      83        6895 : void CategoryPositionHelper::setCategoryWidth( double fCategoryWidth )
      84             : {
      85        6895 :     m_fCategoryWidth = fCategoryWidth;
      86        6895 : }
      87             : 
      88             : } //namespace chart
      89             : 
      90             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10