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

File VisibilityChartCustomizer.java

 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

4
4
1
1
64
25
4
1
4
1
4

Classes

Class Line # Actions
VisibilityChartCustomizer 41 4 0% 4 4
0.555555655.6%
 

Contributing tests

This file is covered by 8 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.internal;
21   
22    import java.util.Map;
23   
24    import javax.inject.Named;
25    import javax.inject.Singleton;
26   
27    import org.jfree.chart.JFreeChart;
28    import org.xwiki.chart.ChartCustomizer;
29    import org.xwiki.component.annotation.Component;
30   
31    /**
32    * Customize visiblity of items on the chart.
33    *
34    * @version $Id: 19e3d365925b3fc05aca763d5e4e216c2435c494 $
35    * @since 7.4.3
36    * @since 8.0RC1
37    */
38    @Component
39    @Named("visibility")
40    @Singleton
 
41    public class VisibilityChartCustomizer implements ChartCustomizer
42    {
43    /**
44    * Whether the plot border is visible or not.
45    */
46    private static final String PLOT_BORDER_VISIBLE = "plotBorderVisible";
47   
48    /**
49    * Whether the legend is visible or not.
50    */
51    private static final String LEGEND_VISIBLE = "legendVisible";
52   
 
53  15 toggle @Override
54    public void customize(JFreeChart jfchart, Map<String, String> parameters)
55    {
56  15 if (parameters.get(PLOT_BORDER_VISIBLE) != null) {
57  0 jfchart.getPlot().setOutlineVisible(Boolean.parseBoolean(parameters.get(PLOT_BORDER_VISIBLE)));
58    }
59   
60  15 if (parameters.get(LEGEND_VISIBLE) != null && !Boolean.parseBoolean(parameters.get(LEGEND_VISIBLE))) {
61  0 jfchart.removeLegend();
62    }
63    }
64    }