toni@1111
|
1 |
/**
|
toni@1111
|
2 |
* Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
|
toni@1111
|
3 |
* <jaroslav.tulach@apidesign.org>
|
toni@1111
|
4 |
*
|
toni@1111
|
5 |
* This program is free software: you can redistribute it and/or modify it under
|
toni@1111
|
6 |
* the terms of the GNU General Public License as published by the Free Software
|
toni@1111
|
7 |
* Foundation, version 2 of the License.
|
toni@1111
|
8 |
*
|
toni@1111
|
9 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
toni@1111
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
toni@1111
|
11 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
toni@1111
|
12 |
* details.
|
toni@1111
|
13 |
*
|
toni@1111
|
14 |
* You should have received a copy of the GNU General Public License along with
|
toni@1111
|
15 |
* this program. Look for COPYING file in the top folder. If not, see
|
toni@1111
|
16 |
* http://opensource.org/licenses/GPL-2.0.
|
toni@521
|
17 |
*/
|
toni@1109
|
18 |
package net.java.html.canvas;
|
toni@521
|
19 |
|
toni@1128
|
20 |
import java.awt.Dimension;
|
toni@521
|
21 |
|
toni@521
|
22 |
/**
|
toni@521
|
23 |
*
|
toni@1109
|
24 |
* @author antonepple
|
toni@521
|
25 |
*/
|
toni@1128
|
26 |
public final class GraphicsContext {
|
toni@1128
|
27 |
|
toni@1128
|
28 |
GraphicsEnvironment graphicsEnvironmentImpl;
|
toni@1128
|
29 |
|
toni@1128
|
30 |
public GraphicsContext(GraphicsEnvironment graphicsEnvironment) {
|
toni@1128
|
31 |
this.graphicsEnvironmentImpl = graphicsEnvironment;
|
toni@1128
|
32 |
}
|
toni@521
|
33 |
|
toni@1111
|
34 |
public void arc(double centerX,
|
toni@1111
|
35 |
double centerY,
|
toni@1111
|
36 |
double startAngle,
|
toni@1111
|
37 |
double radius,
|
toni@1111
|
38 |
double endAngle,
|
toni@1128
|
39 |
boolean ccw) {
|
toni@1128
|
40 |
graphicsEnvironmentImpl.arc(centerX, centerY, startAngle, radius, endAngle, ccw);
|
toni@1128
|
41 |
}
|
toni@521
|
42 |
|
toni@1111
|
43 |
public void arcTo(double x1,
|
toni@1111
|
44 |
double y1,
|
toni@1111
|
45 |
double x2,
|
toni@1111
|
46 |
double y2,
|
toni@1128
|
47 |
double r) {
|
toni@1128
|
48 |
graphicsEnvironmentImpl.arcTo(x1, y1, x2, y2, r);
|
toni@1128
|
49 |
}
|
toni@521
|
50 |
|
toni@1128
|
51 |
public boolean isPointInPath(double x, double y) {
|
toni@1128
|
52 |
return graphicsEnvironmentImpl.isPointInPath(x, y);
|
toni@1128
|
53 |
}
|
toni@521
|
54 |
|
toni@1128
|
55 |
public void fill() {
|
toni@1128
|
56 |
graphicsEnvironmentImpl.fill();
|
toni@1128
|
57 |
}
|
toni@521
|
58 |
|
toni@1128
|
59 |
public void stroke() {
|
toni@1128
|
60 |
graphicsEnvironmentImpl.stroke();
|
toni@1128
|
61 |
}
|
toni@1109
|
62 |
|
toni@1128
|
63 |
public void beginPath() {
|
toni@1128
|
64 |
graphicsEnvironmentImpl.beginPath();
|
toni@1128
|
65 |
}
|
toni@1109
|
66 |
|
toni@1128
|
67 |
public void closePath(){
|
toni@1128
|
68 |
graphicsEnvironmentImpl.closePath();
|
toni@1128
|
69 |
}
|
toni@521
|
70 |
|
toni@1128
|
71 |
public void clip(){
|
toni@1128
|
72 |
graphicsEnvironmentImpl.clip();
|
toni@1128
|
73 |
}
|
toni@1109
|
74 |
|
toni@1128
|
75 |
public void moveTo(double x, double y){
|
toni@1128
|
76 |
graphicsEnvironmentImpl.moveTo(x, y);
|
toni@1128
|
77 |
}
|
toni@1109
|
78 |
|
toni@1128
|
79 |
public void lineTo(double x, double y){
|
toni@1128
|
80 |
graphicsEnvironmentImpl.lineTo(x, y);
|
toni@1128
|
81 |
}
|
toni@1109
|
82 |
|
toni@1128
|
83 |
public void quadraticCurveTo(double cpx, double cpy, double x, double y){
|
toni@1128
|
84 |
graphicsEnvironmentImpl.quadraticCurveTo(cpx, cpy, x, y);
|
toni@1128
|
85 |
}
|
toni@1109
|
86 |
|
toni@1128
|
87 |
public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y){
|
toni@1128
|
88 |
graphicsEnvironmentImpl.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
toni@1128
|
89 |
}
|
toni@1109
|
90 |
|
toni@1128
|
91 |
public void fillRect(double x, double y, double width, double height){
|
toni@1128
|
92 |
graphicsEnvironmentImpl.fillRect(x, y, width, height);
|
toni@1128
|
93 |
}
|
toni@1109
|
94 |
|
toni@1128
|
95 |
public void strokeRect(double x, double y, double width, double height){
|
toni@1128
|
96 |
graphicsEnvironmentImpl.strokeRect(x, y, width, height);
|
toni@1128
|
97 |
}
|
toni@1109
|
98 |
|
toni@1128
|
99 |
public void clearRect(double x, double y, double width, double height){
|
toni@1128
|
100 |
graphicsEnvironmentImpl.clearRect(x, y, width, height);
|
toni@1128
|
101 |
}
|
toni@1109
|
102 |
|
toni@1128
|
103 |
public void rect(double x, double y, double width, double height){
|
toni@1128
|
104 |
graphicsEnvironmentImpl.rect(x, y, width, height);
|
toni@1128
|
105 |
}
|
toni@1109
|
106 |
|
toni@1128
|
107 |
public void save(){
|
toni@1128
|
108 |
graphicsEnvironmentImpl.save();
|
toni@1128
|
109 |
}
|
toni@1109
|
110 |
|
toni@1128
|
111 |
public void restore(){
|
toni@1128
|
112 |
graphicsEnvironmentImpl.restore();
|
toni@1128
|
113 |
}
|
toni@1109
|
114 |
|
toni@1128
|
115 |
public void rotate(double angle){
|
toni@1128
|
116 |
graphicsEnvironmentImpl.rotate(angle);
|
toni@1128
|
117 |
}
|
toni@1109
|
118 |
|
toni@1128
|
119 |
public void transform(double a, double b, double c, double d, double e, double f){
|
toni@1128
|
120 |
graphicsEnvironmentImpl.transform(a, b, c, d, e, f);
|
toni@1128
|
121 |
}
|
toni@1109
|
122 |
|
toni@1128
|
123 |
public void setTransform(double a, double b, double c, double d, double e, double f){
|
toni@1128
|
124 |
graphicsEnvironmentImpl.setTransform(a, b, c, d, e, f);
|
toni@1128
|
125 |
}
|
toni@1109
|
126 |
|
toni@1128
|
127 |
public void translate(double x, double y){
|
toni@1128
|
128 |
graphicsEnvironmentImpl.translate(x, y);
|
toni@1128
|
129 |
}
|
toni@1109
|
130 |
|
toni@1128
|
131 |
public void scale(double x, double y){
|
toni@1128
|
132 |
graphicsEnvironmentImpl.scale(x, y);
|
toni@1128
|
133 |
}
|
toni@1109
|
134 |
|
toni@1132
|
135 |
public void drawImage(Image image, double x, double y){
|
toni@1128
|
136 |
graphicsEnvironmentImpl.drawImage(image, x, y);
|
toni@1128
|
137 |
}
|
toni@1109
|
138 |
|
toni@1132
|
139 |
public void drawImage(Image image, double x, double y, double width, double height){
|
toni@1128
|
140 |
graphicsEnvironmentImpl.drawImage(image, x, y, width, height);
|
toni@1128
|
141 |
}
|
toni@1109
|
142 |
|
toni@1132
|
143 |
public void drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height){
|
toni@1128
|
144 |
graphicsEnvironmentImpl.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
|
toni@1128
|
145 |
}
|
toni@1109
|
146 |
|
toni@1128
|
147 |
public void setFillStyle(String style){
|
toni@1128
|
148 |
graphicsEnvironmentImpl.setFillStyle(style);
|
toni@1128
|
149 |
}
|
toni@1109
|
150 |
|
toni@1128
|
151 |
public String getFillStyle(){
|
toni@1128
|
152 |
return graphicsEnvironmentImpl.getFillStyle();
|
toni@1128
|
153 |
}
|
toni@1109
|
154 |
|
toni@1128
|
155 |
public void setStrokeStyle(String style){
|
toni@1128
|
156 |
graphicsEnvironmentImpl.setStrokeStyle(style);
|
toni@1128
|
157 |
}
|
toni@1109
|
158 |
|
toni@1128
|
159 |
public void setShadowColor(String color){
|
toni@1128
|
160 |
graphicsEnvironmentImpl.setShadowColor(color);
|
toni@1128
|
161 |
}
|
toni@1109
|
162 |
|
toni@1128
|
163 |
public void setShadowBlur(double blur){
|
toni@1128
|
164 |
graphicsEnvironmentImpl.setShadowBlur(blur);
|
toni@1128
|
165 |
}
|
toni@1109
|
166 |
|
toni@1128
|
167 |
public void setShadowOffsetX(double x){
|
toni@1128
|
168 |
graphicsEnvironmentImpl.setShadowOffsetX(x);
|
toni@1128
|
169 |
}
|
toni@1109
|
170 |
|
toni@1128
|
171 |
public void setShadowOffsetY(double y){
|
toni@1128
|
172 |
graphicsEnvironmentImpl.setShadowOffsetY(y);
|
toni@1128
|
173 |
}
|
toni@1109
|
174 |
|
toni@1128
|
175 |
public String getStrokeStyle(){
|
toni@1128
|
176 |
return graphicsEnvironmentImpl.getStrokeStyle();
|
toni@1128
|
177 |
}
|
toni@1109
|
178 |
|
toni@1128
|
179 |
public String getShadowColor(){
|
toni@1128
|
180 |
return graphicsEnvironmentImpl.getShadowColor();
|
toni@1128
|
181 |
}
|
toni@1109
|
182 |
|
toni@1128
|
183 |
public double getShadowBlur(){
|
toni@1128
|
184 |
return graphicsEnvironmentImpl.getShadowBlur();
|
toni@1128
|
185 |
}
|
toni@1109
|
186 |
|
toni@1128
|
187 |
public double getShadowOffsetX(){
|
toni@1128
|
188 |
return graphicsEnvironmentImpl.getShadowOffsetX();
|
toni@1128
|
189 |
}
|
toni@1109
|
190 |
|
toni@1128
|
191 |
public double getShadowOffsetY(){
|
toni@1128
|
192 |
return graphicsEnvironmentImpl.getShadowOffsetY();
|
toni@1128
|
193 |
}
|
toni@1109
|
194 |
|
toni@1128
|
195 |
public String getLineCap(){
|
toni@1128
|
196 |
return graphicsEnvironmentImpl.getLineCap();
|
toni@1128
|
197 |
}
|
toni@1109
|
198 |
|
toni@1128
|
199 |
public void setLineCap(String style){
|
toni@1128
|
200 |
graphicsEnvironmentImpl.setLineCap(style);
|
toni@1128
|
201 |
}
|
toni@1109
|
202 |
|
toni@1128
|
203 |
public String getLineJoin(){
|
toni@1128
|
204 |
return graphicsEnvironmentImpl.getLineJoin();
|
toni@1128
|
205 |
}
|
toni@1109
|
206 |
|
toni@1128
|
207 |
public void setLineJoin(String style){
|
toni@1128
|
208 |
graphicsEnvironmentImpl.setLineJoin(style);
|
toni@1128
|
209 |
}
|
toni@1109
|
210 |
|
toni@1128
|
211 |
public double getLineWidth(){
|
toni@1128
|
212 |
return graphicsEnvironmentImpl.getLineWidth();
|
toni@1128
|
213 |
}
|
toni@1109
|
214 |
|
toni@1128
|
215 |
public void setLineWidth(double width){
|
toni@1128
|
216 |
graphicsEnvironmentImpl.setLineWidth(width);
|
toni@1128
|
217 |
}
|
toni@1109
|
218 |
|
toni@1128
|
219 |
public double getMiterLimit(){
|
toni@1128
|
220 |
return graphicsEnvironmentImpl.getMiterLimit();
|
toni@1128
|
221 |
}
|
toni@1109
|
222 |
|
toni@1128
|
223 |
public void setMiterLimit(double limit){
|
toni@1128
|
224 |
graphicsEnvironmentImpl.setMiterLimit(limit);
|
toni@1128
|
225 |
}
|
toni@1109
|
226 |
|
toni@1128
|
227 |
public String getFont(){
|
toni@1128
|
228 |
return graphicsEnvironmentImpl.getFont();
|
toni@1128
|
229 |
}
|
toni@1109
|
230 |
|
toni@1128
|
231 |
public void setFont(String font){
|
toni@1128
|
232 |
graphicsEnvironmentImpl.setFont(font);
|
toni@1128
|
233 |
}
|
toni@1109
|
234 |
|
toni@1128
|
235 |
public String getTextAlign(){
|
toni@1128
|
236 |
return graphicsEnvironmentImpl.getTextAlign();
|
toni@1128
|
237 |
}
|
toni@521
|
238 |
|
toni@1128
|
239 |
public void setTextAlign(String textAlign){
|
toni@1128
|
240 |
graphicsEnvironmentImpl.setTextAlign(textAlign);
|
toni@1128
|
241 |
}
|
toni@521
|
242 |
|
toni@1128
|
243 |
public String getTextBaseline(){
|
toni@1128
|
244 |
return graphicsEnvironmentImpl.getTextBaseline();
|
toni@1128
|
245 |
}
|
toni@521
|
246 |
|
toni@1128
|
247 |
public void setTextBaseline(String textbaseline){
|
toni@1128
|
248 |
graphicsEnvironmentImpl.setTextBaseline(textbaseline);
|
toni@1128
|
249 |
}
|
toni@521
|
250 |
|
toni@1128
|
251 |
public void fillText(String text, double x, double y){
|
toni@1128
|
252 |
graphicsEnvironmentImpl.fillText(text, x, y);
|
toni@1128
|
253 |
}
|
toni@521
|
254 |
|
toni@1128
|
255 |
public void fillText(String text, double x, double y, double maxWidth){
|
toni@1128
|
256 |
graphicsEnvironmentImpl.fillText(text, x, y, maxWidth);
|
toni@1128
|
257 |
}
|
toni@521
|
258 |
|
toni@1128
|
259 |
public Dimension measureText(String text){
|
toni@1128
|
260 |
return graphicsEnvironmentImpl.measureText(text);
|
toni@1128
|
261 |
}
|
toni@1111
|
262 |
|
toni@1128
|
263 |
public void strokeText(String text, double x, double y){
|
toni@1128
|
264 |
graphicsEnvironmentImpl.strokeText(text, x, y);
|
toni@1128
|
265 |
}
|
toni@1111
|
266 |
|
toni@1128
|
267 |
public void strokeText(String text, double x, double y, double maxWidth){
|
toni@1128
|
268 |
graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth);
|
toni@1128
|
269 |
}
|
toni@1111
|
270 |
|
toni@1132
|
271 |
public Image createImageData(double x, double y){
|
toni@1128
|
272 |
return graphicsEnvironmentImpl.createImageData(x, y);
|
toni@1128
|
273 |
}
|
toni@1111
|
274 |
|
toni@1132
|
275 |
public Image createImageData(Image imageData){
|
toni@1128
|
276 |
return graphicsEnvironmentImpl.createImageData(imageData);
|
toni@1128
|
277 |
}
|
toni@1111
|
278 |
|
toni@1132
|
279 |
public Image getImageData(double x, double y, double width, double height){
|
toni@1128
|
280 |
return graphicsEnvironmentImpl.getImageData(x, y, width, height);
|
toni@1128
|
281 |
}
|
toni@1111
|
282 |
|
toni@1132
|
283 |
public void putImageData(Image imageData, double x, double y){
|
toni@1128
|
284 |
graphicsEnvironmentImpl.putImageData(imageData, x, y);
|
toni@1128
|
285 |
}
|
toni@1111
|
286 |
|
toni@1132
|
287 |
public void putImageData(Image imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight){
|
toni@1128
|
288 |
graphicsEnvironmentImpl.putImageData(imageData, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
|
toni@1128
|
289 |
}
|
toni@1111
|
290 |
|
toni@1128
|
291 |
public void setGlobalAlpha(double alpha){
|
toni@1128
|
292 |
graphicsEnvironmentImpl.setGlobalAlpha(alpha);
|
toni@1128
|
293 |
}
|
toni@1111
|
294 |
|
toni@1128
|
295 |
public double getGlobalAlpha(){
|
toni@1128
|
296 |
return graphicsEnvironmentImpl.getGlobalAlpha();
|
toni@1128
|
297 |
}
|
toni@1111
|
298 |
|
toni@1128
|
299 |
public void setGlobalCompositeOperation(String operation){
|
toni@1128
|
300 |
graphicsEnvironmentImpl.setGlobalCompositeOperation(operation);
|
toni@1128
|
301 |
}
|
toni@1111
|
302 |
|
toni@1128
|
303 |
public String getGlobalCompositeOperation(){
|
toni@1128
|
304 |
return graphicsEnvironmentImpl.getGlobalCompositeOperation();
|
toni@1128
|
305 |
}
|
toni@1111
|
306 |
|
toni@1128
|
307 |
public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1){
|
toni@1131
|
308 |
return new LinearGradient(x0, y0, x1, y1);
|
toni@1128
|
309 |
}
|
toni@1111
|
310 |
|
toni@1132
|
311 |
public Pattern createPattern(Image image, String repeat){
|
toni@1131
|
312 |
return new Pattern(image, repeat);
|
toni@1128
|
313 |
}
|
toni@1111
|
314 |
|
toni@1128
|
315 |
public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1){
|
toni@1131
|
316 |
return new RadialGradient(x0, y0, r0, x1, y1, r1);
|
toni@1128
|
317 |
}
|
toni@1111
|
318 |
|
toni@1132
|
319 |
public Image getImageDataForPath(String path){
|
toni@1130
|
320 |
return graphicsEnvironmentImpl.getImageDataForPath(path);
|
toni@1128
|
321 |
}
|
toni@1111
|
322 |
|
toni@1128
|
323 |
public int getHeight(){
|
toni@1128
|
324 |
return graphicsEnvironmentImpl.getHeight();
|
toni@1128
|
325 |
}
|
toni@1111
|
326 |
|
toni@1128
|
327 |
public int getWidth(){
|
toni@1128
|
328 |
return graphicsEnvironmentImpl.getWidth();
|
toni@1128
|
329 |
}
|
toni@1111
|
330 |
|
toni@1128
|
331 |
public void setHeight(int height){
|
toni@1128
|
332 |
graphicsEnvironmentImpl.setHeight(height);
|
toni@1128
|
333 |
}
|
toni@1128
|
334 |
|
toni@1128
|
335 |
public void setWidth(int width){
|
toni@1128
|
336 |
graphicsEnvironmentImpl.setWidth(width);
|
toni@1128
|
337 |
}
|
toni@521
|
338 |
}
|