Source for java.awt.GridBagConstraints

   1: /* GridBagConstraints.java -- Constraints for GridBag layout manager
   2:    Copyright (C) 2000, 2001, 2002, 2004  Free Software Foundation
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package java.awt;
  40: 
  41: import java.io.Serializable;
  42: 
  43: /**
  44:  * This specifies the constraints for a component managed by the
  45:  * GridBagLayout layout manager.
  46:  */
  47: public class GridBagConstraints implements Cloneable, Serializable
  48: {
  49:   static final long serialVersionUID = -1000070633030801713L;
  50: 
  51:   // Fill values.
  52:   /**
  53:    * Don't fill.
  54:    */
  55:   public static final int NONE = 0;
  56: 
  57:   /**
  58:    * Fill in both directions.
  59:    */
  60:   public static final int BOTH = 1;
  61: 
  62:   /**
  63:    * Fill horizontally.
  64:    */
  65:   public static final int HORIZONTAL = 2;
  66: 
  67:   /**
  68:    * Fill vertically.
  69:    */
  70:   public static final int VERTICAL = 3;
  71: 
  72:   // Anchor values.
  73:   /**
  74:    * Position in the center.
  75:    */
  76:   public static final int CENTER = 10;
  77: 
  78:   /**
  79:    * Position to the north.
  80:    */
  81:   public static final int NORTH = 11;
  82: 
  83:   /**
  84:    * Position to the northeast.
  85:    */
  86:   public static final int NORTHEAST = 12;
  87: 
  88:   /**
  89:    * Position to the east.
  90:    */
  91:   public static final int EAST = 13;
  92: 
  93:   /**
  94:    * Position to the southeast.
  95:    */
  96:   public static final int SOUTHEAST = 14;
  97: 
  98:   /**
  99:    * Position to the south.
 100:    */
 101:   public static final int SOUTH = 15;
 102: 
 103:   /**
 104:    * Position to the southwest.
 105:    */
 106:   public static final int SOUTHWEST = 16;
 107: 
 108:   /**
 109:    * Position to the west.
 110:    */
 111:   public static final int WEST = 17;
 112: 
 113:   /**
 114:    * Position to the northwest.
 115:    */
 116:   public static final int NORTHWEST = 18;
 117: 
 118:   // gridx and gridy values.
 119:   /**
 120:    * Occupy all remaining cells except last cell.
 121:    */
 122:   public static final int RELATIVE = -1;
 123: 
 124:   /**
 125:    * Occupy all remaining cells.
 126:    */
 127:   public static final int REMAINDER = 0;
 128: 
 129:   /**
 130:    * Position to where a page starts. Equals NORTH for horizontal orientations.
 131:    */
 132:   public static final int PAGE_START = 19;
 133: 
 134:   /**
 135:    * Position to where a page ends. Equals SOUTH for horizontal orientations.
 136:    */
 137:   public static final int PAGE_END = 20;
 138: 
 139:   /**
 140:    * Position to where a text line would start. Equals to WEST for
 141:    * left-to-right orientations.
 142:    */
 143:   public static final int LINE_START = 21;
 144: 
 145:   /**
 146:    * Position to where a text line would end. Equals to EAST for
 147:    * left-to-right orientations.
 148:    */
 149:   public static final int LINE_END = 22;
 150: 
 151:   /**
 152:    * Position to where the first text line would start. Equals to NORTHWEST for
 153:    * horizontal left-to-right orientations.
 154:    */
 155:   public static final int FIRST_LINE_START = 23;
 156: 
 157:   /**
 158:    * Position to where the first text line would end. Equals to NORTHEAST for
 159:    * horizontal left-to-right orientations.
 160:    */
 161:   public static final int FIRST_LINE_END = 24;
 162: 
 163:   /**
 164:    * Position to where the last text line would start. Equals to SOUTHWEST for
 165:    * horizontal left-to-right orientations.
 166:    */
 167:   public static final int LAST_LINE_START = 25;
 168: 
 169:   /**
 170:    * Position to where the last text line would end. Equals to SOUTHEAST for
 171:    * horizontal left-to-right orientations.
 172:    */
 173:   public static final int LAST_LINE_END = 26;
 174: 
 175:   public int anchor;
 176:   public int fill;
 177:   public int gridheight;
 178:   public int gridwidth;
 179:   public int gridx;
 180:   public int gridy;
 181:   public Insets insets;
 182:   public int ipadx;
 183:   public int ipady;
 184:   public double weightx;
 185:   public double weighty;
 186: 
 187:   /**
 188:    * Create a copy of this object.
 189:    */
 190:   public Object clone ()
 191:   {
 192:     try
 193:       {
 194:     GridBagConstraints g = (GridBagConstraints) super.clone ();
 195:     g.insets = (Insets) insets.clone ();
 196:     return g;
 197:       }
 198:     catch (CloneNotSupportedException _)
 199:       {
 200:     // Can't happen.
 201:     return null;
 202:       }
 203:   }
 204: 
 205:   /**
 206:    * Create a new GridBagConstraints object with the default
 207:    * parameters.
 208:    */
 209:   public GridBagConstraints ()
 210:   {
 211:     this.anchor = CENTER;
 212:     this.fill = NONE;
 213:     this.gridx = RELATIVE;
 214:     this.gridy = RELATIVE;
 215:     this.gridwidth = 1;
 216:     this.gridheight = 1;
 217:     this.ipadx = 0;
 218:     this.ipady = 0;
 219:     this.insets = new Insets (0, 0, 0, 0);
 220:     this.weightx = 0;
 221:     this.weighty = 0;
 222:   }
 223: 
 224:   /**
 225:    * Create a new GridBagConstraints object with the indicated
 226:    * parameters.
 227:    */
 228:   public GridBagConstraints (int gridx, int gridy,
 229:                  int gridwidth, int gridheight,
 230:                  double weightx, double weighty,
 231:                  int anchor, int fill,
 232:                  Insets insets, int ipadx, int ipady)
 233:   {
 234:     this.anchor = anchor;
 235:     this.fill = fill;
 236:     this.gridx = gridx;
 237:     this.gridy = gridy;
 238:     this.gridwidth = gridwidth;
 239:     this.gridheight = gridheight;
 240:     this.ipadx = ipadx;
 241:     this.ipady = ipady;
 242:     this.insets = insets;
 243:     this.weightx = weightx;
 244:     this.weighty = weighty;
 245:   }
 246: }