JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / swingjs / j2s / swingjs / JSGraphics2D.js
1 Clazz.declarePackage ("swingjs");\r
2 Clazz.load (["jssun.java2d.SunGraphics2D"], "swingjs.JSGraphics2D", ["java.util.HashMap", "java.awt.BasicStroke", "$.Rectangle", "$.RenderingHints", "$.Toolkit", "java.awt.geom.AffineTransform", "swingjs.JSToolkit", "swingjs.api.HTML5CanvasContext2D"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.constrainX = 0;\r
5 this.constrainY = 0;\r
6 this.windowWidth = 0;\r
7 this.windowHeight = 0;\r
8 this.canvas = null;\r
9 this.ctx = null;\r
10 this.gc = null;\r
11 this.paintState = 0;\r
12 this.compositeState = -2147483648;\r
13 this.strokeState = 0;\r
14 this.$transformState = 0;\r
15 this.clipState = 0;\r
16 this.isShifted = false;\r
17 this.font = null;\r
18 this.inPath = false;\r
19 this.currentClip = null;\r
20 Clazz.instantialize (this, arguments);\r
21 }, swingjs, "JSGraphics2D", jssun.java2d.SunGraphics2D, Cloneable);\r
22 Clazz.makeConstructor (c$, \r
23 function (canvas) {\r
24 Clazz.superConstructor (this, swingjs.JSGraphics2D, []);\r
25 this.hints =  new java.awt.RenderingHints ( new java.util.HashMap ());\r
26 this.canvas = canvas;\r
27 this.ctx = this.canvas.getContext ("2d");\r
28 this.$transform =  new java.awt.geom.AffineTransform ();\r
29 {\r
30 this.gc = SwingJS;\r
31 }}, "~O");\r
32 Clazz.overrideMethod (c$, "getDeviceConfiguration", \r
33 function () {\r
34 return this.gc;\r
35 });\r
36 Clazz.overrideMethod (c$, "drawLine", \r
37 function (x0, y0, x1, y1) {\r
38 var inPath = this.inPath;\r
39 if (!inPath) this.ctx.beginPath ();\r
40 this.ctx.moveTo (x0, y0);\r
41 this.ctx.lineTo (x1, y1);\r
42 if (!inPath) this.ctx.stroke ();\r
43 }, "~N,~N,~N,~N");\r
44 Clazz.defineMethod (c$, "drawCircle", \r
45 function (x, y, diameter) {\r
46 this.drawArc (x, y, diameter, diameter, 0, 360);\r
47 }, "~N,~N,~N");\r
48 Clazz.overrideMethod (c$, "fillArc", \r
49 function (x, y, width, height, startAngle, arcAngle) {\r
50 this.doArc (x, y, width, height, startAngle, arcAngle, true);\r
51 }, "~N,~N,~N,~N,~N,~N");\r
52 Clazz.overrideMethod (c$, "drawArc", \r
53 function (x, y, width, height, startAngle, arcAngle) {\r
54 this.doArc (x, y, width, height, startAngle, arcAngle, false);\r
55 }, "~N,~N,~N,~N,~N,~N");\r
56 Clazz.defineMethod (c$, "save", \r
57  function () {\r
58 this.ctx.save ();\r
59 });\r
60 Clazz.defineMethod (c$, "restore", \r
61  function () {\r
62 this.ctx.restore ();\r
63 });\r
64 Clazz.defineMethod (c$, "doArc", \r
65  function (x, y, width, height, startAngle, arcAngle, fill) {\r
66 var isCircle = (arcAngle - startAngle == 360);\r
67 this.save ();\r
68 this.ctx.translate (x, y);\r
69 this.ctx.scale (Clazz.doubleToInt (width / height), height);\r
70 this.ctx.beginPath ();\r
71 if (fill) {\r
72 }this.ctx.arc (0.5, 0.5, 0.5, this.toRad (startAngle), this.toRad (arcAngle), false);\r
73 if (isCircle) this.ctx.closePath ();\r
74 this.ctx.stroke ();\r
75 this.restore ();\r
76 }, "~N,~N,~N,~N,~N,~N,~B");\r
77 Clazz.defineMethod (c$, "toRad", \r
78  function (a) {\r
79 return a * 3.141592653589793 / 180;\r
80 }, "~N");\r
81 Clazz.defineMethod (c$, "drawPolygon", \r
82 function (ayPoints, axPoints, nPoints) {\r
83 this.doPoly (ayPoints, axPoints, nPoints, false);\r
84 }, "~A,~A,~N");\r
85 Clazz.defineMethod (c$, "doPoly", \r
86  function (axPoints, ayPoints, nPoints, doFill) {\r
87 this.ctx.beginPath ();\r
88 this.ctx.moveTo (axPoints[0], ayPoints[0]);\r
89 for (var i = 1; i < nPoints; i++) this.ctx.lineTo (axPoints[i], ayPoints[i]);\r
90 \r
91 if (doFill) this.ctx.fill ();\r
92  else this.ctx.stroke ();\r
93 }, "~A,~A,~N,~B");\r
94 Clazz.overrideMethod (c$, "drawRect", \r
95 function (x, y, width, height) {\r
96 this.ctx.beginPath ();\r
97 this.ctx.rect (x, y, width, height);\r
98 this.ctx.stroke ();\r
99 }, "~N,~N,~N,~N");\r
100 Clazz.defineMethod (c$, "drawString", \r
101 function (s, x, y) {\r
102 this.ctx.fillText (s, x, y);\r
103 }, "~S,~N,~N");\r
104 Clazz.defineMethod (c$, "background", \r
105 function (bgcolor) {\r
106 this.backgroundColor = bgcolor;\r
107 if (bgcolor == null) {\r
108 if (!this.isShifted) this.ctx.translate (-0.5, -0.5);\r
109 this.isShifted = true;\r
110 return;\r
111 }this.ctx.clearRect (0, 0, this.windowWidth, this.windowHeight);\r
112 this.setGraphicsColor (bgcolor);\r
113 this.fillRect (0, 0, this.windowWidth, this.windowHeight);\r
114 }, "java.awt.Color");\r
115 Clazz.defineMethod (c$, "fillCircle", \r
116 function (x, y, diameter) {\r
117 var r = diameter / 2;\r
118 this.ctx.beginPath ();\r
119 this.ctx.arc (x + r, y + r, r, 0, 6.283185307179586, false);\r
120 this.ctx.fill ();\r
121 }, "~N,~N,~N");\r
122 Clazz.defineMethod (c$, "fillPolygon", \r
123 function (ayPoints, axPoints, nPoints) {\r
124 this.doPoly (ayPoints, axPoints, nPoints, true);\r
125 }, "~A,~A,~N");\r
126 Clazz.overrideMethod (c$, "fillRect", \r
127 function (x, y, width, height) {\r
128 this.ctx.fillRect (x, y, width, height);\r
129 }, "~N,~N,~N,~N");\r
130 Clazz.defineMethod (c$, "setGraphicsColor", \r
131 function (c) {\r
132 var s = swingjs.JSToolkit.getCSSColor (c);\r
133 {\r
134 this.ctx.fillStyle = s; this.ctx.strokeStyle = s;\r
135 }}, "java.awt.Color");\r
136 Clazz.overrideMethod (c$, "setFont", \r
137 function (font) {\r
138 this.font = font;\r
139 if (this.ctx == null) return;\r
140 var s = swingjs.JSToolkit.getCanvasFont (font);\r
141 {\r
142 this.ctx.font = s;\r
143 }}, "java.awt.Font");\r
144 Clazz.defineMethod (c$, "setStrokeBold", \r
145 function (tf) {\r
146 this.setLineWidth (tf ? 2. : 1.);\r
147 }, "~B");\r
148 Clazz.defineMethod (c$, "setLineWidth", \r
149  function (d) {\r
150 {\r
151 this.ctx.lineWidth = d;\r
152 }}, "~N");\r
153 Clazz.defineMethod (c$, "setWindowParameters", \r
154 function (width, height) {\r
155 this.windowWidth = width;\r
156 this.windowHeight = height;\r
157 }, "~N,~N");\r
158 Clazz.defineMethod (c$, "canDoLineTo", \r
159 function () {\r
160 return true;\r
161 });\r
162 Clazz.defineMethod (c$, "doStroke", \r
163 function (isBegin) {\r
164 this.inPath = isBegin;\r
165 if (isBegin) {\r
166 this.ctx.beginPath ();\r
167 } else {\r
168 this.ctx.stroke ();\r
169 }}, "~B");\r
170 Clazz.defineMethod (c$, "lineTo", \r
171 function (x2, y2) {\r
172 this.ctx.lineTo (x2, y2);\r
173 }, "~N,~N");\r
174 Clazz.overrideMethod (c$, "clip", \r
175 function (s) {\r
176 this.doShape (s);\r
177 this.ctx.clip ();\r
178 }, "java.awt.Shape");\r
179 Clazz.overrideMethod (c$, "draw", \r
180 function (s) {\r
181 this.doShape (s);\r
182 this.ctx.stroke ();\r
183 }, "java.awt.Shape");\r
184 Clazz.defineMethod (c$, "doShape", \r
185  function (s) {\r
186 this.ctx.beginPath ();\r
187 var pts =  Clazz.newDoubleArray (6, 0);\r
188 var pi = s.getPathIterator (null);\r
189 while (!pi.isDone ()) {\r
190 switch (pi.currentSegment (pts)) {\r
191 case 0:\r
192 this.ctx.moveTo (pts[0], pts[1]);\r
193 break;\r
194 case 1:\r
195 this.ctx.lineTo (pts[0], pts[1]);\r
196 break;\r
197 case 2:\r
198 this.ctx.quadraticCurveTo (pts[0], pts[1], pts[2], pts[3]);\r
199 break;\r
200 case 3:\r
201 this.ctx.bezeierCurveTo (pts[0], pts[1], pts[2], pts[3], pts[4], pts[5]);\r
202 break;\r
203 case 4:\r
204 this.ctx.closePath ();\r
205 break;\r
206 }\r
207 pi.next ();\r
208 }\r
209 return pi.getWindingRule ();\r
210 }, "java.awt.Shape");\r
211 Clazz.overrideMethod (c$, "fill", \r
212 function (s) {\r
213 if (this.doShape (s) == 0) {\r
214 this.ctx.fill("evenodd");\r
215 } else this.ctx.fill ();\r
216 }, "java.awt.Shape");\r
217 Clazz.defineMethod (c$, "drawImage", \r
218 function (img, x, y, observer) {\r
219 if (img != null) {\r
220 var imgNode = this.getImageNode (img);\r
221 if (imgNode != null) this.ctx.drawImage (imgNode, x, y, img.getWidth (observer), img.getHeight (observer));\r
222 if (observer != null) this.observe (img, observer, imgNode != null);\r
223 }return true;\r
224 }, "java.awt.Image,~N,~N,java.awt.image.ImageObserver");\r
225 Clazz.defineMethod (c$, "observe", \r
226  function (img, observer, isOK) {\r
227 observer.imageUpdate (img, (isOK ? 0 : 192), -1, -1, -1, -1);\r
228 }, "java.awt.Image,java.awt.image.ImageObserver,~B");\r
229 Clazz.defineMethod (c$, "drawImage", \r
230 function (img, x, y, width, height, observer) {\r
231 if (img != null) {\r
232 var imgNode = this.getImageNode (img);\r
233 if (imgNode != null) this.ctx.drawImage (imgNode, x, y, width, height);\r
234 if (observer != null) this.observe (img, observer, imgNode != null);\r
235 }return true;\r
236 }, "java.awt.Image,~N,~N,~N,~N,java.awt.image.ImageObserver");\r
237 Clazz.defineMethod (c$, "drawImage", \r
238 function (img, x, y, bgcolor, observer) {\r
239 swingjs.JSToolkit.notImplemented (null);\r
240 return this.drawImage (img, x, y, null);\r
241 }, "java.awt.Image,~N,~N,java.awt.Color,java.awt.image.ImageObserver");\r
242 Clazz.defineMethod (c$, "drawImage", \r
243 function (img, x, y, width, height, bgcolor, observer) {\r
244 swingjs.JSToolkit.notImplemented (null);\r
245 return this.drawImage (img, x, y, width, height, null);\r
246 }, "java.awt.Image,~N,~N,~N,~N,java.awt.Color,java.awt.image.ImageObserver");\r
247 Clazz.defineMethod (c$, "drawImage", \r
248 function (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer) {\r
249 if (img != null) {\r
250 var imgNode = this.getImageNode (img);\r
251 if (imgNode != null) swingjs.api.HTML5CanvasContext2D.stretchImage (this.ctx, imgNode, sx1, sy1, sx2 - sx1, sy2 - sy1, dx1, dy1, dx2 - dx1, dy2 - dy1);\r
252 if (observer != null) this.observe (img, observer, imgNode != null);\r
253 }return true;\r
254 }, "java.awt.Image,~N,~N,~N,~N,~N,~N,~N,~N,java.awt.image.ImageObserver");\r
255 Clazz.defineMethod (c$, "getImageNode", \r
256  function (img) {\r
257 var imgNode = null;\r
258 {\r
259 imgNode = img._imgNode || img._canvas;\r
260 }if (imgNode == null) imgNode = swingjs.JSToolkit.getCompositor ().createImageNode (img);\r
261 return imgNode;\r
262 }, "java.awt.Image");\r
263 Clazz.defineMethod (c$, "drawImage", \r
264 function (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer) {\r
265 swingjs.JSToolkit.notImplemented (null);\r
266 return this.drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);\r
267 }, "java.awt.Image,~N,~N,~N,~N,~N,~N,~N,~N,java.awt.Color,java.awt.image.ImageObserver");\r
268 Clazz.defineMethod (c$, "drawImage", \r
269 function (img, xform, obs) {\r
270 swingjs.JSToolkit.notImplemented (null);\r
271 return false;\r
272 }, "java.awt.Image,java.awt.geom.AffineTransform,java.awt.image.ImageObserver");\r
273 Clazz.overrideMethod (c$, "drawRenderedImage", \r
274 function (img, xform) {\r
275 swingjs.JSToolkit.notImplemented (null);\r
276 }, "java.awt.image.RenderedImage,java.awt.geom.AffineTransform");\r
277 Clazz.overrideMethod (c$, "drawRenderableImage", \r
278 function (img, xform) {\r
279 swingjs.JSToolkit.notImplemented (null);\r
280 }, "java.awt.image.renderable.RenderableImage,java.awt.geom.AffineTransform");\r
281 Clazz.overrideMethod (c$, "hit", \r
282 function (rect, s, onStroke) {\r
283 swingjs.JSToolkit.notImplemented (null);\r
284 return false;\r
285 }, "java.awt.Rectangle,java.awt.Shape,~B");\r
286 Clazz.overrideMethod (c$, "setPaint", \r
287 function (paint) {\r
288 swingjs.JSToolkit.notImplemented (null);\r
289 }, "java.awt.Paint");\r
290 Clazz.overrideMethod (c$, "setStroke", \r
291 function (s) {\r
292 if (!(Clazz.instanceOf (s, java.awt.BasicStroke))) return;\r
293 var b = s;\r
294 var dash = b.getDashArray ();\r
295 var idash =  Clazz.newIntArray (dash == null ? 0 : dash.length, 0);\r
296 for (var i = idash.length; --i >= 0; ) idash[i] = Clazz.floatToInt (dash[i]);\r
297 \r
298 this.ctx.setLineDash (idash);\r
299 this.setLineWidth (b.getLineWidth ());\r
300 var lineCap;\r
301 var lineJoin;\r
302 var miterLimit = -1;\r
303 switch (b.getEndCap ()) {\r
304 case 0:\r
305 lineCap = "butt";\r
306 break;\r
307 case 2:\r
308 lineCap = "square";\r
309 break;\r
310 case 1:\r
311 default:\r
312 lineCap = "round";\r
313 }\r
314 switch (b.getLineJoin ()) {\r
315 case 2:\r
316 lineJoin = "bevel";\r
317 break;\r
318 case 0:\r
319 lineJoin = "miter";\r
320 miterLimit = b.getMiterLimit ();\r
321 break;\r
322 case 1:\r
323 lineJoin = "round";\r
324 }\r
325 {\r
326 this.ctx.lineCap = lineCap; this.ctx.lineJoin = lineJoin; if\r
327 (miterLimit >= 0) this.ctx.miterLimit = miterLimit;\r
328 }}, "java.awt.Stroke");\r
329 Clazz.overrideMethod (c$, "setRenderingHint", \r
330 function (hintKey, hintValue) {\r
331 this.hints.put (hintKey, hintValue);\r
332 }, "java.awt.RenderingHints.Key,~O");\r
333 Clazz.overrideMethod (c$, "getRenderingHint", \r
334 function (hintKey) {\r
335 return this.hints.get (hintKey);\r
336 }, "java.awt.RenderingHints.Key");\r
337 Clazz.overrideMethod (c$, "setRenderingHints", \r
338 function (hints) {\r
339 this.hints =  new java.awt.RenderingHints (hints);\r
340 }, "java.util.Map");\r
341 Clazz.overrideMethod (c$, "addRenderingHints", \r
342 function (hints) {\r
343 for (var e, $e = hints.entrySet ().iterator (); $e.hasNext () && ((e = $e.next ()) || true);) this.hints.put (e.getKey (), e.getValue ());\r
344 \r
345 }, "java.util.Map");\r
346 Clazz.overrideMethod (c$, "getRenderingHints", \r
347 function () {\r
348 return this.hints;\r
349 });\r
350 Clazz.defineMethod (c$, "translate", \r
351 function (x, y) {\r
352 this.ctx.translate (x, y);\r
353 }, "~N,~N");\r
354 Clazz.overrideMethod (c$, "scale", \r
355 function (sx, sy) {\r
356 this.ctx.scale (sx, sy);\r
357 }, "~N,~N");\r
358 Clazz.overrideMethod (c$, "setBackground", \r
359 function (color) {\r
360 this.background (color);\r
361 }, "java.awt.Color");\r
362 Clazz.overrideMethod (c$, "getBackground", \r
363 function () {\r
364 return this.backgroundColor;\r
365 });\r
366 Clazz.overrideMethod (c$, "createSwingJS", \r
367 function () {\r
368 return this.clone ();\r
369 });\r
370 Clazz.overrideMethod (c$, "clone", \r
371 function () {\r
372 this.save ();\r
373 return this.clone0 ();\r
374 });\r
375 Clazz.overrideMethod (c$, "dispose", \r
376 function () {\r
377 if (this.compositeState >= 0) this.setComposite (null);\r
378 this.restore ();\r
379 });\r
380 Clazz.overrideMethod (c$, "getColor", \r
381 function () {\r
382 return this.foregroundColor;\r
383 });\r
384 Clazz.overrideMethod (c$, "setColor", \r
385 function (c) {\r
386 this.foregroundColor = c;\r
387 this.setGraphicsColor (c);\r
388 }, "java.awt.Color");\r
389 Clazz.overrideMethod (c$, "getFont", \r
390 function () {\r
391 return this.font;\r
392 });\r
393 Clazz.defineMethod (c$, "getFontMetrics", \r
394 function (f) {\r
395 return java.awt.Toolkit.getDefaultToolkit ().getFontMetrics (f);\r
396 }, "java.awt.Font");\r
397 Clazz.overrideMethod (c$, "clipRect", \r
398 function (x, y, width, height) {\r
399 this.ctx.beginPath ();\r
400 this.ctx.rect (x, y, width, height);\r
401 this.currentClip =  new java.awt.Rectangle (x, y, width, height);\r
402 this.ctx.clip ();\r
403 }, "~N,~N,~N,~N");\r
404 Clazz.defineMethod (c$, "setClip", \r
405 function (x, y, width, height) {\r
406 this.currentClip =  new java.awt.Rectangle (x, y, width, height);\r
407 {\r
408 if (arguments.length == 1) { setClip1(x); return; }\r
409 }this.ctx.beginPath ();\r
410 this.ctx.rect (x, y, width, height);\r
411 this.currentClip =  new java.awt.Rectangle (x, y, width, height);\r
412 this.ctx.clip ();\r
413 }, "~N,~N,~N,~N");\r
414 Clazz.defineMethod (c$, "setClip1", \r
415 function (clip) {\r
416 this.ctx.beginPath ();\r
417 this.doShape (clip);\r
418 this.ctx.clip ();\r
419 }, "java.awt.Shape");\r
420 Clazz.overrideMethod (c$, "clearRect", \r
421 function (x, y, width, height) {\r
422 this.ctx.clearRect (x, y, width, height);\r
423 }, "~N,~N,~N,~N");\r
424 Clazz.overrideMethod (c$, "drawPolyline", \r
425 function (xPoints, yPoints, nPoints) {\r
426 if (nPoints < 2) return;\r
427 this.ctx.moveTo (xPoints[0], yPoints[0]);\r
428 for (var i = 1; i < nPoints; i++) {\r
429 this.ctx.lineTo (xPoints[i], yPoints[i]);\r
430 }\r
431 }, "~A,~A,~N");\r
432 Clazz.overrideMethod (c$, "copyArea", \r
433 function (x, y, width, height, dx, dy) {\r
434 swingjs.JSToolkit.notImplemented (null);\r
435 }, "~N,~N,~N,~N,~N,~N");\r
436 Clazz.overrideMethod (c$, "drawRoundRect", \r
437 function (x, y, width, height, arcWidth, arcHeight) {\r
438 swingjs.JSToolkit.notImplemented (null);\r
439 this.drawRect (x, y, width, height);\r
440 }, "~N,~N,~N,~N,~N,~N");\r
441 Clazz.overrideMethod (c$, "fillRoundRect", \r
442 function (x, y, width, height, arcWidth, arcHeight) {\r
443 swingjs.JSToolkit.notImplemented (null);\r
444 this.fillRect (x, y, width, height);\r
445 }, "~N,~N,~N,~N,~N,~N");\r
446 Clazz.overrideMethod (c$, "drawOval", \r
447 function (x, y, width, height) {\r
448 swingjs.JSToolkit.notImplemented (null);\r
449 }, "~N,~N,~N,~N");\r
450 Clazz.overrideMethod (c$, "fillOval", \r
451 function (x, y, width, height) {\r
452 swingjs.JSToolkit.notImplemented (null);\r
453 }, "~N,~N,~N,~N");\r
454 Clazz.overrideMethod (c$, "getClip", \r
455 function () {\r
456 swingjs.JSToolkit.notImplemented (null);\r
457 return null;\r
458 });\r
459 Clazz.overrideMethod (c$, "drawStringTrans", \r
460 function (str, x, y) {\r
461 swingjs.JSToolkit.notImplemented (null);\r
462 }, "~S,~N,~N");\r
463 Clazz.defineMethod (c$, "drawString", \r
464 function (iterator, x, y) {\r
465 swingjs.JSToolkit.notImplemented (null);\r
466 }, "java.text.AttributedCharacterIterator,~N,~N");\r
467 Clazz.overrideMethod (c$, "drawStringAttrTrans", \r
468 function (iterator, x, y) {\r
469 swingjs.JSToolkit.notImplemented (null);\r
470 }, "java.text.AttributedCharacterIterator,~N,~N");\r
471 Clazz.overrideMethod (c$, "translateTrans", \r
472 function (tx, ty) {\r
473 swingjs.JSToolkit.notImplemented (null);\r
474 }, "~N,~N");\r
475 Clazz.defineMethod (c$, "rotate", \r
476 function (theta) {\r
477 swingjs.JSToolkit.notImplemented (null);\r
478 }, "~N");\r
479 Clazz.defineMethod (c$, "rotate", \r
480 function (theta, x, y) {\r
481 swingjs.JSToolkit.notImplemented (null);\r
482 }, "~N,~N,~N");\r
483 Clazz.overrideMethod (c$, "shear", \r
484 function (shx, shy) {\r
485 swingjs.JSToolkit.notImplemented (null);\r
486 }, "~N,~N");\r
487 Clazz.overrideMethod (c$, "transform", \r
488 function (xform) {\r
489 swingjs.JSToolkit.notImplemented (null);\r
490 }, "java.awt.geom.AffineTransform");\r
491 Clazz.overrideMethod (c$, "setTransform", \r
492 function (Tx) {\r
493 swingjs.JSToolkit.notImplemented (null);\r
494 }, "java.awt.geom.AffineTransform");\r
495 Clazz.overrideMethod (c$, "getTransform", \r
496 function () {\r
497 swingjs.JSToolkit.notImplemented (null);\r
498 return null;\r
499 });\r
500 Clazz.defineMethod (c$, "cloneTransform", \r
501 function () {\r
502 swingjs.JSToolkit.notImplemented (null);\r
503 return null;\r
504 });\r
505 Clazz.overrideMethod (c$, "getPaint", \r
506 function () {\r
507 swingjs.JSToolkit.notImplemented (null);\r
508 return null;\r
509 });\r
510 Clazz.overrideMethod (c$, "getStroke", \r
511 function () {\r
512 swingjs.JSToolkit.notImplemented (null);\r
513 return null;\r
514 });\r
515 Clazz.overrideMethod (c$, "getFontRenderContext", \r
516 function () {\r
517 swingjs.JSToolkit.notImplemented (null);\r
518 return null;\r
519 });\r
520 Clazz.overrideMethod (c$, "setPaintMode", \r
521 function () {\r
522 swingjs.JSToolkit.notImplemented (null);\r
523 });\r
524 Clazz.overrideMethod (c$, "setXORMode", \r
525 function (c1) {\r
526 swingjs.JSToolkit.notImplemented (null);\r
527 }, "java.awt.Color");\r
528 Clazz.defineMethod (c$, "getClipBounds", \r
529 function () {\r
530 var r = null;\r
531 {\r
532 if (arguments.length == 1) r = arguments[0];\r
533 }var clipRect = this.getClipBoundsImpl ();\r
534 if (r == null) {\r
535 r = clipRect;\r
536 } else {\r
537 r.x = clipRect.x;\r
538 r.y = clipRect.y;\r
539 r.width = clipRect.width;\r
540 r.height = clipRect.height;\r
541 }return r;\r
542 });\r
543 Clazz.defineMethod (c$, "getClipBoundsImpl", \r
544  function () {\r
545 if (this.currentClip == null) {\r
546 this.currentClip =  new java.awt.Rectangle (0, 0, this.windowWidth, this.windowHeight);\r
547 }return this.currentClip;\r
548 });\r
549 Clazz.overrideMethod (c$, "setComposite", \r
550 function (comp) {\r
551 var newRule = 0;\r
552 var isValid = (comp == null || (Clazz.instanceOf (comp, java.awt.AlphaComposite)) && (newRule = (comp).getRule ()) != this.compositeState);\r
553 if (!isValid) return;\r
554 if (swingjs.JSToolkit.setGraphicsCompositeAlpha (this, newRule)) this.compositeState = newRule;\r
555 }, "java.awt.Composite");\r
556 Clazz.defineMethod (c$, "drawImage", \r
557 function (img, op, x, y) {\r
558 swingjs.JSToolkit.drawImageOp (this, img, op, x, y);\r
559 }, "java.awt.image.BufferedImage,java.awt.image.BufferedImageOp,~N,~N");\r
560 Clazz.defineMethod (c$, "setAlpha", \r
561 function (f) {\r
562 {\r
563 this.ctx.globalAlpha = f;\r
564 }}, "~N");\r
565 Clazz.defineStatics (c$,\r
566 "saveLevel", 0);\r
567 });\r