f0b1a774ee87642919b5b1c29eb520af7329d64e
[jalviewjs.git] / site / j2s / jssun / swing / DefaultLayoutStyle.js
1 Clazz.declarePackage ("jssun.swing");\r
2 Clazz.load (["javax.swing.LayoutStyle"], "jssun.swing.DefaultLayoutStyle", ["java.lang.IllegalArgumentException", "$.NullPointerException", "javax.swing.Icon", "$.JCheckBox", "$.JLabel", "$.JRadioButton", "$.UIManager", "javax.swing.plaf.UIResource"], function () {\r
3 c$ = Clazz.declareType (jssun.swing, "DefaultLayoutStyle", javax.swing.LayoutStyle);\r
4 c$.getInstance = Clazz.overrideMethod (c$, "getInstance", \r
5 function () {\r
6 return jssun.swing.DefaultLayoutStyle.INSTANCE;\r
7 });\r
8 Clazz.overrideMethod (c$, "getPreferredGap", \r
9 function (component1, component2, type, position, parent) {\r
10 if (component1 == null || component2 == null || type == null) {\r
11 throw  new NullPointerException ();\r
12 }this.checkPosition (position);\r
13 if (type === javax.swing.LayoutStyle.ComponentPlacement.INDENT && (position == 3 || position == 7)) {\r
14 var indent = this.getIndent (component1, position);\r
15 if (indent > 0) {\r
16 return indent;\r
17 }}return (type === javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) ? 12 : 6;\r
18 }, "javax.swing.JComponent,javax.swing.JComponent,javax.swing.LayoutStyle.ComponentPlacement,~N,java.awt.Container");\r
19 Clazz.overrideMethod (c$, "getContainerGap", \r
20 function (component, position, parent) {\r
21 if (component == null) {\r
22 throw  new NullPointerException ();\r
23 }this.checkPosition (position);\r
24 return 6;\r
25 }, "javax.swing.JComponent,~N,java.awt.Container");\r
26 Clazz.defineMethod (c$, "isLabelAndNonlabel", \r
27 function (c1, c2, position) {\r
28 if (position == 3 || position == 7) {\r
29 var c1Label = (Clazz.instanceOf (c1, javax.swing.JLabel));\r
30 var c2Label = (Clazz.instanceOf (c2, javax.swing.JLabel));\r
31 return ((c1Label || c2Label) && (c1Label != c2Label));\r
32 }return false;\r
33 }, "javax.swing.JComponent,javax.swing.JComponent,~N");\r
34 Clazz.defineMethod (c$, "getButtonGap", \r
35 function (source, target, position, offset) {\r
36 offset -= this.getButtonGap (source, position);\r
37 if (offset > 0) {\r
38 offset -= this.getButtonGap (target, this.flipDirection (position));\r
39 }if (offset < 0) {\r
40 return 0;\r
41 }return offset;\r
42 }, "javax.swing.JComponent,javax.swing.JComponent,~N,~N");\r
43 Clazz.defineMethod (c$, "getButtonGap", \r
44 function (source, position, offset) {\r
45 offset -= this.getButtonGap (source, position);\r
46 return Math.max (offset, 0);\r
47 }, "javax.swing.JComponent,~N,~N");\r
48 Clazz.defineMethod (c$, "getButtonGap", \r
49 function (c, position) {\r
50 var classID = c.getUIClassID ();\r
51 if ((classID === "CheckBoxUI" || classID === "RadioButtonUI") && !(c).isBorderPainted ()) {\r
52 var border = c.getBorder ();\r
53 if (Clazz.instanceOf (border, javax.swing.plaf.UIResource)) {\r
54 return this.getInset (c, position);\r
55 }}return 0;\r
56 }, "javax.swing.JComponent,~N");\r
57 Clazz.defineMethod (c$, "checkPosition", \r
58  function (position) {\r
59 if (position != 1 && position != 5 && position != 7 && position != 3) {\r
60 throw  new IllegalArgumentException ();\r
61 }}, "~N");\r
62 Clazz.defineMethod (c$, "flipDirection", \r
63 function (position) {\r
64 switch (position) {\r
65 case 1:\r
66 return 5;\r
67 case 5:\r
68 return 1;\r
69 case 3:\r
70 return 7;\r
71 case 7:\r
72 return 3;\r
73 }\r
74 return 0;\r
75 }, "~N");\r
76 Clazz.defineMethod (c$, "getIndent", \r
77 function (c, position) {\r
78 var classID = c.getUIClassID ();\r
79 if (classID === "CheckBoxUI" || classID === "RadioButtonUI") {\r
80 var button = c;\r
81 var insets = c.getInsets ();\r
82 var icon = this.getIcon (button);\r
83 var gap = button.getIconTextGap ();\r
84 if (this.isLeftAligned (button, position)) {\r
85 return insets.left + icon.getIconWidth () + gap;\r
86 } else if (this.isRightAligned (button, position)) {\r
87 return insets.right + icon.getIconWidth () + gap;\r
88 }}return 0;\r
89 }, "javax.swing.JComponent,~N");\r
90 Clazz.defineMethod (c$, "getIcon", \r
91  function (button) {\r
92 var icon = button.getIcon ();\r
93 if (icon != null) {\r
94 return icon;\r
95 }var key = null;\r
96 if (Clazz.instanceOf (button, javax.swing.JCheckBox)) {\r
97 key = "CheckBox.icon";\r
98 } else if (Clazz.instanceOf (button, javax.swing.JRadioButton)) {\r
99 key = "RadioButton.icon";\r
100 }if (key != null) {\r
101 var oIcon = javax.swing.UIManager.get (key);\r
102 if (Clazz.instanceOf (oIcon, javax.swing.Icon)) {\r
103 return oIcon;\r
104 }}return null;\r
105 }, "javax.swing.AbstractButton");\r
106 Clazz.defineMethod (c$, "isLeftAligned", \r
107  function (button, position) {\r
108 if (position == 7) {\r
109 var ltr = button.getComponentOrientation ().isLeftToRight ();\r
110 var hAlign = button.getHorizontalAlignment ();\r
111 return ((ltr && (hAlign == 2 || hAlign == 10)) || (!ltr && (hAlign == 11)));\r
112 }return false;\r
113 }, "javax.swing.AbstractButton,~N");\r
114 Clazz.defineMethod (c$, "isRightAligned", \r
115  function (button, position) {\r
116 if (position == 3) {\r
117 var ltr = button.getComponentOrientation ().isLeftToRight ();\r
118 var hAlign = button.getHorizontalAlignment ();\r
119 return ((ltr && (hAlign == 4 || hAlign == 11)) || (!ltr && (hAlign == 10)));\r
120 }return false;\r
121 }, "javax.swing.AbstractButton,~N");\r
122 Clazz.defineMethod (c$, "getInset", \r
123  function (c, position) {\r
124 return this.getInset (c.getInsets (), position);\r
125 }, "javax.swing.JComponent,~N");\r
126 Clazz.defineMethod (c$, "getInset", \r
127  function (insets, position) {\r
128 if (insets == null) {\r
129 return 0;\r
130 }switch (position) {\r
131 case 1:\r
132 return insets.top;\r
133 case 5:\r
134 return insets.bottom;\r
135 case 3:\r
136 return insets.right;\r
137 case 7:\r
138 return insets.left;\r
139 }\r
140 return 0;\r
141 }, "java.awt.Insets,~N");\r
142 c$.INSTANCE = c$.prototype.INSTANCE =  new jssun.swing.DefaultLayoutStyle ();\r
143 });\r