1 Clazz.declarePackage ("jssun.swing");
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 () {
3 c$ = Clazz.declareType (jssun.swing, "DefaultLayoutStyle", javax.swing.LayoutStyle);
4 c$.getInstance = Clazz.overrideMethod (c$, "getInstance",
6 return jssun.swing.DefaultLayoutStyle.INSTANCE;
8 Clazz.overrideMethod (c$, "getPreferredGap",
9 function (component1, component2, type, position, parent) {
10 if (component1 == null || component2 == null || type == null) {
11 throw new NullPointerException ();
12 }this.checkPosition (position);
13 if (type === javax.swing.LayoutStyle.ComponentPlacement.INDENT && (position == 3 || position == 7)) {
14 var indent = this.getIndent (component1, position);
17 }}return (type === javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) ? 12 : 6;
18 }, "javax.swing.JComponent,javax.swing.JComponent,javax.swing.LayoutStyle.ComponentPlacement,~N,java.awt.Container");
19 Clazz.overrideMethod (c$, "getContainerGap",
20 function (component, position, parent) {
21 if (component == null) {
22 throw new NullPointerException ();
23 }this.checkPosition (position);
25 }, "javax.swing.JComponent,~N,java.awt.Container");
26 Clazz.defineMethod (c$, "isLabelAndNonlabel",
27 function (c1, c2, position) {
28 if (position == 3 || position == 7) {
29 var c1Label = (Clazz.instanceOf (c1, javax.swing.JLabel));
30 var c2Label = (Clazz.instanceOf (c2, javax.swing.JLabel));
31 return ((c1Label || c2Label) && (c1Label != c2Label));
33 }, "javax.swing.JComponent,javax.swing.JComponent,~N");
34 Clazz.defineMethod (c$, "getButtonGap",
35 function (source, target, position, offset) {
36 offset -= this.getButtonGap (source, position);
38 offset -= this.getButtonGap (target, this.flipDirection (position));
42 }, "javax.swing.JComponent,javax.swing.JComponent,~N,~N");
43 Clazz.defineMethod (c$, "getButtonGap",
44 function (source, position, offset) {
45 offset -= this.getButtonGap (source, position);
46 return Math.max (offset, 0);
47 }, "javax.swing.JComponent,~N,~N");
48 Clazz.defineMethod (c$, "getButtonGap",
49 function (c, position) {
50 var classID = c.getUIClassID ();
51 if ((classID === "CheckBoxUI" || classID === "RadioButtonUI") && !(c).isBorderPainted ()) {
52 var border = c.getBorder ();
53 if (Clazz.instanceOf (border, javax.swing.plaf.UIResource)) {
54 return this.getInset (c, position);
56 }, "javax.swing.JComponent,~N");
57 Clazz.defineMethod (c$, "checkPosition",
59 if (position != 1 && position != 5 && position != 7 && position != 3) {
60 throw new IllegalArgumentException ();
62 Clazz.defineMethod (c$, "flipDirection",
76 Clazz.defineMethod (c$, "getIndent",
77 function (c, position) {
78 var classID = c.getUIClassID ();
79 if (classID === "CheckBoxUI" || classID === "RadioButtonUI") {
81 var insets = c.getInsets ();
82 var icon = this.getIcon (button);
83 var gap = button.getIconTextGap ();
84 if (this.isLeftAligned (button, position)) {
85 return insets.left + icon.getIconWidth () + gap;
86 } else if (this.isRightAligned (button, position)) {
87 return insets.right + icon.getIconWidth () + gap;
89 }, "javax.swing.JComponent,~N");
90 Clazz.defineMethod (c$, "getIcon",
92 var icon = button.getIcon ();
96 if (Clazz.instanceOf (button, javax.swing.JCheckBox)) {
97 key = "CheckBox.icon";
98 } else if (Clazz.instanceOf (button, javax.swing.JRadioButton)) {
99 key = "RadioButton.icon";
101 var oIcon = javax.swing.UIManager.get (key);
102 if (Clazz.instanceOf (oIcon, javax.swing.Icon)) {
105 }, "javax.swing.AbstractButton");
106 Clazz.defineMethod (c$, "isLeftAligned",
107 function (button, position) {
109 var ltr = button.getComponentOrientation ().isLeftToRight ();
110 var hAlign = button.getHorizontalAlignment ();
111 return ((ltr && (hAlign == 2 || hAlign == 10)) || (!ltr && (hAlign == 11)));
113 }, "javax.swing.AbstractButton,~N");
114 Clazz.defineMethod (c$, "isRightAligned",
115 function (button, position) {
117 var ltr = button.getComponentOrientation ().isLeftToRight ();
118 var hAlign = button.getHorizontalAlignment ();
119 return ((ltr && (hAlign == 4 || hAlign == 11)) || (!ltr && (hAlign == 10)));
121 }, "javax.swing.AbstractButton,~N");
122 Clazz.defineMethod (c$, "getInset",
123 function (c, position) {
124 return this.getInset (c.getInsets (), position);
125 }, "javax.swing.JComponent,~N");
126 Clazz.defineMethod (c$, "getInset",
127 function (insets, position) {
128 if (insets == null) {
134 return insets.bottom;
141 }, "java.awt.Insets,~N");
142 c$.INSTANCE = c$.prototype.INSTANCE = new jssun.swing.DefaultLayoutStyle ();