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; |
21 |
|
|
22 |
|
import java.awt.Color; |
23 |
|
import java.awt.Paint; |
24 |
|
import java.util.ArrayList; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Map; |
27 |
|
|
28 |
|
import org.jfree.chart.plot.DefaultDrawingSupplier; |
29 |
|
import org.jfree.chart.plot.DrawingSupplier; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 31.8% |
Uncovered Elements: 15 (22) |
Complexity: 3 |
Complexity Density: 0.18 |
|
37 |
|
public class DrawingSupplierFactory |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
private static final String COLORS_PARAM = "colors"; |
45 |
|
|
46 |
|
|
47 |
|
@param@link |
48 |
|
@return |
49 |
|
|
|
|
| 28.6% |
Uncovered Elements: 15 (21) |
Complexity: 3 |
Complexity Density: 0.18 |
|
50 |
15 |
public DrawingSupplier createDrawingSupplier(Map<String, String> parameters)... |
51 |
|
{ |
52 |
15 |
DrawingSupplier supplier; |
53 |
|
|
54 |
15 |
String colorParam = parameters.get(COLORS_PARAM); |
55 |
15 |
if (colorParam != null) { |
56 |
0 |
List<Color> colors = new ArrayList<Color>(); |
57 |
0 |
for (String colorAsString : colorParam.split(",")) { |
58 |
0 |
if (colorAsString.length() == 6) { |
59 |
0 |
int red = Integer.parseInt(colorAsString.substring(0, 2), 16); |
60 |
0 |
int green = Integer.parseInt(colorAsString.substring(2, 4), 16); |
61 |
0 |
int blue = Integer.parseInt(colorAsString.substring(4, 6), 16); |
62 |
0 |
colors.add(new Color(red, green, blue)); |
63 |
|
} |
64 |
|
} |
65 |
0 |
Paint[] paint = new Paint[colors.size()]; |
66 |
0 |
int i = 0; |
67 |
0 |
for (Color color : colors) { |
68 |
0 |
paint[i++] = color; |
69 |
|
} |
70 |
0 |
supplier = new DefaultDrawingSupplier(paint, |
71 |
|
DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, |
72 |
|
DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, |
73 |
|
DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, |
74 |
|
DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); |
75 |
|
} else { |
76 |
15 |
supplier = new DefaultDrawingSupplier(); |
77 |
|
} |
78 |
|
|
79 |
15 |
return supplier; |
80 |
|
} |
81 |
|
} |