JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / javax / swing / table / DefaultTableCellRenderer.js
1 Clazz.declarePackage ("javax.swing.table");\r
2 Clazz.load (["javax.swing.JLabel", "javax.swing.plaf.UIResource", "javax.swing.table.TableCellRenderer", "javax.swing.border.EmptyBorder"], "javax.swing.table.DefaultTableCellRenderer", ["jssun.swing.DefaultLookup"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.unselectedForeground = null;\r
5 this.unselectedBackground = null;\r
6 Clazz.instantialize (this, arguments);\r
7 }, javax.swing.table, "DefaultTableCellRenderer", javax.swing.JLabel, javax.swing.table.TableCellRenderer);\r
8 Clazz.makeConstructor (c$, \r
9 function () {\r
10 Clazz.superConstructor (this, javax.swing.table.DefaultTableCellRenderer);\r
11 this.setOpaque (true);\r
12 this.setBorder (this.getNoFocusBorder ());\r
13 this.setName ("Table.cellRenderer");\r
14 });\r
15 Clazz.defineMethod (c$, "getNoFocusBorder", \r
16  function () {\r
17 var border = jssun.swing.DefaultLookup.getBorder (this, this.ui, "Table.cellNoFocusBorder");\r
18 if (System.getSecurityManager () != null) {\r
19 if (border != null) return border;\r
20 return javax.swing.table.DefaultTableCellRenderer.SAFE_NO_FOCUS_BORDER;\r
21 } else if (border != null) {\r
22 if (javax.swing.table.DefaultTableCellRenderer.noFocusBorder == null || javax.swing.table.DefaultTableCellRenderer.noFocusBorder === javax.swing.table.DefaultTableCellRenderer.DEFAULT_NO_FOCUS_BORDER) {\r
23 return border;\r
24 }}return javax.swing.table.DefaultTableCellRenderer.noFocusBorder;\r
25 });\r
26 Clazz.defineMethod (c$, "setForeground", \r
27 function (c) {\r
28 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setForeground", [c]);\r
29 this.unselectedForeground = c;\r
30 }, "java.awt.Color");\r
31 Clazz.defineMethod (c$, "setBackground", \r
32 function (c) {\r
33 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setBackground", [c]);\r
34 this.unselectedBackground = c;\r
35 }, "java.awt.Color");\r
36 Clazz.defineMethod (c$, "updateUI", \r
37 function () {\r
38 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "updateUI", []);\r
39 this.setForeground (null);\r
40 this.setBackground (null);\r
41 });\r
42 Clazz.overrideMethod (c$, "getTableCellRendererComponent", \r
43 function (table, value, isSelected, hasFocus, row, column) {\r
44 var fg = null;\r
45 var bg = null;\r
46 if (isSelected) {\r
47 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setForeground", [fg == null ? table.getSelectionForeground () : fg]);\r
48 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setBackground", [bg == null ? table.getSelectionBackground () : bg]);\r
49 } else {\r
50 var background = this.unselectedBackground != null ? this.unselectedBackground : table.getBackground ();\r
51 if (background == null || Clazz.instanceOf (background, javax.swing.plaf.UIResource)) {\r
52 var alternateColor = jssun.swing.DefaultLookup.getColor (this, this.ui, "Table.alternateRowColor");\r
53 if (alternateColor != null && row % 2 != 0) {\r
54 background = alternateColor;\r
55 }}Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setForeground", [this.unselectedForeground != null ? this.unselectedForeground : table.getForeground ()]);\r
56 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setBackground", [background]);\r
57 }this.setFont (table.getFont ());\r
58 if (hasFocus) {\r
59 var border = null;\r
60 if (isSelected) {\r
61 border = jssun.swing.DefaultLookup.getBorder (this, this.ui, "Table.focusSelectedCellHighlightBorder");\r
62 }if (border == null) {\r
63 border = jssun.swing.DefaultLookup.getBorder (this, this.ui, "Table.focusCellHighlightBorder");\r
64 }this.setBorder (border);\r
65 if (!isSelected && table.isCellEditable (row, column)) {\r
66 var col;\r
67 col = jssun.swing.DefaultLookup.getColor (this, this.ui, "Table.focusCellForeground");\r
68 if (col != null) {\r
69 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setForeground", [col]);\r
70 }col = jssun.swing.DefaultLookup.getColor (this, this.ui, "Table.focusCellBackground");\r
71 if (col != null) {\r
72 Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "setBackground", [col]);\r
73 }}} else {\r
74 this.setBorder (this.getNoFocusBorder ());\r
75 }this.setValue (value);\r
76 return this;\r
77 }, "javax.swing.JTable,~O,~B,~B,~N,~N");\r
78 Clazz.defineMethod (c$, "isOpaque", \r
79 function () {\r
80 var back = this.getBackground ();\r
81 var p = this.getParent ();\r
82 if (p != null) {\r
83 p = p.getParent ();\r
84 }var colorMatch = (back != null) && (p != null) && back.equals (p.getBackground ()) && p.isOpaque ();\r
85 return !colorMatch && Clazz.superCall (this, javax.swing.table.DefaultTableCellRenderer, "isOpaque", []);\r
86 });\r
87 Clazz.overrideMethod (c$, "invalidate", \r
88 function () {\r
89 });\r
90 Clazz.overrideMethod (c$, "validate", \r
91 function () {\r
92 });\r
93 Clazz.overrideMethod (c$, "revalidate", \r
94 function () {\r
95 });\r
96 Clazz.defineMethod (c$, "repaint", \r
97 function (tm, x, y, width, height) {\r
98 }, "~N,~N,~N,~N,~N");\r
99 Clazz.defineMethod (c$, "repaint", \r
100 function (r) {\r
101 }, "java.awt.Rectangle");\r
102 Clazz.defineMethod (c$, "repaint", \r
103 function () {\r
104 });\r
105 Clazz.overrideMethod (c$, "firePropertyChangeObject", \r
106 function (propertyName, oldValue, newValue) {\r
107 }, "~S,~O,~O");\r
108 Clazz.overrideMethod (c$, "firePropertyChangeBool", \r
109 function (propertyName, oldValue, newValue) {\r
110 }, "~S,~B,~B");\r
111 Clazz.defineMethod (c$, "setValue", \r
112 function (value) {\r
113 this.setText ((value == null) ? "" : value.toString ());\r
114 }, "~O");\r
115 Clazz.pu$h(self.c$);\r
116 c$ = Clazz.declareType (javax.swing.table.DefaultTableCellRenderer, "UIResource", javax.swing.table.DefaultTableCellRenderer, javax.swing.plaf.UIResource);\r
117 c$ = Clazz.p0p ();\r
118 c$.SAFE_NO_FOCUS_BORDER = c$.prototype.SAFE_NO_FOCUS_BORDER =  new javax.swing.border.EmptyBorder (1, 1, 1, 1);\r
119 c$.DEFAULT_NO_FOCUS_BORDER = c$.prototype.DEFAULT_NO_FOCUS_BORDER =  new javax.swing.border.EmptyBorder (1, 1, 1, 1);\r
120 c$.noFocusBorder = c$.prototype.noFocusBorder = javax.swing.table.DefaultTableCellRenderer.DEFAULT_NO_FOCUS_BORDER;\r
121 });\r