1 /* 2 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package java.awt; 26 27 /** 28 * Defines an interface for classes that know how to layout Containers 29 * based on a layout constraints object. 30 * 31 * This interface extends the LayoutManager interface to deal with layouts 32 * explicitly in terms of constraint objects that specify how and where 33 * components should be added to the layout. 34 * <p> 35 * This minimal extension to LayoutManager is intended for tool 36 * providers who wish to the creation of constraint-based layouts. 37 * It does not yet provide full, general support for custom 38 * constraint-based layout managers. 39 * 40 * @see LayoutManager 41 * @see Container 42 * 43 * @author Jonni Kanerva 44 */ 45 public interface LayoutManager2 extends LayoutManager { 46 47 /** 48 * Adds the specified component to the layout, using the specified 49 * constraint object. 50 * @param comp the component to be added 51 * @param constraints where/how the component is added to the layout. 52 */ 53 void addLayoutComponent(Component comp, Object constraints); 54 55 /** 56 * Calculates the maximum size dimensions for the specified container, 57 * given the components it contains. 58 * @see java.awt.Component#getMaximumSize 59 * @see LayoutManager 60 * @param target the target container 61 * @return the maximum size of the container 62 */ 63 public Dimension maximumLayoutSize(Container target); 64 65 /** 66 * Returns the alignment along the x axis. This specifies how 67 * the component would like to be aligned relative to other 68 * components. The value should be a number between 0 and 1 69 * where 0 represents alignment along the origin, 1 is aligned 70 * the furthest away from the origin, 0.5 is centered, etc. 71 * 72 * @param target the target container 73 * @return the x-axis alignment preference 74 */ 75 public float getLayoutAlignmentX(Container target); 76 77 /** 78 * Returns the alignment along the y axis. This specifies how 79 * the component would like to be aligned relative to other 80 * components. The value should be a number between 0 and 1 81 * where 0 represents alignment along the origin, 1 is aligned 82 * the furthest away from the origin, 0.5 is centered, etc. 83 * 84 * @param target the target container 85 * @return the y-axis alignment preference 86 */ 87 public float getLayoutAlignmentY(Container target); 88 89 /** 90 * Invalidates the layout, indicating that if the layout manager 91 * has cached information it should be discarded. 92 * @param target the target container 93 */ 94 public void invalidateLayout(Container target); 95 96 }