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
6 return jssun.swing.DefaultLayoutStyle.INSTANCE;
\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
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
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
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
38 offset -= this.getButtonGap (target, this.flipDirection (position));
\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
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
62 Clazz.defineMethod (c$, "flipDirection",
\r
63 function (position) {
\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
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
89 }, "javax.swing.JComponent,~N");
\r
90 Clazz.defineMethod (c$, "getIcon",
\r
92 var icon = button.getIcon ();
\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
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
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
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
130 }switch (position) {
\r
134 return insets.bottom;
\r
136 return insets.right;
\r
138 return insets.left;
\r
141 }, "java.awt.Insets,~N");
\r
142 c$.INSTANCE = c$.prototype.INSTANCE = new jssun.swing.DefaultLayoutStyle ();
\r