KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > GridBagLayoutInfo


1 package java.awt;
2
3 /**
4  * The {@code GridBagLayoutInfo} is an utility class for
5  * {@code GridBagLayout} layout manager.
6  * It stores align, size and baseline parameters for every component within a container.
7  * <p>
8  * @see java.awt.GridBagLayout
9  * @see java.awt.GridBagConstraints
10  * @since 1.6
11  */

12 public class GridBagLayoutInfo implements java.io.Serializable JavaDoc {
13     /*
14      * serialVersionUID
15      */

16     private static final long serialVersionUID = -4899416460737170217L;
17
18     int width, height; /* number of cells: horizontal and vertical */
19     int startx, starty; /* starting point for layout */
20     int minWidth[]; /* largest minWidth in each column */
21     int minHeight[]; /* largest minHeight in each row */
22     double weightX[]; /* largest weight in each column */
23     double weightY[]; /* largest weight in each row */
24     boolean hasBaseline; /* Whether or not baseline layout has been
25                                  * requested and one of the components
26                                  * has a valid baseline. */

27     // These are only valid if hasBaseline is true and are indexed by
28
// row.
29
short baselineType[]; /* The type of baseline for a particular
30                                  * row. A mix of the BaselineResizeBehavior
31                                  * constants (1 << ordinal()) */

32     int maxAscent[]; /* Max ascent (baseline). */
33     int maxDescent[]; /* Max descent (height - baseline) */
34
35     /**
36      * Creates an instance of GridBagLayoutInfo representing {@code GridBagLayout}
37      * grid cells with it's own parameters.
38      * @param width the columns
39      * @param height the rows
40      * @since 6.0
41      */

42     GridBagLayoutInfo(int width, int height) {
43         this.width = width;
44         this.height = height;
45     }
46
47     /**
48      * Returns true if the specified row has any component aligned on the
49      * baseline with a baseline resize behavior of CONSTANT_DESCENT.
50      */

51     boolean hasConstantDescent(int row) {
52         return ((baselineType[row] & (1 << Component.BaselineResizeBehavior.
53                                       CONSTANT_DESCENT.ordinal())) != 0);
54     }
55
56     /**
57      * Returns true if there is a baseline for the specified row.
58      */

59     boolean hasBaseline(int row) {
60         return (hasBaseline && baselineType[row] != 0);
61     }
62 }
63
Popular Tags