e4cfff92775ee564c5090b78b6a5390eb44b03ba
[jalview.git] / src / net / miginfocom / layout / CC.java
1 package net.miginfocom.layout;
2
3 import java.util.ArrayList;
4 /*
5  * License (BSD):
6  * ==============
7  *
8  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without modification,
12  * are permitted provided that the following conditions are met:
13  * Redistributions of source code must retain the above copyright notice, this list
14  * of conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice, this
16  * list of conditions and the following disclaimer in the documentation and/or other
17  * materials provided with the distribution.
18  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
19  * used to endorse or promote products derived from this software without specific
20  * prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31  * OF SUCH DAMAGE.
32  *
33  * @version 1.0
34  * @author Mikael Grev, MiG InfoCom AB
35  *         Date: 2006-sep-08
36  */
37
38 /** A simple value holder for one component's constraint.
39  */
40 public final class CC// s implements Externalizable
41 {
42         private static final BoundSize DEF_GAP = BoundSize.NULL_SIZE;    // Only used to denote default wrap/newline gap.
43
44         static final String[] DOCK_SIDES = {"north", "west", "south", "east"};
45
46         // See the getters and setters for information about the properties below.
47
48         private int dock = -1;
49
50         private UnitValue[] pos = null; // [x1, y1, x2, y2]
51
52         private UnitValue[] padding = null;   // top, left, bottom, right
53
54         private UnitValue[] visualPadding = null;   // top, left, bottom, right
55
56         private Boolean flowX = null;
57
58         private int skip = 0;
59
60         private int split = 1;
61
62         private int spanX = 1, spanY = 1;
63
64         private int cellX = -1, cellY = 0; // If cellX is -1 then cellY is also considered -1. cellY is never negative.
65
66         private String tag = null;
67
68         private String id = null;
69
70         private int hideMode = -1;
71
72         private DimConstraint hor = new DimConstraint();
73
74         private DimConstraint ver = new DimConstraint();
75
76         private BoundSize newline = null;
77
78         private BoundSize wrap = null;
79
80         private boolean boundsInGrid = true;
81
82         private boolean external = false;
83
84         private Float pushX = null, pushY = null;
85
86         private AnimSpec animSpec = AnimSpec.DEF;
87
88
89         // ***** Tmp cache field
90
91         private static final String[] EMPTY_ARR = new String[0];
92
93         private transient String[] linkTargets = null;
94
95         /** Empty constructor.
96          */
97         public CC()
98         {
99         }
100
101         String[] getLinkTargets()
102         {
103                 if (linkTargets == null) {
104                         final ArrayList<String> targets = new ArrayList<String>(2);
105
106                         if (pos != null) {
107                                 for (int i = 0; i < pos.length ; i++)
108                                         addLinkTargetIDs(targets, pos[i]);
109                         }
110
111                         linkTargets = targets.size() == 0 ? EMPTY_ARR : targets.toArray(new String[targets.size()]);
112                 }
113                 return linkTargets;
114         }
115
116         private void addLinkTargetIDs(ArrayList<String> targets, UnitValue uv)
117         {
118                 if (uv != null) {
119                         String linkId = uv.getLinkTargetId();
120                         if (linkId != null) {
121                                 targets.add(linkId);
122                         } else {
123                                 for (int i = uv.getSubUnitCount() - 1; i >= 0; i--) {
124                                         UnitValue subUv = uv.getSubUnitValue(i);
125                                         if (subUv.isLinkedDeep())
126                                                 addLinkTargetIDs(targets, subUv);
127                                 }
128                         }
129                 }
130         }
131
132         // **********************************************************
133         // Chaining constraint setters
134         // **********************************************************
135
136         /** Specifies that the component should be put in the end group <code>s</code> and will thus share the same ending
137          * coordinate as them within the group.
138          * <p>
139          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
140          * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
141          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
142          */
143         public final CC endGroupX(String s)
144         {
145                 hor.setEndGroup(s);
146                 return this;
147         }
148
149         /** Specifies that the component should be put in the size group <code>s</code> and will thus share the same size
150          * as them within the group.
151          * <p>
152          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
153          * @param s A name to associate on the group that should be the same for other rows/columns in the same group.
154          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
155          */
156         public final CC sizeGroupX(String s)
157         {
158                 hor.setSizeGroup(s);
159                 return this;
160         }
161
162         /** The minimum size for the component. The value will override any value that is set on the component itself.
163          * <p>
164          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
165          * @param size The size expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm".
166          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
167          */
168         public final CC minWidth(String size)
169         {
170                 hor.setSize(LayoutUtil.derive(hor.getSize(), ConstraintParser.parseUnitValue(size, true), null, null));
171                 return this;
172         }
173
174         /** The size for the component as a min and/or preferred and/or maximum size. The value will override any value that is set on
175          * the component itself.
176          * <p>
177          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
178          * @param size The size expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px".
179          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
180          */
181         public final CC width(String size)
182         {
183                 hor.setSize(ConstraintParser.parseBoundSize(size, false, true));
184                 return this;
185         }
186
187         /** The maximum size for the component. The value will override any value that is set on the component itself.
188          * <p>
189          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
190          * @param size The size expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm".
191          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
192          */
193         public final CC maxWidth(String size)
194         {
195                 hor.setSize(LayoutUtil.derive(hor.getSize(), null, null, ConstraintParser.parseUnitValue(size, true)));
196                 return this;
197         }
198
199
200         /** The horizontal gap before and/or after the component. The gap is towards cell bounds and/or other component bounds.
201          * <p>
202          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
203          * @param before The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
204          * @param after The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
205          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
206          */
207         public final CC gapX(String before, String after)
208         {
209                 if (before != null)
210                         hor.setGapBefore(ConstraintParser.parseBoundSize(before, true, true));
211
212                 if (after != null)
213                         hor.setGapAfter(ConstraintParser.parseBoundSize(after, true, true));
214
215                 return this;
216         }
217
218         /** Same functionality as <code>getHorizontal().setAlign(ConstraintParser.parseUnitValue(unitValue, true))</code> only this method
219          * returns <code>this</code> for chaining multiple calls.
220          * <p>
221          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
222          * @param align The align keyword or for instance "100px". E.g "left", "right", "leading" or "trailing".
223          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
224          */
225         public final CC alignX(String align)
226         {
227                 hor.setAlign(ConstraintParser.parseUnitValueOrAlign(align, true, null));
228                 return this;
229         }
230
231         /** The grow priority compared to other components in the same cell.
232          * <p>
233          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
234          * @param p The grow priority.
235          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
236          */
237         public final CC growPrioX(int p)
238         {
239                 hor.setGrowPriority(p);
240                 return this;
241         }
242
243         /** Grow priority for the component horizontally and optionally vertically.
244          * <p>
245          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
246          * @param widthHeight The new shrink weight and height. 1-2 arguments, never null.
247          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
248          * @since 3.7.2
249          */
250         public final CC growPrio(int ... widthHeight)
251         {
252                 switch (widthHeight.length) {
253                         default:
254                                 throw new IllegalArgumentException("Illegal argument count: " + widthHeight.length);
255                         case 2:
256                                 growPrioY(widthHeight[1]);
257                         case 1:
258                                 growPrioX(widthHeight[0]);
259                 }
260                 return this;
261         }
262
263         /** Grow weight for the component horizontally. It default to weight <code>100</code>.
264          * <p>
265          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
266          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
267          * @see #growX(float)
268          */
269         public final CC growX()
270         {
271                 hor.setGrow(ResizeConstraint.WEIGHT_100);
272                 return this;
273         }
274
275         /** Grow weight for the component horizontally.
276          * <p>
277          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
278          * @param w The new grow weight.
279          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
280          */
281         public final CC growX(float w)
282         {
283                 hor.setGrow(new Float(w));
284                 return this;
285         }
286
287         /** grow weight for the component horizontally and optionally vertically.
288          * <p>
289          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
290          * @param widthHeight The new shrink weight and height. 1-2 arguments, never null.
291          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
292          * @since 3.7.2
293          */
294         public final CC grow(float ... widthHeight)
295         {
296                 switch (widthHeight.length) {
297                         default:
298                                 throw new IllegalArgumentException("Illegal argument count: " + widthHeight.length);
299                         case 2:
300                                 growY(widthHeight[1]);
301                         case 1:
302                                 growX(widthHeight[0]);
303                 }
304                 return this;
305         }
306
307         /** The shrink priority compared to other components in the same cell.
308          * <p>
309          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
310          * @param p The shrink priority.
311          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
312          */
313         public final CC shrinkPrioX(int p)
314         {
315                 hor.setShrinkPriority(p);
316                 return this;
317         }
318
319         /** Shrink priority for the component horizontally and optionally vertically.
320          * <p>
321          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
322          * @param widthHeight The new shrink weight and height. 1-2 arguments, never null.
323          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
324          * @since 3.7.2
325          */
326         public final CC shrinkPrio(int ... widthHeight)
327         {
328                 switch (widthHeight.length) {
329                         default:
330                                 throw new IllegalArgumentException("Illegal argument count: " + widthHeight.length);
331                         case 2:
332                                 shrinkPrioY(widthHeight[1]);
333                         case 1:
334                                 shrinkPrioX(widthHeight[0]);
335                 }
336                 return this;
337         }
338
339         /** Shrink weight for the component horizontally.
340          * <p>
341          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
342          * @param w The new shrink weight.
343          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
344          */
345         public final CC shrinkX(float w)
346         {
347                 hor.setShrink(new Float(w));
348                 return this;
349         }
350
351         /** Shrink weight for the component horizontally and optionally vertically.
352          * <p>
353          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
354          * @param widthHeight The new shrink weight and height. 1-2 arguments, never null.
355          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
356          * @since 3.7.2
357          */
358         public final CC shrink(float ... widthHeight)
359         {
360                 switch (widthHeight.length) {
361                         default:
362                                 throw new IllegalArgumentException("Illegal argument count: " + widthHeight.length);
363                         case 2:
364                                 shrinkY(widthHeight[1]);
365                         case 1:
366                                 shrinkX(widthHeight[0]);
367                 }
368                 return this;
369         }
370
371         /** The end group that this component should be placed in.
372          * <p>
373          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
374          * @param s The name of the group. If <code>null</code> that means no group (default)
375          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
376          */
377         public final CC endGroupY(String s)
378         {
379                 ver.setEndGroup(s);
380                 return this;
381         }
382
383         /** The end group(s) that this component should be placed in.
384          * <p>
385          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
386          * @param xy The end group for x and y respectively. 1-2 arguments, not null.
387          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
388          * @since 3.7.2
389          */
390         public final CC endGroup(String ... xy)
391         {
392                 switch (xy.length) {
393                         default:
394                                 throw new IllegalArgumentException("Illegal argument count: " + xy.length);
395                         case 2:
396                                 endGroupY(xy[1]);
397                         case 1:
398                                 endGroupX(xy[0]);
399                 }
400                 return this;
401         }
402
403         /** The size group that this component should be placed in.
404          * <p>
405          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
406          * @param s The name of the group. If <code>null</code> that means no group (default)
407          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
408          */
409         public final CC sizeGroupY(String s)
410         {
411                 ver.setSizeGroup(s);
412                 return this;
413         }
414
415         /** The size group(s) that this component should be placed in.
416          * <p>
417          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
418          * @param xy The size group for x and y respectively. 1-2 arguments, not null.
419          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
420          * @since 3.7.2
421          */
422         public final CC sizeGroup(String ... xy)
423         {
424                 switch (xy.length) {
425                         default:
426                                 throw new IllegalArgumentException("Illegal argument count: " + xy.length);
427                         case 2:
428                                 sizeGroupY(xy[1]);
429                         case 1:
430                                 sizeGroupX(xy[0]);
431                 }
432                 return this;
433         }
434
435         /** The minimum size for the component. The value will override any value that is set on the component itself.
436          * <p>
437          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
438          * @param size The size expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm".
439          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
440          */
441         public final CC minHeight(String size)
442         {
443                 ver.setSize(LayoutUtil.derive(ver.getSize(), ConstraintParser.parseUnitValue(size, false), null, null));
444                 return this;
445         }
446
447         /** The size for the component as a min and/or preferred and/or maximum size. The value will override any value that is set on
448          * the component itself.
449          * <p>
450          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
451          * @param size The size expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px".
452          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
453          */
454         public final CC height(String size)
455         {
456                 ver.setSize(ConstraintParser.parseBoundSize(size, false, false));
457                 return this;
458         }
459
460         /** The maximum size for the component. The value will override any value that is set on the component itself.
461          * <p>
462          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
463          * @param size The size expressed as a <code>UnitValue</code>. E.g. "100px" or "200mm".
464          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
465          */
466         public final CC maxHeight(String size)
467         {
468                 ver.setSize(LayoutUtil.derive(ver.getSize(), null, null, ConstraintParser.parseUnitValue(size, false)));
469                 return this;
470         }
471
472         /** The vertical gap before (normally above) and/or after (normally below) the component. The gap is towards cell bounds and/or other component bounds.
473          * <p>
474          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
475          * @param before The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
476          * @param after The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
477          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
478          */
479         public final CC gapY(String before, String after)
480         {
481                 if (before != null)
482                         ver.setGapBefore(ConstraintParser.parseBoundSize(before, true, false));
483
484                 if (after != null)
485                         ver.setGapAfter(ConstraintParser.parseBoundSize(after, true, false));
486
487                 return this;
488         }
489
490         /** Same functionality as <code>getVertical().setAlign(ConstraintParser.parseUnitValue(unitValue, true))</code> only this method
491          * returns <code>this</code> for chaining multiple calls.
492          * <p>
493          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
494          * @param align The align keyword or for instance "100px". E.g "top" or "bottom".
495          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
496          */
497         public final CC alignY(String align)
498         {
499                 ver.setAlign(ConstraintParser.parseUnitValueOrAlign(align, false, null));
500                 return this;
501         }
502
503         /** The grow priority compared to other components in the same cell.
504          * <p>
505          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
506          * @param p The grow priority.
507          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
508          */
509         public final CC growPrioY(int p)
510         {
511                 ver.setGrowPriority(p);
512                 return this;
513         }
514
515         /** Grow weight for the component vertically. Defaults to <code>100</code>.
516          * <p>
517          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
518          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
519          * @see #growY(Float)
520          */
521         public final CC growY()
522         {
523                 ver.setGrow(ResizeConstraint.WEIGHT_100);
524                 return this;
525         }
526
527         /** Grow weight for the component vertically.
528          * <p>
529          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
530          * @param w The new grow weight.
531          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
532          */
533         public final CC growY(float w)
534         {
535                 ver.setGrow(w);
536                 return this;
537         }
538
539         /** Grow weight for the component vertically.
540          * <p>
541          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
542          * @param w The new grow weight.
543          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
544          */
545         @Deprecated
546         public final CC growY(Float w)
547         {
548                 ver.setGrow(w);
549                 return this;
550         }
551
552         /** The shrink priority compared to other components in the same cell.
553          * <p>
554          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
555          * @param p The shrink priority.
556          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
557          */
558         public final CC shrinkPrioY(int p)
559         {
560                 ver.setShrinkPriority(p);
561                 return this;
562         }
563
564         /** Shrink weight for the component horizontally.
565          * <p>
566          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
567          * @param w The new shrink weight.
568          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
569          */
570         public final CC shrinkY(float w)
571         {
572                 ver.setShrink(new Float(w));
573                 return this;
574         }
575
576         /** How this component, if hidden (not visible), should be treated.
577          * <p>
578          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
579          * @param mode The mode. Default to the mode in the {@link net.miginfocom.layout.LC}.
580          * 0 == Normal. Bounds will be calculated as if the component was visible.<br>
581          * 1 == If hidden the size will be 0, 0 but the gaps remain.<br>
582          * 2 == If hidden the size will be 0, 0 and gaps set to zero.<br>
583          * 3 == If hidden the component will be disregarded completely and not take up a cell in the grid..
584          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
585          */
586         public final CC hideMode(int mode)
587         {
588                 setHideMode(mode);
589                 return this;
590         }
591
592         /** The id used to reference this component in some constraints.
593          * <p>
594          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
595          * @param s The id or <code>null</code>. May consist of a groupID and an componentID which are separated by a dot: ".". E.g. "grp1.id1".
596          * The dot should never be first or last if present.
597          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
598          */
599         public final CC id(String s)
600         {
601                 setId(s);
602                 return this;
603         }
604
605         /** Same functionality as {@link #setTag(String tag)} only this method returns <code>this</code> for chaining multiple calls.
606          * <p>
607          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
608          * @param tag The new tag. May be <code>null</code>.
609          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
610          * @see #setTag(String)
611          */
612         public final CC tag(String tag)
613         {
614                 setTag(tag);
615                 return this;
616         }
617
618         /** Set the cell(s) that the component should occupy in the grid. Same functionality as {@link #setCellX(int col)} and
619          * {@link #setCellY(int row)} together with {@link #setSpanX(int width)} and {@link #setSpanY(int height)}. This method
620          * returns <code>this</code> for chaining multiple calls.
621          * <p>
622          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
623          * @param colRowWidthHeight cellX, cellY, spanX, spanY respectively. 1-4 arguments, not null.
624          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
625          * @see #setCellX(int)
626          * @see #setCellY(int)
627          * @see #setSpanX(int)
628          * @see #setSpanY(int)
629          * @since 3.7.2. Replacing cell(int, int) and cell(int, int, int, int)
630          */
631         public final CC cell(int ... colRowWidthHeight)
632         {
633                 switch (colRowWidthHeight.length) {
634                         default:
635                                 throw new IllegalArgumentException("Illegal argument count: " + colRowWidthHeight.length);
636                         case 4:
637                                 setSpanY(colRowWidthHeight[3]);
638                         case 3:
639                                 setSpanX(colRowWidthHeight[2]);
640                         case 2:
641                                 setCellY(colRowWidthHeight[1]);
642                         case 1:
643                                 setCellX(colRowWidthHeight[0]);
644                 }
645                 return this;
646         }
647
648         /** Same functionality as <code>spanX(cellsX).spanY(cellsY)</code> which means this cell will span cells in both x and y.
649          * This method returns <code>this</code> for chaining multiple calls.
650          * <p>
651          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
652          * Since 3.7.2 this takes an array/vararg whereas it previously only took two specific values, xSpan and ySpan.
653          * @param cells spanX and spanY, when present, and in that order.
654          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
655          * @see #setSpanY(int)
656          * @see #setSpanX(int)
657          * @see #spanY()
658          * @see #spanX()
659          * @since 3.7.2 Replaces span(int, int).
660          */
661         public final CC span(int ... cells)
662         {
663                 if (cells == null || cells.length == 0) {
664                         setSpanX(LayoutUtil.INF);
665                         setSpanY(1);
666                 } else if (cells.length == 1) {
667                         setSpanX(cells[0]);
668                         setSpanY(1);
669                 } else {
670                         setSpanX(cells[0]);
671                         setSpanY(cells[1]);
672                 }
673                 return this;
674         }
675
676         /** Corresponds exactly to the "gap left right top bottom" keyword.
677          * @param args Same as for the "gap" keyword. Length 1-4, never null buf elements can be null.
678          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
679          * @since 3.7.2
680          */
681         public final CC gap(String ... args)
682         {
683                 switch (args.length) {
684                         default:
685                                 throw new IllegalArgumentException("Illegal argument count: " + args.length);
686                         case 4:
687                                 gapBottom(args[3]);
688                         case 3:
689                                 gapTop(args[2]);
690                         case 2:
691                                 gapRight(args[1]);
692                         case 1:
693                                 gapLeft(args[0]);
694                 }
695                 return this;
696         }
697
698         /** Sets the horizontal gap before the component.
699          * <p>
700          * Note! This is currently same as gapLeft(). This might change in 4.x.
701          * @param boundsSize The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
702          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
703          * @since 3.7.2
704          */
705         public final CC gapBefore(String boundsSize)
706         {
707                 hor.setGapBefore(ConstraintParser.parseBoundSize(boundsSize, true, true));
708                 return this;
709         }
710
711         /** Sets the horizontal gap after the component.
712          * <p>
713          * Note! This is currently same as gapRight(). This might change in 4.x.
714          * @param boundsSize The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
715          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
716          * @since 3.7.2
717          */
718         public final CC gapAfter(String boundsSize)
719         {
720                 hor.setGapAfter(ConstraintParser.parseBoundSize(boundsSize, true, true));
721                 return this;
722         }
723
724         /** Sets the gap above the component.
725          * @param boundsSize The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
726          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
727          * @since 3.7.2
728          */
729         public final CC gapTop(String boundsSize)
730         {
731                 ver.setGapBefore(ConstraintParser.parseBoundSize(boundsSize, true, false));
732                 return this;
733         }
734
735         /** Sets the gap to the left the component.
736          * @param boundsSize The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
737          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
738          * @since 3.7.2
739          */
740         public final CC gapLeft(String boundsSize)
741         {
742                 hor.setGapBefore(ConstraintParser.parseBoundSize(boundsSize, true, true));
743                 return this;
744         }
745
746         /** Sets the gap below the component.
747          * @param boundsSize The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
748          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
749          * @since 3.7.2
750          */
751         public final CC gapBottom(String boundsSize)
752         {
753                 ver.setGapAfter(ConstraintParser.parseBoundSize(boundsSize, true, false));
754                 return this;
755         }
756
757         /** Sets the gap to the right of the component.
758          * @param boundsSize The size of the gap expressed as a <code>BoundSize</code>. E.g. "50:100px:200mm" or "100px!".
759          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
760          * @since 3.7.2
761          */
762         public final CC gapRight(String boundsSize)
763         {
764                 hor.setGapAfter(ConstraintParser.parseBoundSize(boundsSize, true, true));
765                 return this;
766         }
767
768         /** Same functionality as calling {@link #setSpanY(int)} with <code>LayoutUtil.INF</code> which means this cell will span the rest of the column.
769          * This method returns <code>this</code> for chaining multiple calls.
770          * <p>
771          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
772          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
773          * @see #setSpanY(int)
774          * @see #spanY()
775          */
776         public final CC spanY()
777         {
778                 return spanY(LayoutUtil.INF);
779         }
780
781         /** Same functionality as {@link #setSpanY(int)} only this method returns <code>this</code> for chaining multiple calls.
782          * <p>
783          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
784          * @param cells The number of cells to span (i.e. merge).
785          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
786          * @see #setSpanY(int)
787          */
788         public final CC spanY(int cells)
789         {
790                 setSpanY(cells);
791                 return this;
792         }
793
794         /** Same functionality as {@link #setSpanX(int)} which means this cell will span the rest of the row.
795          * This method returns <code>this</code> for chaining multiple calls.
796          * <p>
797          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
798          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
799          * @see #setSpanX(int)
800          * @see #spanX()
801          */
802         public final CC spanX()
803         {
804                 return spanX(LayoutUtil.INF);
805         }
806
807         /** Same functionality as {@link #setSpanX(int)} only this method returns <code>this</code> for chaining multiple calls.
808          * <p>
809          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
810          * @param cells The number of cells to span (i.e. merge).
811          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
812          * @see #setSpanY(int)
813          */
814         public final CC spanX(int cells)
815         {
816                 setSpanX(cells);
817                 return this;
818         }
819
820         /** Same functionality as <code>pushX().pushY()</code> which means this cell will push in both x and y dimensions.
821          * This method returns <code>this</code> for chaining multiple calls.
822          * <p>
823          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
824          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
825          * @see #setPushX(Float)
826          * @see #setPushX(Float)
827          * @see #pushY()
828          * @see #pushX()
829          */
830         public final CC push()
831         {
832                 return pushX().pushY();
833         }
834
835         /** Same functionality as <code>pushX(weightX).pushY(weightY)</code> which means this cell will push in both x and y dimensions.
836          * This method returns <code>this</code> for chaining multiple calls.
837          * <p>
838          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
839          * @param weightX The weight used in the push.
840          * @param weightY The weight used in the push.
841          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
842          * @see #setPushY(Float)
843          * @see #setPushX(Float)
844          * @see #pushY()
845          * @see #pushX()
846          */
847         public final CC push(Float weightX, Float weightY)
848         {
849                 return pushX(weightX).pushY(weightY);
850         }
851
852         /** Same functionality as {@link #setPushY(Float)} which means this cell will push the rest of the column.
853          * This method returns <code>this</code> for chaining multiple calls.
854          * <p>
855          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
856          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
857          * @see #setPushY(Float)
858          */
859         public final CC pushY()
860         {
861                 return pushY(ResizeConstraint.WEIGHT_100);
862         }
863
864         /** Same functionality as {@link #setPushY(Float weight)} only this method returns <code>this</code> for chaining multiple calls.
865          * <p>
866          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
867          * @param weight The weight used in the push.
868          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
869          * @see #setPushY(Float)
870          */
871         public final CC pushY(Float weight)
872         {
873                 setPushY(weight);
874                 return this;
875         }
876
877         /** Same functionality as {@link #setPushX(Float)} which means this cell will push the rest of the row.
878          * This method returns <code>this</code> for chaining multiple calls.
879          * <p>
880          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
881          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
882          * @see #setPushX(Float)
883          */
884         public final CC pushX()
885         {
886                 return pushX(ResizeConstraint.WEIGHT_100);
887         }
888
889         /** Same functionality as {@link #setPushX(Float weight)} only this method returns <code>this</code> for chaining multiple calls.
890          * <p>
891          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
892          * @param weight The weight used in the push.
893          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new LayoutConstraint().noGrid().gap().fill()</code>.
894          * @see #setPushY(Float)
895          */
896         public final CC pushX(Float weight)
897         {
898                 setPushX(weight);
899                 return this;
900         }
901
902         /** Same functionality as {@link #setSplit(int parts)} only this method returns <code>this</code> for chaining multiple calls.
903          * <p>
904          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
905          * @param parts The number of parts (i.e. component slots) the cell should be divided into.
906          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
907          * @see #setSplit(int)
908          */
909         public final CC split(int parts)
910         {
911                 setSplit(parts);
912                 return this;
913         }
914
915         /** Same functionality as split(LayoutUtil.INF), which means split until one of the keywords that breaks the split is found for
916          * a component after this one (e.g. wrap, newline and skip).
917          * <p>
918          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
919          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
920          * @see #setSplit(int)
921          * @since 3.7.2
922          */
923         public final CC split()
924         {
925                 setSplit(LayoutUtil.INF);
926                 return this;
927         }
928
929         /** Same functionality as {@link #setSkip(int)} only this method returns <code>this</code> for chaining multiple calls.
930          * <p>
931          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
932          * @param cells How many cells in the grid that should be skipped <b>before</b> the component that this constraint belongs to
933          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
934          * @see #setSkip(int)
935          */
936         public final CC skip(int cells)
937         {
938                 setSkip(cells);
939                 return this;
940         }
941
942         /** Same functionality as skip(1).
943          * <p>
944          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
945          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
946          * @see #setSkip(int)
947          * @since 3.7.2
948          */
949         public final CC skip()
950         {
951                 setSkip(1);
952                 return this;
953         }
954
955         /** Same functionality as calling {@link #setExternal(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
956          * <p>
957          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
958          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
959          * @see #setExternal(boolean)
960          */
961         public final CC external()
962         {
963                 setExternal(true);
964                 return this;
965         }
966
967         /** Same functionality as calling {@link #setFlowX(Boolean)} with <code>Boolean.TRUE</code> only this method returns <code>this</code> for chaining multiple calls.
968          * <p>
969          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
970          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
971          * @see #setFlowX(Boolean)
972          */
973         public final CC flowX()
974         {
975                 setFlowX(Boolean.TRUE);
976                 return this;
977         }
978
979         /** Same functionality as calling {@link #setFlowX(Boolean)} with <code>Boolean.FALSE</code> only this method returns <code>this</code> for chaining multiple calls.
980          * <p>
981          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
982          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
983          * @see #setFlowX(Boolean)
984          */
985         public final CC flowY()
986         {
987                 setFlowX(Boolean.FALSE);
988                 return this;
989         }
990
991
992         /** Same functionality as {@link #growX()} and {@link #growY()}.
993          * <p>
994          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
995          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
996          * @see #growX()
997          * @see #growY()
998          */
999         public final CC grow()
1000         {
1001                 growX();
1002                 growY();
1003                 return this;
1004         }
1005
1006         /** Same functionality as calling {@link #setNewline(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
1007          * <p>
1008          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1009          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1010          * @see #setNewline(boolean)
1011          */
1012         public final CC newline()
1013         {
1014                 setNewline(true);
1015                 return this;
1016         }
1017
1018         /** Same functionality as {@link #setNewlineGapSize(BoundSize)} only this method returns <code>this</code> for chaining multiple calls.
1019          * <p>
1020          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1021          * @param gapSize The gap size that will override the gap size in the row/column constraints if <code>!= null</code>. E.g. "5px" or "unrel".
1022          * If <code>null</code> or <code>""</code> the newline size will be set to the default size and turned on. This is different compared to
1023          * {@link #setNewlineGapSize(BoundSize)}.
1024          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1025          * @see #setNewlineGapSize(BoundSize)
1026          */
1027         public final CC newline(String gapSize)
1028         {
1029                 BoundSize bs = ConstraintParser.parseBoundSize(gapSize, true, (flowX != null && flowX == false));
1030                 if (bs != null) {
1031                         setNewlineGapSize(bs);
1032                 } else {
1033                         setNewline(true);
1034                 }
1035                 return this;
1036         }
1037
1038         /** Same functionality as calling {@link #setWrap(boolean)} with <code>true</code> only this method returns <code>this</code> for chaining multiple calls.
1039          * <p>
1040          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1041          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1042          * @see #setWrap(boolean)
1043          */
1044         public final CC wrap()
1045         {
1046                 setWrap(true);
1047                 return this;
1048         }
1049
1050         /** Same functionality as {@link #setWrapGapSize(BoundSize)} only this method returns <code>this</code> for chaining multiple calls.
1051          * <p>
1052          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1053          * @param gapSize The gap size that will override the gap size in the row/column constraints if <code>!= null</code>. E.g. "5px" or "unrel".
1054          * If <code>null</code> or <code>""</code> the wrap size will be set to the default size and turned on. This is different compared to
1055          * {@link #setWrapGapSize(BoundSize)}.
1056          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1057          * @see #setWrapGapSize(BoundSize)
1058          */
1059         public final CC wrap(String gapSize)
1060         {
1061                 BoundSize bs = ConstraintParser.parseBoundSize(gapSize, true, (flowX != null && flowX == false));
1062                 if (bs != null) {
1063                         setWrapGapSize(bs);
1064                 } else {
1065                         setWrap(true);
1066                 }
1067                 return this;
1068         }
1069
1070         /** Same functionality as calling {@link #setDockSide(int)} with <code>0</code> only this method returns <code>this</code> for chaining multiple calls.
1071          * <p>
1072          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1073          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1074          * @see #setDockSide(int)
1075          */
1076         public final CC dockNorth()
1077         {
1078                 setDockSide(0);
1079                 return this;
1080         }
1081
1082         /** Same functionality as calling {@link #setDockSide(int)} with <code>1</code> only this method returns <code>this</code> for chaining multiple calls.
1083          * <p>
1084          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1085          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1086          * @see #setDockSide(int)
1087          */
1088         public final CC dockWest()
1089         {
1090                 setDockSide(1);
1091                 return this;
1092         }
1093
1094         /** Same functionality as calling {@link #setDockSide(int)} with <code>2</code> only this method returns <code>this</code> for chaining multiple calls.
1095          * <p>
1096          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1097          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1098          * @see #setDockSide(int)
1099          */
1100         public final CC dockSouth()
1101         {
1102                 setDockSide(2);
1103                 return this;
1104         }
1105
1106         /** Same functionality as calling {@link #setDockSide(int)} with <code>3</code> only this method returns <code>this</code> for chaining multiple calls.
1107          * <p>
1108          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1109          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1110          * @see #setDockSide(int)
1111          */
1112         public final CC dockEast()
1113         {
1114                 setDockSide(3);
1115                 return this;
1116         }
1117
1118         /** Sets the x-coordinate for the component. This is used to set the x coordinate position to a specific value. The component
1119          * bounds is still precalculated to the grid cell and this method should be seen as a way to correct the x position.
1120          * <p>
1121          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1122          * @param x The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
1123          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1124          * @see #setPos(UnitValue[])
1125          * @see #setBoundsInGrid(boolean)
1126          */
1127         public final CC x(String x)
1128         {
1129                 return corrPos(x, 0);
1130         }
1131
1132         /** Sets the y-coordinate for the component. This is used to set the y coordinate position to a specific value. The component
1133          * bounds is still precalculated to the grid cell and this method should be seen as a way to correct the y position.
1134          * <p>
1135          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1136          * @param y The y position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
1137          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1138          * @see #setPos(UnitValue[])
1139          * @see #setBoundsInGrid(boolean)
1140          */
1141         public final CC y(String y)
1142         {
1143                 return corrPos(y, 1);
1144         }
1145
1146         /** Sets the x2-coordinate for the component (right side). This is used to set the x2 coordinate position to a specific value. The component
1147          * bounds is still precalculated to the grid cell and this method should be seen as a way to correct the x position.
1148          * <p>
1149          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1150          * @param x2 The x2 side's position as a UnitValue. E.g. "10" or "40mm" or "container.x2 - 10".
1151          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1152          * @see #setPos(UnitValue[])
1153          * @see #setBoundsInGrid(boolean)
1154          */
1155         public final CC x2(String x2)
1156         {
1157                 return corrPos(x2, 2);
1158         }
1159
1160         /** Sets the y2-coordinate for the component (bottom side). This is used to set the y2 coordinate position to a specific value. The component
1161          * bounds is still precalculated to the grid cell and this method should be seen as a way to correct the y position.
1162          * <p>
1163          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1164          * @param y2 The y2 side's position as a UnitValue. E.g. "10" or "40mm" or "container.x2 - 10".
1165          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1166          * @see #setPos(UnitValue[])
1167          * @see #setBoundsInGrid(boolean)
1168          */
1169         public final CC y2(String y2)
1170         {
1171                 return corrPos(y2, 3);
1172         }
1173
1174         private final CC corrPos(String uv, int ix)
1175         {
1176                 UnitValue[] b = getPos();
1177                 if (b == null)
1178                         b = new UnitValue[4];
1179
1180                 b[ix] = ConstraintParser.parseUnitValue(uv, (ix % 2 == 0));
1181                 setPos(b);
1182
1183                 setBoundsInGrid(true);
1184                 return this;
1185         }
1186
1187         /** Same functionality as {@link #x(String x)} and {@link #y(String y)} together.
1188          * <p>
1189          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1190          * @param x The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
1191          * @param y The y position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
1192          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1193          * @see #setPos(UnitValue[])
1194          */
1195         public final CC pos(String x, String y)
1196         {
1197                 UnitValue[] b = getPos();
1198                 if (b == null)
1199                         b = new UnitValue[4];
1200
1201                 b[0] = ConstraintParser.parseUnitValue(x, true);
1202                 b[1] = ConstraintParser.parseUnitValue(y, false);
1203                 setPos(b);
1204
1205                 setBoundsInGrid(false);
1206                 return this;
1207         }
1208
1209         /** Same functionality as {@link #x(String x)}, {@link #y(String y)}, {@link #y2(String y)} and {@link #y2(String y)} together.
1210          * <p>
1211          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1212          * @param x The x position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
1213          * @param y The y position as a UnitValue. E.g. "10" or "40mm" or "container.x+10".
1214          * @param x2 The x2 side's position as a UnitValue. E.g. "10" or "40mm" or "container.x2 - 10".
1215          * @param y2 The y2 side's position as a UnitValue. E.g. "10" or "40mm" or "container.x2 - 10".
1216          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1217          * @see #setPos(UnitValue[])
1218          */
1219         public final CC pos(String x, String y, String x2, String y2)
1220         {
1221                 setPos(new UnitValue[] {
1222                                 ConstraintParser.parseUnitValue(x, true),
1223                                 ConstraintParser.parseUnitValue(y, false),
1224                                 ConstraintParser.parseUnitValue(x2, true),
1225                                 ConstraintParser.parseUnitValue(y2, false),
1226                 });
1227                 setBoundsInGrid(false);
1228                 return this;
1229         }
1230
1231         /** Same functionality as {@link #setPadding(UnitValue[])} but the unit values as absolute pixels. This method returns <code>this</code> for chaining multiple calls.
1232          * <p>
1233          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1234          * @param top The top padding that will be added to the y coordinate at the last stage in the layout.
1235          * @param left The top padding that will be added to the x coordinate at the last stage in the layout.
1236          * @param bottom The top padding that will be added to the y2 coordinate at the last stage in the layout.
1237          * @param right The top padding that will be added to the x2 coordinate at the last stage in the layout.
1238          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1239          * @see #setTag(String)
1240          */
1241         public final CC pad(int top, int left, int bottom, int right)
1242         {
1243                 setPadding(new UnitValue[] {
1244                                 new UnitValue(top),     new UnitValue(left), new UnitValue(bottom), new UnitValue(right)
1245                 });
1246                 return this;
1247         }
1248
1249         /** Same functionality as <code>setPadding(ConstraintParser.parseInsets(pad, false))}</code> only this method returns <code>this</code> for chaining multiple calls.
1250          * <p>
1251          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1252          * @param pad The string to parse. E.g. "10 10 10 10" or "20". If less than 4 groups the last will be used for the missing.
1253          * @return <code>this</code> so it is possible to chain calls. E.g. <code>new ComponentConstraint().noGrid().gap().fill()</code>.
1254          * @see #setTag(String)
1255          */
1256         public final CC pad(String pad)
1257         {
1258                 setPadding(pad != null ? ConstraintParser.parseInsets(pad, false) : null);
1259                 return this;
1260         }
1261
1262         // **********************************************************
1263         // Bean properties
1264         // **********************************************************
1265
1266         /** Returns the horizontal dimension constraint for this component constraint. It has constraints for the horizontal size
1267          * and grow/shrink priorities and weights.
1268          * <p>
1269          * Note! If any changes is to be made it must be made direct when the object is returned. It is not allowed to save the
1270          * constraint for later use.
1271          * @return The current dimension constraint. Never <code>null</code>.
1272          */
1273         public DimConstraint getHorizontal()
1274         {
1275                 return hor;
1276         }
1277
1278         /** Sets the horizontal dimension constraint for this component constraint. It has constraints for the horizontal size
1279          * and grow/shrink priorities and weights.
1280          * @param h The new dimension constraint. If <code>null</code> it will be reset to <code>new DimConstraint();</code>
1281          */
1282         public void setHorizontal(DimConstraint h)
1283         {
1284                 hor = h != null ? h : new DimConstraint();
1285         }
1286
1287         /** Returns the vertical dimension constraint for this component constraint. It has constraints for the vertical size
1288          * and grow/shrink priorities and weights.
1289          * <p>
1290          * Note! If any changes is to be made it must be made direct when the object is returned. It is not allowed to save the
1291          * constraint for later use.
1292          * @return The current dimension constraint. Never <code>null</code>.
1293          */
1294         public DimConstraint getVertical()
1295         {
1296                 return ver;
1297         }
1298
1299         /** Sets the vertical dimension constraint for this component constraint. It has constraints for the vertical size
1300          * and grow/shrink priorities and weights.
1301          * @param v The new dimension constraint. If <code>null</code> it will be reset to <code>new DimConstraint();</code>
1302          */
1303         public void setVertical(DimConstraint v)
1304         {
1305                 ver = v != null ? v : new DimConstraint();
1306         }
1307
1308         /** Returns the vertical or horizontal dim constraint.
1309          * <p>
1310          * Note! If any changes is to be made it must be made direct when the object is returned. It is not allowed to save the
1311          * constraint for later use.
1312          * @param isHor If the horizontal constraint should be returned.
1313          * @return The dim constraint. Never <code>null</code>.
1314          */
1315         public DimConstraint getDimConstraint(boolean isHor)
1316         {
1317                 return isHor ? hor : ver;
1318         }
1319
1320         /** Returns the absolute positioning of one or more of the edges. This will be applied last in the layout cycle and will not
1321          * affect the flow or grid positions. The positioning is relative to the parent and can not (as padding) be used
1322          * to adjust the edges relative to the old value. May be <code>null</code> and elements may be <code>null</code>.
1323          * <code>null</code> value(s) for the x2 and y2 will be interpreted as to keep the preferred size and thus the x1
1324          * and x2 will just absolutely positions the component.
1325          * <p>
1326          * Note that {@link #setBoundsInGrid(boolean)} changes the interpretation of this property slightly.
1327          * <p>
1328          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1329          * @return The current value as a new array, free to modify.
1330          */
1331         public UnitValue[] getPos()
1332         {
1333                 return pos != null ? new UnitValue[] {pos[0], pos[1], pos[2], pos[3]} : null;
1334         }
1335
1336         /** Sets absolute positioning of one or more of the edges. This will be applied last in the layout cycle and will not
1337          * affect the flow or grid positions. The positioning is relative to the parent and can not (as padding) be used
1338          * to adjust the edges relative to the old value. May be <code>null</code> and elements may be <code>null</code>.
1339          * <code>null</code> value(s) for the x2 and y2 will be interpreted as to keep the preferred size and thus the x1
1340          * and x2 will just absolutely positions the component.
1341          * <p>
1342          * Note that {@link #setBoundsInGrid(boolean)} changes the interpretation of this property slightly.
1343          * <p>
1344          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1345          * @param pos <code>UnitValue[] {x, y, x2, y2}</code>. Must be <code>null</code> or of length 4. Elements can be <code>null</code>.
1346          */
1347         public void setPos(UnitValue[] pos)
1348         {
1349                 this.pos = pos != null ? new UnitValue[] {pos[0], pos[1], pos[2], pos[3]} : null;
1350                 linkTargets = null;
1351         }
1352
1353         /** Returns if the absolute <code>pos</code> value should be corrections to the component that is in a normal cell. If <code>false</code>
1354          * the value of <code>pos</code> is truly absolute in that it will not affect the grid or have a default bounds in the grid.
1355          * <p>
1356          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1357          * @return The current value.
1358          * @see #getPos()
1359          */
1360         public boolean isBoundsInGrid()
1361         {
1362                 return boundsInGrid;
1363         }
1364
1365         /** Sets if the absolute <code>pos</code> value should be corrections to the component that is in a normal cell. If <code>false</code>
1366          * the value of <code>pos</code> is truly absolute in that it will not affect the grid or have a default bounds in the grid.
1367          * <p>
1368          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1369          * @param b <code>true</code> for bounds taken from the grid position. <code>false</code> is default.
1370          * @see #setPos(UnitValue[])
1371          */
1372         void setBoundsInGrid(boolean b)
1373         {
1374                 this.boundsInGrid = b;
1375         }
1376
1377         /** Returns the absolute cell position in the grid or <code>-1</code> if cell positioning is not used.
1378          * <p>
1379          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1380          * @return The current value.
1381          */
1382         public int getCellX()
1383         {
1384                 return cellX;
1385         }
1386
1387         /** Set an absolute cell x-position in the grid. If &gt;= 0 this point points to the absolute cell that this constaint's component should occupy.
1388          * If there's already a component in that cell they will split the cell. The flow will then continue after this cell.
1389          * <p>
1390          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1391          * @param x The x-position or <code>-1</code> to disable cell positioning.
1392          */
1393         public void setCellX(int x)
1394         {
1395                 cellX = x;
1396         }
1397
1398         /** Returns the absolute cell position in the grid or <code>-1</code> if cell positioning is not used.
1399          * <p>
1400          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1401          * @return The current value.
1402          */
1403         public int getCellY()
1404         {
1405                 return cellX < 0 ? -1 : cellY;
1406         }
1407
1408         /** Set an absolute cell x-position in the grid. If &gt;= 0 this point points to the absolute cell that this constaint's component should occupy.
1409          * If there's already a component in that cell they will split the cell. The flow will then continue after this cell.
1410          * <p>
1411          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1412          * @param y The y-position or <code>-1</code> to disable cell positioning.
1413          */
1414         public void setCellY(int y)
1415         {
1416                 if (y < 0)
1417                         cellX = -1;
1418                 cellY = y < 0 ? 0 : y;
1419         }
1420
1421         /** Sets the docking side. -1 means no docking.<br>
1422          * Valid sides are: <code> north = 0, west = 1, south = 2, east = 3</code>.
1423          * <p>
1424          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1425          * @return The current side.
1426          */
1427         public int getDockSide()
1428         {
1429                 return dock;
1430         }
1431
1432         /** Sets the docking side. -1 means no docking.<br>
1433          * Valid sides are: <code> north = 0, west = 1, south = 2, east = 3</code>.
1434          * <p>
1435          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1436          * @param side -1 or 0-3.
1437          */
1438         public void setDockSide(int side)
1439         {
1440                 if (side < -1 || side > 3)
1441                         throw new IllegalArgumentException("Illegal dock side: " + side);
1442                 dock = side;
1443         }
1444
1445         /** Returns if this component should have its bounds handled by an external source and not this layout manager.
1446          * <p>
1447          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1448          * @return The current value.
1449          */
1450         public boolean isExternal()
1451         {
1452                 return external;
1453         }
1454
1455         /** If this boolean is true this component is not handled in any way by the layout manager and the component can have its bounds set by an external
1456          * handler which is normally by the use of some <code>component.setBounds(x, y, width, height)</code> directly (for Swing).
1457          * <p>
1458          * The bounds <b>will not</b> affect the minimum and preferred size of the container.
1459          * <p>
1460          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1461          * @param b <code>true</code> means that the bounds are not changed.
1462          */
1463         public void setExternal(boolean b)
1464         {
1465                 this.external = b;
1466         }
1467
1468         /** Returns if the flow in the <b>cell</b> is in the horizontal dimension. Vertical if <code>false</code>. Only the first
1469          * component is a cell can set the flow.
1470          * <p>
1471          * If <code>null</code> the flow direction is inherited by from the {@link net.miginfocom.layout.LC}.
1472          * <p>
1473          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1474          * @return The current value.
1475          */
1476         public Boolean getFlowX()
1477         {
1478                 return flowX;
1479         }
1480
1481         /** Sets if the flow in the <b>cell</b> is in the horizontal dimension. Vertical if <code>false</code>. Only the first
1482          * component is a cell can set the flow.
1483          * <p>
1484          * If <code>null</code> the flow direction is inherited by from the {@link net.miginfocom.layout.LC}.
1485          * <p>
1486          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1487          * @param b <code>Boolean.TRUE</code> means horizontal flow in the cell.
1488          */
1489         public void setFlowX(Boolean b)
1490         {
1491                 this.flowX = b;
1492         }
1493
1494         /** Sets how a component that is hidden (not visible) should be treated by default.
1495          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1496          * @return The mode:<br>
1497          * 0 == Normal. Bounds will be calculated as if the component was visible.<br>
1498          * 1 == If hidden the size will be 0, 0 but the gaps remain.<br>
1499          * 2 == If hidden the size will be 0, 0 and gaps set to zero.<br>
1500          * 3 == If hidden the component will be disregarded completely and not take up a cell in the grid..
1501          */
1502         public int getHideMode()
1503         {
1504                 return hideMode;
1505         }
1506
1507         /** Sets how a component that is hidden (not visible) should be treated by default.
1508          * @param mode The mode:<br>
1509          * 0 == Normal. Bounds will be calculated as if the component was visible.<br>
1510          * 1 == If hidden the size will be 0, 0 but the gaps remain.<br>
1511          * 2 == If hidden the size will be 0, 0 and gaps set to zero.<br>
1512          * 3 == If hidden the component will be disregarded completely and not take up a cell in the grid..
1513          */
1514         public void setHideMode(int mode)
1515         {
1516                 if (mode < -1 || mode > 3)
1517                         throw new IllegalArgumentException("Wrong hideMode: " + mode);
1518
1519                 hideMode = mode;
1520         }
1521
1522         /** Returns the id used to reference this component in some constraints.
1523          * <p>
1524          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1525          * @return The id or <code>null</code>. May consist of a groupID and an componentID which are separated by a dot: ".". E.g. "grp1.id1".
1526          * The dot should never be first or last if present.
1527          */
1528         public String getId()
1529         {
1530                 return id;
1531         }
1532
1533         /** Sets the id used to reference this component in some constraints.
1534          * <p>
1535          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1536          * @param id The id or <code>null</code>. May consist of a groupID and an componentID which are separated by a dot: ".". E.g. "grp1.id1".
1537          * The dot should never be first or last if present.
1538          */
1539         public void setId(String id)
1540         {
1541                 this.id = id;
1542         }
1543
1544         /** Returns the absolute resizing in the last stage of the layout cycle. May be <code>null</code> and elements may be <code>null</code>.
1545          * <p>
1546          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1547          * @return The current value. <code>null</code> or of length 4.
1548          */
1549         public UnitValue[] getPadding()
1550         {
1551                 return padding != null ? new UnitValue[] {padding[0], padding[1], padding[2], padding[3]} : null;
1552         }
1553
1554         /** Sets the absolute resizing in the last stage of the layout cycle. These values are added to the edges and can thus for
1555          * instance be used to grow or reduce the size or move the component an absolute number of pixels. May be <code>null</code>
1556          * and elements may be <code>null</code>.
1557          * <p>
1558          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1559          * @param sides top, left, bottom right. Must be <code>null</code> or of length 4.
1560          */
1561         public void setPadding(UnitValue[] sides)
1562         {
1563                 this.padding = sides != null ? new UnitValue[] {sides[0], sides[1], sides[2], sides[3]} : null;
1564         }
1565
1566         /** Returns the visual padding used when laying out this Component. May be <code>null</code> and elements may be <code>null</code>.
1567          * <p>
1568          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1569          * @return The current value. <code>null</code> or of length 4.
1570          */
1571         public UnitValue[] getVisualPadding()
1572         {
1573                 return visualPadding != null ? new UnitValue[] {visualPadding[0], visualPadding[1], visualPadding[2], visualPadding[3]} : null;
1574         }
1575
1576         /** Sets the visual padding used when laying out this Component.
1577          * <p>
1578          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1579          * @param sides top, left, bottom right. Must be <code>null</code> or of length 4.
1580          */
1581         public void setVisualPadding(UnitValue[] sides)
1582         {
1583                 this.visualPadding = sides != null ? new UnitValue[] {sides[0], sides[1], sides[2], sides[3]} : null;
1584         }
1585
1586         /** Returns how many cells in the grid that should be skipped <b>before</b> the component that this constraint belongs to.
1587          * <p>
1588          * Note that only the first component will be checked for this property.
1589          * <p>
1590          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1591          * @return The current value. 0 if no skip.
1592          */
1593         public int getSkip()
1594         {
1595                 return skip;
1596         }
1597
1598         /** Sets how many cells in the grid that should be skipped <b>before</b> the component that this constraint belongs to.
1599          * <p>
1600          * Note that only the first component will be checked for this property.
1601          * <p>
1602          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1603          * @param cells How many cells in the grid that should be skipped <b>before</b> the component that this constraint belongs to
1604          */
1605         public void setSkip(int cells)
1606         {
1607                 this.skip = cells;
1608         }
1609
1610         /** Returns the number of cells the cell that this constraint's component will span in the indicated dimension. <code>1</code> is default and
1611          * means that it only spans the current cell. <code>LayoutUtil.INF</code> is used to indicate a span to the end of the column/row.
1612          * <p>
1613          * Note that only the first component will be checked for this property.
1614          * <p>
1615          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1616          * @return The current value.
1617          */
1618         public int getSpanX()
1619         {
1620                 return spanX;
1621         }
1622
1623         /** Sets the number of cells the cell that this constraint's component will span in the indicated dimension. <code>1</code> is default and
1624          * means that it only spans the current cell. <code>LayoutUtil.INF</code> is used to indicate a span to the end of the column/row.
1625          * <p>
1626          * Note that only the first component will be checked for this property.
1627          * <p>
1628          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1629          * @param cells The number of cells to span (i.e. merge).
1630          */
1631         public void setSpanX(int cells)
1632         {
1633                 this.spanX = cells;
1634         }
1635
1636         /** Returns the number of cells the cell that this constraint's component will span in the indicated dimension. <code>1</code> is default and
1637          * means that it only spans the current cell. <code>LayoutUtil.INF</code> is used to indicate a span to the end of the column/row.
1638          * <p>
1639          * Note that only the first component will be checked for this property.
1640          * <p>
1641          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1642          * @return The current value.
1643          */
1644         public int getSpanY()
1645         {
1646                 return spanY;
1647         }
1648
1649         /** Sets the number of cells the cell that this constraint's component will span in the indicated dimension. <code>1</code> is default and
1650          * means that it only spans the current cell. <code>LayoutUtil.INF</code> is used to indicate a span to the end of the column/row.
1651          * <p>
1652          * Note that only the first component will be checked for this property.
1653          * <p>
1654          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1655          * @param cells The number of cells to span (i.e. merge).
1656          */
1657         public void setSpanY(int cells)
1658         {
1659                 this.spanY = cells;
1660         }
1661
1662         /** "pushx" indicates that the column that this component is in (this first if the component spans) should default to growing.
1663          * If any other column has been set to grow this push value on the component does nothing as the column's explicit grow weight
1664          * will take precedence. Push is normally used when the grid has not been defined in the layout.
1665          * <p>
1666          * If multiple components in a column has push weights set the largest one will be used for the column.
1667          * @return The current push value. Default is <code>null</code>.
1668          */
1669         public Float getPushX()
1670         {
1671                 return pushX;
1672         }
1673
1674         /** "pushx" indicates that the column that this component is in (this first if the component spans) should default to growing.
1675          * If any other column has been set to grow this push value on the component does nothing as the column's explicit grow weight
1676          * will take precedence. Push is normally used when the grid has not been defined in the layout.
1677          * <p>
1678          * If multiple components in a column has push weights set the largest one will be used for the column.
1679          * @param weight The new push value. Default is <code>null</code>.
1680          */
1681         public void setPushX(Float weight)
1682         {
1683                 this.pushX = weight;
1684         }
1685
1686         /** "pushx" indicates that the row that this component is in (this first if the component spans) should default to growing.
1687          * If any other row has been set to grow this push value on the component does nothing as the row's explicit grow weight
1688          * will take precedence. Push is normally used when the grid has not been defined in the layout.
1689          * <p>
1690          * If multiple components in a row has push weights set the largest one will be used for the row.
1691          * @return The current push value. Default is <code>null</code>.
1692          */
1693         public Float getPushY()
1694         {
1695                 return pushY;
1696         }
1697
1698         /** "pushx" indicates that the row that this component is in (this first if the component spans) should default to growing.
1699          * If any other row has been set to grow this push value on the component does nothing as the row's explicit grow weight
1700          * will take precedence. Push is normally used when the grid has not been defined in the layout.
1701          * <p>
1702          * If multiple components in a row has push weights set the largest one will be used for the row.
1703          * @param weight The new push value. Default is <code>null</code>.
1704          */
1705         public void setPushY(Float weight)
1706         {
1707                 this.pushY = weight;
1708         }
1709
1710         /** Returns in how many parts the current cell (that this constraint's component will be in) should be split in. If for instance
1711          * it is split in two, the next component will also share the same cell. Note that the cell can also span a number of
1712          * cells, which means that you can for instance span three cells and split that big cell for two components. Split can be
1713          * set to a very high value to make all components in the same row/column share the same cell (e.g. <code>LayoutUtil.INF</code>).
1714          * <p>
1715          * Note that only the first component will be checked for this property.
1716          * <p>
1717          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1718          * @return The current value.
1719          */
1720         public int getSplit()
1721         {
1722                 return split;
1723         }
1724
1725         /** Sets in how many parts the current cell (that this constraint's component will be in) should be split in. If for instance
1726          * it is split in two, the next component will also share the same cell. Note that the cell can also span a number of
1727          * cells, which means that you can for instance span three cells and split that big cell for two components. Split can be
1728          * set to a very high value to make all components in the same row/column share the same cell (e.g. <code>LayoutUtil.INF</code>).
1729          * <p>
1730          * Note that only the first component will be checked for this property.
1731          * <p>
1732          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1733          * @param parts The number of parts (i.e. component slots) the cell should be divided into.
1734          */
1735         public void setSplit(int parts)
1736         {
1737                 this.split = parts;
1738         }
1739
1740         /** Tags the component with metadata. Currently only used to tag buttons with for instance "cancel" or "ok" to make them
1741          * show up in the correct order depending on platform. See {@link PlatformDefaults#setButtonOrder(String)} for information.
1742          * <p>
1743          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1744          * @return The current value. May be <code>null</code>.
1745          */
1746         public String getTag()
1747         {
1748                 return tag;
1749         }
1750
1751         /** Optional tag that gives more context to this constraint's component. It is for instance used to tag buttons in a
1752          * button bar with the button type such as "ok", "help" or "cancel".
1753          * <p>
1754          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1755          * @param tag The new tag. May be <code>null</code>.
1756          */
1757         public void setTag(String tag)
1758         {
1759                 this.tag = tag;
1760         }
1761
1762         /** Returns if the flow should wrap to the next line/column <b>after</b> the component that this constraint belongs to.
1763          * <p>
1764          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1765          * @return The current value.
1766          */
1767         public boolean isWrap()
1768         {
1769                 return wrap != null;
1770         }
1771
1772         /** Sets if the flow should wrap to the next line/column <b>after</b> the component that this constraint belongs to.
1773          * <p>
1774          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1775          * @param b <code>true</code> means wrap after.
1776          */
1777         public void setWrap(boolean b)
1778         {
1779                 wrap = b ? (wrap == null ? DEF_GAP : wrap) : null;
1780         }
1781
1782         /** Returns the wrap size if it is a custom size. If wrap was set to true with {@link #setWrap(boolean)} then this method will
1783          * return <code>null</code> since that means that the gap size should be the default one as defined in the rows spec.
1784          * @return The custom gap size. NOTE! Will return <code>null</code> for both no wrap <b>and</b> default wrap.
1785          * @see #isWrap()
1786          * @see #setWrap(boolean)
1787          * @since 2.4.2
1788          */
1789         public BoundSize getWrapGapSize()
1790         {
1791                 return wrap == DEF_GAP ? null : wrap;
1792         }
1793
1794         /** Set the wrap size and turns wrap on if <code>!= null</code>.
1795          * @param s The custom gap size. NOTE! <code>null</code> will not turn on or off wrap, it will only set the wrap gap size to "default".
1796          * A non-null value will turn on wrap though.
1797          * @see #isWrap()
1798          * @see #setWrap(boolean)
1799          * @since 2.4.2
1800          */
1801         public void setWrapGapSize(BoundSize s)
1802         {
1803                 wrap = s == null ? (wrap != null ? DEF_GAP : null) : s;
1804         }
1805
1806         /** Returns if the flow should wrap to the next line/column <b>before</b> the component that this constraint belongs to.
1807          * <p>
1808          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1809          * @return The current value.
1810          */
1811         public boolean isNewline()
1812         {
1813                 return newline != null;
1814         }
1815
1816         /** Sets if the flow should wrap to the next line/column <b>before</b> the component that this constraint belongs to.
1817          * <p>
1818          * For a more thorough explanation of what this constraint does see the white paper or cheat Sheet at www.migcomponents.com.
1819          * @param b <code>true</code> means wrap before.
1820          */
1821         public void setNewline(boolean b)
1822         {
1823                 newline = b ? (newline == null ? DEF_GAP : newline) : null;
1824         }
1825
1826         /** Returns the newline size if it is a custom size. If newline was set to true with {@link #setNewline(boolean)} then this method will
1827          * return <code>null</code> since that means that the gap size should be the default one as defined in the rows spec.
1828          * @return The custom gap size. NOTE! Will return <code>null</code> for both no newline <b>and</b> default newline.
1829          * @see #isNewline()
1830          * @see #setNewline(boolean)
1831          * @since 2.4.2
1832          */
1833         public BoundSize getNewlineGapSize()
1834         {
1835                 return newline == DEF_GAP ? null : newline;
1836         }
1837
1838         /** Set the newline size and turns newline on if <code>!= null</code>.
1839          * @param s The custom gap size. NOTE! <code>null</code> will not turn on or off newline, it will only set the newline gap size to "default".
1840          * A non-null value will turn on newline though.
1841          * @see #isNewline()
1842          * @see #setNewline(boolean)
1843          * @since 2.4.2
1844          */
1845         public void setNewlineGapSize(BoundSize s)
1846         {
1847                 newline = s == null ? (newline != null ? DEF_GAP : null) : s;
1848         }
1849
1850         /** Returns the animation spec. Default is a spec where animation is off (prio 0).
1851          * @return Never null.
1852          */
1853         public AnimSpec getAnimSpec()
1854         {
1855                 return animSpec;
1856         }
1857
1858
1859 //      // ************************************************
1860 //      // Persistence Delegate and Serializable combined.
1861 //      // ************************************************
1862 //
1863 //      private Object readResolve() throws ObjectStreamException
1864 //      {
1865 //              return LayoutUtil.getSerializedObject(this);
1866 //      }
1867 //
1868 //      @Override
1869 //      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
1870 //      {
1871 //              LayoutUtil.setSerializedObject(this, LayoutUtil.readAsXML(in));
1872 //      }
1873 //
1874 //      @Override
1875 //      public void writeExternal(ObjectOutput out) throws IOException
1876 //      {
1877 //              if (getClass() == CC.class)
1878 //                      LayoutUtil.writeAsXML(out, this);
1879 //      }
1880 }