1 Clazz.declarePackage ("javax.swing.colorchooser");
\r
2 Clazz.load (["java.awt.LayoutManager"], "javax.swing.colorchooser.SmartGridLayout", ["java.awt.Dimension"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
8 this.componentCount = 0;
\r
9 this.layoutGrid = null;
\r
10 Clazz.instantialize (this, arguments);
\r
11 }, javax.swing.colorchooser, "SmartGridLayout", null, java.awt.LayoutManager);
\r
12 Clazz.makeConstructor (c$,
\r
13 function (numColumns, numRows) {
\r
14 this.rows = numRows;
\r
15 this.columns = numColumns;
\r
16 this.layoutGrid = Clazz.newArray (numColumns, numRows, null);
\r
18 Clazz.overrideMethod (c$, "layoutContainer",
\r
20 this.buildLayoutGrid (c);
\r
21 var rowHeights = Clazz.newIntArray (this.rows, 0);
\r
22 var columnWidths = Clazz.newIntArray (this.columns, 0);
\r
23 for (var row = 0; row < this.rows; row++) {
\r
24 rowHeights[row] = this.computeRowHeight (row);
\r
26 for (var column = 0; column < this.columns; column++) {
\r
27 columnWidths[column] = this.computeColumnWidth (column);
\r
29 var insets = c.getInsets ();
\r
30 if (c.getComponentOrientation ().isLeftToRight ()) {
\r
31 var horizLoc = insets.left;
\r
32 for (var column = 0; column < this.columns; column++) {
\r
33 var vertLoc = insets.top;
\r
34 for (var row = 0; row < this.rows; row++) {
\r
35 var current = this.layoutGrid[column][row];
\r
36 current.setBounds (horizLoc, vertLoc, columnWidths[column], rowHeights[row]);
\r
37 vertLoc += (rowHeights[row] + this.yGap);
\r
39 horizLoc += (columnWidths[column] + this.xGap);
\r
42 var horizLoc = c.getWidth () - insets.right;
\r
43 for (var column = 0; column < this.columns; column++) {
\r
44 var vertLoc = insets.top;
\r
45 horizLoc -= columnWidths[column];
\r
46 for (var row = 0; row < this.rows; row++) {
\r
47 var current = this.layoutGrid[column][row];
\r
48 current.setBounds (horizLoc, vertLoc, columnWidths[column], rowHeights[row]);
\r
49 vertLoc += (rowHeights[row] + this.yGap);
\r
51 horizLoc -= this.xGap;
\r
53 }}, "java.awt.Container");
\r
54 Clazz.overrideMethod (c$, "minimumLayoutSize",
\r
56 this.buildLayoutGrid (c);
\r
57 var insets = c.getInsets ();
\r
60 for (var row = 0; row < this.rows; row++) {
\r
61 height += this.computeRowHeight (row);
\r
63 for (var column = 0; column < this.columns; column++) {
\r
64 width += this.computeColumnWidth (column);
\r
66 height += (this.yGap * (this.rows - 1)) + insets.top + insets.bottom;
\r
67 width += (this.xGap * (this.columns - 1)) + insets.right + insets.left;
\r
68 return new java.awt.Dimension (width, height);
\r
69 }, "java.awt.Container");
\r
70 Clazz.overrideMethod (c$, "preferredLayoutSize",
\r
72 return this.minimumLayoutSize (c);
\r
73 }, "java.awt.Container");
\r
74 Clazz.overrideMethod (c$, "addLayoutComponent",
\r
76 }, "~S,java.awt.Component");
\r
77 Clazz.overrideMethod (c$, "removeLayoutComponent",
\r
79 }, "java.awt.Component");
\r
80 Clazz.defineMethod (c$, "buildLayoutGrid",
\r
82 var children = c.getComponents ();
\r
83 for (var componentCount = 0; componentCount < children.length; componentCount++) {
\r
86 if (componentCount != 0) {
\r
87 column = componentCount % this.columns;
\r
88 row = Clazz.doubleToInt ((componentCount - column) / this.columns);
\r
89 }this.layoutGrid[column][row] = children[componentCount];
\r
91 }, "java.awt.Container");
\r
92 Clazz.defineMethod (c$, "computeColumnWidth",
\r
93 function (columnNum) {
\r
95 for (var row = 0; row < this.rows; row++) {
\r
96 var width = this.layoutGrid[columnNum][row].getPreferredSize ().width;
\r
97 if (width > maxWidth) {
\r
102 Clazz.defineMethod (c$, "computeRowHeight",
\r
103 function (rowNum) {
\r
105 for (var column = 0; column < this.columns; column++) {
\r
106 var height = this.layoutGrid[column][rowNum].getPreferredSize ().height;
\r
107 if (height > maxHeight) {
\r
108 maxHeight = height;
\r