001    /* GridBagConstraints.java -- Constraints for GridBag layout manager
002       Copyright (C) 2000, 2001, 2002, 2004  Free Software Foundation
003    
004    This file is part of GNU Classpath.
005    
006    GNU Classpath is free software; you can redistribute it and/or modify
007    it under the terms of the GNU General Public License as published by
008    the Free Software Foundation; either version 2, or (at your option)
009    any later version.
010    
011    GNU Classpath is distributed in the hope that it will be useful, but
012    WITHOUT ANY WARRANTY; without even the implied warranty of
013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014    General Public License for more details.
015    
016    You should have received a copy of the GNU General Public License
017    along with GNU Classpath; see the file COPYING.  If not, write to the
018    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019    02110-1301 USA.
020    
021    Linking this library statically or dynamically with other modules is
022    making a combined work based on this library.  Thus, the terms and
023    conditions of the GNU General Public License cover the whole
024    combination.
025    
026    As a special exception, the copyright holders of this library give you
027    permission to link this library with independent modules to produce an
028    executable, regardless of the license terms of these independent
029    modules, and to copy and distribute the resulting executable under
030    terms of your choice, provided that you also meet, for each linked
031    independent module, the terms and conditions of the license of that
032    module.  An independent module is a module which is not derived from
033    or based on this library.  If you modify this library, you may extend
034    this exception to your version of the library, but you are not
035    obligated to do so.  If you do not wish to do so, delete this
036    exception statement from your version. */
037    
038    
039    package java.awt;
040    
041    import java.io.Serializable;
042    
043    /**
044     * This specifies the constraints for a component managed by the
045     * GridBagLayout layout manager.
046     */
047    public class GridBagConstraints implements Cloneable, Serializable
048    {
049      static final long serialVersionUID = -1000070633030801713L;
050    
051      // Fill values.
052      /**
053       * Don't fill.
054       */
055      public static final int NONE = 0;
056    
057      /**
058       * Fill in both directions.
059       */
060      public static final int BOTH = 1;
061    
062      /**
063       * Fill horizontally.
064       */
065      public static final int HORIZONTAL = 2;
066    
067      /**
068       * Fill vertically.
069       */
070      public static final int VERTICAL = 3;
071    
072      // Anchor values.
073      /**
074       * Position in the center.
075       */
076      public static final int CENTER = 10;
077    
078      /**
079       * Position to the north.
080       */
081      public static final int NORTH = 11;
082    
083      /**
084       * Position to the northeast.
085       */
086      public static final int NORTHEAST = 12;
087    
088      /**
089       * Position to the east.
090       */
091      public static final int EAST = 13;
092    
093      /**
094       * Position to the southeast.
095       */
096      public static final int SOUTHEAST = 14;
097    
098      /**
099       * 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    }