annotate java-genomics-toolkit/gui/javax/swing/layout/SpringUtilities.java @ 0:1daf3026d231

Upload alpha version
author timpalpant
date Mon, 13 Feb 2012 21:55:55 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
1 /*
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
2 * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
3 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
4 * Redistribution and use in source and binary forms, with or without
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
5 * modification, are permitted provided that the following conditions
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
6 * are met:
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
7 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
8 * - Redistributions of source code must retain the above copyright
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
9 * notice, this list of conditions and the following disclaimer.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
10 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
11 * - Redistributions in binary form must reproduce the above copyright
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
12 * notice, this list of conditions and the following disclaimer in the
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
13 * documentation and/or other materials provided with the distribution.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
14 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
15 * - Neither the name of Oracle or the names of its
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
16 * contributors may be used to endorse or promote products derived
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
17 * from this software without specific prior written permission.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
18 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
30 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
31
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
32 package javax.swing.layout;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
33
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
34 import javax.swing.*;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
35 import javax.swing.SpringLayout;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
36 import java.awt.*;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
37
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
38 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
39 * A 1.4 file that provides utility methods for
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
40 * creating form- or grid-style layouts with SpringLayout.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
41 * These utilities are used by several programs, such as
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
42 * SpringBox and SpringCompactGrid.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
43 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
44 public class SpringUtilities {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
45 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
46 * A debugging utility that prints to stdout the component's
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
47 * minimum, preferred, and maximum sizes.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
48 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
49 public static void printSizes(Component c) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
50 System.out.println("minimumSize = " + c.getMinimumSize());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
51 System.out.println("preferredSize = " + c.getPreferredSize());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
52 System.out.println("maximumSize = " + c.getMaximumSize());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
53 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
54
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
55 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
56 * Aligns the first <code>rows</code> * <code>cols</code>
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
57 * components of <code>parent</code> in
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
58 * a grid. Each component is as big as the maximum
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
59 * preferred width and height of the components.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
60 * The parent is made just big enough to fit them all.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
61 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
62 * @param rows number of rows
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
63 * @param cols number of columns
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
64 * @param initialX x location to start the grid at
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
65 * @param initialY y location to start the grid at
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
66 * @param xPad x padding between cells
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
67 * @param yPad y padding between cells
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
68 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
69 public static void makeGrid(Container parent,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
70 int rows, int cols,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
71 int initialX, int initialY,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
72 int xPad, int yPad) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
73 SpringLayout layout;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
74 try {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
75 layout = (SpringLayout)parent.getLayout();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
76 } catch (ClassCastException exc) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
77 System.err.println("The first argument to makeGrid must use SpringLayout.");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
78 return;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
79 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
80
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
81 Spring xPadSpring = Spring.constant(xPad);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
82 Spring yPadSpring = Spring.constant(yPad);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
83 Spring initialXSpring = Spring.constant(initialX);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
84 Spring initialYSpring = Spring.constant(initialY);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
85 int max = rows * cols;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
86
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
87 //Calculate Springs that are the max of the width/height so that all
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
88 //cells have the same size.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
89 Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
90 getWidth();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
91 Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
92 getHeight();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
93 for (int i = 1; i < max; i++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
94 SpringLayout.Constraints cons = layout.getConstraints(
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
95 parent.getComponent(i));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
96
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
97 maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
98 maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
99 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
100
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
101 //Apply the new width/height Spring. This forces all the
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
102 //components to have the same size.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
103 for (int i = 0; i < max; i++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
104 SpringLayout.Constraints cons = layout.getConstraints(
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
105 parent.getComponent(i));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
106
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
107 cons.setWidth(maxWidthSpring);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
108 cons.setHeight(maxHeightSpring);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
109 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
110
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
111 //Then adjust the x/y constraints of all the cells so that they
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
112 //are aligned in a grid.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
113 SpringLayout.Constraints lastCons = null;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
114 SpringLayout.Constraints lastRowCons = null;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
115 for (int i = 0; i < max; i++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
116 SpringLayout.Constraints cons = layout.getConstraints(
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
117 parent.getComponent(i));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
118 if (i % cols == 0) { //start of new row
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
119 lastRowCons = lastCons;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
120 cons.setX(initialXSpring);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
121 } else { //x position depends on previous component
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
122 cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
123 xPadSpring));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
124 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
125
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
126 if (i / cols == 0) { //first row
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
127 cons.setY(initialYSpring);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
128 } else { //y position depends on previous row
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
129 cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
130 yPadSpring));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
131 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
132 lastCons = cons;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
133 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
134
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
135 //Set the parent's size.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
136 SpringLayout.Constraints pCons = layout.getConstraints(parent);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
137 pCons.setConstraint(SpringLayout.SOUTH,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
138 Spring.sum(
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
139 Spring.constant(yPad),
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
140 lastCons.getConstraint(SpringLayout.SOUTH)));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
141 pCons.setConstraint(SpringLayout.EAST,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
142 Spring.sum(
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
143 Spring.constant(xPad),
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
144 lastCons.getConstraint(SpringLayout.EAST)));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
145 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
146
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
147 /* Used by makeCompactGrid. */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
148 private static SpringLayout.Constraints getConstraintsForCell(
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
149 int row, int col,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
150 Container parent,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
151 int cols) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
152 SpringLayout layout = (SpringLayout) parent.getLayout();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
153 Component c = parent.getComponent(row * cols + col);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
154 return layout.getConstraints(c);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
155 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
156
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
157 /**
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
158 * Aligns the first <code>rows</code> * <code>cols</code>
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
159 * components of <code>parent</code> in
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
160 * a grid. Each component in a column is as wide as the maximum
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
161 * preferred width of the components in that column;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
162 * height is similarly determined for each row.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
163 * The parent is made just big enough to fit them all.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
164 *
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
165 * @param rows number of rows
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
166 * @param cols number of columns
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
167 * @param initialX x location to start the grid at
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
168 * @param initialY y location to start the grid at
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
169 * @param xPad x padding between cells
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
170 * @param yPad y padding between cells
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
171 */
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
172 public static void makeCompactGrid(Container parent,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
173 int rows, int cols,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
174 int initialX, int initialY,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
175 int xPad, int yPad) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
176 SpringLayout layout;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
177 try {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
178 layout = (SpringLayout)parent.getLayout();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
179 } catch (ClassCastException exc) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
180 System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
181 return;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
182 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
183
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
184 //Align all cells in each column and make them the same width.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
185 Spring x = Spring.constant(initialX);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
186 for (int c = 0; c < cols; c++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
187 Spring width = Spring.constant(0);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
188 for (int r = 0; r < rows; r++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
189 width = Spring.max(width,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
190 getConstraintsForCell(r, c, parent, cols).
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
191 getWidth());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
192 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
193 for (int r = 0; r < rows; r++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
194 SpringLayout.Constraints constraints =
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
195 getConstraintsForCell(r, c, parent, cols);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
196 constraints.setX(x);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
197 constraints.setWidth(width);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
198 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
199 x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
200 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
201
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
202 //Align all cells in each row and make them the same height.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
203 Spring y = Spring.constant(initialY);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
204 for (int r = 0; r < rows; r++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
205 Spring height = Spring.constant(0);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
206 for (int c = 0; c < cols; c++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
207 height = Spring.max(height,
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
208 getConstraintsForCell(r, c, parent, cols).
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
209 getHeight());
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
210 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
211 for (int c = 0; c < cols; c++) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
212 SpringLayout.Constraints constraints =
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
213 getConstraintsForCell(r, c, parent, cols);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
214 constraints.setY(y);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
215 constraints.setHeight(height);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
216 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
217 y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
218 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
219
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
220 //Set the parent's size.
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
221 SpringLayout.Constraints pCons = layout.getConstraints(parent);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
222 pCons.setConstraint(SpringLayout.SOUTH, y);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
223 pCons.setConstraint(SpringLayout.EAST, x);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
224 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
225 }