1 Clazz.declarePackage ("javax.swing.border");
\r
2 Clazz.load (["javax.swing.border.EmptyBorder"], "javax.swing.border.MatteBorder", ["java.awt.Color", "$.Insets"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
5 this.tileIcon = null;
\r
6 Clazz.instantialize (this, arguments);
\r
7 }, javax.swing.border, "MatteBorder", javax.swing.border.EmptyBorder);
\r
8 Clazz.makeConstructor (c$,
\r
9 function (top, left, bottom, right, matteColor) {
\r
10 Clazz.superConstructor (this, javax.swing.border.MatteBorder, [top, left, bottom, right]);
\r
11 this.color = matteColor;
\r
12 }, "~N,~N,~N,~N,java.awt.Color");
\r
13 Clazz.makeConstructor (c$,
\r
14 function (borderInsets, matteColor) {
\r
15 Clazz.superConstructor (this, javax.swing.border.MatteBorder, [borderInsets]);
\r
16 this.color = matteColor;
\r
17 }, "java.awt.Insets,java.awt.Color");
\r
18 Clazz.makeConstructor (c$,
\r
19 function (top, left, bottom, right, tileIcon) {
\r
20 Clazz.superConstructor (this, javax.swing.border.MatteBorder, [top, left, bottom, right]);
\r
21 this.tileIcon = tileIcon;
\r
22 }, "~N,~N,~N,~N,javax.swing.Icon");
\r
23 Clazz.makeConstructor (c$,
\r
24 function (borderInsets, tileIcon) {
\r
25 Clazz.superConstructor (this, javax.swing.border.MatteBorder, [borderInsets]);
\r
26 this.tileIcon = tileIcon;
\r
27 }, "java.awt.Insets,javax.swing.Icon");
\r
28 Clazz.makeConstructor (c$,
\r
29 function (tileIcon) {
\r
30 this.construct (-1, -1, -1, -1, tileIcon);
\r
31 }, "javax.swing.Icon");
\r
32 Clazz.overrideMethod (c$, "paintBorder",
\r
33 function (c, g, x, y, width, height) {
\r
34 var insets = this.getBorderInsets (c);
\r
35 var oldColor = g.getColor ();
\r
37 if (this.tileIcon != null) {
\r
38 this.color = (this.tileIcon.getIconWidth () == -1) ? java.awt.Color.gray : null;
\r
39 }if (this.color != null) {
\r
40 g.setColor (this.color);
\r
41 g.fillRect (0, 0, width - insets.right, insets.top);
\r
42 g.fillRect (0, insets.top, insets.left, height - insets.top);
\r
43 g.fillRect (insets.left, height - insets.bottom, width - insets.left, insets.bottom);
\r
44 g.fillRect (width - insets.right, 0, insets.right, height - insets.bottom);
\r
45 } else if (this.tileIcon != null) {
\r
46 var tileW = this.tileIcon.getIconWidth ();
\r
47 var tileH = this.tileIcon.getIconHeight ();
\r
53 cg = g.createSwingJS ();
\r
54 cg.setClip (0, 0, width, insets.top);
\r
55 for (ypos = 0; insets.top - ypos > 0; ypos += tileH) {
\r
56 for (xpos = 0; width - xpos > 0; xpos += tileW) {
\r
57 this.tileIcon.paintIcon (c, cg, xpos, ypos);
\r
61 cg = g.createSwingJS ();
\r
62 cg.setClip (0, insets.top, insets.left, height - insets.top);
\r
63 starty = insets.top - (insets.top % tileH);
\r
65 for (ypos = starty; height - ypos > 0; ypos += tileH) {
\r
66 for (xpos = startx; insets.left - xpos > 0; xpos += tileW) {
\r
67 this.tileIcon.paintIcon (c, cg, xpos, ypos);
\r
71 cg = g.createSwingJS ();
\r
72 cg.setClip (insets.left, height - insets.bottom, width - insets.left, insets.bottom);
\r
73 starty = (height - insets.bottom) - ((height - insets.bottom) % tileH);
\r
74 startx = insets.left - (insets.left % tileW);
\r
75 for (ypos = starty; height - ypos > 0; ypos += tileH) {
\r
76 for (xpos = startx; width - xpos > 0; xpos += tileW) {
\r
77 this.tileIcon.paintIcon (c, cg, xpos, ypos);
\r
81 cg = g.createSwingJS ();
\r
82 cg.setClip (width - insets.right, insets.top, insets.right, height - insets.top - insets.bottom);
\r
83 starty = insets.top - (insets.top % tileH);
\r
84 startx = width - insets.right - ((width - insets.right) % tileW);
\r
85 for (ypos = starty; height - ypos > 0; ypos += tileH) {
\r
86 for (xpos = startx; width - xpos > 0; xpos += tileW) {
\r
87 this.tileIcon.paintIcon (c, cg, xpos, ypos);
\r
91 }g.translate (-x, -y);
\r
92 g.setColor (oldColor);
\r
93 }, "java.awt.Component,java.awt.Graphics,~N,~N,~N,~N");
\r
94 Clazz.defineMethod (c$, "getBorderInsets",
\r
96 return this.getBorderInsets ();
\r
97 }, "java.awt.Component");
\r
98 Clazz.defineMethod (c$, "getBorderInsets",
\r
99 function (c, insets) {
\r
100 return this.computeInsets (insets);
\r
101 }, "java.awt.Component,java.awt.Insets");
\r
102 Clazz.defineMethod (c$, "getBorderInsets",
\r
104 return this.computeInsets ( new java.awt.Insets (0, 0, 0, 0));
\r
106 Clazz.defineMethod (c$, "computeInsets",
\r
107 function (insets) {
\r
108 if (this.tileIcon != null && this.top == -1 && this.bottom == -1 && this.left == -1 && this.right == -1) {
\r
109 var w = this.tileIcon.getIconWidth ();
\r
110 var h = this.tileIcon.getIconHeight ();
\r
116 insets.left = this.left;
\r
117 insets.top = this.top;
\r
118 insets.right = this.right;
\r
119 insets.bottom = this.bottom;
\r
121 }, "java.awt.Insets");
\r
122 Clazz.defineMethod (c$, "getMatteColor",
\r
126 Clazz.defineMethod (c$, "getTileIcon",
\r
128 return this.tileIcon;
\r
130 Clazz.overrideMethod (c$, "isBorderOpaque",
\r
132 return this.color != null;
\r