JAL-1807
[jalview.git] / site / swingjs / j2s / javax / swing / colorchooser / CenterLayout.js
1 Clazz.declarePackage ("javax.swing.colorchooser");
2 Clazz.load (["java.awt.LayoutManager"], "javax.swing.colorchooser.CenterLayout", ["java.awt.Dimension"], function () {
3 c$ = Clazz.declareType (javax.swing.colorchooser, "CenterLayout", null, java.awt.LayoutManager);
4 Clazz.overrideMethod (c$, "addLayoutComponent", 
5 function (name, comp) {
6 }, "~S,java.awt.Component");
7 Clazz.overrideMethod (c$, "removeLayoutComponent", 
8 function (comp) {
9 }, "java.awt.Component");
10 Clazz.overrideMethod (c$, "preferredLayoutSize", 
11 function (container) {
12 var c = container.getComponent (0);
13 if (c != null) {
14 var size = c.getPreferredSize ();
15 var insets = container.getInsets ();
16 size.width += insets.left + insets.right;
17 size.height += insets.top + insets.bottom;
18 return size;
19 } else {
20 return  new java.awt.Dimension (0, 0);
21 }}, "java.awt.Container");
22 Clazz.overrideMethod (c$, "minimumLayoutSize", 
23 function (cont) {
24 return this.preferredLayoutSize (cont);
25 }, "java.awt.Container");
26 Clazz.overrideMethod (c$, "layoutContainer", 
27 function (container) {
28 try {
29 var c = container.getComponent (0);
30 c.setSize (c.getPreferredSize ());
31 var size = c.getSize ();
32 var containerSize = container.getSize ();
33 var containerInsets = container.getInsets ();
34 containerSize.width -= containerInsets.left + containerInsets.right;
35 containerSize.height -= containerInsets.top + containerInsets.bottom;
36 var componentLeft = (Clazz.doubleToInt (containerSize.width / 2)) - (Clazz.doubleToInt (size.width / 2));
37 var componentTop = (Clazz.doubleToInt (containerSize.height / 2)) - (Clazz.doubleToInt (size.height / 2));
38 componentLeft += containerInsets.left;
39 componentTop += containerInsets.top;
40 c.setBounds (componentLeft, componentTop, size.width, size.height);
41 } catch (e) {
42 if (Clazz.exceptionOf (e, Exception)) {
43 } else {
44 throw e;
45 }
46 }
47 }, "java.awt.Container");
48 });