unused - could be trashed.
[jalview.git] / unused / net / miginfocom / layout / AC.java
1 package net.miginfocom.layout;
2
3 import java.io.*;
4 import java.util.ArrayList;
5
6 /*
7  * License (BSD):
8  * ==============
9  *
10  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
11  * All rights reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without modification,
14  * are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright notice, this list
16  * of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright notice, this
18  * list of conditions and the following disclaimer in the documentation and/or other
19  * materials provided with the distribution.
20  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
21  * used to endorse or promote products derived from this software without specific
22  * prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
30  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
33  * OF SUCH DAMAGE.
34  *
35  * @version 1.0
36  * @author Mikael Grev, MiG InfoCom AB
37  *         Date: 2006-sep-08
38  */
39
40 /** A constraint that holds the column <b>or</b> row constraints for the grid. It also holds the gaps between the rows and columns.
41  * <p>
42  * This class is a holder and builder for a number of {@link net.miginfocom.layout.DimConstraint}s.
43  * <p>
44  * For a more thorough explanation of what these constraints do, and how to build the constraints, see the White Paper or Cheat Sheet at www.migcomponents.com.
45  * <p>
46  * Note that there are two way to build this constraint. Through String (e.g. <code>"[100]3[200,fill]"</code> or through API (E.g.
47  * <code>new AC().size("100").gap("3").size("200").fill()</code>.
48  */
49 public final class AC implements Externalizable
50 {
51         private final ArrayList<DimConstraint> cList = new ArrayList<DimConstraint>(1);
52
53         private transient int curIx = 0;
54
55         /** Constructor. Creates an instance that can be configured manually. Will be initialized with a default
56          * {@link net.miginfocom.layout.DimConstraint}.
57          */
58         public AC()
59         {
60                 cList.add(new DimConstraint());
61         }
62
63         /** Property. The different {@link net.miginfocom.layout.DimConstraint}s that this object consists of.
64          * These <code>DimConstraints</code> contains all information in this class.
65          * <p>
66          * Yes, we are embarrassingly aware that the method is misspelled.
67          * @return The different {@link net.miginfocom.layout.DimConstraint}s that this object consists of. A new list and
68          * never <code>null</code>.
69          */
70         public final DimConstraint[] getConstaints()
71         {
72                 return cList.toArray(new DimConstraint[cList.size()]);
73         }
74
75         /** Sets the different {@link net.miginfocom.layout.DimConstraint}s that this object should consists of.
76          * <p>
77          * Yes, we are embarrassingly aware that the method is misspelled.
78          * @param constr The different {@link net.miginfocom.layout.DimConstraint}s that this object consists of. The list
79          * will be copied for storage. <code>null</code> or and empty array will reset the constraints to one <code>DimConstraint</code>
80          * with default values.
81          */
82         public final void setConstaints(DimConstraint[] constr)
83         {
84                 if (constr == null || constr.length < 1 )
85                         constr = new DimConstraint[] {new DimConstraint()};
86
87                 cList.clear();
88                 cList.ensureCapacity(constr.length);
89                 for (DimConstraint c : constr)
90                         cList.add(c);
91         }
92
93         /** Returns the number of rows/columns that this constraints currently have.
94          * @return The number of rows/columns that this constraints currently have. At least 1.
95          */
96         public int getCount()
97         {
98                 return cList.size();
99         }
100
101         /** Sets the total number of rows/columns to <code>size</code>. If the number of rows/columns is already more
102          * than <code>size</code> nothing will happen.
103          * @param size The total number of rows/columns
104          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
105          */
106         public final AC count(int size)
107         {
108                 makeSize(size);
109                 return this;
110         }
111
112         /** Specifies that the current row/column should not be grid-like. The while row/column will have its components layed out
113          * in one single cell. It is the same as to say that the cells in this column/row will all be merged (a.k.a spanned).
114          * <p>
115          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
116          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
117          */
118         public final AC noGrid()
119         {
120                 return noGrid(curIx);
121         }
122
123         /** Specifies that the indicated rows/columns should not be grid-like. The while row/column will have its components layed out
124          * in one single cell. It is the same as to say that the cells in this column/row will all be merged (a.k.a spanned).
125          * <p>
126          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
127          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
128          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
129          */
130         public final AC noGrid(int... indexes)
131         {
132                 for (int i = indexes.length - 1; i >= 0; i--) {
133                         int ix = indexes[i];
134                         makeSize(ix);
135                         cList.get(ix).setNoGrid(true);
136                 }
137                 return this;
138         }
139
140         /** Sets the current row/column to <code>i</code>. If the current number of rows/columns is less than <code>i</code> a call
141          * to {@link #count(int)} will set the size accordingly.
142          * <p>
143          * The next call to any of the constraint methods (e.g. {@link net.miginfocom.layout.AC#noGrid}) will be carried
144          * out on this new row/column.
145          * <p>
146          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
147          * @param i The new current row/column.
148          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
149          */
150         public final AC index(int i)
151         {
152                 makeSize(i);
153                 curIx = i;
154                 return this;
155         }
156
157         /** Specifies that the current row/column's component should grow by default. It does not affect the size of the row/column.
158          * <p>
159          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
160          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
161          */
162         public final AC fill()
163         {
164                 return fill(curIx);
165         }
166
167         /** Specifies that the indicated rows'/columns' component should grow by default. It does not affect the size of the row/column.
168          * <p>
169          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
170          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
171          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
172          */
173         public final AC fill(int... indexes)
174         {
175                 for (int i = indexes.length - 1; i >= 0; i--) {
176                         int ix = indexes[i];
177                         makeSize(ix);
178                         cList.get(ix).setFill(true);
179                 }
180                 return this;
181         }
182
183 //      /** Specifies that the current row/column should be put in the end group <code>s</code> and will thus share the same ending
184 //       * coordinate within the group.
185 //       * <p>
186 //       * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
187 //       * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
188 //       * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
189 //       */
190 //      public final AxisConstraint endGroup(String s)
191 //      {
192 //              return endGroup(s, curIx);
193 //      }
194 //
195 //      /** Specifies that the indicated rows/columns should be put in the end group <code>s</code> and will thus share the same ending
196 //       * coordinate within the group.
197 //       * <p>
198 //       * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
199 //       * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
200 //       * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
201 //       * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
202 //       */
203 //      public final AxisConstraint endGroup(String s, int... indexes)
204 //      {
205 //              for (int i = indexes.length - 1; i >= 0; i--) {
206 //                      int ix = indexes[i];
207 //                      makeSize(ix);
208 //                      cList.get(ix).setEndGroup(s);
209 //              }
210 //              return this;
211 //      }
212
213         /** Specifies that the current row/column should be put in the size group <code>s</code> and will thus share the same size
214          * constraints as the other components in the group.
215          * <p>
216          * Same as <code>sizeGroup("")</code>
217          * <p>
218          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
219          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
220          * @since 3.7.2
221          */
222         public final AC sizeGroup()
223         {
224                 return sizeGroup("", curIx);
225         }
226
227         /** Specifies that the current row/column should be put in the size group <code>s</code> and will thus share the same size
228          * constraints as the other components in the group.
229          * <p>
230          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
231          * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
232          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
233          */
234         public final AC sizeGroup(String s)
235         {
236                 return sizeGroup(s, curIx);
237         }
238
239         /** Specifies that the indicated rows/columns should be put in the size group <code>s</code> and will thus share the same size
240          * constraints as the other components in the group.
241          * <p>
242          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
243          * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
244          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
245          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
246          */
247         public final AC sizeGroup(String s, int... indexes)
248         {
249                 for (int i = indexes.length - 1; i >= 0; i--) {
250                         int ix = indexes[i];
251                         makeSize(ix);
252                         cList.get(ix).setSizeGroup(s);
253                 }
254                 return this;
255         }
256
257         /** Specifies the current row/column's min and/or preferred and/or max size. E.g. <code>"10px"</code> or <code>"50:100:200"</code>.
258          * <p>
259          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
260          * @param s The minimum and/or preferred and/or maximum size of this row. The string will be interpreted
261          * as a <b>BoundSize</b>. For more info on how <b>BoundSize</b> is formatted see the documentation.
262          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
263          */
264         public final AC size(String s)
265         {
266                 return size(s, curIx);
267         }
268
269         /** Specifies the indicated rows'/columns' min and/or preferred and/or max size. E.g. <code>"10px"</code> or <code>"50:100:200"</code>.
270          * <p>
271          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
272          * @param size The minimum and/or preferred and/or maximum size of this row. The string will be interpreted
273          * as a <b>BoundSize</b>. For more info on how <b>BoundSize</b> is formatted see the documentation.
274          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
275          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
276          */
277         public final AC size(String size, int... indexes)
278         {
279                 BoundSize bs = ConstraintParser.parseBoundSize(size, false, true);
280                 for (int i = indexes.length - 1; i >= 0; i--) {
281                         int ix = indexes[i];
282                         makeSize(ix);
283                         cList.get(ix).setSize(bs);
284                 }
285                 return this;
286         }
287
288         /** Specifies the gap size to be the default one <b>AND</b> moves to the next column/row. The method is called <code>.gap()</code>
289          * rather the more natural <code>.next()</code> to indicate that it is very much related to the other <code>.gap(..)</code> methods.
290          * <p>
291          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
292          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
293          */
294         public final AC gap()
295         {
296                 curIx++;
297                 makeSize(curIx);
298                 return this;
299         }
300
301         /** Specifies the gap size to <code>size</code> <b>AND</b> moves to the next column/row.
302          * <p>
303          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
304          * @param size minimum and/or preferred and/or maximum size of the gap between this and the next row/column.
305          * The string will be interpreted as a <b>BoundSize</b>. For more info on how <b>BoundSize</b> is formatted see the documentation.
306          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
307          */
308         public final AC gap(String size)
309         {
310                 return gap(size, curIx++);
311         }
312
313         /** Specifies the indicated rows'/columns' gap size to <code>size</code>.
314          * <p>
315          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
316          * @param size minimum and/or preferred and/or maximum size of the gap between this and the next row/column.
317          * The string will be interpreted as a <b>BoundSize</b>. For more info on how <b>BoundSize</b> is formatted see the documentation.
318          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
319          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
320          */
321         public final AC gap(String size, int... indexes)
322         {
323                 BoundSize bsa = size != null ? ConstraintParser.parseBoundSize(size, true, true) : null;
324
325                 for (int i = indexes.length - 1; i >= 0; i--) {
326                         int ix = indexes[i];
327                         makeSize(ix + 1);
328                         if (bsa != null)
329                                 cList.get(ix).setGapAfter(bsa);
330                 }
331                 return this;
332         }
333
334         /** Specifies the current row/column's columns default alignment <b>for its components</b>. It does not affect the positioning
335          * or size of the columns/row itself. For columns it is the horizontal alignment (e.g. "left") and for rows it is the vertical
336          * alignment (e.g. "top").
337          * <p>
338          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
339          * @param side The default side to align the components. E.g. "top" or "left", or "leading" or "trailing" or "bottom" or "right".
340          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
341          */
342         public final AC align(String side)
343         {
344                 return align(side, curIx);
345         }
346
347         /** Specifies the indicated rows'/columns' columns default alignment <b>for its components</b>. It does not affect the positioning
348          * or size of the columns/row itself. For columns it is the horizontal alignment (e.g. "left") and for rows it is the vertical
349          * alignment (e.g. "top").
350          * <p>
351          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
352          * @param side The default side to align the components. E.g. "top" or "left", or "before" or "after" or "bottom" or "right".
353          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
354          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
355          */
356         public final AC align(String side, int... indexes)
357         {
358                 UnitValue al = ConstraintParser.parseAlignKeywords(side, true);
359                 if (al == null)
360                         al = ConstraintParser.parseAlignKeywords(side, false);
361
362                 for (int i = indexes.length - 1; i >= 0; i--) {
363                         int ix = indexes[i];
364                         makeSize(ix);
365                         cList.get(ix).setAlign(al);
366                 }
367                 return this;
368         }
369
370         /** Specifies the current row/column's grow priority.
371          * <p>
372          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
373          * @param p The new grow priority.
374          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
375          */
376         public final AC growPrio(int p)
377         {
378                 return growPrio(p, curIx);
379         }
380
381         /** Specifies the indicated rows'/columns' grow priority.
382          * <p>
383          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
384          * @param p The new grow priority.
385          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
386          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
387          */
388         public final AC growPrio(int p, int... indexes)
389         {
390                 for (int i = indexes.length - 1; i >= 0; i--) {
391                         int ix = indexes[i];
392                         makeSize(ix);
393                         cList.get(ix).setGrowPriority(p);
394                 }
395                 return this;
396         }
397
398         /** Specifies the current row/column's grow weight within columns/rows with the <code>grow priority</code> 100f.
399          * <p>
400          * Same as <code>grow(100f)</code>
401          * <p>
402          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
403          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
404          * @since 3.7.2
405          */
406         public final AC grow()
407         {
408                 return grow(100f, curIx);
409         }
410
411         /** Specifies the current row/column's grow weight within columns/rows with the same <code>grow priority</code>.
412          * <p>
413          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
414          * @param w The new grow weight.
415          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
416          */
417         public final AC grow(float w)
418         {
419                 return grow(w, curIx);
420         }
421
422         /** Specifies the indicated rows'/columns' grow weight within columns/rows with the same <code>grow priority</code>.
423          * <p>
424          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
425          * @param w The new grow weight.
426          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
427          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
428          */
429         public final AC grow(float w, int... indexes)
430         {
431                 Float gw = new Float(w);
432                 for (int i = indexes.length - 1; i >= 0; i--) {
433                         int ix = indexes[i];
434                         makeSize(ix);
435                         cList.get(ix).setGrow(gw);
436                 }
437                 return this;
438         }
439
440         /** Specifies the current row/column's shrink priority.
441          * <p>
442          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
443          * @param p The new shrink priority.
444                  * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
445          */
446         public final AC shrinkPrio(int p)
447         {
448                 return shrinkPrio(p, curIx);
449         }
450
451         /** Specifies the indicated rows'/columns' shrink priority.
452          * <p>
453          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
454          * @param p The new shrink priority.
455          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
456          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
457          */
458         public final AC shrinkPrio(int p, int... indexes)
459         {
460                 for (int i = indexes.length - 1; i >= 0; i--) {
461                         int ix = indexes[i];
462                         makeSize(ix);
463                         cList.get(ix).setShrinkPriority(p);
464                 }
465                 return this;
466         }
467
468         /** Specifies that the current row/column's shrink weight within the columns/rows with the <code>shrink priority</code> 100f.
469          * <p>
470          * Same as <code>shrink(100f)</code>.
471          * <p>
472          * For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
473          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
474          * @since 3.7.2
475          */
476         public final AC shrink()
477         {
478                 return shrink(100f, curIx);
479         }
480
481         /** Specifies that the current row/column's shrink weight within the columns/rows with the same <code>shrink priority</code>.
482          * <p>
483          * For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
484          * @param w The shrink weight.
485          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
486          * @since 3.7.2
487          */
488         public final AC shrink(float w)
489         {
490                 return shrink(w, curIx);
491         }
492
493         /** Specifies the indicated rows'/columns' shrink weight within the columns/rows with the same <code>shrink priority</code>.
494          * <p>
495          * For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
496          * @param w The shrink weight.
497          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
498          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
499          * @since 3.7.2
500          */
501         public final AC shrink(float w, int... indexes)
502         {
503                 Float sw = new Float(w);
504                 for (int i = indexes.length - 1; i >= 0; i--) {
505                         int ix = indexes[i];
506                         makeSize(ix);
507                         cList.get(ix).setShrink(sw);
508                 }
509                 return this;
510         }
511
512         /** Specifies that the current row/column's shrink weight within the columns/rows with the same <code>shrink priority</code>.
513          * <p>
514          * For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
515          * @param w The shrink weight.
516          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
517          * @deprecated in 3.7.2. Use {@link #shrink(float)} instead.
518          */
519         public final AC shrinkWeight(float w)
520         {
521                 return shrink(w);
522         }
523
524         /** Specifies the indicated rows'/columns' shrink weight within the columns/rows with the same <code>shrink priority</code>.
525          * <p>
526          * For a more thorough explanation of what this constraint does see the White Paper or Cheat Sheet at www.migcomponents.com.
527          * @param w The shrink weight.
528          * @param indexes The index(es) (0-based) of the columns/rows that should be affected by this constraint.
529          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new AxisConstraint().noGrid().gap().fill()</code>.
530          * @deprecated in 3.7.2. Use {@link #shrink(float, int...)} instead.
531          */
532         public final AC shrinkWeight(float w, int... indexes)
533         {
534                 return shrink(w, indexes);
535         }
536
537         private void makeSize(int sz)
538         {
539                 if (cList.size() <= sz) {
540                         cList.ensureCapacity(sz);
541                         for (int i = cList.size(); i <= sz; i++)
542                                 cList.add(new DimConstraint());
543                 }
544         }
545
546         // ************************************************
547         // Persistence Delegate and Serializable combined.
548         // ************************************************
549
550         private Object readResolve() throws ObjectStreamException
551         {
552                 return LayoutUtil.getSerializedObject(this);
553         }
554
555         @Override
556         public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
557         {
558                 LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
559         }
560
561         @Override
562         public void writeExternal(ObjectOutput out) throws IOException
563         {
564                 if (getClass() == AC.class)
565                         LayoutUtil.writeAsXML(out, this);
566         }
567 }