1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.macro.chart.source.table; |
21 |
|
|
22 |
|
import java.util.HashSet; |
23 |
|
import java.util.Map; |
24 |
|
import java.util.Set; |
25 |
|
|
26 |
|
import org.jfree.data.category.DefaultCategoryDataset; |
27 |
|
import org.jfree.data.general.Dataset; |
28 |
|
import org.xwiki.rendering.internal.macro.chart.source.LocaleConfiguration; |
29 |
|
import org.xwiki.rendering.macro.MacroExecutionException; |
30 |
|
|
31 |
|
|
32 |
|
@see |
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 88.2% |
Uncovered Elements: 4 (34) |
Complexity: 14 |
Complexity Density: 0.82 |
|
37 |
|
public class TableCategoryDatasetBuilder implements TableDatasetBuilder |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
private final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
private String[] rowKeys; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
private String[] columnKeys; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
private boolean transpose; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
private final Set<String> rowKeySet = new HashSet<String>(); |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
private final Set<String> columnKeySet = new HashSet<String>(); |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
16 |
@Override... |
70 |
|
public void setNumberOfRows(int numberOfRows) |
71 |
|
{ |
72 |
16 |
rowKeys = new String[numberOfRows]; |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
16 |
@Override... |
76 |
|
public void setNumberOfColumns(int numberOfColumns) |
77 |
|
{ |
78 |
16 |
columnKeys = new String[numberOfColumns]; |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
11 |
@Override... |
82 |
|
public void setTranspose(boolean transpose) |
83 |
|
{ |
84 |
11 |
this.transpose = transpose; |
85 |
|
} |
86 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
87 |
35 |
@Override... |
88 |
|
public void setColumnHeading(int columnIndex, String heading) throws MacroExecutionException |
89 |
|
{ |
90 |
35 |
if (columnKeySet.contains(heading)) { |
91 |
0 |
throw new MacroExecutionException(String.format("Duplicate column keys in table: [%s]", heading)); |
92 |
|
} |
93 |
35 |
columnKeySet.add(heading); |
94 |
35 |
columnKeys[columnIndex] = heading; |
95 |
|
} |
96 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
97 |
19 |
@Override... |
98 |
|
public void setRowHeading(int rowIndex, String heading) throws MacroExecutionException |
99 |
|
{ |
100 |
19 |
if (rowKeySet.contains(heading)) { |
101 |
0 |
throw new MacroExecutionException(String.format("Duplicate row keys in table: [%s]", heading)); |
102 |
|
} |
103 |
19 |
rowKeySet.add(heading); |
104 |
19 |
rowKeys[rowIndex] = heading; |
105 |
|
} |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
107 |
58 |
@Override... |
108 |
|
public void setValue(int rowIndex, int columnIndex, Number value) |
109 |
|
{ |
110 |
58 |
if (transpose) { |
111 |
28 |
dataset.addValue(value, columnKeys[columnIndex], rowKeys[rowIndex]); |
112 |
|
} else { |
113 |
30 |
dataset.addValue(value, rowKeys[rowIndex], columnKeys[columnIndex]); |
114 |
|
} |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
16 |
@Override... |
118 |
|
public Dataset getDataset() |
119 |
|
{ |
120 |
16 |
return dataset; |
121 |
|
} |
122 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
123 |
16 |
@Override... |
124 |
|
public void setParameters(Map<String, String> parameters) |
125 |
|
{ |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
4 |
@Override... |
129 |
|
public boolean forceColumnHeadings() |
130 |
|
{ |
131 |
4 |
return false; |
132 |
|
} |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
4 |
@Override... |
135 |
|
public boolean forceRowHeadings() |
136 |
|
{ |
137 |
4 |
return false; |
138 |
|
} |
139 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
140 |
16 |
@Override... |
141 |
|
public void setLocaleConfiguration(LocaleConfiguration localeConfiguration) |
142 |
|
{ |
143 |
|
} |
144 |
|
} |