29 import java.beans.ConstructorProperties;
30 import java.io.Serializable;
31
32 /**
33 * A layout manager to arrange components over the top
34 * of each other. The requested size of the container
35 * will be the largest requested size of the children,
36 * taking alignment needs into consideration.
37 *
38 * The alignment is based upon what is needed to properly
39 * fit the children in the allocation area. The children
40 * will be placed such that their alignment points are all
41 * on top of each other.
42 * <p>
43 * <strong>Warning:</strong>
44 * Serialized objects of this class will not be compatible with
45 * future Swing releases. The current serialization support is
46 * appropriate for short term storage or RMI between applications running
47 * the same version of Swing. As of 1.4, support for long term storage
48 * of all JavaBeans™
49 * has been added to the <code>java.beans</code> package.
50 * Please see {@link java.beans.XMLEncoder}.
51 *
52 * @author Timothy Prinzing
53 * @since 1.2
54 */
55 @SuppressWarnings("serial") // Same-version serialization only
56 public class OverlayLayout implements LayoutManager2,Serializable {
57
58 /**
59 * Constructs a layout manager that performs overlay
60 * arrangement of the children. The layout manager
61 * created is dedicated to the given container.
62 *
63 * @param target the container to do layout against
64 */
65 @ConstructorProperties({"target"})
66 public OverlayLayout(Container target) {
67 this.target = target;
68 }
69
153 *
154 * @param target the component which needs to be laid out
155 * @return a Dimension object containing the minimum dimensions
156 * @see #preferredLayoutSize
157 */
158 public Dimension minimumLayoutSize(Container target) {
159 checkContainer(target);
160 checkRequests();
161
162 Dimension size = new Dimension(xTotal.minimum, yTotal.minimum);
163 Insets insets = target.getInsets();
164 size.width += insets.left + insets.right;
165 size.height += insets.top + insets.bottom;
166 return size;
167 }
168
169 /**
170 * Returns the maximum dimensions needed to lay out the components
171 * contained in the specified target container. Recomputes the
172 * layout if it has been invalidated, and factors in the inset setting
173 * returned by <code>getInset</code>.
174 *
175 * @param target the component that needs to be laid out
176 * @return a <code>Dimension</code> object containing the maximum
177 * dimensions
178 * @see #preferredLayoutSize
179 */
180 public Dimension maximumLayoutSize(Container target) {
181 checkContainer(target);
182 checkRequests();
183
184 Dimension size = new Dimension(xTotal.maximum, yTotal.maximum);
185 Insets insets = target.getInsets();
186 size.width += insets.left + insets.right;
187 size.height += insets.top + insets.bottom;
188 return size;
189 }
190
191 /**
192 * Returns the alignment along the x axis for the container.
193 *
194 * @param target the container
195 * @return the alignment >= 0.0f && <= 1.0f
196 */
|
29 import java.beans.ConstructorProperties;
30 import java.io.Serializable;
31
32 /**
33 * A layout manager to arrange components over the top
34 * of each other. The requested size of the container
35 * will be the largest requested size of the children,
36 * taking alignment needs into consideration.
37 *
38 * The alignment is based upon what is needed to properly
39 * fit the children in the allocation area. The children
40 * will be placed such that their alignment points are all
41 * on top of each other.
42 * <p>
43 * <strong>Warning:</strong>
44 * Serialized objects of this class will not be compatible with
45 * future Swing releases. The current serialization support is
46 * appropriate for short term storage or RMI between applications running
47 * the same version of Swing. As of 1.4, support for long term storage
48 * of all JavaBeans™
49 * has been added to the {@code java.beans} package.
50 * Please see {@link java.beans.XMLEncoder}.
51 *
52 * @author Timothy Prinzing
53 * @since 1.2
54 */
55 @SuppressWarnings("serial") // Same-version serialization only
56 public class OverlayLayout implements LayoutManager2,Serializable {
57
58 /**
59 * Constructs a layout manager that performs overlay
60 * arrangement of the children. The layout manager
61 * created is dedicated to the given container.
62 *
63 * @param target the container to do layout against
64 */
65 @ConstructorProperties({"target"})
66 public OverlayLayout(Container target) {
67 this.target = target;
68 }
69
153 *
154 * @param target the component which needs to be laid out
155 * @return a Dimension object containing the minimum dimensions
156 * @see #preferredLayoutSize
157 */
158 public Dimension minimumLayoutSize(Container target) {
159 checkContainer(target);
160 checkRequests();
161
162 Dimension size = new Dimension(xTotal.minimum, yTotal.minimum);
163 Insets insets = target.getInsets();
164 size.width += insets.left + insets.right;
165 size.height += insets.top + insets.bottom;
166 return size;
167 }
168
169 /**
170 * Returns the maximum dimensions needed to lay out the components
171 * contained in the specified target container. Recomputes the
172 * layout if it has been invalidated, and factors in the inset setting
173 * returned by {@code getInset}.
174 *
175 * @param target the component that needs to be laid out
176 * @return a {@code Dimension} object containing the maximum
177 * dimensions
178 * @see #preferredLayoutSize
179 */
180 public Dimension maximumLayoutSize(Container target) {
181 checkContainer(target);
182 checkRequests();
183
184 Dimension size = new Dimension(xTotal.maximum, yTotal.maximum);
185 Insets insets = target.getInsets();
186 size.width += insets.left + insets.right;
187 size.height += insets.top + insets.bottom;
188 return size;
189 }
190
191 /**
192 * Returns the alignment along the x axis for the container.
193 *
194 * @param target the container
195 * @return the alignment >= 0.0f && <= 1.0f
196 */
|