1 Clazz.declarePackage ("java.awt");
2 c$ = Clazz.declareType (java.awt, "Graphics");
3 Clazz.makeConstructor (c$,
6 Clazz.defineMethod (c$, "create",
8 return this.createSwingJS ();
10 Clazz.defineMethod (c$, "create",
11 function (x, y, width, height) {
12 return this.create4 (x, y, width, height);
14 Clazz.defineMethod (c$, "create4",
15 function (x, y, width, height) {
16 var g = this.createSwingJS ();
17 if (g == null) return null;
19 g.clipRect (0, 0, width, height);
22 Clazz.defineMethod (c$, "getFontMetrics",
24 return this.getFontMetrics (this.getFont ());
26 Clazz.defineMethod (c$, "drawRect",
27 function (x, y, width, height) {
28 if ((width < 0) || (height < 0)) {
30 }if (height == 0 || width == 0) {
31 this.drawLine (x, y, x + width, y + height);
33 this.drawLine (x, y, x + width - 1, y);
34 this.drawLine (x + width, y, x + width, y + height - 1);
35 this.drawLine (x + width, y + height, x + 1, y + height);
36 this.drawLine (x, y + height, x, y + 1);
38 Clazz.defineMethod (c$, "draw3DRect",
39 function (x, y, width, height, raised) {
40 var c = this.getColor ();
41 var brighter = c.brighter ();
42 var darker = c.darker ();
43 this.setColor (raised ? brighter : darker);
44 this.drawLine (x, y, x, y + height);
45 this.drawLine (x + 1, y, x + width - 1, y);
46 this.setColor (raised ? darker : brighter);
47 this.drawLine (x + 1, y + height, x + width, y + height);
48 this.drawLine (x + width, y, x + width, y + height - 1);
51 Clazz.defineMethod (c$, "fill3DRect",
52 function (x, y, width, height, raised) {
53 var c = this.getColor ();
54 var brighter = c.brighter ();
55 var darker = c.darker ();
57 this.setColor (darker);
58 }this.fillRect (x + 1, y + 1, width - 2, height - 2);
59 this.setColor (raised ? brighter : darker);
60 this.drawLine (x, y, x, y + height - 1);
61 this.drawLine (x + 1, y, x + width - 2, y);
62 this.setColor (raised ? darker : brighter);
63 this.drawLine (x + 1, y + height - 1, x + width - 1, y + height - 1);
64 this.drawLine (x + width - 1, y, x + width - 1, y + height - 2);
67 Clazz.defineMethod (c$, "drawPolygon",
69 this.drawPolygon (p.xpoints, p.ypoints, p.npoints);
70 }, "java.awt.Polygon");
71 Clazz.defineMethod (c$, "fillPolygon",
73 this.fillPolygon (p.xpoints, p.ypoints, p.npoints);
74 }, "java.awt.Polygon");
75 Clazz.defineMethod (c$, "drawChars",
76 function (data, offset, length, x, y) {
77 this.drawString ( String.instantialize (data, offset, length), x, y);
79 Clazz.defineMethod (c$, "drawBytes",
80 function (data, offset, length, x, y) {
81 this.drawString ( String.instantialize (data, 0, offset, length), x, y);
83 Clazz.overrideMethod (c$, "finalize",
87 Clazz.overrideMethod (c$, "toString",
89 return this.getClass ().getName () + "[font=" + this.getFont () + ",color=" + this.getColor () + "]";
91 Clazz.defineMethod (c$, "getClipRect",
93 return this.getClipBounds ();
95 Clazz.defineMethod (c$, "hitClip",
96 function (x, y, width, height) {
97 var clipRect = this.getClipBounds ();
98 if (clipRect == null) {
100 }return clipRect.intersects (x, y, width, height);