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