JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / swingjs / j2s / javax / swing / tree / DefaultTreeCellRenderer.js
1 Clazz.declarePackage ("javax.swing.tree");\r
2 Clazz.load (["javax.swing.JLabel", "javax.swing.tree.TreeCellRenderer"], "javax.swing.tree.DefaultTreeCellRenderer", ["java.awt.Dimension", "javax.swing.border.EmptyBorder", "javax.swing.plaf.ColorUIResource", "$.FontUIResource", "jssun.swing.DefaultLookup"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.tree = null;\r
5 this.selected = false;\r
6 this.$hasFocus = false;\r
7 this.drawsFocusBorderAroundIcon = false;\r
8 this.drawDashedFocusIndicator = false;\r
9 this.treeBGColor = null;\r
10 this.focusBGColor = null;\r
11 this.closedIcon = null;\r
12 this.leafIcon = null;\r
13 this.openIcon = null;\r
14 this.textSelectionColor = null;\r
15 this.textNonSelectionColor = null;\r
16 this.backgroundSelectionColor = null;\r
17 this.backgroundNonSelectionColor = null;\r
18 this.borderSelectionColor = null;\r
19 this.isDropCell = false;\r
20 this.fillBackground = true;\r
21 Clazz.instantialize (this, arguments);\r
22 }, javax.swing.tree, "DefaultTreeCellRenderer", javax.swing.JLabel, javax.swing.tree.TreeCellRenderer);\r
23 Clazz.makeConstructor (c$, \r
24 function () {\r
25 Clazz.superConstructor (this, javax.swing.tree.DefaultTreeCellRenderer, []);\r
26 this.setLeafIcon (jssun.swing.DefaultLookup.getIcon (this, this.ui, "Tree.leafIcon"));\r
27 this.setClosedIcon (jssun.swing.DefaultLookup.getIcon (this, this.ui, "Tree.closedIcon"));\r
28 this.setOpenIcon (jssun.swing.DefaultLookup.getIcon (this, this.ui, "Tree.openIcon"));\r
29 this.setTextSelectionColor (jssun.swing.DefaultLookup.getColor (this, this.ui, "Tree.selectionForeground"));\r
30 this.setTextNonSelectionColor (jssun.swing.DefaultLookup.getColor (this, this.ui, "Tree.textForeground"));\r
31 this.setBackgroundSelectionColor (jssun.swing.DefaultLookup.getColor (this, this.ui, "Tree.selectionBackground"));\r
32 this.setBackgroundNonSelectionColor (jssun.swing.DefaultLookup.getColor (this, this.ui, "Tree.textBackground"));\r
33 this.setBorderSelectionColor (jssun.swing.DefaultLookup.getColor (this, this.ui, "Tree.selectionBorderColor"));\r
34 this.drawsFocusBorderAroundIcon = jssun.swing.DefaultLookup.getBoolean (this, this.ui, "Tree.drawsFocusBorderAroundIcon", false);\r
35 this.drawDashedFocusIndicator = jssun.swing.DefaultLookup.getBoolean (this, this.ui, "Tree.drawDashedFocusIndicator", false);\r
36 this.fillBackground = jssun.swing.DefaultLookup.getBoolean (this, this.ui, "Tree.rendererFillBackground", true);\r
37 var margins = jssun.swing.DefaultLookup.getInsets (this, this.ui, "Tree.rendererMargins");\r
38 if (margins != null) {\r
39 this.setBorder ( new javax.swing.border.EmptyBorder (margins.top, margins.left, margins.bottom, margins.right));\r
40 }this.setName ("Tree.cellRenderer");\r
41 });\r
42 Clazz.defineMethod (c$, "getDefaultOpenIcon", \r
43 function () {\r
44 return jssun.swing.DefaultLookup.getIcon (this, this.ui, "Tree.openIcon");\r
45 });\r
46 Clazz.defineMethod (c$, "getDefaultClosedIcon", \r
47 function () {\r
48 return jssun.swing.DefaultLookup.getIcon (this, this.ui, "Tree.closedIcon");\r
49 });\r
50 Clazz.defineMethod (c$, "getDefaultLeafIcon", \r
51 function () {\r
52 return jssun.swing.DefaultLookup.getIcon (this, this.ui, "Tree.leafIcon");\r
53 });\r
54 Clazz.defineMethod (c$, "setOpenIcon", \r
55 function (newIcon) {\r
56 this.openIcon = newIcon;\r
57 }, "javax.swing.Icon");\r
58 Clazz.defineMethod (c$, "getOpenIcon", \r
59 function () {\r
60 return this.openIcon;\r
61 });\r
62 Clazz.defineMethod (c$, "setClosedIcon", \r
63 function (newIcon) {\r
64 this.closedIcon = newIcon;\r
65 }, "javax.swing.Icon");\r
66 Clazz.defineMethod (c$, "getClosedIcon", \r
67 function () {\r
68 return this.closedIcon;\r
69 });\r
70 Clazz.defineMethod (c$, "setLeafIcon", \r
71 function (newIcon) {\r
72 this.leafIcon = newIcon;\r
73 }, "javax.swing.Icon");\r
74 Clazz.defineMethod (c$, "getLeafIcon", \r
75 function () {\r
76 return this.leafIcon;\r
77 });\r
78 Clazz.defineMethod (c$, "setTextSelectionColor", \r
79 function (newColor) {\r
80 this.textSelectionColor = newColor;\r
81 }, "java.awt.Color");\r
82 Clazz.defineMethod (c$, "getTextSelectionColor", \r
83 function () {\r
84 return this.textSelectionColor;\r
85 });\r
86 Clazz.defineMethod (c$, "setTextNonSelectionColor", \r
87 function (newColor) {\r
88 this.textNonSelectionColor = newColor;\r
89 }, "java.awt.Color");\r
90 Clazz.defineMethod (c$, "getTextNonSelectionColor", \r
91 function () {\r
92 return this.textNonSelectionColor;\r
93 });\r
94 Clazz.defineMethod (c$, "setBackgroundSelectionColor", \r
95 function (newColor) {\r
96 this.backgroundSelectionColor = newColor;\r
97 }, "java.awt.Color");\r
98 Clazz.defineMethod (c$, "getBackgroundSelectionColor", \r
99 function () {\r
100 return this.backgroundSelectionColor;\r
101 });\r
102 Clazz.defineMethod (c$, "setBackgroundNonSelectionColor", \r
103 function (newColor) {\r
104 this.backgroundNonSelectionColor = newColor;\r
105 }, "java.awt.Color");\r
106 Clazz.defineMethod (c$, "getBackgroundNonSelectionColor", \r
107 function () {\r
108 return this.backgroundNonSelectionColor;\r
109 });\r
110 Clazz.defineMethod (c$, "setBorderSelectionColor", \r
111 function (newColor) {\r
112 this.borderSelectionColor = newColor;\r
113 }, "java.awt.Color");\r
114 Clazz.defineMethod (c$, "getBorderSelectionColor", \r
115 function () {\r
116 return this.borderSelectionColor;\r
117 });\r
118 Clazz.defineMethod (c$, "setFont", \r
119 function (font) {\r
120 if (Clazz.instanceOf (font, javax.swing.plaf.FontUIResource)) font = null;\r
121 Clazz.superCall (this, javax.swing.tree.DefaultTreeCellRenderer, "setFont", [font]);\r
122 }, "java.awt.Font");\r
123 Clazz.defineMethod (c$, "getFont", \r
124 function () {\r
125 var font = Clazz.superCall (this, javax.swing.tree.DefaultTreeCellRenderer, "getFont", []);\r
126 if (font == null && this.tree != null) {\r
127 font = this.tree.getFont ();\r
128 }return font;\r
129 });\r
130 Clazz.defineMethod (c$, "setBackground", \r
131 function (color) {\r
132 if (Clazz.instanceOf (color, javax.swing.plaf.ColorUIResource)) color = null;\r
133 Clazz.superCall (this, javax.swing.tree.DefaultTreeCellRenderer, "setBackground", [color]);\r
134 }, "java.awt.Color");\r
135 Clazz.overrideMethod (c$, "getTreeCellRendererComponent", \r
136 function (tree, value, sel, expanded, leaf, row, hasFocus) {\r
137 var stringValue = tree.convertValueToText (value, sel, expanded, leaf, row, hasFocus);\r
138 this.tree = tree;\r
139 this.$hasFocus = hasFocus;\r
140 this.setText (stringValue);\r
141 var fg = null;\r
142 this.isDropCell = false;\r
143 if (sel) {\r
144 fg = this.getTextSelectionColor ();\r
145 } else {\r
146 fg = this.getTextNonSelectionColor ();\r
147 }this.setForeground (fg);\r
148 var icon = null;\r
149 if (leaf) {\r
150 icon = this.getLeafIcon ();\r
151 } else if (expanded) {\r
152 icon = this.getOpenIcon ();\r
153 } else {\r
154 icon = this.getClosedIcon ();\r
155 }if (!tree.isEnabled ()) {\r
156 this.setEnabled (false);\r
157 this.setDisabledIcon (icon);\r
158 } else {\r
159 this.setEnabled (true);\r
160 this.setIcon (icon);\r
161 }this.setComponentOrientation (tree.getComponentOrientation ());\r
162 this.selected = sel;\r
163 return this;\r
164 }, "javax.swing.JTree,~O,~B,~B,~B,~N,~B");\r
165 Clazz.defineMethod (c$, "paint", \r
166 function (g) {\r
167 var bColor;\r
168 if (this.isDropCell) {\r
169 bColor = jssun.swing.DefaultLookup.getColor (this, this.ui, "Tree.dropCellBackground");\r
170 if (bColor == null) {\r
171 bColor = this.getBackgroundSelectionColor ();\r
172 }} else if (this.selected) {\r
173 bColor = this.getBackgroundSelectionColor ();\r
174 } else {\r
175 bColor = this.getBackgroundNonSelectionColor ();\r
176 if (bColor == null) {\r
177 bColor = this.getBackground ();\r
178 }}var imageOffset = -1;\r
179 if (bColor != null && this.fillBackground) {\r
180 imageOffset = this.getLabelStart ();\r
181 g.setColor (bColor);\r
182 if (this.getComponentOrientation ().isLeftToRight ()) {\r
183 g.fillRect (imageOffset, 0, this.getWidth () - imageOffset, this.getHeight ());\r
184 } else {\r
185 g.fillRect (0, 0, this.getWidth () - imageOffset, this.getHeight ());\r
186 }}if (this.$hasFocus) {\r
187 if (this.drawsFocusBorderAroundIcon) {\r
188 imageOffset = 0;\r
189 } else if (imageOffset == -1) {\r
190 imageOffset = this.getLabelStart ();\r
191 }if (this.getComponentOrientation ().isLeftToRight ()) {\r
192 this.paintFocus (g, imageOffset, 0, this.getWidth () - imageOffset, this.getHeight (), bColor);\r
193 } else {\r
194 this.paintFocus (g, 0, 0, this.getWidth () - imageOffset, this.getHeight (), bColor);\r
195 }}Clazz.superCall (this, javax.swing.tree.DefaultTreeCellRenderer, "paint", [g]);\r
196 }, "java.awt.Graphics");\r
197 Clazz.defineMethod (c$, "paintFocus", \r
198  function (g, x, y, w, h, notColor) {\r
199 var bsColor = this.getBorderSelectionColor ();\r
200 if (bsColor != null && (this.selected || !this.drawDashedFocusIndicator)) {\r
201 g.setColor (bsColor);\r
202 g.drawRect (x, y, w - 1, h - 1);\r
203 }}, "java.awt.Graphics,~N,~N,~N,~N,java.awt.Color");\r
204 Clazz.defineMethod (c$, "getLabelStart", \r
205  function () {\r
206 var currentI = this.getIcon ();\r
207 if (currentI != null && this.getText () != null) {\r
208 return currentI.getIconWidth () + Math.max (0, this.getIconTextGap () - 1);\r
209 }return 0;\r
210 });\r
211 Clazz.overrideMethod (c$, "getPreferredSize", \r
212 function () {\r
213 var retDimension = this.getPrefSizeJComp ();\r
214 return (retDimension == null ? null :  new java.awt.Dimension (retDimension.width + 3, retDimension.height));\r
215 });\r
216 Clazz.overrideMethod (c$, "validate", \r
217 function () {\r
218 });\r
219 Clazz.overrideMethod (c$, "invalidate", \r
220 function () {\r
221 });\r
222 Clazz.overrideMethod (c$, "revalidate", \r
223 function () {\r
224 });\r
225 Clazz.defineMethod (c$, "repaint", \r
226 function (tm, x, y, width, height) {\r
227 }, "~N,~N,~N,~N,~N");\r
228 Clazz.defineMethod (c$, "repaint", \r
229 function (r) {\r
230 }, "java.awt.Rectangle");\r
231 Clazz.defineMethod (c$, "repaint", \r
232 function () {\r
233 });\r
234 Clazz.overrideMethod (c$, "firePropertyChangeObject", \r
235 function (propertyName, oldValue, newValue) {\r
236 }, "~S,~O,~O");\r
237 Clazz.defineMethod (c$, "firePropertyChange", \r
238 function (propertyName, oldValue, newValue) {\r
239 }, "~S,~N,~N");\r
240 Clazz.defineMethod (c$, "firePropertyChange", \r
241 function (propertyName, oldValue, newValue) {\r
242 }, "~S,~S,~S");\r
243 Clazz.defineMethod (c$, "firePropertyChange", \r
244 function (propertyName, oldValue, newValue) {\r
245 }, "~S,~N,~N");\r
246 Clazz.overrideMethod (c$, "firePropertyChangeInt", \r
247 function (propertyName, oldValue, newValue) {\r
248 }, "~S,~N,~N");\r
249 Clazz.defineMethod (c$, "firePropertyChange", \r
250 function (propertyName, oldValue, newValue) {\r
251 }, "~S,~N,~N");\r
252 Clazz.defineMethod (c$, "firePropertyChange", \r
253 function (propertyName, oldValue, newValue) {\r
254 }, "~S,~N,~N");\r
255 Clazz.defineMethod (c$, "firePropertyChange", \r
256 function (propertyName, oldValue, newValue) {\r
257 }, "~S,~N,~N");\r
258 Clazz.overrideMethod (c$, "firePropertyChangeBool", \r
259 function (propertyName, oldValue, newValue) {\r
260 }, "~S,~B,~B");\r
261 });\r