Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / FlowLayout.js
index 0e1d78d..c1babe0 100644 (file)
-Clazz.declarePackage ("java.awt");\r
-Clazz.load (["java.awt.LayoutManager"], "java.awt.FlowLayout", ["java.awt.Dimension"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.align = 0;\r
-this.newAlign = 0;\r
-this.hgap = 0;\r
-this.vgap = 0;\r
-this.alignOnBaseline = false;\r
-Clazz.instantialize (this, arguments);\r
-}, java.awt, "FlowLayout", null, [java.awt.LayoutManager, java.io.Serializable]);\r
-Clazz.makeConstructor (c$, \r
-function () {\r
-this.construct (1, 5, 5);\r
-});\r
-Clazz.makeConstructor (c$, \r
-function (align) {\r
-this.construct (align, 5, 5);\r
-}, "~N");\r
-Clazz.makeConstructor (c$, \r
-function (align, hgap, vgap) {\r
-this.hgap = hgap;\r
-this.vgap = vgap;\r
-this.setAlignment (align);\r
-}, "~N,~N,~N");\r
-Clazz.defineMethod (c$, "getAlignment", \r
-function () {\r
-return this.newAlign;\r
-});\r
-Clazz.defineMethod (c$, "setAlignment", \r
-function (align) {\r
-this.newAlign = align;\r
-switch (align) {\r
-case 3:\r
-this.align = 0;\r
-break;\r
-case 4:\r
-this.align = 2;\r
-break;\r
-default:\r
-this.align = align;\r
-break;\r
-}\r
-}, "~N");\r
-Clazz.defineMethod (c$, "getHgap", \r
-function () {\r
-return this.hgap;\r
-});\r
-Clazz.defineMethod (c$, "setHgap", \r
-function (hgap) {\r
-this.hgap = hgap;\r
-}, "~N");\r
-Clazz.defineMethod (c$, "getVgap", \r
-function () {\r
-return this.vgap;\r
-});\r
-Clazz.defineMethod (c$, "setVgap", \r
-function (vgap) {\r
-this.vgap = vgap;\r
-}, "~N");\r
-Clazz.defineMethod (c$, "setAlignOnBaseline", \r
-function (alignOnBaseline) {\r
-this.alignOnBaseline = alignOnBaseline;\r
-}, "~B");\r
-Clazz.defineMethod (c$, "getAlignOnBaseline", \r
-function () {\r
-return this.alignOnBaseline;\r
-});\r
-Clazz.overrideMethod (c$, "addLayoutComponent", \r
-function (name, comp) {\r
-}, "~S,java.awt.Component");\r
-Clazz.overrideMethod (c$, "removeLayoutComponent", \r
-function (comp) {\r
-}, "java.awt.Component");\r
-Clazz.overrideMethod (c$, "preferredLayoutSize", \r
-function (target) {\r
-{\r
-var dim =  new java.awt.Dimension (0, 0);\r
-var nmembers = target.getComponentCount ();\r
-var firstVisibleComponent = true;\r
-var useBaseline = this.getAlignOnBaseline ();\r
-var maxAscent = 0;\r
-var maxDescent = 0;\r
-for (var i = 0; i < nmembers; i++) {\r
-var m = target.getComponent (i);\r
-if (m.isVisible ()) {\r
-var d = m.getPreferredSize ();\r
-dim.height = Math.max (dim.height, d.height);\r
-if (firstVisibleComponent) {\r
-firstVisibleComponent = false;\r
-} else {\r
-dim.width += this.hgap;\r
-}dim.width += d.width;\r
-if (useBaseline) {\r
-var baseline = m.getBaseline (d.width, d.height);\r
-if (baseline >= 0) {\r
-maxAscent = Math.max (maxAscent, baseline);\r
-maxDescent = Math.max (maxDescent, d.height - baseline);\r
-}}}}\r
-if (useBaseline) {\r
-dim.height = Math.max (maxAscent + maxDescent, dim.height);\r
-}var insets = target.getInsets ();\r
-dim.width += insets.left + insets.right + this.hgap * 2;\r
-dim.height += insets.top + insets.bottom + this.vgap * 2;\r
-return dim;\r
-}}, "java.awt.Container");\r
-Clazz.overrideMethod (c$, "minimumLayoutSize", \r
-function (target) {\r
-{\r
-var useBaseline = this.getAlignOnBaseline ();\r
-var dim =  new java.awt.Dimension (0, 0);\r
-var nmembers = target.getComponentCount ();\r
-var maxAscent = 0;\r
-var maxDescent = 0;\r
-var firstVisibleComponent = true;\r
-for (var i = 0; i < nmembers; i++) {\r
-var m = target.getComponent (i);\r
-if (m.visible) {\r
-var d = m.getMinimumSize ();\r
-dim.height = Math.max (dim.height, d.height);\r
-if (firstVisibleComponent) {\r
-firstVisibleComponent = false;\r
-} else {\r
-dim.width += this.hgap;\r
-}dim.width += d.width;\r
-if (useBaseline) {\r
-var baseline = m.getBaseline (d.width, d.height);\r
-if (baseline >= 0) {\r
-maxAscent = Math.max (maxAscent, baseline);\r
-maxDescent = Math.max (maxDescent, dim.height - baseline);\r
-}}}}\r
-if (useBaseline) {\r
-dim.height = Math.max (maxAscent + maxDescent, dim.height);\r
-}var insets = target.getInsets ();\r
-dim.width += insets.left + insets.right + this.hgap * 2;\r
-dim.height += insets.top + insets.bottom + this.vgap * 2;\r
-return dim;\r
-}}, "java.awt.Container");\r
-Clazz.defineMethod (c$, "moveComponents", \r
- function (target, x, y, width, height, rowStart, rowEnd, ltr, useBaseline, ascent, descent) {\r
-switch (this.newAlign) {\r
-case 0:\r
-x += ltr ? 0 : width;\r
-break;\r
-case 1:\r
-x += Clazz.doubleToInt (width / 2);\r
-break;\r
-case 2:\r
-x += ltr ? width : 0;\r
-break;\r
-case 3:\r
-break;\r
-case 4:\r
-x += width;\r
-break;\r
-}\r
-var maxAscent = 0;\r
-var nonbaselineHeight = 0;\r
-var baselineOffset = 0;\r
-if (useBaseline) {\r
-var maxDescent = 0;\r
-for (var i = rowStart; i < rowEnd; i++) {\r
-var m = target.getComponent (i);\r
-if (m.visible) {\r
-if (ascent[i] >= 0) {\r
-maxAscent = Math.max (maxAscent, ascent[i]);\r
-maxDescent = Math.max (maxDescent, descent[i]);\r
-} else {\r
-nonbaselineHeight = Math.max (m.getHeight (), nonbaselineHeight);\r
-}}}\r
-height = Math.max (maxAscent + maxDescent, nonbaselineHeight);\r
-baselineOffset = Clazz.doubleToInt ((height - maxAscent - maxDescent) / 2);\r
-}for (var i = rowStart; i < rowEnd; i++) {\r
-var m = target.getComponent (i);\r
-if (m.isVisible ()) {\r
-var cy;\r
-if (useBaseline && ascent[i] >= 0) {\r
-cy = y + baselineOffset + maxAscent - ascent[i];\r
-} else {\r
-cy = y + Clazz.doubleToInt ((height - m.height) / 2);\r
-}if (ltr) {\r
-m.setLocation (x, cy);\r
-} else {\r
-m.setLocation (target.width - x - m.width, cy);\r
-}x += m.width + this.hgap;\r
-}}\r
-return height;\r
-}, "java.awt.Container,~N,~N,~N,~N,~N,~N,~B,~B,~A,~A");\r
-Clazz.overrideMethod (c$, "layoutContainer", \r
-function (target) {\r
-System.out.println ("FlowLayout laying out " + target);\r
-{\r
-var insets = target.getInsets ();\r
-var maxwidth = target.width - (insets.left + insets.right + this.hgap * 2);\r
-var nmembers = target.getComponentCount ();\r
-var x = 0;\r
-var y = insets.top + this.vgap;\r
-var rowh = 0;\r
-var start = 0;\r
-var ltr = target.getComponentOrientation ().isLeftToRight ();\r
-var useBaseline = this.getAlignOnBaseline ();\r
-var ascent = null;\r
-var descent = null;\r
-if (useBaseline) {\r
-ascent =  Clazz.newIntArray (nmembers, 0);\r
-descent =  Clazz.newIntArray (nmembers, 0);\r
-}for (var i = 0; i < nmembers; i++) {\r
-var m = target.getComponent (i);\r
-if (m.isVisible ()) {\r
-var d = m.getPreferredSize ();\r
-m.setSize (d.width, d.height);\r
-if (useBaseline) {\r
-var baseline = m.getBaseline (d.width, d.height);\r
-if (baseline >= 0) {\r
-ascent[i] = baseline;\r
-descent[i] = d.height - baseline;\r
-} else {\r
-ascent[i] = -1;\r
-}}if ((x == 0) || ((x + d.width) <= maxwidth)) {\r
-if (x > 0) {\r
-x += this.hgap;\r
-}x += d.width;\r
-rowh = Math.max (rowh, d.height);\r
-} else {\r
-rowh = this.moveComponents (target, insets.left + this.hgap, y, maxwidth - x, rowh, start, i, ltr, useBaseline, ascent, descent);\r
-x = d.width;\r
-y += this.vgap + rowh;\r
-rowh = d.height;\r
-start = i;\r
-}}}\r
-this.moveComponents (target, insets.left + this.hgap, y, maxwidth - x, rowh, start, nmembers, ltr, useBaseline, ascent, descent);\r
-}}, "java.awt.Container");\r
-Clazz.overrideMethod (c$, "toString", \r
-function () {\r
-var str = "";\r
-switch (this.align) {\r
-case 0:\r
-str = ",align=left";\r
-break;\r
-case 1:\r
-str = ",align=center";\r
-break;\r
-case 2:\r
-str = ",align=right";\r
-break;\r
-case 3:\r
-str = ",align=leading";\r
-break;\r
-case 4:\r
-str = ",align=trailing";\r
-break;\r
-}\r
-return this.getClass ().getName () + "[hgap=" + this.hgap + ",vgap=" + this.vgap + str + "]";\r
-});\r
-Clazz.defineStatics (c$,\r
-"LEFT", 0,\r
-"CENTER", 1,\r
-"RIGHT", 2,\r
-"LEADING", 3,\r
-"TRAILING", 4);\r
-});\r
+Clazz.declarePackage ("java.awt");
+Clazz.load (["java.awt.LayoutManager"], "java.awt.FlowLayout", ["java.awt.Dimension"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.align = 0;
+this.newAlign = 0;
+this.hgap = 0;
+this.vgap = 0;
+this.alignOnBaseline = false;
+Clazz.instantialize (this, arguments);
+}, java.awt, "FlowLayout", null, [java.awt.LayoutManager, java.io.Serializable]);
+Clazz.makeConstructor (c$, 
+function () {
+this.construct (1, 5, 5);
+});
+Clazz.makeConstructor (c$, 
+function (align) {
+this.construct (align, 5, 5);
+}, "~N");
+Clazz.makeConstructor (c$, 
+function (align, hgap, vgap) {
+this.hgap = hgap;
+this.vgap = vgap;
+this.setAlignment (align);
+}, "~N,~N,~N");
+Clazz.defineMethod (c$, "getAlignment", 
+function () {
+return this.newAlign;
+});
+Clazz.defineMethod (c$, "setAlignment", 
+function (align) {
+this.newAlign = align;
+switch (align) {
+case 3:
+this.align = 0;
+break;
+case 4:
+this.align = 2;
+break;
+default:
+this.align = align;
+break;
+}
+}, "~N");
+Clazz.defineMethod (c$, "getHgap", 
+function () {
+return this.hgap;
+});
+Clazz.defineMethod (c$, "setHgap", 
+function (hgap) {
+this.hgap = hgap;
+}, "~N");
+Clazz.defineMethod (c$, "getVgap", 
+function () {
+return this.vgap;
+});
+Clazz.defineMethod (c$, "setVgap", 
+function (vgap) {
+this.vgap = vgap;
+}, "~N");
+Clazz.defineMethod (c$, "setAlignOnBaseline", 
+function (alignOnBaseline) {
+this.alignOnBaseline = alignOnBaseline;
+}, "~B");
+Clazz.defineMethod (c$, "getAlignOnBaseline", 
+function () {
+return this.alignOnBaseline;
+});
+Clazz.overrideMethod (c$, "addLayoutComponent", 
+function (name, comp) {
+}, "~S,java.awt.Component");
+Clazz.overrideMethod (c$, "removeLayoutComponent", 
+function (comp) {
+}, "java.awt.Component");
+Clazz.overrideMethod (c$, "preferredLayoutSize", 
+function (target) {
+{
+var dim =  new java.awt.Dimension (0, 0);
+var nmembers = target.getComponentCount ();
+var firstVisibleComponent = true;
+var useBaseline = this.getAlignOnBaseline ();
+var maxAscent = 0;
+var maxDescent = 0;
+for (var i = 0; i < nmembers; i++) {
+var m = target.getComponent (i);
+if (m.isVisible ()) {
+var d = m.getPreferredSize ();
+dim.height = Math.max (dim.height, d.height);
+if (firstVisibleComponent) {
+firstVisibleComponent = false;
+} else {
+dim.width += this.hgap;
+}dim.width += d.width;
+if (useBaseline) {
+var baseline = m.getBaseline (d.width, d.height);
+if (baseline >= 0) {
+maxAscent = Math.max (maxAscent, baseline);
+maxDescent = Math.max (maxDescent, d.height - baseline);
+}}}}
+if (useBaseline) {
+dim.height = Math.max (maxAscent + maxDescent, dim.height);
+}var insets = target.getInsets ();
+dim.width += insets.left + insets.right + this.hgap * 2;
+dim.height += insets.top + insets.bottom + this.vgap * 2;
+return dim;
+}}, "java.awt.Container");
+Clazz.overrideMethod (c$, "minimumLayoutSize", 
+function (target) {
+{
+var useBaseline = this.getAlignOnBaseline ();
+var dim =  new java.awt.Dimension (0, 0);
+var nmembers = target.getComponentCount ();
+var maxAscent = 0;
+var maxDescent = 0;
+var firstVisibleComponent = true;
+for (var i = 0; i < nmembers; i++) {
+var m = target.getComponent (i);
+if (m.visible) {
+var d = m.getMinimumSize ();
+dim.height = Math.max (dim.height, d.height);
+if (firstVisibleComponent) {
+firstVisibleComponent = false;
+} else {
+dim.width += this.hgap;
+}dim.width += d.width;
+if (useBaseline) {
+var baseline = m.getBaseline (d.width, d.height);
+if (baseline >= 0) {
+maxAscent = Math.max (maxAscent, baseline);
+maxDescent = Math.max (maxDescent, dim.height - baseline);
+}}}}
+if (useBaseline) {
+dim.height = Math.max (maxAscent + maxDescent, dim.height);
+}var insets = target.getInsets ();
+dim.width += insets.left + insets.right + this.hgap * 2;
+dim.height += insets.top + insets.bottom + this.vgap * 2;
+return dim;
+}}, "java.awt.Container");
+Clazz.defineMethod (c$, "moveComponents", 
+ function (target, x, y, width, height, rowStart, rowEnd, ltr, useBaseline, ascent, descent) {
+switch (this.newAlign) {
+case 0:
+x += ltr ? 0 : width;
+break;
+case 1:
+x += Clazz.doubleToInt (width / 2);
+break;
+case 2:
+x += ltr ? width : 0;
+break;
+case 3:
+break;
+case 4:
+x += width;
+break;
+}
+var maxAscent = 0;
+var nonbaselineHeight = 0;
+var baselineOffset = 0;
+if (useBaseline) {
+var maxDescent = 0;
+for (var i = rowStart; i < rowEnd; i++) {
+var m = target.getComponent (i);
+if (m.visible) {
+if (ascent[i] >= 0) {
+maxAscent = Math.max (maxAscent, ascent[i]);
+maxDescent = Math.max (maxDescent, descent[i]);
+} else {
+nonbaselineHeight = Math.max (m.getHeight (), nonbaselineHeight);
+}}}
+height = Math.max (maxAscent + maxDescent, nonbaselineHeight);
+baselineOffset = Clazz.doubleToInt ((height - maxAscent - maxDescent) / 2);
+}for (var i = rowStart; i < rowEnd; i++) {
+var m = target.getComponent (i);
+if (m.isVisible ()) {
+var cy;
+if (useBaseline && ascent[i] >= 0) {
+cy = y + baselineOffset + maxAscent - ascent[i];
+} else {
+cy = y + Clazz.doubleToInt ((height - m.height) / 2);
+}if (ltr) {
+m.setLocation (x, cy);
+} else {
+m.setLocation (target.width - x - m.width, cy);
+}x += m.width + this.hgap;
+}}
+return height;
+}, "java.awt.Container,~N,~N,~N,~N,~N,~N,~B,~B,~A,~A");
+Clazz.overrideMethod (c$, "layoutContainer", 
+function (target) {
+System.out.println ("FlowLayout laying out " + target);
+{
+var insets = target.getInsets ();
+var maxwidth = target.width - (insets.left + insets.right + this.hgap * 2);
+var nmembers = target.getComponentCount ();
+var x = 0;
+var y = insets.top + this.vgap;
+var rowh = 0;
+var start = 0;
+var ltr = target.getComponentOrientation ().isLeftToRight ();
+var useBaseline = this.getAlignOnBaseline ();
+var ascent = null;
+var descent = null;
+if (useBaseline) {
+ascent =  Clazz.newIntArray (nmembers, 0);
+descent =  Clazz.newIntArray (nmembers, 0);
+}for (var i = 0; i < nmembers; i++) {
+var m = target.getComponent (i);
+if (m.isVisible ()) {
+var d = m.getPreferredSize ();
+m.setSize (d.width, d.height);
+if (useBaseline) {
+var baseline = m.getBaseline (d.width, d.height);
+if (baseline >= 0) {
+ascent[i] = baseline;
+descent[i] = d.height - baseline;
+} else {
+ascent[i] = -1;
+}}if ((x == 0) || ((x + d.width) <= maxwidth)) {
+if (x > 0) {
+x += this.hgap;
+}x += d.width;
+rowh = Math.max (rowh, d.height);
+} else {
+rowh = this.moveComponents (target, insets.left + this.hgap, y, maxwidth - x, rowh, start, i, ltr, useBaseline, ascent, descent);
+x = d.width;
+y += this.vgap + rowh;
+rowh = d.height;
+start = i;
+}}}
+this.moveComponents (target, insets.left + this.hgap, y, maxwidth - x, rowh, start, nmembers, ltr, useBaseline, ascent, descent);
+}}, "java.awt.Container");
+Clazz.overrideMethod (c$, "toString", 
+function () {
+var str = "";
+switch (this.align) {
+case 0:
+str = ",align=left";
+break;
+case 1:
+str = ",align=center";
+break;
+case 2:
+str = ",align=right";
+break;
+case 3:
+str = ",align=leading";
+break;
+case 4:
+str = ",align=trailing";
+break;
+}
+return this.getClass ().getName () + "[hgap=" + this.hgap + ",vgap=" + this.vgap + str + "]";
+});
+Clazz.defineStatics (c$,
+"LEFT", 0,
+"CENTER", 1,
+"RIGHT", 2,
+"LEADING", 3,
+"TRAILING", 4);
+});