GridBagConstraints.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // GridBagConstraints.java - Constraints for GridBag layout manager
  2. /* Copyright (C) 2000, 2001, 2002 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., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 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. /** This specifies the constraints for a component managed by the
  34. * GridBagLayout layout manager. */
  35. public class GridBagConstraints implements Cloneable, Serializable
  36. {
  37. static final long serialVersionUID = -1000070633030801713L;
  38. /** Fill in both directions. */
  39. public static final int BOTH = 1;
  40. /** Don't fill. */
  41. public static final int NONE = 0;
  42. /** Fill horizontally. */
  43. public static final int HORIZONTAL = 2;
  44. /** Fill vertically. */
  45. public static final int VERTICAL = 3;
  46. /** Position in the center. */
  47. public static final int CENTER = 10;
  48. /** Position to the east. */
  49. public static final int EAST = 13;
  50. /** Position to the north. */
  51. public static final int NORTH = 11;
  52. /** Position to the northeast. */
  53. public static final int NORTHEAST = 12;
  54. /** Position to the northwest. */
  55. public static final int NORTHWEST = 18;
  56. /** Position to the south. */
  57. public static final int SOUTH = 15;
  58. /** Position to the southeast. */
  59. public static final int SOUTHEAST = 14;
  60. /** Position to the southwest. */
  61. public static final int SOUTHWEST = 16;
  62. /** Position to the west. */
  63. public static final int WEST = 17;
  64. /** Occupy all remaining cells except last cell. */
  65. public static final int RELATIVE = -1;
  66. /** Occupy all remaining cells. */
  67. public static final int REMAINDER = 0;
  68. public int anchor;
  69. public int fill;
  70. public int gridheight;
  71. public int gridwidth;
  72. public int gridx;
  73. public int gridy;
  74. public Insets insets;
  75. public int ipadx;
  76. public int ipady;
  77. public double weightx;
  78. public double weighty;
  79. /** Create a copy of this object. */
  80. public Object clone ()
  81. {
  82. try
  83. {
  84. GridBagConstraints g = (GridBagConstraints) super.clone ();
  85. g.insets = (Insets) insets.clone ();
  86. return g;
  87. }
  88. catch (CloneNotSupportedException _)
  89. {
  90. // Can't happen.
  91. return null;
  92. }
  93. }
  94. /** Create a new GridBagConstraints object with the default
  95. * parameters. */
  96. public GridBagConstraints ()
  97. {
  98. this.anchor = CENTER;
  99. this.fill = NONE;
  100. this.gridx = RELATIVE;
  101. this.gridy = RELATIVE;
  102. this.gridwidth = 1;
  103. this.gridheight = 1;
  104. this.ipadx = 0;
  105. this.ipady = 0;
  106. this.insets = new Insets (0, 0, 0, 0);
  107. this.weightx = 0;
  108. this.weighty = 0;
  109. }
  110. /** Create a new GridBagConstraints object with the indicated
  111. * parameters. */
  112. public GridBagConstraints (int gridx, int gridy,
  113. int gridwidth, int gridheight,
  114. double weightx, double weighty,
  115. int anchor, int fill,
  116. Insets insets, int ipadx, int ipady)
  117. {
  118. this.anchor = anchor;
  119. this.fill = fill;
  120. this.gridx = gridx;
  121. this.gridy = gridy;
  122. this.gridwidth = gridwidth;
  123. this.gridheight = gridheight;
  124. this.ipadx = ipadx;
  125. this.ipady = ipady;
  126. this.insets = insets;
  127. this.weightx = weightx;
  128. this.weighty = weighty;
  129. }
  130. }