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@1112
|
18 |
package org.apidesign.bck2brwsr.htmlpage.api;
|
toni@521
|
19 |
|
toni@1112
|
20 |
import net.java.html.canvas.GraphicsContext;
|
toni@1112
|
21 |
import net.java.html.canvas.Image;
|
toni@1112
|
22 |
import net.java.html.canvas.ImageData;
|
toni@1112
|
23 |
import net.java.html.canvas.LinearGradient;
|
toni@1112
|
24 |
import net.java.html.canvas.Pattern;
|
toni@1112
|
25 |
import net.java.html.canvas.RadialGradient;
|
toni@1112
|
26 |
import net.java.html.canvas.TextMetrics;
|
toni@521
|
27 |
import org.apidesign.bck2brwsr.core.JavaScriptBody;
|
toni@521
|
28 |
|
toni@521
|
29 |
/**
|
toni@521
|
30 |
*
|
toni@1112
|
31 |
* @author Anton Epple <toni.epple@eppleton.de>
|
toni@521
|
32 |
*/
|
toni@1112
|
33 |
public class HTML5GraphicsContext implements GraphicsContext {
|
toni@521
|
34 |
|
toni@1112
|
35 |
Object context;
|
toni@1112
|
36 |
|
toni@1112
|
37 |
HTML5GraphicsContext(Object contextImpl) {
|
toni@1112
|
38 |
this.context = contextImpl;
|
toni@1112
|
39 |
}
|
toni@1112
|
40 |
|
toni@1112
|
41 |
@JavaScriptBody(args = {"centerx", "centery", "radius", "startangle", "endangle", "ccw"},
|
toni@1112
|
42 |
body = "this._context().arc(centerx,centery, radius, startangle, endangle,ccw);")
|
toni@1112
|
43 |
@Override
|
toni@1112
|
44 |
public native void arc(double centerX,
|
toni@1111
|
45 |
double centerY,
|
toni@1111
|
46 |
double startAngle,
|
toni@1111
|
47 |
double radius,
|
toni@1111
|
48 |
double endAngle,
|
toni@1111
|
49 |
boolean ccw);
|
toni@521
|
50 |
|
toni@1112
|
51 |
@JavaScriptBody(args = {"x1", "y1", "x2", "y2", "r"},
|
toni@1112
|
52 |
body = "this._context().arcTo(x1,y1,x2,y2,r);")
|
toni@1112
|
53 |
@Override
|
toni@1112
|
54 |
public native void arcTo(double x1,
|
toni@1111
|
55 |
double y1,
|
toni@1111
|
56 |
double x2,
|
toni@1111
|
57 |
double y2,
|
toni@1111
|
58 |
double r);
|
toni@521
|
59 |
|
toni@1112
|
60 |
@JavaScriptBody(args = {"x", "y"},
|
toni@1112
|
61 |
body = "return this._context().isPointInPath(x,y);")
|
toni@1112
|
62 |
@Override
|
toni@1112
|
63 |
public native boolean isPointInPath(double x, double y);
|
toni@521
|
64 |
|
toni@1112
|
65 |
@JavaScriptBody(args = {}, body = "this._context().fill();")
|
toni@1112
|
66 |
@Override
|
toni@1112
|
67 |
public native void fill();
|
toni@521
|
68 |
|
toni@1112
|
69 |
@JavaScriptBody(args = {}, body = "this._context().stroke();")
|
toni@1112
|
70 |
@Override
|
toni@1112
|
71 |
public native void stroke();
|
toni@1109
|
72 |
|
toni@1112
|
73 |
@JavaScriptBody(args = {}, body = "this._context().beginPath();")
|
toni@1112
|
74 |
@Override
|
toni@1112
|
75 |
public native void beginPath();
|
toni@1109
|
76 |
|
toni@1112
|
77 |
@JavaScriptBody(args = {}, body = "this._context().closePath();")
|
toni@1112
|
78 |
@Override
|
toni@1112
|
79 |
public native void closePath();
|
toni@521
|
80 |
|
toni@1112
|
81 |
@JavaScriptBody(args = {}, body = "this._context().clip();")
|
toni@1112
|
82 |
@Override
|
toni@1112
|
83 |
public native void clip();
|
toni@1109
|
84 |
|
toni@1112
|
85 |
@JavaScriptBody(args = {"x", "y"}, body = "this._context().moveTo(x,y);")
|
toni@1112
|
86 |
@Override
|
toni@1112
|
87 |
public native void moveTo(double x, double y);
|
toni@1109
|
88 |
|
toni@1112
|
89 |
@JavaScriptBody(args = {"x", "y"}, body = "this._context().lineTo(x,y);")
|
toni@1112
|
90 |
@Override
|
toni@1112
|
91 |
public native void lineTo(double x, double y);
|
toni@1109
|
92 |
|
toni@1112
|
93 |
@JavaScriptBody(args = {"cpx", "cpy", "x", "y"}, body = "this._context().quadraticCurveTo(cpx,cpy,x,y);")
|
toni@1112
|
94 |
@Override
|
toni@1112
|
95 |
public native void quadraticCurveTo(double cpx, double cpy, double x, double y);
|
toni@1109
|
96 |
|
toni@1112
|
97 |
@JavaScriptBody(args = {"cp1x", "cp1y", "cp2x", "cp2y", "x", "y"},
|
toni@1112
|
98 |
body = "this._context().bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y);")
|
toni@1112
|
99 |
@Override
|
toni@1112
|
100 |
public native void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
|
toni@1109
|
101 |
|
toni@1112
|
102 |
@JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().fillRect(x,y,width,height);")
|
toni@1112
|
103 |
@Override
|
toni@1112
|
104 |
public native void fillRect(double x, double y, double width, double height);
|
toni@1109
|
105 |
|
toni@1112
|
106 |
@JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().strokeRect(x,y,width,height);")
|
toni@1112
|
107 |
@Override
|
toni@1112
|
108 |
public native void strokeRect(double x, double y, double width, double height);
|
toni@1109
|
109 |
|
toni@1112
|
110 |
@JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().clearRect(x,y,width,height);")
|
toni@1112
|
111 |
@Override
|
toni@1112
|
112 |
public native void clearRect(double x, double y, double width, double height);
|
toni@1109
|
113 |
|
toni@1112
|
114 |
@JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().rectect(x,y,width,height);")
|
toni@1112
|
115 |
@Override
|
toni@1112
|
116 |
public native void rect(double x, double y, double width, double height);
|
toni@1109
|
117 |
|
toni@1112
|
118 |
@JavaScriptBody(args = {}, body = "this._context().save();")
|
toni@1112
|
119 |
@Override
|
toni@1112
|
120 |
public native void save();
|
toni@1109
|
121 |
|
toni@1112
|
122 |
@JavaScriptBody(args = {}, body = "this._context().restore();")
|
toni@1112
|
123 |
@Override
|
toni@1112
|
124 |
public native void restore();
|
toni@1109
|
125 |
|
toni@1112
|
126 |
@JavaScriptBody(args = {"angle"}, body = "this._context().rotate(angle);")
|
toni@1112
|
127 |
@Override
|
toni@1112
|
128 |
public native void rotate(double angle);
|
toni@1109
|
129 |
|
toni@1112
|
130 |
@JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().transform(a,b,c,d,e,f);")
|
toni@1112
|
131 |
@Override
|
toni@1112
|
132 |
public native void transform(double a, double b, double c, double d, double e, double f);
|
toni@1109
|
133 |
|
toni@1112
|
134 |
@JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().setTransform(a,b,c,d,e,f);")
|
toni@1112
|
135 |
@Override
|
toni@1112
|
136 |
public native void setTransform(double a, double b, double c, double d, double e, double f);
|
toni@1109
|
137 |
|
toni@1112
|
138 |
@JavaScriptBody(args = {"x", "y"}, body = "this._context().translate(x,y);")
|
toni@1112
|
139 |
@Override
|
toni@1112
|
140 |
public native void translate(double x, double y);
|
toni@1109
|
141 |
|
toni@1112
|
142 |
@JavaScriptBody(args = {"x", "y"}, body = "this._context().scale(x,y);")
|
toni@1112
|
143 |
@Override
|
toni@1112
|
144 |
public native void scale(double x, double y);
|
toni@1109
|
145 |
|
toni@1112
|
146 |
@Override
|
toni@1112
|
147 |
public void drawImage(Image image, double x, double y) {
|
toni@1112
|
148 |
drawImageImpl(context, Element.getElementById((HTML5Image)image), x, y);
|
toni@1112
|
149 |
}
|
toni@1109
|
150 |
|
toni@1112
|
151 |
@Override
|
toni@1112
|
152 |
public void drawImage(Image image, double x, double y, double width, double height) {
|
toni@1112
|
153 |
drawImageImpl(context, Element.getElementById((HTML5Image)image), x, y, width, height);
|
toni@1112
|
154 |
}
|
toni@1109
|
155 |
|
toni@1112
|
156 |
@Override
|
toni@1112
|
157 |
public void drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) {
|
toni@1112
|
158 |
drawImageImpl(context, Element.getElementById((HTML5Image)image), sx, sy, sWidth, sHeight, x, y, width, height);
|
toni@1112
|
159 |
}
|
toni@1109
|
160 |
|
toni@1112
|
161 |
@JavaScriptBody(args = {"ctx", "img", "x", "y", "width", "height"}, body = "ctx.drawImage(img,x,y,width,height);")
|
toni@1112
|
162 |
private native static void drawImageImpl(Object ctx, Object img, double x, double y, double width, double height);
|
toni@1109
|
163 |
|
toni@1112
|
164 |
@JavaScriptBody(args = {"ctx", "img", "sx", "sy", "swidth", "sheight", "x", "y", "width", "height"}, body = "ctx.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);")
|
toni@1112
|
165 |
private native static void drawImageImpl(Object ctx, Object img, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height);
|
toni@1109
|
166 |
|
toni@1112
|
167 |
@JavaScriptBody(args = {"ctx", "img", "x", "y"}, body = "ctx.drawImage(img,x,y);")
|
toni@1112
|
168 |
private native static void drawImageImpl(Object ctx, Object img, double x, double y);
|
toni@1109
|
169 |
|
toni@1112
|
170 |
@JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style.valueOf();")
|
toni@1112
|
171 |
@Override
|
toni@1112
|
172 |
public native void setFillStyle(String style);
|
toni@1109
|
173 |
|
toni@1112
|
174 |
@JavaScriptBody(args = {}, body = "return this._context().fillStyle;")
|
toni@1112
|
175 |
@Override
|
toni@1112
|
176 |
public native String getFillStyle();
|
toni@1109
|
177 |
|
toni@1112
|
178 |
@Override
|
toni@1112
|
179 |
public void setFillStyle(LinearGradient style) {
|
toni@1112
|
180 |
setFillStyleImpl(context, ((HTML5LinearGradient)style).object());
|
toni@1112
|
181 |
}
|
toni@1109
|
182 |
|
toni@1112
|
183 |
@Override
|
toni@1112
|
184 |
public void setFillStyle(RadialGradient style) {
|
toni@1112
|
185 |
setFillStyleImpl(context, ((HTML5RadialGradient)style).object());
|
toni@1112
|
186 |
}
|
toni@1109
|
187 |
|
toni@1112
|
188 |
@Override
|
toni@1112
|
189 |
public void setFillStyle(Pattern style) {
|
toni@1112
|
190 |
setFillStyleImpl(context, ((HTML5Pattern)style).object());
|
toni@1112
|
191 |
}
|
toni@1109
|
192 |
|
toni@1112
|
193 |
@JavaScriptBody(args = {"context", "obj"}, body = "context.fillStyle=obj;")
|
toni@1112
|
194 |
private native void setFillStyleImpl(Object context, Object obj);
|
toni@1109
|
195 |
|
toni@1112
|
196 |
@JavaScriptBody(args = {"style"}, body = "this._context().strokeStyle=style.valueOf();")
|
toni@1112
|
197 |
@Override
|
toni@1112
|
198 |
public native void setStrokeStyle(String style);
|
toni@1109
|
199 |
|
toni@1112
|
200 |
@Override
|
toni@1112
|
201 |
public void setStrokeStyle(LinearGradient style) {
|
toni@1112
|
202 |
setStrokeStyleImpl(context, ((HTML5LinearGradient)style).object());
|
toni@1112
|
203 |
}
|
toni@1109
|
204 |
|
toni@1117
|
205 |
@Override
|
toni@1112
|
206 |
public void setStrokeStyle(RadialGradient style) {
|
toni@1112
|
207 |
setStrokeStyleImpl(context, ((HTML5RadialGradient)style).object());
|
toni@1112
|
208 |
}
|
toni@1109
|
209 |
|
toni@1112
|
210 |
@JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style;")
|
toni@1112
|
211 |
@Override
|
toni@1112
|
212 |
public void setStrokeStyle(Pattern style) {
|
toni@1112
|
213 |
setStrokeStyleImpl(context, ((HTML5LinearGradient)style).object());
|
toni@1112
|
214 |
}
|
toni@1109
|
215 |
|
toni@1112
|
216 |
@JavaScriptBody(args = {"context", "obj"}, body = "context.strokeStyle=obj;")
|
toni@1112
|
217 |
private native void setStrokeStyleImpl(Object context, Object obj);
|
toni@1109
|
218 |
|
toni@1112
|
219 |
@JavaScriptBody(args = {"color"}, body = "this._context().shadowColor=color.valueOf();")
|
toni@1112
|
220 |
@Override
|
toni@1112
|
221 |
public native void setShadowColor(String color);
|
toni@1109
|
222 |
|
toni@1112
|
223 |
@JavaScriptBody(args = {"blur"}, body = "this._context().shadowBlur=blur;")
|
toni@1112
|
224 |
@Override
|
toni@1112
|
225 |
public native void setShadowBlur(double blur);
|
toni@1109
|
226 |
|
toni@1112
|
227 |
@JavaScriptBody(args = {"x"}, body = "this._context().shadowOffsetX=x;")
|
toni@1112
|
228 |
@Override
|
toni@1112
|
229 |
public native void setShadowOffsetX(double x);
|
toni@1109
|
230 |
|
toni@1112
|
231 |
@JavaScriptBody(args = {"y"}, body = "this._context().shadowOffsetY=y;")
|
toni@1112
|
232 |
@Override
|
toni@1112
|
233 |
public native void setShadowOffsetY(double y);
|
toni@1109
|
234 |
|
toni@1112
|
235 |
@JavaScriptBody(args = {}, body = "return this._context().strokeStyle;")
|
toni@1112
|
236 |
@Override
|
toni@1112
|
237 |
public native String getStrokeStyle();
|
toni@1109
|
238 |
|
toni@1112
|
239 |
@JavaScriptBody(args = {}, body = "return this._context().shadowColor;")
|
toni@1112
|
240 |
@Override
|
toni@1112
|
241 |
public native String getShadowColor();
|
toni@1109
|
242 |
|
toni@1112
|
243 |
@JavaScriptBody(args = {}, body = "return this._context().shadowBlur;")
|
toni@1112
|
244 |
@Override
|
toni@1112
|
245 |
public native double getShadowBlur();
|
toni@1109
|
246 |
|
toni@1112
|
247 |
@JavaScriptBody(args = {}, body = "return this._context().shadowOffsetX;")
|
toni@1112
|
248 |
@Override
|
toni@1112
|
249 |
public native double getShadowOffsetX();
|
toni@1109
|
250 |
|
toni@1112
|
251 |
@JavaScriptBody(args = {}, body = "return this._context().shadowOffsetY;")
|
toni@1112
|
252 |
@Override
|
toni@1112
|
253 |
public native double getShadowOffsetY();
|
toni@1109
|
254 |
|
toni@1112
|
255 |
@JavaScriptBody(args = {}, body = "return this._context().lineCap;")
|
toni@1112
|
256 |
@Override
|
toni@1112
|
257 |
public native String getLineCap();
|
toni@1109
|
258 |
|
toni@1112
|
259 |
@JavaScriptBody(args = {"style"}, body = "this._context().lineCap=style.valueOf();")
|
toni@1112
|
260 |
@Override
|
toni@1112
|
261 |
public native void setLineCap(String style);
|
toni@521
|
262 |
|
toni@1112
|
263 |
@JavaScriptBody(args = {}, body = "return this._context().lineJoin;")
|
toni@1112
|
264 |
@Override
|
toni@1112
|
265 |
public native String getLineJoin();
|
toni@521
|
266 |
|
toni@1112
|
267 |
@JavaScriptBody(args = {"style"}, body = "this._context().lineJoin=style.valueOf();")
|
toni@1112
|
268 |
@Override
|
toni@1112
|
269 |
public native void setLineJoin(String style);
|
toni@521
|
270 |
|
toni@1112
|
271 |
@JavaScriptBody(args = {}, body = "return this._context().lineWidth;")
|
toni@1112
|
272 |
@Override
|
toni@1112
|
273 |
public native double getLineWidth();
|
toni@521
|
274 |
|
toni@1112
|
275 |
@JavaScriptBody(args = {"width"}, body = "this._context().lineWidth=width;")
|
toni@1112
|
276 |
@Override
|
toni@1112
|
277 |
public native void setLineWidth(double width);
|
toni@521
|
278 |
|
toni@1112
|
279 |
@JavaScriptBody(args = {}, body = "return this._context().miterLimit;")
|
toni@1112
|
280 |
@Override
|
toni@1112
|
281 |
public native double getMiterLimit();
|
toni@521
|
282 |
|
toni@1112
|
283 |
@JavaScriptBody(args = {"limit"}, body = "this._context().miterLimit=limit;")
|
toni@1112
|
284 |
@Override
|
toni@1112
|
285 |
public native void setMiterLimit(double limit);
|
toni@1111
|
286 |
|
toni@1112
|
287 |
@JavaScriptBody(args = {}, body = "return this._context().font;")
|
toni@1112
|
288 |
@Override
|
toni@1112
|
289 |
public native String getFont();
|
toni@1111
|
290 |
|
toni@1112
|
291 |
@JavaScriptBody(args = {"font"}, body = "this._context().font=font.valueOf();")
|
toni@1112
|
292 |
@Override
|
toni@1112
|
293 |
public native void setFont(String font);
|
toni@1111
|
294 |
|
toni@1112
|
295 |
@JavaScriptBody(args = {}, body = "return this._context().textAlign;")
|
toni@1112
|
296 |
@Override
|
toni@1112
|
297 |
public native String getTextAlign();
|
toni@1111
|
298 |
|
toni@1112
|
299 |
@JavaScriptBody(args = {"textalign"}, body = "this._context().textAlign=textalign.valueOf();")
|
toni@1112
|
300 |
@Override
|
toni@1112
|
301 |
public native void setTextAlign(String textAlign);
|
toni@1111
|
302 |
|
toni@1112
|
303 |
@JavaScriptBody(args = {}, body = "return this._context().textBaseline;")
|
toni@1112
|
304 |
@Override
|
toni@1112
|
305 |
public native String getTextBaseline();
|
toni@1111
|
306 |
|
toni@1112
|
307 |
@JavaScriptBody(args = {"textbaseline"}, body = "this._context().textBaseline=textbaseline.valueOf();")
|
toni@1112
|
308 |
@Override
|
toni@1112
|
309 |
public native void setTextBaseline(String textbaseline);
|
toni@1111
|
310 |
|
toni@1112
|
311 |
@JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().fillText(text,x,y);")
|
toni@1112
|
312 |
@Override
|
toni@1112
|
313 |
public native void fillText(String text, double x, double y);
|
toni@1111
|
314 |
|
toni@1112
|
315 |
@JavaScriptBody(args = {"text", "x", "y", "maxwidth"}, body = "this._context().fillText(text,x,y,maxwidth);")
|
toni@1112
|
316 |
@Override
|
toni@1112
|
317 |
public void fillText(String text, double x, double y, double maxWidth) {
|
toni@1112
|
318 |
}
|
toni@1111
|
319 |
|
toni@1112
|
320 |
@Override
|
toni@1112
|
321 |
public TextMetrics measureText(String text) {
|
toni@1112
|
322 |
return new HTML5TextMetrics(measureTextImpl(text));
|
toni@1112
|
323 |
}
|
toni@1111
|
324 |
|
toni@1112
|
325 |
@JavaScriptBody(args = {"text"},
|
toni@1112
|
326 |
body = "return this._context().measureText(text);")
|
toni@1112
|
327 |
private native Object measureTextImpl(String text);
|
toni@1111
|
328 |
|
toni@1112
|
329 |
@JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().strokeText(text,x,y);")
|
toni@1112
|
330 |
@Override
|
toni@1112
|
331 |
public native void strokeText(String text, double x, double y);
|
toni@1111
|
332 |
|
toni@1112
|
333 |
@JavaScriptBody(args = {"text", "x", "y", "maxWidth"}, body = "this._context().strokeText(text,x,y,maxWidth);")
|
toni@1112
|
334 |
@Override
|
toni@1112
|
335 |
public native void strokeText(String text, double x, double y, double maxWidth);
|
toni@1111
|
336 |
|
toni@1112
|
337 |
@Override
|
toni@1112
|
338 |
public ImageData createImageData(double x, double y) {
|
toni@1112
|
339 |
return new HTML5ImageData(createImageDataImpl(x, y));
|
toni@1112
|
340 |
}
|
toni@1111
|
341 |
|
toni@1112
|
342 |
@JavaScriptBody(args = {"x", "y"},
|
toni@1112
|
343 |
body = "return this._context().createImageData(x,y);")
|
toni@1112
|
344 |
private native Object createImageDataImpl(double x, double y);
|
toni@1111
|
345 |
|
toni@1112
|
346 |
@Override
|
toni@1112
|
347 |
public ImageData createImageData(ImageData imageData) {
|
toni@1112
|
348 |
return new HTML5ImageData(createImageDataImpl(imageData.getWidth(), imageData.getHeight()));
|
toni@1112
|
349 |
}
|
toni@1111
|
350 |
|
toni@1112
|
351 |
@Override
|
toni@1112
|
352 |
public ImageData getImageData(double x, double y, double width, double height) {
|
toni@1112
|
353 |
return new HTML5ImageData(getImageDataImpl(x, y, width, height));
|
toni@1112
|
354 |
}
|
toni@1111
|
355 |
|
toni@1112
|
356 |
@JavaScriptBody(args = {"x", "y", "width", "height"},
|
toni@1112
|
357 |
body = "return this._context().getImageData(x,y,width,height);")
|
toni@1112
|
358 |
private native Object getImageDataImpl(double x, double y, double width, double height);
|
toni@1111
|
359 |
|
toni@1112
|
360 |
@Override
|
toni@1112
|
361 |
public void putImageData(ImageData imageData, double x, double y) {
|
toni@1112
|
362 |
putImageDataImpl(((HTML5ImageData)imageData).object(), x, y);
|
toni@1112
|
363 |
}
|
toni@1112
|
364 |
|
toni@1112
|
365 |
@JavaScriptBody(args = {"imageData", "x", "y"},
|
toni@1112
|
366 |
body = "this._context().putImageData(imageData,x,y);")
|
toni@1112
|
367 |
private native void putImageDataImpl(Object imageData, double x, double y);
|
toni@1112
|
368 |
|
toni@1112
|
369 |
@Override
|
toni@1112
|
370 |
public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) {
|
toni@1112
|
371 |
putImageDataImpl(((HTML5ImageData)imageData).object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
|
toni@1112
|
372 |
}
|
toni@1112
|
373 |
|
toni@1112
|
374 |
@JavaScriptBody(args = {"imageData", "x", "y", "dirtyx", "dirtyy", "dirtywidth", "dirtyheight"},
|
toni@1112
|
375 |
body = "this._context().putImageData(imageData,x,y, dirtyx, dirtyy, dirtywidth,dirtyheight);")
|
toni@1112
|
376 |
private native void putImageDataImpl(Object imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
|
toni@1112
|
377 |
|
toni@1112
|
378 |
@JavaScriptBody(args = {"alpha"}, body = "this._context().globalAlpha=alpha;")
|
toni@1112
|
379 |
@Override
|
toni@1112
|
380 |
public native void setGlobalAlpha(double alpha);
|
toni@1112
|
381 |
|
toni@1112
|
382 |
@JavaScriptBody(args = {}, body = "return this._context().globalAlpha;")
|
toni@1112
|
383 |
@Override
|
toni@1112
|
384 |
public native double getGlobalAlpha();
|
toni@1112
|
385 |
|
toni@1112
|
386 |
@JavaScriptBody(args = {"operation"}, body = "this._context().globalCompositeOperation=operation.valueOf();")
|
toni@1112
|
387 |
@Override
|
toni@1112
|
388 |
public native void setGlobalCompositeOperation(String operation);
|
toni@1112
|
389 |
|
toni@1112
|
390 |
@JavaScriptBody(args = {}, body = "return this._context().globalCompositeOperation;")
|
toni@1112
|
391 |
@Override
|
toni@1112
|
392 |
public native String getGlobalCompositeOperation();
|
toni@1112
|
393 |
|
toni@1112
|
394 |
@Override
|
toni@1112
|
395 |
public HTML5LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) {
|
toni@1112
|
396 |
return new HTML5LinearGradient(createLinearGradientImpl(context, x0, y0, x1, y1));
|
toni@1112
|
397 |
}
|
toni@1112
|
398 |
|
toni@1112
|
399 |
@JavaScriptBody(args = {"context", "x0", "y0", "x1", "y1"}, body = "return context.createLinearGradient(x0,y0,x1,y1);")
|
toni@1112
|
400 |
private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1);
|
toni@1112
|
401 |
|
toni@1112
|
402 |
@Override
|
toni@1112
|
403 |
public Pattern createPattern(Image image, String repeat) {
|
toni@1112
|
404 |
return new HTML5Pattern(createPatternImpl(context, image, repeat));
|
toni@1112
|
405 |
}
|
toni@1112
|
406 |
|
toni@1112
|
407 |
@JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);")
|
toni@1112
|
408 |
private static native Object createPatternImpl(Object context, Image image, String repeat);
|
toni@1112
|
409 |
|
toni@1112
|
410 |
@Override
|
toni@1112
|
411 |
public HTML5RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) {
|
toni@1112
|
412 |
return new HTML5RadialGradient(createRadialGradientImpl(context, x0, y0, r0, x1, y1, r1));
|
toni@1112
|
413 |
}
|
toni@1112
|
414 |
|
toni@1112
|
415 |
@JavaScriptBody(args = {"context", "x0", "y0", "r0", "x1", "y1", "r1"}, body = "return context.createRadialGradient(x0,y0,r0,x1,y1,r1);")
|
toni@1112
|
416 |
private static native Object createRadialGradientImpl(Object context, double x0, double y0, double r0, double x1, double y1, double r1);
|
toni@1121
|
417 |
|
toni@1121
|
418 |
@Override
|
toni@1121
|
419 |
public Image getImageForPath(String path) {
|
toni@1121
|
420 |
throw new UnsupportedOperationException("getImageForPath is not yet supported");
|
toni@1121
|
421 |
}
|
toni@521
|
422 |
}
|