89abe8337f91cd252495c8c2a736501348c27808
[jalviewjs.git] / site / j2s / jssun / swing / DefaultLayoutStyle.js
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", 
5 function () {
6 return jssun.swing.DefaultLayoutStyle.INSTANCE;
7 });
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);
15 if (indent > 0) {
16 return indent;
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);
24 return 6;
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));
32 }return false;
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);
37 if (offset > 0) {
38 offset -= this.getButtonGap (target, this.flipDirection (position));
39 }if (offset < 0) {
40 return 0;
41 }return offset;
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);
55 }}return 0;
56 }, "javax.swing.JComponent,~N");
57 Clazz.defineMethod (c$, "checkPosition", 
58  function (position) {
59 if (position != 1 && position != 5 && position != 7 && position != 3) {
60 throw  new IllegalArgumentException ();
61 }}, "~N");
62 Clazz.defineMethod (c$, "flipDirection", 
63 function (position) {
64 switch (position) {
65 case 1:
66 return 5;
67 case 5:
68 return 1;
69 case 3:
70 return 7;
71 case 7:
72 return 3;
73 }
74 return 0;
75 }, "~N");
76 Clazz.defineMethod (c$, "getIndent", 
77 function (c, position) {
78 var classID = c.getUIClassID ();
79 if (classID === "CheckBoxUI" || classID === "RadioButtonUI") {
80 var button = c;
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;
88 }}return 0;
89 }, "javax.swing.JComponent,~N");
90 Clazz.defineMethod (c$, "getIcon", 
91  function (button) {
92 var icon = button.getIcon ();
93 if (icon != null) {
94 return icon;
95 }var key = null;
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";
100 }if (key != null) {
101 var oIcon = javax.swing.UIManager.get (key);
102 if (Clazz.instanceOf (oIcon, javax.swing.Icon)) {
103 return oIcon;
104 }}return null;
105 }, "javax.swing.AbstractButton");
106 Clazz.defineMethod (c$, "isLeftAligned", 
107  function (button, position) {
108 if (position == 7) {
109 var ltr = button.getComponentOrientation ().isLeftToRight ();
110 var hAlign = button.getHorizontalAlignment ();
111 return ((ltr && (hAlign == 2 || hAlign == 10)) || (!ltr && (hAlign == 11)));
112 }return false;
113 }, "javax.swing.AbstractButton,~N");
114 Clazz.defineMethod (c$, "isRightAligned", 
115  function (button, position) {
116 if (position == 3) {
117 var ltr = button.getComponentOrientation ().isLeftToRight ();
118 var hAlign = button.getHorizontalAlignment ();
119 return ((ltr && (hAlign == 4 || hAlign == 11)) || (!ltr && (hAlign == 10)));
120 }return false;
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) {
129 return 0;
130 }switch (position) {
131 case 1:
132 return insets.top;
133 case 5:
134 return insets.bottom;
135 case 3:
136 return insets.right;
137 case 7:
138 return insets.left;
139 }
140 return 0;
141 }, "java.awt.Insets,~N");
142 c$.INSTANCE = c$.prototype.INSTANCE =  new jssun.swing.DefaultLayoutStyle ();
143 });