1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.chart.plot

File PlotType.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
10
5
1
115
49
6
0.6
2
5
1.2

Classes

Class Line # Actions
PlotType 31 10 0% 6 1
0.941176594.1%
 

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.chart.plot;
21   
22    import org.xwiki.chart.dataset.DatasetType;
23    import org.xwiki.chart.axis.AxisType;
24   
25    /**
26    * Enumeration of supported plot types.
27    *
28    * @version $Id: 7189d3385d282d4e09730a657124f7b9dc28d876 $
29    * @since 4.2M1
30    */
 
31    public enum PlotType
32    {
33    /** Line plot type. */
34    LINE("line", DatasetType.CATEGORY, AxisType.CATEGORY, AxisType.NUMBER),
35    /** Area plot type. */
36    AREA("area", DatasetType.CATEGORY, AxisType.CATEGORY, AxisType.NUMBER),
37    /** Bar plot type. */
38    BAR("bar", DatasetType.CATEGORY, AxisType.CATEGORY, AxisType.NUMBER),
39    /** Stacked Bar plot type. */
40    STACKEDBAR("stackedbar", DatasetType.CATEGORY, AxisType.CATEGORY, AxisType.NUMBER),
41    /** Pie plot type. */
42    PIE("pie", DatasetType.PIE),
43    /** 3D bar plot type. */
44    BAR3D("bar3D", DatasetType.CATEGORY, AxisType.CATEGORY, AxisType.NUMBER),
45    /** Stacked 3D bar plot type. */
46    STACKEDBAR3D("stackedbar3D", DatasetType.CATEGORY, AxisType.CATEGORY, AxisType.NUMBER),
47    /** 3D line plot type. */
48    LINE3D("line3D", DatasetType.CATEGORY, AxisType.CATEGORY, AxisType.NUMBER),
49    /** xy area plot type. */
50    XYAREA("xy_area", DatasetType.XY, AxisType.NUMBER, AxisType.NUMBER),
51    /** xy line and shape plot type. */
52    XYLINEANDSHAPE("xy_line_and_shape", DatasetType.XY, AxisType.NUMBER, AxisType.NUMBER),
53    /** xy line3D plot type. */
54    XYLINE3D("xy_line3D", DatasetType.XY, AxisType.NUMBER, AxisType.NUMBER),
55    /** xy step plot type. */
56    XYSTEP("xy_step", DatasetType.XY, AxisType.NUMBER, AxisType.NUMBER);
57   
58    /** The name of the plot type. */
59    private final String name;
60   
61    /** The default dataset for the plot type. */
62    private final DatasetType defaultDatasetType;
63   
64    /** The default axis types for the plot type. */
65    private final AxisType [] defaultAxisTypes;
66   
67    /**
68    * @param name The name used as value for the plot type parameter.
69    * @param defaultDatasetType The default dataset type to use with this plot type.
70    * @param defaultAxisTypes The default axis types to use with this plot type.
71    */
 
72  24 toggle PlotType(String name, DatasetType defaultDatasetType, AxisType... defaultAxisTypes)
73    {
74  24 this.name = name;
75  24 this.defaultDatasetType = defaultDatasetType;
76  24 this.defaultAxisTypes = defaultAxisTypes;
77    }
78   
79    /** @return the name (the string representation) of this dataset type. */
 
80  107 toggle public String getName()
81    {
82  107 return name;
83    }
84   
85    /** @return the default dataset type used by this plot type. */
 
86  16 toggle public DatasetType getDefaultDatasetType()
87    {
88  16 return defaultDatasetType;
89    }
90   
91    /**
92    * @param name A plot type.
93    * @return the plot type corresponding to the name, or {@code null}.
94    */
 
95  21 toggle public static PlotType forName(String name)
96    {
97  21 for (PlotType plotType : values())
98    {
99  107 if (name.equals(plotType.getName())) {
100  21 return plotType;
101    }
102    }
103   
104  0 return null;
105    }
106   
107    /**
108    * @return the default axis types.
109    */
 
110  21 toggle public AxisType [] getDefaultAxisTypes()
111    {
112  21 return defaultAxisTypes;
113    }
114   
115    }