GridBagConstraints.java 6.2 KB

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