LibreOffice Module chart2 (master) 1
CategoryPositionHelper.cxx
Go to the documentation of this file.
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
21
22namespace chart
23{
24
25CategoryPositionHelper::CategoryPositionHelper( double fSeriesCount, double fCategoryWidth )
26 : m_fSeriesCount(fSeriesCount)
27 , m_fCategoryWidth(fCategoryWidth)
28 , m_fInnerDistance(0.0)
29 , m_fOuterDistance(1.0)
30{
31}
32
34{
35}
36
38{
39 double fWidth = m_fCategoryWidth /
43 return fWidth;
44}
45
46double CategoryPositionHelper::getScaledSlotPos( double fScaledXPos, double fSeriesNumber ) const
47{
48 //the returned position is in the middle of the rect
49 //fSeriesNumber 0...n-1
50 double fPos = fScaledXPos
51 - (m_fCategoryWidth/2.0)
52 + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getScaledSlotWidth()
53 + getScaledSlotWidth()/2.0;
54 return fPos;
55}
56
57void CategoryPositionHelper::setInnerDistance( double fInnerDistance )
58{
59 if( fInnerDistance < -1.0 )
60 fInnerDistance = -1.0;
61 if( fInnerDistance > 1.0 )
62 fInnerDistance = 1.0;
63 m_fInnerDistance = fInnerDistance;
64}
65
66void CategoryPositionHelper::setOuterDistance( double fOuterDistance )
67{
68 if( fOuterDistance < 0.0 )
69 fOuterDistance = 0.0;
70 if( fOuterDistance > 6.0 )
71 fOuterDistance = 6.0;
72 m_fOuterDistance = fOuterDistance;
73}
74
75void CategoryPositionHelper::setCategoryWidth( double fCategoryWidth )
76{
77 m_fCategoryWidth = fCategoryWidth;
78}
79
80} //namespace chart
81
82/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setCategoryWidth(double fCategoryWidth)
CategoryPositionHelper(double fSeriesCount, double CategoryWidth=1.0)
void setOuterDistance(double fOuterDistance)
virtual double getScaledSlotPos(double fCategoryX, double fSeriesNumber) const
void setInnerDistance(double fInnerDistance)