| 1 | // GridBagConstraints.java - Constraints for GridBag layout manager
|
|---|
| 2 |
|
|---|
| 3 | /* Copyright (C) 2000, 2001, 2002 Free Software Foundation
|
|---|
| 4 |
|
|---|
| 5 | This file is part of GNU Classpath.
|
|---|
| 6 |
|
|---|
| 7 | GNU Classpath is free software; you can redistribute it and/or modify
|
|---|
| 8 | it under the terms of the GNU General Public License as published by
|
|---|
| 9 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 10 | any later version.
|
|---|
| 11 |
|
|---|
| 12 | GNU Classpath is distributed in the hope that it will be useful, but
|
|---|
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 15 | General Public License for more details.
|
|---|
| 16 |
|
|---|
| 17 | You should have received a copy of the GNU General Public License
|
|---|
| 18 | along with GNU Classpath; see the file COPYING. If not, write to the
|
|---|
| 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 20 | 02111-1307 USA.
|
|---|
| 21 |
|
|---|
| 22 | Linking this library statically or dynamically with other modules is
|
|---|
| 23 | making a combined work based on this library. Thus, the terms and
|
|---|
| 24 | conditions of the GNU General Public License cover the whole
|
|---|
| 25 | combination.
|
|---|
| 26 |
|
|---|
| 27 | As a special exception, the copyright holders of this library give you
|
|---|
| 28 | permission to link this library with independent modules to produce an
|
|---|
| 29 | executable, regardless of the license terms of these independent
|
|---|
| 30 | modules, and to copy and distribute the resulting executable under
|
|---|
| 31 | terms of your choice, provided that you also meet, for each linked
|
|---|
| 32 | independent module, the terms and conditions of the license of that
|
|---|
| 33 | module. An independent module is a module which is not derived from
|
|---|
| 34 | or based on this library. If you modify this library, you may extend
|
|---|
| 35 | this exception to your version of the library, but you are not
|
|---|
| 36 | obligated to do so. If you do not wish to do so, delete this
|
|---|
| 37 | exception statement from your version. */
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | package java.awt;
|
|---|
| 41 |
|
|---|
| 42 | import java.io.Serializable;
|
|---|
| 43 |
|
|---|
| 44 | /** This specifies the constraints for a component managed by the
|
|---|
| 45 | * GridBagLayout layout manager. */
|
|---|
| 46 | public class GridBagConstraints implements Cloneable, Serializable
|
|---|
| 47 | {
|
|---|
| 48 | /** Fill in both directions. */
|
|---|
| 49 | public static final int BOTH = 1;
|
|---|
| 50 | /** Don't fill. */
|
|---|
| 51 | public static final int NONE = 0;
|
|---|
| 52 | /** Fill horizontally. */
|
|---|
| 53 | public static final int HORIZONTAL = 2;
|
|---|
| 54 | /** Fill vertically. */
|
|---|
| 55 | public static final int VERTICAL = 3;
|
|---|
| 56 |
|
|---|
| 57 | /** Position in the center. */
|
|---|
| 58 | public static final int CENTER = 10;
|
|---|
| 59 | /** Position to the east. */
|
|---|
| 60 | public static final int EAST = 13;
|
|---|
| 61 | /** Position to the north. */
|
|---|
| 62 | public static final int NORTH = 11;
|
|---|
| 63 | /** Position to the northeast. */
|
|---|
| 64 | public static final int NORTHEAST = 12;
|
|---|
| 65 | /** Position to the northwest. */
|
|---|
| 66 | public static final int NORTHWEST = 18;
|
|---|
| 67 | /** Position to the south. */
|
|---|
| 68 | public static final int SOUTH = 15;
|
|---|
| 69 | /** Position to the southeast. */
|
|---|
| 70 | public static final int SOUTHEAST = 14;
|
|---|
| 71 | /** Position to the southwest. */
|
|---|
| 72 | public static final int SOUTHWEST = 16;
|
|---|
| 73 | /** Position to the west. */
|
|---|
| 74 | public static final int WEST = 17;
|
|---|
| 75 |
|
|---|
| 76 | /** Occupy all remaining cells except last cell. */
|
|---|
| 77 | public static final int RELATIVE = -1;
|
|---|
| 78 | /** Occupy all remaining cells. */
|
|---|
| 79 | public static final int REMAINDER = 0;
|
|---|
| 80 |
|
|---|
| 81 | public int anchor;
|
|---|
| 82 | public int fill;
|
|---|
| 83 | public int gridheight;
|
|---|
| 84 | public int gridwidth;
|
|---|
| 85 | public int gridx;
|
|---|
| 86 | public int gridy;
|
|---|
| 87 | public Insets insets;
|
|---|
| 88 | public int ipadx;
|
|---|
| 89 | public int ipady;
|
|---|
| 90 | public double weightx;
|
|---|
| 91 | public double weighty;
|
|---|
| 92 |
|
|---|
| 93 | /** Create a copy of this object. */
|
|---|
| 94 | public Object clone ()
|
|---|
| 95 | {
|
|---|
| 96 | try
|
|---|
| 97 | {
|
|---|
| 98 | GridBagConstraints g = (GridBagConstraints) super.clone ();
|
|---|
| 99 | g.insets = (Insets) insets.clone ();
|
|---|
| 100 | return g;
|
|---|
| 101 | }
|
|---|
| 102 | catch (CloneNotSupportedException _)
|
|---|
| 103 | {
|
|---|
| 104 | // Can't happen.
|
|---|
| 105 | return null;
|
|---|
| 106 | }
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | /** Create a new GridBagConstraints object with the default
|
|---|
| 110 | * parameters. */
|
|---|
| 111 | public GridBagConstraints ()
|
|---|
| 112 | {
|
|---|
| 113 | this.anchor = CENTER;
|
|---|
| 114 | this.fill = NONE;
|
|---|
| 115 | this.gridx = RELATIVE;
|
|---|
| 116 | this.gridy = RELATIVE;
|
|---|
| 117 | this.gridwidth = 1;
|
|---|
| 118 | this.gridheight = 1;
|
|---|
| 119 | this.ipadx = 0;
|
|---|
| 120 | this.ipady = 0;
|
|---|
| 121 | this.insets = new Insets (0, 0, 0, 0);
|
|---|
| 122 | this.weightx = 0;
|
|---|
| 123 | this.weighty = 0;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | /** Create a new GridBagConstraints object with the indicated
|
|---|
| 127 | * parameters. */
|
|---|
| 128 | public GridBagConstraints (int gridx, int gridy,
|
|---|
| 129 | int gridwidth, int gridheight,
|
|---|
| 130 | double weightx, double weighty,
|
|---|
| 131 | int anchor, int fill,
|
|---|
| 132 | Insets insets, int ipadx, int ipady)
|
|---|
| 133 | {
|
|---|
| 134 | this.anchor = anchor;
|
|---|
| 135 | this.fill = fill;
|
|---|
| 136 | this.gridx = gridx;
|
|---|
| 137 | this.gridy = gridy;
|
|---|
| 138 | this.gridwidth = gridwidth;
|
|---|
| 139 | this.gridheight = gridheight;
|
|---|
| 140 | this.ipadx = ipadx;
|
|---|
| 141 | this.ipady = ipady;
|
|---|
| 142 | this.insets = insets;
|
|---|
| 143 | this.weightx = weightx;
|
|---|
| 144 | this.weighty = weighty;
|
|---|
| 145 | }
|
|---|
| 146 | }
|
|---|