1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.internal.macro.chart.source

File SimpleChartModel.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

4
9
6
1
100
43
8
0.89
1.5
6
1.33

Classes

Class Line # Actions
SimpleChartModel 35 9 0% 8 6
0.6842105468.4%
 

Contributing tests

This file is covered by 14 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.internal.macro.chart.source;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.jfree.chart.axis.Axis;
26    import org.jfree.data.general.Dataset;
27    import org.xwiki.chart.model.ChartModel;
28   
29    /**
30    * A chart model implementation that simply holds a dataset and axis configurations.
31    *
32    * @version $Id: 327538047c6df773db55f80fdf39e686723b0fda $
33    * @since 4.2M1
34    */
 
35    public class SimpleChartModel implements ChartModel
36    {
37    /**
38    * The dataset.
39    */
40    private Dataset dataset;
41   
42    /**
43    * The axes.
44    */
45    private final List<Axis> axes = new ArrayList<Axis>();
46   
47    /**
48    * Public constructor.
49    */
 
50  21 toggle public SimpleChartModel()
51    {
52    }
53   
54    /**
55    * @param dataset The dataset.
56    */
 
57  21 toggle void setDataset(Dataset dataset)
58    {
59  21 this.dataset = dataset;
60    }
61   
 
62  30 toggle @Override
63    public Dataset getDataset()
64    {
65  30 return dataset;
66    }
67   
 
68  40 toggle @Override
69    public Axis getAxis(int index)
70    {
71  40 return axes.get(index);
72    }
73   
74    /**
75    * Set the axis at the given index.
76    *
77    * @param index The index.
78    * @param axis The axis.
79    */
 
80  24 toggle void setAxis(int index, Axis axis)
81    {
82  24 while (index > axes.size()) {
83  0 axes.add(null);
84    }
85   
86  24 if (index == axes.size()) {
87  24 axes.add(axis);
88    } else {
89  0 axes.set(index, axis);
90    }
91    }
92   
93    /**
94    * @param axis The axis to add.
95    */
 
96  0 toggle void addAxis(Axis axis)
97    {
98  0 axes.add(axis);
99    }
100    }