1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.chart.internal.plot; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import org.jfree.chart.axis.ValueAxis; |
25 |
|
import org.jfree.chart.plot.Plot; |
26 |
|
import org.jfree.chart.plot.XYPlot; |
27 |
|
import org.jfree.chart.renderer.xy.XYItemRenderer; |
28 |
|
import org.jfree.data.xy.XYDataset; |
29 |
|
import org.xwiki.chart.PlotGeneratorException; |
30 |
|
import org.xwiki.chart.model.ChartModel; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 70% |
Uncovered Elements: 6 (20) |
Complexity: 4 |
Complexity Density: 0.31 |
|
38 |
|
public abstract class AbstractXYPlotGenerator implements PlotGenerator |
39 |
|
{ |
|
|
| 68.4% |
Uncovered Elements: 6 (19) |
Complexity: 4 |
Complexity Density: 0.31 |
|
40 |
3 |
@Override... |
41 |
|
public Plot generate(ChartModel model, Map<String, String> parameters) throws PlotGeneratorException |
42 |
|
{ |
43 |
3 |
XYDataset dataset; |
44 |
3 |
ValueAxis domainAxis; |
45 |
3 |
ValueAxis rangeAxis; |
46 |
|
|
47 |
3 |
if (model.getDataset() instanceof XYDataset) { |
48 |
3 |
dataset = (XYDataset) model.getDataset(); |
49 |
|
} else { |
50 |
0 |
throw new PlotGeneratorException("Incompatible dataset for xy plot."); |
51 |
|
} |
52 |
|
|
53 |
3 |
if (model.getAxis(0) instanceof ValueAxis) { |
54 |
3 |
domainAxis = (ValueAxis) model.getAxis(0); |
55 |
|
} else { |
56 |
0 |
throw new PlotGeneratorException("Incompatible axis 0 for xy plot."); |
57 |
|
} |
58 |
|
|
59 |
3 |
if (model.getAxis(1) instanceof ValueAxis) { |
60 |
3 |
rangeAxis = (ValueAxis) model.getAxis(1); |
61 |
|
} else { |
62 |
0 |
throw new PlotGeneratorException("Incompatible axis 1 for xy plot."); |
63 |
|
} |
64 |
|
|
65 |
3 |
return new XYPlot(dataset, domainAxis, rangeAxis, getRenderer(parameters)); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
@param |
70 |
|
@return@link |
71 |
|
|
72 |
|
protected abstract XYItemRenderer getRenderer(Map<String, String> parameters); |
73 |
|
} |