1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.imaging.operations.load; |
35 |
|
|
36 |
|
import info.magnolia.imaging.ImagingException; |
37 |
|
import info.magnolia.imaging.ParameterProvider; |
38 |
|
import info.magnolia.imaging.operations.ImageOperation; |
39 |
|
|
40 |
|
import java.awt.Color; |
41 |
|
import java.awt.Graphics2D; |
42 |
|
import java.awt.Rectangle; |
43 |
|
import java.awt.image.BufferedImage; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@param |
52 |
|
|
|
|
| 92% |
Uncovered Elements: 2 (25) |
Complexity: 7 |
Complexity Density: 0.44 |
|
53 |
|
public class Blank<P extends ParameterProvider<?>> implements ImageOperation<P> { |
54 |
|
private static final int DEFAULT_TYPE = BufferedImage.TYPE_INT_ARGB_PRE; |
55 |
|
private static final int DEFAULT_SIZE = 200; |
56 |
|
private int type; |
57 |
|
private Color backgroundColor; |
58 |
|
private int width; |
59 |
|
private int height; |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
1 |
public Blank() {... |
62 |
1 |
this(DEFAULT_SIZE, DEFAULT_SIZE); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
3 |
public Blank(int width, int height) {... |
66 |
3 |
this(null, width, height); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
4 |
public Blank(Color backgroundColor, int width, int height) {... |
70 |
4 |
this(DEFAULT_TYPE, backgroundColor, width, height); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
73 |
4 |
public Blank(int type, Color backgroundColor, int width, int height) {... |
74 |
4 |
this.type = type; |
75 |
4 |
this.backgroundColor = backgroundColor; |
76 |
4 |
this.width = width; |
77 |
4 |
this.height = height; |
78 |
|
} |
79 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
80 |
4 |
@Override... |
81 |
|
public BufferedImage apply(BufferedImage source, P params) throws ImagingException { |
82 |
4 |
if (source != null) { |
83 |
0 |
throw new ImagingException("This operation currently does not support overlaying images"); |
84 |
|
} |
85 |
|
|
86 |
4 |
final BufferedImage img = new BufferedImage(width, height, type); |
87 |
|
|
88 |
4 |
if (backgroundColor != null) { |
89 |
2 |
final Graphics2D g = img.createGraphics(); |
90 |
2 |
g.setColor(backgroundColor); |
91 |
2 |
g.fill(new Rectangle(0, 0, width, height)); |
92 |
2 |
g.dispose(); |
93 |
|
} |
94 |
|
|
95 |
4 |
return img; |
96 |
|
} |
97 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
98 |
|
public int getType() {... |
99 |
|
return type; |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
@see |
106 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
107 |
|
public void setType(int type) {... |
108 |
|
this.type = type; |
109 |
|
} |
110 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
111 |
|
public Color getBackgroundColor() {... |
112 |
|
return backgroundColor; |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
118 |
|
public void setBackgroundColor(Color backgroundColor) {... |
119 |
|
this.backgroundColor = backgroundColor; |
120 |
|
} |
121 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
122 |
|
public int getWidth() {... |
123 |
|
return width; |
124 |
|
} |
125 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
126 |
|
public void setWidth(int width) {... |
127 |
|
this.width = width; |
128 |
|
} |
129 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
130 |
|
public int getHeight() {... |
131 |
|
return height; |
132 |
|
} |
133 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
134 |
|
public void setHeight(int height) {... |
135 |
|
this.height = height; |
136 |
|
} |
137 |
|
} |