3261N/A * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * {@code GroupLayout} is a {@code LayoutManager} that hierarchically 0N/A * groups components in order to position them in a {@code Container}. 0N/A * {@code GroupLayout} is intended for use by builders, but may be 0N/A * hand-coded as well. 0N/A * Grouping is done by instances of the {@link Group Group} class. {@code 0N/A * GroupLayout} supports two types of groups. A sequential group 0N/A * positions its child elements sequentially, one after another. A 0N/A * parallel group aligns its child elements in one of four ways. 0N/A * Each group may contain any number of elements, where an element is 0N/A * a {@code Group}, {@code Component}, or gap. A gap can be thought 0N/A * of as an invisible component with a minimum, preferred and maximum 0N/A * size. In addition {@code GroupLayout} supports a preferred gap, 0N/A * whose value comes from {@code LayoutStyle}. 0N/A * Elements are similar to a spring. Each element has a range as 0N/A * specified by a minimum, preferred and maximum. Gaps have either a 0N/A * developer-specified range, or a range determined by {@code 0N/A * LayoutStyle}. The range for {@code Component}s is determined from 0N/A * the {@code Component}'s {@code getMinimumSize}, {@code 0N/A * getPreferredSize} and {@code getMaximumSize} methods. In addition, 0N/A * when adding {@code Component}s you may specify a particular range 0N/A * to use instead of that from the component. The range for a {@code 0N/A * Group} is determined by the type of group. A {@code ParallelGroup}'s 0N/A * range is the maximum of the ranges of its elements. A {@code 0N/A * SequentialGroup}'s range is the sum of the ranges of its elements. 0N/A * {@code GroupLayout} treats each axis independently. That is, there 0N/A * is a group representing the horizontal axis, and a group 0N/A * representing the vertical axis. The horizontal group is 0N/A * responsible for determining the minimum, preferred and maximum size 0N/A * along the horizontal axis as well as setting the x and width of the 0N/A * components contained in it. The vertical group is responsible for 0N/A * determining the minimum, preferred and maximum size along the 0N/A * vertical axis as well as setting the y and height of the 0N/A * components contained in it. Each {@code Component} must exist in both 0N/A * a horizontal and vertical group, otherwise an {@code IllegalStateException} 0N/A * is thrown during layout, or when the minimum, preferred or 0N/A * maximum size is requested. 0N/A * The following diagram shows a sequential group along the horizontal 0N/A * axis. The sequential group contains three components. A parallel group 0N/A * was used along the vertical axis. 0N/A * <p align="center"> 0N/A * To reinforce that each axis is treated independently the diagram shows 0N/A * the range of each group and element along each axis. The 0N/A * range of each component has been projected onto the axes, 0N/A * and the groups are rendered in blue (horizontal) and red (vertical). 0N/A * For readability there is a gap between each of the elements in the 0N/A * The sequential group along the horizontal axis is rendered as a solid 0N/A * blue line. Notice the sequential group is the sum of the children elements 0N/A * Along the vertical axis the parallel group is the maximum of the height 0N/A * of each of the components. As all three components have the same height, 0N/A * the parallel group has the same height. 0N/A * The following diagram shows the same three components, but with the 0N/A * parallel group along the horizontal axis and the sequential group along 0N/A * the vertical axis. 0N/A * <p align="center"> 0N/A * As {@code c1} is the largest of the three components, the parallel 0N/A * group is sized to {@code c1}. As {@code c2} and {@code c3} are smaller 0N/A * than {@code c1} they are aligned based on the alignment specified 0N/A * for the component (if specified) or the default alignment of the 0N/A * parallel group. In the diagram {@code c2} and {@code c3} were created 0N/A * with an alignment of {@code LEADING}. If the component orientation were 0N/A * right-to-left then {@code c2} and {@code c3} would be positioned on 0N/A * the opposite side. 0N/A * The following diagram shows a sequential group along both the horizontal 0N/A * and vertical axis. 0N/A * <p align="center"> 0N/A * {@code GroupLayout} provides the ability to insert gaps between 0N/A * {@code Component}s. The size of the gap is determined by an 0N/A * instance of {@code LayoutStyle}. This may be turned on using the 0N/A * {@code setAutoCreateGaps} method. Similarly, you may use 0N/A * the {@code setAutoCreateContainerGaps} method to insert gaps 0N/A * between components that touch the edge of the parent container and the 0N/A * The following builds a panel consisting of two labels in 0N/A * one column, followed by two textfields in the next column: 0N/A * JComponent panel = ...; 0N/A * GroupLayout layout = new GroupLayout(panel); 0N/A * panel.setLayout(layout); 0N/A * // Turn on automatically adding gaps between components 0N/A * layout.setAutoCreateGaps(true); 0N/A * // Turn on automatically creating gaps between components that touch 0N/A * // the edge of the container and the container. 0N/A * layout.setAutoCreateContainerGaps(true); 0N/A * // Create a sequential group for the horizontal axis. 0N/A * GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup(); 0N/A * // The sequential group in turn contains two parallel groups. 0N/A * // One parallel group contains the labels, the other the text fields. 0N/A * // Putting the labels in a parallel group along the horizontal axis 0N/A * // positions them at the same x location. 0N/A * // Variable indentation is used to reinforce the level of grouping. 0N/A * hGroup.addGroup(layout.createParallelGroup(). 0N/A * addComponent(label1).addComponent(label2)); 0N/A * hGroup.addGroup(layout.createParallelGroup(). 0N/A * addComponent(tf1).addComponent(tf2)); 0N/A * layout.setHorizontalGroup(hGroup); 0N/A * // Create a sequential group for the vertical axis. 0N/A * GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup(); 0N/A * // The sequential group contains two parallel groups that align 0N/A * // the contents along the baseline. The first parallel group contains 0N/A * // the first label and text field, and the second parallel group contains 0N/A * // the second label and text field. By using a sequential group 0N/A * // the labels and text fields are positioned vertically after one another. 0N/A * vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE). 0N/A * addComponent(label1).addComponent(tf1)); 0N/A * vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE). 0N/A * addComponent(label2).addComponent(tf2)); 0N/A * layout.setVerticalGroup(vGroup); 0N/A * When run the following is produced. 0N/A * <p align="center"> 0N/A * This layout consists of the following. 0N/A * <ul><li>The horizontal axis consists of a sequential group containing two 0N/A * parallel groups. The first parallel group contains the labels, 0N/A * and the second parallel group contains the text fields. 0N/A * <li>The vertical axis consists of a sequential group 0N/A * containing two parallel groups. The parallel groups are configured 0N/A * to align their components along the baseline. The first parallel 0N/A * group contains the first label and first text field, and 0N/A * the second group consists of the second label and second 0N/A * There are a couple of things to notice in this code: 0N/A * <li>You need not explicitly add the components to the container; this 0N/A * is indirectly done by using one of the {@code add} methods of 0N/A * <li>The various {@code add} methods return 0N/A * the caller. This allows for easy chaining of invocations. For 0N/A * example, {@code group.addComponent(label1).addComponent(label2);} is 0N/A * {@code group.addComponent(label1); group.addComponent(label2);}. 0N/A * <li>There are no public constructors for {@code Group}s; instead 0N/A * use the create methods of {@code GroupLayout}. 0N/A * @author Tomas Pavek 0N/A * @author Scott Violet 0N/A // Used in size calculations 0N/A // Used by prepare, indicates min, pref or max isn't going to be used. 0N/A * Indicates the size from the component or gap should be used for a 0N/A * particular range value. 0N/A * Indicates the preferred size from the component or gap should 0N/A * be used for a particular range value. 0N/A // Whether or not we automatically try and create the preferred 0N/A // padding between components. 0N/A // Whether or not we automatically try and create the preferred 0N/A // padding between components the touch the edge of the container and 0N/A * Group responsible for layout along the horizontal axis. This is NOT 0N/A * the user specified group, use getHorizontalGroup to dig that out. 0N/A * Group responsible for layout along the vertical axis. This is NOT 0N/A * the user specified group, use getVerticalGroup to dig that out. 0N/A // Maps from Component to ComponentInfo. This is used for tracking 0N/A // information specific to a Component. 0N/A // Container we're doing layout for. 0N/A // Used by areParallelSiblings, cached to avoid excessive garbage. 0N/A // Indicates Springs have changed in some way since last change. 0N/A // Indicates invalidateLayout has been invoked. 0N/A // Whether or not any preferred padding (or container padding) springs 0N/A * The LayoutStyle instance to use, if null the sharedInstance is used. 0N/A * If true, components that are not visible are treated as though they 0N/A * Enumeration of the possible ways {@code ParallelGroup} can align 0N/A * @see #createParallelGroup(Alignment) 0N/A * Indicates the elements should be 0N/A * aligned to the origin. For the horizontal axis with a left to 0N/A * right orientation this means aligned to the left edge. For the 0N/A * vertical axis leading means aligned to the top edge. 0N/A * @see #createParallelGroup(Alignment) 0N/A * Indicates the elements should be aligned to the end of the 0N/A * region. For the horizontal axis with a left to right 0N/A * orientation this means aligned to the right edge. For the 0N/A * vertical axis trailing means aligned to the bottom edge. 0N/A * @see #createParallelGroup(Alignment) 0N/A * Indicates the elements should be centered in 0N/A * @see #createParallelGroup(Alignment) 0N/A * Indicates the elements should be aligned along 0N/A * @see #createParallelGroup(Alignment) 0N/A * @see #createBaselineGroup(boolean,boolean) 0N/A "Following is not met: min<=pref<=max");
0N/A * Creates a {@code GroupLayout} for the specified {@code Container}. 0N/A * @param host the {@code Container} the {@code GroupLayout} is 0N/A * the {@code LayoutManager} for 0N/A * @throws IllegalArgumentException if host is {@code null} 0N/A * Sets whether component visiblity is considered when sizing and 0N/A * positioning components. A value of {@code true} indicates that 0N/A * non-visible components should not be treated as part of the 0N/A * layout. A value of {@code false} indicates that components should be 0N/A * positioned and sized regardless of visibility. 0N/A * A value of {@code false} is useful when the visibility of components 0N/A * is dynamically adjusted and you don't want surrounding components and 0N/A * the sizing to change. 0N/A * The specified value is used for components that do not have an 0N/A * explicit visibility specified. 0N/A * The default is {@code true}. 0N/A * @param honorsVisibility whether component visiblity is considered when 0N/A * sizing and positioning components 0N/A * @see #setHonorsVisibility(Component,Boolean) 0N/A * Returns whether component visiblity is considered when sizing and 0N/A * positioning components. 0N/A * @return whether component visiblity is considered when sizing and 0N/A * positioning components 0N/A * Sets whether the component's visiblity is considered for 0N/A * sizing and positioning. A value of {@code Boolean.TRUE} 0N/A * indicates that if {@code component} is not visible it should 0N/A * not be treated as part of the layout. A value of {@code false} 0N/A * indicates that {@code component} is positioned and sized 0N/A * regardless of it's visibility. A value of {@code null} 0N/A * indicates the value specified by the single argument method {@code 0N/A * setHonorsVisibility} should be used. 0N/A * If {@code component} is not a child of the {@code Container} this 0N/A * {@code GroupLayout} is managine, it will be added to the 0N/A * {@code Container}. 0N/A * @param component the component 0N/A * @param honorsVisibility whether {@code component}'s visiblity should be 0N/A * considered for sizing and positioning 0N/A * @throws IllegalArgumentException if {@code component} is {@code null} 0N/A * @see #setHonorsVisibility(Component,Boolean) 0N/A * Sets whether a gap between components should automatically be 0N/A * created. For example, if this is {@code true} and you add two 0N/A * components to a {@code SequentialGroup} a gap between the 0N/A * two components is automatically be created. The default is 0N/A * @param autoCreatePadding whether a gap between components is 0N/A * automatically created 0N/A * Returns {@code true} if gaps between components are automatically 0N/A * @return {@code true} if gaps between components are automatically 0N/A * Sets whether a gap between the container and components that 0N/A * touch the border of the container should automatically be 0N/A * created. The default is {@code false}. 0N/A * @param autoCreateContainerPadding whether a gap between the container and 0N/A * components that touch the border of the container should 0N/A * automatically be created 0N/A * Returns {@code true} if gaps between the container and components that 0N/A * border the container are automatically created. 0N/A * @return {@code true} if gaps between the container and components that 0N/A * border the container are automatically created 0N/A * Sets the {@code Group} that positions and sizes 0N/A * components along the horizontal axis. 0N/A * @param group the {@code Group} that positions and sizes 0N/A * components along the horizontal axis 0N/A * @throws IllegalArgumentException if group is {@code null} 0N/A * Returns the {@code Group} that positions and sizes components 0N/A * along the horizontal axis. 0N/A * @return the {@code Group} responsible for positioning and 0N/A * sizing component along the horizontal axis 0N/A * Sets the {@code Group} that positions and sizes 0N/A * components along the vertical axis. 0N/A * @param group the {@code Group} that positions and sizes 0N/A * components along the vertical axis 0N/A * @throws IllegalArgumentException if group is {@code null} 0N/A * Returns the {@code Group} that positions and sizes components 0N/A * along the vertical axis. 0N/A * @return the {@code Group} responsible for positioning and 0N/A * sizing component along the vertical axis 0N/A * Wraps the user specified group in a sequential group. If 0N/A * container gaps should be generated the necessary springs are 0N/A * Creates and returns a {@code SequentialGroup}. 0N/A * @return a new {@code SequentialGroup} 0N/A * Creates and returns a {@code ParallelGroup} with an alignment of 0N/A * {@code Alignment.LEADING}. This is a cover method for the more 0N/A * general {@code createParallelGroup(Alignment)} method. 0N/A * @return a new {@code ParallelGroup} 0N/A * @see #createParallelGroup(Alignment) 0N/A * Creates and returns a {@code ParallelGroup} with the specified 0N/A * alignment. This is a cover method for the more general {@code 0N/A * createParallelGroup(Alignment,boolean)} method with {@code true} 0N/A * supplied for the second argument. 0N/A * @param alignment the alignment for the elements of the group 0N/A * @throws IllegalArgumentException if {@code alignment} is {@code null} 0N/A * @return a new {@code ParallelGroup} 0N/A * @see #createBaselineGroup 0N/A * @see ParallelGroup 0N/A * Creates and returns a {@code ParallelGroup} with the specified 0N/A * alignment and resize behavior. The {@code 0N/A * alignment} argument specifies how children elements are 0N/A * positioned that do not fill the group. For example, if a {@code 0N/A * ParallelGroup} with an alignment of {@code TRAILING} is given 0N/A * 100 and a child only needs 50, the child is 0N/A * positioned at the position 50 (with a component orientation of 0N/A * Baseline alignment is only useful when used along the vertical 0N/A * axis. A {@code ParallelGroup} created with a baseline alignment 0N/A * along the horizontal axis is treated as {@code LEADING}. 0N/A * Refer to {@link GroupLayout.ParallelGroup ParallelGroup} for details on 0N/A * the behavior of baseline groups. 0N/A * @param alignment the alignment for the elements of the group 0N/A * @param resizable {@code true} if the group is resizable; if the group 0N/A * is not resizable the preferred size is used for the 0N/A * minimum and maximum size of the group 0N/A * @throws IllegalArgumentException if {@code alignment} is {@code null} 0N/A * @return a new {@code ParallelGroup} 0N/A * @see #createBaselineGroup 0N/A * @see GroupLayout.ParallelGroup 0N/A * Creates and returns a {@code ParallelGroup} that aligns it's 0N/A * elements along the baseline. 0N/A * @param resizable whether the group is resizable 0N/A * @param anchorBaselineToTop whether the baseline is anchored to 0N/A * the top or bottom of the group 0N/A * @see #createBaselineGroup 0N/A * @see ParallelGroup 0N/A * Forces the specified components to have the same size 0N/A * regardless of their preferred, minimum or maximum sizes. Components that 0N/A * are linked are given the maximum of the preferred size of each of 0N/A * the linked components. For example, if you link two components with 0N/A * a preferred width of 10 and 20, both components are given a width of 20. 0N/A * This can be used multiple times to force any number of 0N/A * components to share the same size. 0N/A * Linked Components are not be resizable. 0N/A * @param components the {@code Component}s that are to have the same size 0N/A * @throws IllegalArgumentException if {@code components} is 0N/A * {@code null}, or contains {@code null} 0N/A * @see #linkSize(int,Component[]) 0N/A * Forces the specified components to have the same size along the 0N/A * specified axis regardless of their preferred, minimum or 0N/A * maximum sizes. Components that are linked are given the maximum 0N/A * of the preferred size of each of the linked components. For 0N/A * example, if you link two components along the horizontal axis 0N/A * and the preferred width is 10 and 20, both components are given 0N/A * This can be used multiple times to force any number of 0N/A * components to share the same size. 0N/A * Linked {@code Component}s are not be resizable. 0N/A * @param components the {@code Component}s that are to have the same size 0N/A * @param axis the axis to link the size along; one of 0N/A * {@code SwingConstants.HORIZONTAL} or 0N/A * {@code SwingConstans.VERTICAL} 0N/A * @throws IllegalArgumentException if {@code components} is 0N/A * {@code null}, or contains {@code null}; or {@code axis} 0N/A * is not {@code SwingConstants.HORIZONTAL} or 0N/A * {@code SwingConstants.VERTICAL} 0N/A "Components must be non-null");
0N/A // Force the component to be added 0N/A "SwingConstants.HORIZONTAL or SwingConstants.VERTICAL");
0N/A * Replaces an existing component with a new one. 0N/A * @param existingComponent the component that should be removed 0N/A * and replaced with {@code newComponent} 0N/A * @param newComponent the component to put in 0N/A * {@code existingComponent}'s place 0N/A * @throws IllegalArgumentException if either of the components are 0N/A * {@code null} or {@code existingComponent} is not being managed 0N/A * by this layout manager 0N/A // Make sure all the components have been registered, otherwise we may 0N/A // not update the correct Springs. 0N/A * Sets the {@code LayoutStyle} used to calculate the preferred 0N/A * gaps between components. A value of {@code null} indicates the 0N/A * shared instance of {@code LayoutStyle} should be used. 0N/A * @param layoutStyle the {@code LayoutStyle} to use 0N/A * Returns the {@code LayoutStyle} used for calculating the preferred 0N/A * gap between components. This returns the value specified to 0N/A * {@code setLayoutStyle}, which may be {@code null}. 0N/A * @return the {@code LayoutStyle} used for calculating the preferred 0N/A * gap between components 0N/A * Notification that a {@code Component} has been added to 0N/A * the parent container. You should not invoke this method 0N/A * directly, instead you should use one of the {@code Group} 0N/A * methods to add a {@code Component}. 0N/A * @param name the string to be associated with the component 0N/A * @param component the {@code Component} to be added 0N/A * Notification that a {@code Component} has been removed from 0N/A * the parent container. You should not invoke this method 0N/A * directly, instead invoke {@code remove} on the parent 0N/A * {@code Container}. 0N/A * @param component the component to be removed 0N/A * @see java.awt.Component#remove 0N/A * Returns the preferred size for the specified container. 0N/A * @param parent the container to return the preferred size for 0N/A * @return the preferred size for {@code parent} 0N/A * @throws IllegalArgumentException if {@code parent} is not 0N/A * the same {@code Container} this was created with 0N/A * @throws IllegalStateException if any of the components added to 0N/A * this layout are not in both a horizontal and vertical group 0N/A * @see java.awt.Container#getPreferredSize 0N/A * Returns the minimum size for the specified container. 0N/A * @param parent the container to return the size for 0N/A * @return the minimum size for {@code parent} 0N/A * @throws IllegalArgumentException if {@code parent} is not 0N/A * the same {@code Container} that this was created with 0N/A * @throws IllegalStateException if any of the components added to 0N/A * this layout are not in both a horizontal and vertical group 0N/A * @see java.awt.Container#getMinimumSize 0N/A * Lays out the specified container. 0N/A * @param parent the container to be laid out 0N/A * @throws IllegalStateException if any of the components added to 0N/A * this layout are not in both a horizontal and vertical group 0N/A // Step 1: Prepare for layout. 0N/A // Step 2: Calculate autopadding springs 0N/A // Step 3: set the size of the groups. 0N/A // Step 4: apply the size to the components. 0N/A * Notification that a {@code Component} has been added to 0N/A * the parent container. You should not invoke this method 0N/A * directly, instead you should use one of the {@code Group} 0N/A * methods to add a {@code Component}. 0N/A * @param component the component added 0N/A * @param constraints description of where to place the component 0N/A * Returns the maximum size for the specified container. 0N/A * @param parent the container to return the size for 0N/A * @return the maximum size for {@code parent} 0N/A * @throws IllegalArgumentException if {@code parent} is not 0N/A * the same {@code Container} that this was created with 0N/A * @throws IllegalStateException if any of the components added to 0N/A * this layout are not in both a horizontal and vertical group 0N/A * @see java.awt.Container#getMaximumSize 0N/A * Returns the alignment along the x axis. This specifies how 0N/A * the component would like to be aligned relative to other 0N/A * components. The value should be a number between 0 and 1 0N/A * where 0 represents alignment along the origin, 1 is aligned 0N/A * the furthest away from the origin, 0.5 is centered, etc. 0N/A * @param parent the {@code Container} hosting this {@code LayoutManager} 0N/A * @throws IllegalArgumentException if {@code parent} is not 0N/A * the same {@code Container} that this was created with 0N/A * @return the alignment; this implementation returns {@code .5} 0N/A * Returns the alignment along the y axis. This specifies how 0N/A * the component would like to be aligned relative to other 0N/A * components. The value should be a number between 0 and 1 0N/A * where 0 represents alignment along the origin, 1 is aligned 0N/A * the furthest away from the origin, 0.5 is centered, etc. 0N/A * @param parent the {@code Container} hosting this {@code LayoutManager} 0N/A * @throws IllegalArgumentException if {@code parent} is not 0N/A * the same {@code Container} that this was created with 0N/A * @return alignment; this implementation returns {@code .5} 0N/A * Invalidates the layout, indicating that if the layout manager 0N/A * has cached information it should be discarded. 0N/A * @param parent the {@code Container} hosting this LayoutManager 0N/A * @throws IllegalArgumentException if {@code parent} is not 0N/A * the same {@code Container} that this was created with 0N/A // invalidateLayout is called from Container.invalidate, which 0N/A // does NOT grab the treelock. All other methods do. To make sure 0N/A // there aren't any possible threading problems we grab the tree lock 0N/A // Step 1: If not-valid, clear springs and update visibility. 0N/A // Step 2: Make sure components are bound to ComponentInfos 0N/A // Step 3: Adjust the autopadding. This removes existing 0N/A // autopadding, then recalculates where it should go. 0N/A // Step 4: (for min/pref/max size calculations only) calculate the 0N/A // autopadding. This invokes for unsetting the calculated values, then 0N/A // recalculating them. 0N/A // If sizeType == SPECIFIC_SIZE, it indicates we're doing layout, this 0N/A // step will be done later on. 0N/A " is not attached to a horizontal group");
0N/A " is not attached to a vertical group");
0N/A "GroupLayout can only be used with one Container at a time");
0N/A * Returns the {@code ComponentInfo} for the specified Component, 0N/A * creating one if necessary. 0N/A * Adjusts the autopadding springs for the horizontal and vertical 0N/A * groups. If {@code insert} is {@code true} this will insert auto padding 0N/A * springs, otherwise this will only adjust the springs that 0N/A * comprise auto preferred padding springs. 0N/A * Returns {@code true} if the two Components have a common ParallelGroup 0N/A * ancestor along the particular axis. 0N/A * Returns a string representation of this {@code GroupLayout}. 0N/A * This method is intended to be used for debugging purposes, 0N/A * and the content and format of the returned string may vary 0N/A * between implementations. 0N/A * @return a string representation of this {@code GroupLayout} 0N/A * Spring consists of a range: min, pref and max, a value some where in 0N/A * the middle of that, and a location. Spring caches the 0N/A * to be updated you must invoke clear. 0N/A * Calculates and returns the minimum size. 0N/A * @param axis the axis of layout; one of HORIZONTAL or VERTICAL 0N/A * @return the minimum size 0N/A * Calculates and returns the preferred size. 0N/A * @param axis the axis of layout; one of HORIZONTAL or VERTICAL 0N/A * @return the preferred size 0N/A * Calculates and returns the minimum size. 0N/A * @param axis the axis of layout; one of HORIZONTAL or VERTICAL 0N/A * @return the minimum size 0N/A * Sets the parent of this Spring. 0N/A * Returns the parent of this spring. 0N/A // This is here purely as a conveniance for ParallelGroup to avoid 0N/A // having to track alignment separately. 0N/A * Alignment for this Spring, this may be null. 0N/A * Returns the minimum size. 0N/A * Returns the preferred size. 0N/A * Returns the maximum size. 0N/A * Sets the value and location of the spring. Subclasses 0N/A * will want to invoke super, then do any additional sizing. 0N/A * @param axis HORIZONTAL or VERTICAL 0N/A * @param origin of this Spring 0N/A * @param size of the Spring. If size is UNSET, this invokes 0N/A * Returns the current size. 0N/A * Returns {@code true} if this spring will ALWAYS have a zero 0N/A * size. This should NOT check the current size, rather it's 0N/A * meant to quickly test if this Spring will always have a 0N/A * @param treatAutopaddingAsZeroSized if {@code true}, auto padding 0N/A * springs should be treated as having a size of {@code 0} 0N/A * @return {@code true} if this spring will have a zero size, 0N/A * {@code false} otherwise 0N/A * {@code Group} provides the basis for the two types of 0N/A * operations supported by {@code GroupLayout}: laying out 0N/A * components one after another ({@link SequentialGroup SequentialGroup}) 0N/A * or aligned ({@link ParallelGroup ParallelGroup}). {@code Group} and 0N/A * its subclasses have no public constructor; to create one use 0N/A * one of {@code createSequentialGroup} or 0N/A * {@code createParallelGroup}. Additionally, taking a {@code Group} 0N/A * created from one {@code GroupLayout} and using it with another 0N/A * will produce undefined results. 0N/A * Various methods in {@code Group} and its subclasses allow you 0N/A * to explicitly specify the range. The arguments to these methods 0N/A * can take two forms, either a value greater than or equal to 0, 0N/A * or one of {@code DEFAULT_SIZE} or {@code PREFERRED_SIZE}. A 0N/A * value greater than or equal to {@code 0} indicates a specific 0N/A * size. {@code DEFAULT_SIZE} indicates the corresponding size 0N/A * from the component should be used. For example, if {@code 0N/A * DEFAULT_SIZE} is passed as the minimum size argument, the 0N/A * minimum size is obtained from invoking {@code getMinimumSize} 0N/A * on the component. Likewise, {@code PREFERRED_SIZE} indicates 0N/A * the value from {@code getPreferredSize} should be used. 0N/A * The following example adds {@code myComponent} to {@code group} 0N/A * with specific values for the range. That is, the minimum is 0N/A * explicitly specified as 100, preferred as 200, and maximum as 0N/A * group.addComponent(myComponent, 100, 200, 300); 0N/A * The following example adds {@code myComponent} to {@code group} using 0N/A * a combination of the forms. The minimum size is forced to be the 0N/A * same as the preferred size, the preferred size is determined by 0N/A * using {@code myComponent.getPreferredSize} and the maximum is 0N/A * determined by invoking {@code getMaximumSize} on the component. 0N/A * group.addComponent(myComponent, GroupLayout.PREFERRED_SIZE, 0N/A * GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE); 0N/A * Unless otherwise specified all the methods of {@code Group} and 0N/A * its subclasses that allow you to specify a range throw an 0N/A * {@code IllegalArgumentException} if passed an invalid range. An 0N/A * invalid range is one in which any of the values are < 0 and 0N/A * not one of {@code PREFERRED_SIZE} or {@code DEFAULT_SIZE}, or 0N/A * the following is not met (for specific values): {@code min} 0N/A * <= {@code pref} <= {@code max}. 0N/A * Similarly any methods that take a {@code Component} throw a 2779N/A * {@code IllegalArgumentException} if passed {@code null} and any methods 2779N/A * that take a {@code Group} throw an {@code NullPointerException} if 0N/A * passed {@code null}. 0N/A * @see #createSequentialGroup 0N/A * @see #createParallelGroup 0N/A // private int origin; 0N/A // private int size; 0N/A * Adds a {@code Group} to this {@code Group}. 0N/A * @param group the {@code Group} to add 0N/A * @return this {@code Group} 0N/A * Adds a {@code Component} to this {@code Group}. 0N/A * @param component the {@code Component} to add 0N/A * @return this {@code Group} 0N/A * Adds a {@code Component} to this {@code Group} 0N/A * with the specified size. 0N/A * @param component the {@code Component} to add 0N/A * @param min the minimum size or one of {@code DEFAULT_SIZE} or 0N/A * {@code PREFERRED_SIZE} 0N/A * @param pref the preferred size or one of {@code DEFAULT_SIZE} or 0N/A * {@code PREFERRED_SIZE} 0N/A * @param max the maximum size or one of {@code DEFAULT_SIZE} or 0N/A * {@code PREFERRED_SIZE} 0N/A * @return this {@code Group} 0N/A * Adds a rigid gap to this {@code Group}. 0N/A * @param size the size of the gap 0N/A * @return this {@code Group} 0N/A * @throws IllegalArgumentException if {@code size} is less than 0N/A * Adds a gap to this {@code Group} with the specified size. 0N/A * @param min the minimum size of the gap 0N/A * @param pref the preferred size of the gap 0N/A * @param max the maximum size of the gap 0N/A * @throws IllegalArgumentException if any of the values are 0N/A * less than {@code 0} 0N/A * @return this {@code Group} 0N/A * Adds the Spring to the list of {@code Spring}s and returns 0N/A * This is invoked from {@code setSize} if passed a value 0N/A * Calculates the specified size. This is called from 0N/A * one of the {@code getMinimumSize0}, 0N/A * {@code getPreferredSize0} or 0N/A * {@code getMaximumSize0} methods. This will invoke 0N/A * to {@code operator} to combine the values. 0N/A * Used to compute how the two values representing two springs 0N/A * will be combined. For example, a group that layed things out 0N/A * one after the next would return {@code a + b}. 0N/A * Adjusts the autopadding springs in this group and its children. 0N/A * If {@code insert} is true this will insert auto padding 0N/A * springs, otherwise this will only adjust the springs that 0N/A * comprise auto preferred padding springs. 0N/A * @param axis the axis of the springs; HORIZONTAL or VERTICAL 0N/A * @param leadingPadding List of AutopaddingSprings that occur before 0N/A * @param trailingPadding any trailing autopadding springs are added 0N/A * @param leading List of ComponentSprings that occur before this Group 0N/A * @param trailing any trailing ComponentSpring are added to this 0N/A * @param insert Whether or not to insert AutopaddingSprings or just 0N/A * adjust any existing AutopaddingSprings. 0N/A * Removes any AutopaddingSprings for this Group and its children. 0N/A // Force size to be reset. 0N/A * A {@code Group} that positions and sizes its elements 0N/A * sequentially, one after another. This class has no public 0N/A * constructor, use the {@code createSequentialGroup} method 0N/A * In order to align a {@code SequentialGroup} along the baseline 0N/A * of a baseline aligned {@code ParallelGroup} you need to specify 0N/A * which of the elements of the {@code SequentialGroup} is used to 0N/A * determine the baseline. The element used to calculate the 0N/A * baseline is specified using one of the {@code add} methods that 0N/A * take a {@code boolean}. The last element added with a value of 0N/A * {@code true} for {@code useAsBaseline} is used to calculate the 0N/A * @see #createSequentialGroup 0N/A * Adds a {@code Group} to this {@code Group}. 0N/A * @param group the {@code Group} to add 0N/A * @param useAsBaseline whether the specified {@code Group} should 0N/A * be used to calculate the baseline for this {@code Group} 0N/A * @return this {@code Group} 0N/A * Adds a {@code Component} to this {@code Group}. 0N/A * @param useAsBaseline whether the specified {@code Component} should 0N/A * be used to calculate the baseline for this {@code Group} 0N/A * @param component the {@code Component} to add 0N/A * @return this {@code Group} 0N/A * Adds a {@code Component} to this {@code Group} 0N/A * with the specified size. 0N/A * @param useAsBaseline whether the specified {@code Component} should 0N/A * be used to calculate the baseline for this {@code Group} 0N/A * @param component the {@code Component} to add 0N/A * @param min the minimum size or one of {@code DEFAULT_SIZE} or 0N/A * {@code PREFERRED_SIZE} 0N/A * @param pref the preferred size or one of {@code DEFAULT_SIZE} or 0N/A * {@code PREFERRED_SIZE} 0N/A * @param max the maximum size or one of {@code DEFAULT_SIZE} or 0N/A * {@code PREFERRED_SIZE} 0N/A * @return this {@code Group} 0N/A * Adds an element representing the preferred gap between two 0N/A * components. The element created to represent the gap is not 0N/A * @param comp1 the first component 0N/A * @param comp2 the second component 0N/A * @param type the type of gap; one of the constants defined by 0N/A * {@code LayoutStyle} 0N/A * @return this {@code SequentialGroup} 0N/A * @throws IllegalArgumentException if {@code type}, {@code comp1} or 0N/A * {@code comp2} is {@code null} 0N/A * Adds an element representing the preferred gap between two 0N/A * @param comp1 the first component 0N/A * @param comp2 the second component 0N/A * @param type the type of gap 0N/A * @param pref the preferred size of the grap; one of 0N/A * {@code DEFAULT_SIZE} or a value >= 0 0N/A * @param max the maximum size of the gap; one of 0N/A * {@code DEFAULT_SIZE}, {@code PREFERRED_SIZE} 0N/A * or a value >= 0 0N/A * @return this {@code SequentialGroup} 0N/A * @throws IllegalArgumentException if {@code type}, {@code comp1} or 0N/A * {@code comp2} is {@code null} 0N/A "Components must be non-null");
0N/A * Adds an element representing the preferred gap between the 0N/A * nearest components. During layout, neighboring 0N/A * components are found, and the size of the added gap is set 0N/A * based on the preferred gap between the components. If no 0N/A * neighboring components are found the gap has a size of {@code 0}. 0N/A * The element created to represent the gap is not 0N/A * @param type the type of gap; one of 0N/A * {@code LayoutStyle.ComponentPlacement.RELATED} or 0N/A * {@code LayoutStyle.ComponentPlacement.UNRELATED} 0N/A * @return this {@code SequentialGroup} 0N/A * @throws IllegalArgumentException if {@code type} is not one of 0N/A * {@code LayoutStyle.ComponentPlacement.RELATED} or 0N/A * {@code LayoutStyle.ComponentPlacement.UNRELATED} 0N/A * Adds an element representing the preferred gap between the 0N/A * nearest components. During layout, neighboring 0N/A * components are found, and the minimum of this 0N/A * gap is set based on the size of the preferred gap between the 0N/A * neighboring components. If no neighboring components are found the 0N/A * minimum size is set to 0. 0N/A * @param type the type of gap; one of 0N/A * {@code LayoutStyle.ComponentPlacement.RELATED} or 0N/A * {@code LayoutStyle.ComponentPlacement.UNRELATED} 0N/A * @param pref the preferred size of the grap; one of 0N/A * {@code DEFAULT_SIZE} or a value >= 0 0N/A * @param max the maximum size of the gap; one of 0N/A * {@code DEFAULT_SIZE}, {@code PREFERRED_SIZE} 0N/A * or a value >= 0 0N/A * @return this {@code SequentialGroup} 0N/A * @throws IllegalArgumentException if {@code type} is not one of 0N/A * {@code LayoutStyle.ComponentPlacement.RELATED} or 0N/A * {@code LayoutStyle.ComponentPlacement.UNRELATED} 0N/A "Type must be one of " +
0N/A "LayoutStyle.ComponentPlacement.RELATED or " +
0N/A "LayoutStyle.ComponentPlacement.UNRELATED");
0N/A * Adds an element representing the preferred gap between an edge 0N/A * the container and components that touch the border of the 0N/A * container. This has no effect if the added gap does not 0N/A * touch an edge of the parent container. 0N/A * The element created to represent the gap is not 0N/A * @return this {@code SequentialGroup} 0N/A * Adds an element representing the preferred gap between one 0N/A * edge of the container and the next or previous {@code 0N/A * Component} with the specified size. This has no 0N/A * effect if the next or previous element is not a {@code 0N/A * Component} and does not touch one edge of the parent 0N/A * @param pref the preferred size; one of {@code DEFAULT_SIZE} or a 0N/A * @param max the maximum size; one of {@code DEFAULT_SIZE}, 0N/A * {@code PREFERRED_SIZE} or a value >= 0 0N/A * @return this {@code SequentialGroup} 0N/A "Pref and max must be either DEFAULT_VALUE " +
0N/A "or >= 0 and pref <= max");
0N/A // Layout at preferred size 0N/A // The following algorithm if used for resizing springs: 0N/A // 1. Calculate the resizability of each spring (pref - min or 0N/A // max - pref) into a list. 0N/A // 2. Sort the list in ascending order 0N/A // 3. Iterate through each of the resizable Springs, attempting 0N/A // to give them (pref - size) / resizeCount 0N/A // 4. For any Springs that can not accomodate that much space 0N/A // add the remainder back to the amount to distribute and 0N/A // recalculate how must space the remaining springs will get. 0N/A // 5. Set the size of the springs. 0N/A // First pass, sort the resizable springs into the List resizable 0N/A // How much we would like to give each Spring. 0N/A // Second pass, accumulate the resulting deltas (relative to 0N/A // preferred) into sizes. 0N/A // Spring didn't take all the space, reset how much 0N/A // each spring will get. 0N/A // And finally set the size of each spring 0N/A // Nothing resizable, use the min or max of each of the 0N/A * Returns the sorted list of SpringDelta's for the current set of 0N/A * Springs. The list is ordered based on the amount of flexibility of 0N/A // First pass, figure out what is resizable 0N/A // Warning, this must use springs.size, as it may change during the 0N/A // Autopadding spring. Set the sources of the 0N/A // autopadding spring based on newLeading. 0N/A // Last spring in the list, add it to 0N/A // Not a padding spring 0N/A // There's leading ComponentSprings, create an 0N/A // autopadding spring. 0N/A // Force the newly created spring to be considered 0N/A // by NOT incrementing counter 0N/A // Spring is a Component, make it the target of any 0N/A // leading AutopaddingSpring. 0N/A // Last Spring, add it to trailing 0N/A // Not that last Spring, add it to leading 0N/A // Forward call to child Group 0N/A // Spring to use for baseline isn't resizable. In this case 0N/A // baseline resize behavior can be determined based on how 0N/A // preceeding springs resize. 0N/A // If we get here, both leading and trailing springs are 0N/A // resizable. Fall through to OTHER. 0N/A // Not resizable, treat as constant_ascent 0N/A "Pref and max must be either DEFAULT_SIZE, " +
0N/A "PREFERRED_SIZE, or >= 0 and pref <= max");
0N/A * Used by SequentialGroup in calculating resizability of springs. 0N/A // Delta, one of pref - min or max - pref. 0N/A * A {@code Group} that aligns and sizes it's children. 0N/A * {@code ParallelGroup} aligns it's children in 0N/A * four possible ways: along the baseline, centered, anchored to the 0N/A * leading edge, or anchored to the trailing edge. 0N/A * A {@code ParallelGroup} that aligns it's children along the 0N/A * baseline must first decide where the baseline is 0N/A * anchored. The baseline can either be anchored to the top, or 0N/A * anchored to the bottom of the group. That is, the distance between the 0N/A * baseline and the beginning of the group can be a constant 0N/A * distance, or the distance between the end of the group and the 0N/A * baseline can be a constant distance. The possible choices 0N/A * correspond to the {@code BaselineResizeBehavior} constants 0N/A * java.awt.Component.BaselineResizeBehavior#CONSTANT_ASCENT CONSTANT_ASCENT} and 0N/A * java.awt.Component.BaselineResizeBehavior#CONSTANT_DESCENT CONSTANT_DESCENT}. 0N/A * The baseline anchor may be explicitly specified by the 0N/A * {@code createBaselineGroup} method, or determined based on the elements. 0N/A * If not explicitly specified, the baseline will be anchored to 0N/A * the bottom if all the elements with a baseline, and that are 0N/A * aligned to the baseline, have a baseline resize behavior of 0N/A * {@code CONSTANT_DESCENT}; otherwise the baseline is anchored to the top 0N/A * Elements aligned to the baseline are resizable if they have have 0N/A * a baseline resize behavior of {@code CONSTANT_ASCENT} or 0N/A * {@code CONSTANT_DESCENT}. Elements with a baseline resize 0N/A * behavior of {@code OTHER} or {@code CENTER_OFFSET} are not resizable. 0N/A * The baseline is calculated based on the preferred height of each 0N/A * of the elements that have a baseline. The baseline is 0N/A * calculated using the following algorithm: 0N/A * {@code max(maxNonBaselineHeight, maxAscent + maxDescent)}, where the 0N/A * {@code maxNonBaselineHeight} is the maximum height of all elements 0N/A * that do not have a baseline, or are not aligned along the baseline. 0N/A * {@code maxAscent} is the maximum ascent (baseline) of all elements that 0N/A * have a baseline and are aligned along the baseline. 0N/A * {@code maxDescent} is the maximum descent (preferred height - baseline) 0N/A * of all elements that have a baseline and are aligned along the baseline. 0N/A * A {@code ParallelGroup} that aligns it's elements along the baseline 0N/A * is only useful along the vertical axis. If you create a 0N/A * baseline group and use it along the horizontal axis an 0N/A * {@code IllegalStateException} is thrown when you ask 0N/A * {@code GroupLayout} for the minimum, preferred or maximum size or 0N/A * attempt to layout the components. 0N/A * Elements that are not aligned to the baseline and smaller than the size 0N/A * of the {@code ParallelGroup} are positioned in one of three 0N/A * ways: centered, anchored to the leading edge, or anchored to the 0N/A * <h3>Non-baseline {@code ParallelGroup}</h3> 0N/A * {@code ParallelGroup}s created with an alignment other than 0N/A * {@code BASELINE} align elements that are smaller than the size 0N/A * of the group in one of three ways: centered, anchored to the 0N/A * leading edge, or anchored to the trailing edge. 0N/A * The leading edge is based on the axis and {@code 0N/A * ComponentOrientation}. For the vertical axis the top edge is 0N/A * always the leading edge, and the bottom edge is always the 0N/A * trailing edge. When the {@code ComponentOrientation} is {@code 0N/A * LEFT_TO_RIGHT}, the leading edge is the left edge and the 0N/A * trailing edge the right edge. A {@code ComponentOrientation} of 0N/A * {@code RIGHT_TO_LEFT} flips the left and right edges. Child 0N/A * elements are aligned based on the specified alignment the 0N/A * element was added with. If you do not specify an alignment, the 0N/A * alignment specified for the {@code ParallelGroup} is used. 0N/A * To align elements along the baseline you {@code createBaselineGroup}, 0N/A * or {@code createParallelGroup} with an alignment of {@code BASELINE}. 0N/A * If the group was not created with a baseline alignment, and you attempt 0N/A * to add an element specifying a baseline alignment, an 0N/A * {@code IllegalArgumentException} is thrown. 0N/A * @see #createParallelGroup() 0N/A * @see #createBaselineGroup(boolean,boolean) 0N/A // How children are layed out. 0N/A // Whether or not we're resizable. 0N/A * Adds a {@code Group} to this {@code ParallelGroup} with the 0N/A * specified alignment. If the child is smaller than the 0N/A * {@code Group} it is aligned based on the specified 0N/A * @param alignment the alignment 0N/A * @param group the {@code Group} to add 0N/A * @return this {@code ParallelGroup} 0N/A * @throws IllegalArgumentException if {@code alignment} is 0N/A * Adds a {@code Component} to this {@code ParallelGroup} with 0N/A * the specified alignment. 0N/A * @param alignment the alignment 0N/A * @param component the {@code Component} to add 0N/A * @return this {@code Group} 0N/A * @throws IllegalArgumentException if {@code alignment} is 0N/A * Adds a {@code Component} to this {@code ParallelGroup} with the 0N/A * specified alignment and size. 0N/A * @param alignment the alignment 0N/A * @param component the {@code Component} to add 0N/A * @param min the minimum size 0N/A * @param pref the preferred size 0N/A * @param max the maximum size 0N/A * @throws IllegalArgumentException if {@code alignment} is 0N/A * @return this {@code Group} 0N/A default:
// LEADING, or BASELINE 0N/A "LEADING, TRAILING or CENTER");
0N/A * An extension of {@code ParallelGroup} that aligns its 0N/A * constituent {@code Spring}s along the baseline. 0N/A // Whether or not all child springs have a baseline 0N/A // max(spring.getBaseline()) of all springs aligned along the baseline 0N/A // that have a baseline 0N/A // max(spring.getPreferredSize().height - spring.getBaseline()) of all 0N/A // springs aligned along the baseline that have a baseline 0N/A // Whether baselineAnchoredToTop was explicitly set 0N/A // Whether the baseline is anchored to the top or the bottom. 0N/A // If anchored to the top the baseline is always at prefAscent, 0N/A // otherwise the baseline is at (height - prefDescent) 0N/A // Whether or not the baseline has been calculated. 0N/A // do baseline layout 0N/A // calculate baseline 0N/A default:
// CENTER_OFFSET and OTHER, not resizable 0N/A // Not aligned along the baseline, or no baseline. 0N/A // CENTER_OFFSET and OTHER are !resizable, use 0N/A // the preferred size. 0N/A // Not aligned along the baseline, or no baseline. 0N/A * Lays out springs that have a baseline along the baseline. All 0N/A * others are centered. 0N/A default:
// CENTER_OFFSET & OTHER, not resizable 0N/A // Force the baseline to be calculated 0N/A // If the axis is VERTICAL, throws an IllegalStateException 0N/A "Baseline must be used along vertical axis");
0N/A // DEFAULT_SIZE or PREFERRED_SIZE 0N/A // Baseline for the component, computed as necessary. 0N/A // Whether or not the size has been requested yet. 0N/A "Component must be non-null");
0N/A // getComponentInfo makes sure component is a child of the 0N/A // Container GroupLayout is the LayoutManager for. 0N/A * Spring representing the preferred distance between two components. 0N/A * Spring represented a certain amount of space. 0N/A * Spring reprensenting the distance between any number of sources and 0N/A * targets. The targets and sources are computed during layout. An 0N/A * instance of this can either be dynamically created when 0N/A * autocreatePadding is true, or explicitly created by the developer. 0N/A * Represents two springs that should have autopadding inserted between 0N/A * An extension of AutopaddingSpring used for container level padding. 0N/A // LinkInfo contains the set of ComponentInfosthat are linked along a 0N/A * This class is also used to handle Springs that have their sizes 0N/A // Component being layed out 0N/A // If the component's size is linked to other components, the 0N/A // horizontalMaster and/or verticalMaster reference the group of 0N/A // linked components. 0N/A * Updates the cached visibility. 0N/A * @return true if the visibility changed 0N/A * Returns true if this component has its size linked to 0N/A // horizontalMaster field is directly set by adding 0N/A // us to the LinkInfo. 0N/A // verticalMaster field is directly set by adding 0N/A // us to the LinkInfo.