GBLayout.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* @(#)GBLayout.java 1.23 97/09/03 Doug Stein
*
* Copyright (c) 1996, 2001 by Sun Microsystems, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
class GBLayoutInfo {
int minWidth[]; /* largest minWidth in each column */
int minHeight[]; /* largest minHeight in each row */
double weightX[]; /* largest weight in each column */
double weightY[]; /* largest weight in each row */
GBLayoutInfo(int w, int h) {
width = w;
height = h;
minWidth = new int[w];
minHeight = new int[h];
weightX = new double[w];
weightY = new double[h];
}
}
/* BEGIN JSTYLED */
/**
GBLayout is a flexible layout manager
that aligns components vertically and horizontally,
without requiring that the components be the same size.
Each GBLayout uses a rectangular grid of cells,
with each component occupying one or more cells
(called its < em >display area</em>).
Each component managed by a GBLayout
is associated with a
< a href = java.awt.GBConstraints.html >GBConstraints</a> instance
that specifies how the component is laid out
within its display area.
How a GBLayout places a set of components
depends on each component's GBConstraints and minimum size,
as well as the preferred size of the components' container.
< p>
To use a GBLayout effectively,
you must customize one or more of its components' GBConstraints.
You customize a GBConstraints object by setting one or more
of its instance variables:
< dl>
< dt > <a href = java.awt.GBConstraints.html#gridx> gridx</a>,
< a href = java.awt.GBConstraints.html#gridy> gridy</a>
< dd> Specifies the cell at the upper left of the component's display area,
where the upper-left-most cell has address gridx = 0, gridy=0.
Use GBConstraints.RELATIVE(the default value)
to specify that the component be just placed
just to the right of(for gridx)
or just below(for gridy)
the component that was added to the container
just before this component was added.
< dt > <a href = java.awt.GBConstraints.html#gridwidth> gridwidth</a>,
< a href = java.awt.GBConstraints.html#gridheight> gridheight</a>
< dd> Specifies the number of cells in a row(for gridwidth)
or column(for gridheight)
in the component's display area.
The default value is 1.
Use GBConstraints.REMAINDER to specify
that the component be the last one in its row(for gridwidth)
or column(for gridheight).
Use GBConstraints.RELATIVE to specify
that the component be the next to last one
in its row(for gridwidth) or column (for gridheight).
< dt> <a href = java.awt.GBConstraints.html#fill>fill</a>
< dd> Used when the component's display area
is larger than the component's requested size
to determine whether(and how) to resize the component.
Valid values are
GBConstraints.NONE
(the default),
GBConstraints.HORIZONTAL
(make the component wide enough to fill its display area
horizontally, but don't change its height),
GBConstraints.VERTICAL
(make the component tall enough to fill its display area
vertically, but don't change its width),
and
GBConstraints.BOTH
(make the component fill its display area entirely).
< dt > <a href = java.awt.GBConstraints.html#ipadx> ipadx</a>,
< a href = java.awt.GBConstraints.html#ipady> ipady</a>
< dd> Specifies the internal padding:
how much to add to the minimum size of the component.
The width of the component will be at least
its minimum width plus ipadx*2 pixels
(since the padding applies to both sides of the component).
Similarly, the height of the component will be at least
the minimum height plus ipady*2 pixels.
< dt> <a href = java.awt.GBConstraints.html#insets>insets</a>
< dd> Specifies the external padding of the component --
the minimum amount of space between the component
and the edges of its display area.
< dt> <a href = java.awt.GBConstraints.html#anchor>anchor</a>
< dd> Used when the component is smaller than its display area
to determine where(within the area) to place the component.
Valid values are
GBConstraints.CENTER(the default),
GBConstraints.NORTH,
GBConstraints.NORTHEAST,
GBConstraints.EAST,
GBConstraints.SOUTHEAST,
GBConstraints.SOUTH,
GBConstraints.SOUTHWEST,
GBConstraints.WEST, and
GBConstraints.NORTHWEST.
< dt > <a href = java.awt.GBConstraints.html#weightx> weightx</a>,
< a href = java.awt.GBConstraints.html#weighty> weighty</a>
< dd> Used to determine how to distribute space;
this is important for specifying resizing behavior.
Unless you specify a weight
for at least one component in a row(weightx)
and column(weighty),
all the components clump together in the center of
their container.
This is because when the weight is zero(the default),
the GBLayout puts any extra space
between its grid of cells and the edges of the container.
< /dl>
The following figure shows ten components(all buttons)
managed by a GBLayout:
< blockquote>
< img src = images/java.awt/GridBagEx.gif width=262 height=155>
< /blockquote>
All the components have fill = GBConstraints.BOTH.
In addition, the components have the following non-default constraints:
< ul>
< li >Button1, Button2, Button3:
weightx = 1.0
< li >Button4:
weightx = 1.0,
gridwidth = GBConstraints.REMAINDER
< li >Button5:
gridwidth = GBConstraints.REMAINDER
< li >Button6:
gridwidth = GBConstraints.RELATIVE
< li >Button7:
gridwidth = GBConstraints.REMAINDER
< li >Button8:
gridheight = 2, weighty=1.0,
< li >Button9, Button 10:
gridwidth = GBConstraints.REMAINDER
< /ul>
Here is the code that implements the example shown above:
< blockquote>
< pre>
import java.awt.*;
import java.util.*;
import java.applet.Applet;
public class GridBagEx1 extends Applet {
protected void makebutton(String name,
GBLayout gridbag,
GBConstraints c) {
Button button = new Button(name);
gridbag.setConstraints(button, c);
add(button);
}
public void init() {
GBLayout gridbag = new GBLayout();
GBConstraints c = new GBConstraints();
setFont(new Font("Sansserif", Font.PLAIN, 14));
setLayout(gridbag);
c.fill = GBConstraints.BOTH;
c.weightx = 1.0;
makebutton("Button1", gridbag, c);
makebutton("Button2", gridbag, c);
makebutton("Button3", gridbag, c);
c.gridwidth = GBConstraints.REMAINDER; // end row
makebutton("Button4", gridbag, c);
c.weightx = 0.0; // reset to the default
makebutton("Button5", gridbag, c); // another row
c.gridwidth = GBConstraints.RELATIVE; // next-to-last in row
makebutton("Button6", gridbag, c);
c.gridwidth = GBConstraints.REMAINDER; // end row
makebutton("Button7", gridbag, c);
c.gridwidth = 1; // reset to the default
c.gridheight = 2;
c.weighty = 1.0;
makebutton("Button8", gridbag, c);
c.weighty = 0.0; // reset to the default
c.gridwidth = GBConstraints.REMAINDER; // end row
c.gridheight = 1; // reset to the default
makebutton("Button9", gridbag, c);
makebutton("Button10", gridbag, c);
resize(300, 100);
}
public static void main(String args[]) {
Frame f = new Frame("GridBag Layout Example");
GridBagEx1 ex1 = new GridBagEx1();
ex1.init();
f.add("Center", ex1);
f.pack();
f.resize(f.getPreferredSize());
f.show();
}
}
< /pre>
< /blockquote>
*
* @version 1.23, 08/06/97
* @author Doug Stein
*/
/* END JSTYLED */
public class GBLayout implements LayoutManager {
/**
* Determines the minimum widths for the grid columns.
*/
public int columnWidths[];
/**
* Determines the minimum heights for the grid rows.
*/
public int rowHeights[];
/**
* Determines the minimum weights for the grid columns.
*/
public double columnWeights[];
/**
* Determines the minimum weights for the grid rows.
*/
public double rowWeights[];
protected static final int INITGRIDSIZE = 16;
protected static final int MINSIZE = 1;
protected static final int PREFERREDSIZE = 2;
protected static final int TINYSIZE = 3;
protected GBConstraints defaultConstraints;
protected GBLayoutInfo layoutInfo;
protected int anchor;
protected int clipAnchor;
private static boolean layoutDisabled = false;
private static int disableCount = 0;
/**
* Globally enable gridbag layout. The
* default is for gridbag layout to
* be enabled.
*/
public synchronized static void enable() {
disableCount--;
if (disableCount <= 0)
layoutDisabled = false;
}
/**
* Globally disable gridbag layout. This can be used to improve
* performance by temporarily disabling layout during
* spurious calls to validate.
*/
public synchronized static void disable() {
disableCount++;
if (disableCount > 0)
layoutDisabled = true;
}
/**
* Set the window insets. The window insets default to (0,0,0,0).
*/
else
}
/**
* Get the window insets.
*/
public synchronized static Insets getWindowInsets() {
}
/**
* Creates a gridbag layout.
*/
public GBLayout() {
defaultConstraints = new GBConstraints();
}
/**
* Sets the constraints for the specified component.
* @param comp the component to be modified
* @param constraints the constraints to be applied
*/
if (c.hardinsets == null)
}
/**
* Sets the constraints from an option string.
* Each option has the form key=value. Options are separated by
* semicolons (;).
* @param comp the component to be modified
* @param constraints the constraints string
*/
if (constraints == null)
return;
}
/**
* Retrieves the constraints for the specified component. A copy of
* the constraints is returned.
* @param comp the component to be queried
*/
if (constraints == null) {
}
}
/**
* Retrieves the constraints for the specified
* component. The return
* value is not a copy, but is the actual constraints
* class used by the
* layout mechanism.
* @param comp the component to be queried
*/
if (constraints == null) {
}
return constraints;
}
/**
* Returns the coordinates of the upper-left corner of the grid.
* The coordinates are based on the current layout of the grid.
*/
public Point getLayoutOrigin() {
if (layoutInfo != null) {
}
return origin;
}
/**
* Returns the widths and heights of the grid columns and rows.
* The dimensions are based on the current layout of the grid.
*/
public int [][] getLayoutDimensions() {
if (layoutInfo == null)
return new int[2][0];
int dim[][] = new int [2][];
return dim;
}
/**
* Returns the minimum widths and heights of the
* grid columns and rows.
* This is how the grid would be arranged if the parent were
* to be reshaped to its minimum size.
*/
int dim[][] = new int[2][];
return dim;
}
/**
* Returns the preferred widths and heights of the
* grid columns and rows.
* This is how the grid would be arranged if the parent were
* to be reshaped to its preferred size.
*/
int dim[][] = new int[2][];
return dim;
}
/* BEGIN JSTYLED */
/**
* Returns the current set of weights for the grid
* columns and rows.
* The return value reflects the effective weights for the columns
* and rows after taking into account the weight constraints that
* are set on the child components.
*/
/* END JSTYLED */
public double [][] getLayoutWeights() {
if (layoutInfo == null)
return new double[2][0];
double weights[][] = new double [2][];
return weights;
}
/**
* Returns the coordinates of the grid cell corresponding
* to the given
* pixel coordinates.
*/
int i, d;
if (layoutInfo == null)
return loc;
d = layoutInfo.startx;
d += layoutInfo.minWidth[i];
if (d > x)
break;
}
loc.x = i;
d = layoutInfo.starty;
d += layoutInfo.minHeight[i];
if (d > y)
break;
}
loc.y = i;
return loc;
}
/**
* Sets the anchor for the gridbag. The anchor determines
* the placement
* for the child components when the container
* has extra space and none
* of the children have weights. The default anchor is CENTER.
*/
}
/**
* Returns the current anchor.
*/
public int getAnchor() {
return anchor;
}
/**
* Sets the clip anchor. The clip anchor determines
* which edge(s) of
* the container get clipped when there is not enough space. The
* default clip anchor is NORTHWEST. A clip anchor
* of NORTHWEST means
* that northwest corner is anchored, so the south
* and east edges will
* be clipped if there is not enough space.
*/
public void setClipAnchor(int clipAnchor) {
this.clipAnchor = clipAnchor;
}
/**
* Returns the current clip anchor.
*/
public int getClipAnchor() {
return clipAnchor;
}
/**
* If the parent is a Window, then adjust the insets according to
* the window insets.
*/
if (parentInsets != null) {
} else {
}
}
return insets;
}
/**
* Adds the specified component with the specified
* name to the layout.
* The name is converted to a set of GBConstraints.
* @param name the constraints string
* @param comp the component to be added
*/
}
/**
* Removes the specified component from the layout. Does not apply.
* @param comp the component to be removed
*/
}
/**
* Returns the preferred dimensions for this layout
* given the components
* in the specified panel.
* @param parent the component which needs to be laid out
* @see #minimumLayoutSize
*/
}
/**
* Returns the minimum dimensions needed to layout the components
* contained in the specified panel.
* @param parent the component which needs to be laid out
* @see #preferredLayoutSize
*/
}
/**
* Returns the smallest allowable size for the specified panel.
* This can be smaller than getMinimumSize if there are insets and
* pads set on any of the panel's children.
* @param parent the component which needs to be laid out
* @see #preferredLayoutSize
*/
}
/**
* Lays out the container in the specified panel.
* @param parent the specified component being laid out
* @see Container
*/
if (!layoutDisabled)
ArrangeGrid(parent, true);
}
/**
* Does everything that layout normally does, except the components
* aren't actually reshaped. This has the useful side effect of
* setting the location and size variables in the constraints
* for each component.
* @param parent the specified component being laid out
* @see Container
*/
if (!layoutDisabled)
ArrangeGrid(parent, false);
}
/**
* Returns the String representation of this GBLayout's values.
*/
}
/* BEGIN JSTYLED */
/**
* Print the layout information. Useful for debugging.
*/
/* DEBUG
*
* protected void DumpLayoutInfo(GBLayoutInfo s) {
* int x;
*
* System.out.println("Col\tWidth\tWeight");
* for (x=0; x<s.width; x++) {
* System.out.println(x + "\t" +
* s.minWidth[x] + "\t" +
* s.weightX[x]);
* }
* System.out.println("Row\tHeight\tWeight");
* for (x=0; x<s.height; x++) {
* System.out.println(x + "\t" +
* s.minHeight[x] + "\t" +
* s.weightY[x]);
* }
* }
*/
/**
* Print the layout constraints. Useful for debugging.
*/
/* DEBUG
*
* protected void DumpConstraints(GBConstraints constraints) {
* System.out.println(
* "wt " +
* constraints.weightx +
* " " +
* constraints.weighty +
* ", " +
*
* "box " +
* constraints.gridx +
* " " +
* constraints.gridy +
* " " +
* constraints.gridwidth +
* " " +
* constraints.gridheight +
* ", " +
*
* "min " +
* constraints.minWidth +
* " " +
* constraints.minHeight +
* ", " +
*
* "pad " +
* constraints.insets.bottom +
* " " +
* constraints.insets.left +
* " " +
* constraints.insets.right +
* " " +
* constraints.insets.top +
* " " +
* constraints.ipadx +
* " " +
* constraints.ipady);
* }
*/
/**
* Fill in an instance of the GBLayoutInfo structure for the
* current set of managed children. This requires four passes
* through the child components:
*<pre>
* 1) Figure out the dimensions of the layout grid.
* 2) Determine which cells the components occupy.
*</pre>
* This also caches the minsizes for all the children when they are
* first encountered (so subsequent loops don't need to ask again).
*/
/* END JSTYLED */
int sizeflag) {
Dimension d;
/* BEGIN JSTYLED */
/*
* Pass #1
*
* Figure out the dimensions of the layout
* grid (use a value of 1 for
* zero or negative widths and heights).
*/
/* END JSTYLED */
xMax = new int[INITGRIDSIZE];
yMax = new int[INITGRIDSIZE];
continue;
if (curWidth <= 0)
curWidth = 1;
if (curHeight <= 0)
curHeight = 1;
/* If x or y is negative, then use relative positioning: */
if (curRow >= 0)
else if (curCol >= 0)
else
curY = 0;
}
if (curX < 0) {
px = 0;
if (curX < 0)
curX = 0;
} else if (curY < 0) {
py = 0;
if (curY < 0)
curY = 0;
}
/* Adjust the grid width and height */
/* Adjust the xMax and yMax arrays */
/* Cache the current slave's size. */
else
d = comp.getMinimumSize();
}
else
d = comp.getMinimumSize();
if (constraints.shrinkx)
if (constraints.shrinky)
d = comp.getMinimumSize();
d.height);
}
} else {
if (sizeflag == PREFERREDSIZE) {
d = comp.getPreferredSize();
// If the preferred size is not reasonable
// then try the minumum size
d = comp.getMinimumSize();
// Both preferred and minimun size
// are small so use the actual size
// that was set for the component.
}
}
d.height);
} else {
d = comp.getMinimumSize();
// If the component is less than 1,1 minumum
// size then
// use getPreferredSize instead. This is
// a workaround for
// Beans that do not have getMinimumSize
// implemented.
d = comp.getPreferredSize();
}
}
d.height);
}
}
/* BEGIN JSTYLED */
/*
* Zero width and height must mean that this is
* the last item (or
* else something is wrong).
*/
/* Zero width starts a new row */
/* Zero height starts a new column */
}
/*
*/
/* END JSTYLED */
/*
* Pass #2
*
* Negative values for gridX are filled in with
* the current x value.
* Negative values for gridY are filled in with
* the current y value.
* Negative or zero values for gridWidth and
* gridHeight end the current
* row or column, respectively.
*
* Pass #1 figures out the grid dimensions.
* Pass #2 replaces the
* negative and zero values for gridWidth and gridHeight with
* real values that are based on the grid dimensions determined
* in pass #1.
*/
compindex++) {
continue;
/* If x or y is negative, then use relative positioning: */
if (curRow >= 0)
else if (curCol >= 0)
else
curY = 0;
}
if (curX < 0) {
if (curHeight <= 0) {
if (curHeight < 1)
curHeight = 1;
}
px = 0;
if (curX < 0)
curX = 0;
} else if (curY < 0) {
if (curWidth <= 0) {
if (curWidth < 1)
curWidth = 1;
}
py = 0;
if (curY < 0)
curY = 0;
}
if (curWidth <= 0) {
if (curWidth < 1)
curWidth = 1;
}
if (curHeight <= 0) {
if (curHeight < 1)
curHeight = 1;
}
/* Assign the new values to the gridbag slave */
}
/*
*/
if (columnWeights != null)
if (rowWeights != null)
/*
* Pass #3
*
* Distribute the weights.
*/
for (i = 1;
compindex++) {
continue;
if (constraints.tempWidth == i) {
/* right column */
/*
* Figure out if we should use this slave\'s
* weight. If the weight
* is less than the total weight spanned
* by the width of the cell,
* then discard the weight. Otherwise
* split the difference
* according to the existing weights.
*/
weight_diff -= r.weightX[k];
if (weight_diff > 0.0) {
weight = 0.0;
&& k < px; k++) {
weight_diff -= dx;
}
/* BEGIN JSTYLED */
/* Assign the remainder to the
* rightmost cell */
/* END JSTYLED */
}
} else if (constraints.tempWidth > i &&
if (constraints.tempHeight == i) {
/* bottom row */
/*
* Figure out if we should use this slave\'s
* weight. If the weight
* is less than the total weight spanned by
* the height of the cell,
* then discard the weight. Otherwise split
* it the difference
* according to the existing weights.
*/
weight_diff -= r.weightY[k];
if (weight_diff > 0.0) {
weight = 0.0;
&& k < py; k++) {
weight_diff -= dy;
}
/* Assign the remainder to the bottom cell */
}
} else if (constraints.tempHeight > i &&
}
}
/*
*/
if (columnWidths != null) {
if (r.weightX[i] == 0)
r.minWidth[i] = columnWidths[i];
}
}
if (rowHeights != null) {
if (r.weightY[i] == 0)
r.minHeight[i] = rowHeights[i];
}
}
} else {
if (columnWidths != null)
if (rowHeights != null)
}
/*
* Pass #4
*
* Distribute the minimum widths.
*/
for (i = 1;
compindex++) {
continue;
if (constraints.tempWidth == i) {
/* right column */
/*
* Calculate the minWidth array values.
* First, figure out how wide the current
* slave needs to be.
* Then, see if it will fit within the
* current minWidth values.
* If it will not fit, add the difference
* according to the
* weightX array.
*/
constraints)) {
+ constraints.hardipadx +
} else {
}
pixels_diff -= r.minWidth[k];
if (pixels_diff > 0) {
weight = 0.0;
k < px; k++) {
pixels_diff)) / weight);
pixels_diff -= dx;
}
/* Any leftovers are evenly distributed */
pixels_diff -= dx;
}
}
} else if (constraints.tempWidth > i &&
if (constraints.tempHeight == i) {
/* bottom row */
/*
* Calculate the minHeight array values.
* First, figure out how tall the current
* slave needs to be.
* Then, see if it will fit within the
* current minHeight values.
* If it will not fit, add the difference
* according to the
* weightY array.
*/
constraints)) {
} else {
}
pixels_diff -= r.minHeight[k];
if (pixels_diff > 0) {
weight = 0.0;
k < py; k++) {
/ weight);
pixels_diff -= dy;
}
/* Any leftovers are evenly distributed */
pixels_diff -= dy;
}
}
} else if (constraints.tempHeight > i &&
}
}
return r;
}
if (newSize == 0)
newSize = 1;
}
return arr;
}
if (r.weightX[i] != 0)
return true;
}
return false;
}
if (r.weightY[i] != 0)
return true;
}
return false;
}
/**
* Adjusts the x, y, width, and height fields to the correct
* values according to the constraint geometry and pads.
*/
w = r.width -
c.hardinsets.right);
h = r.height -
c.hardinsets.bottom);
if (w < c.tinyWidth) {
}
}
} else {
switch (c.anchor) {
case GBConstraints.NORTH:
case GBConstraints.SOUTH:
case GBConstraints.CENTER:
}
}
break;
case GBConstraints.NORTHWEST:
case GBConstraints.SOUTHWEST:
case GBConstraints.WEST:
}
break;
case GBConstraints.NORTHEAST:
case GBConstraints.SOUTHEAST:
case GBConstraints.EAST:
}
break;
default:
/* JSTYLED */
throw new IllegalArgumentException(Global.getMsg("sunsoft.jws.visual.rt.awt.GBLayout.illegal__anchor__value.4"));
}
}
}
if (h < c.tinyHeight) {
diffy = c.tinyHeight - h;
}
}
} else {
switch (c.anchor) {
case GBConstraints.WEST:
case GBConstraints.EAST:
case GBConstraints.CENTER:
diffy = c.tinyHeight - h;
}
}
break;
case GBConstraints.NORTHWEST:
case GBConstraints.NORTHEAST:
case GBConstraints.NORTH:
diffy = c.tinyHeight - h;
}
break;
case GBConstraints.SOUTHWEST:
case GBConstraints.SOUTHEAST:
case GBConstraints.SOUTH:
diffy = c.tinyHeight - h;
}
break;
default:
/* JSTYLED */
throw new IllegalArgumentException(Global.getMsg("sunsoft.jws.visual.rt.awt.GBLayout.illegal__anchor__value.4"));
}
}
}
diffx = 0;
c.hardipadx);
}
diffy = 0;
c.hardipady);
}
switch (c.anchor) {
case GBConstraints.CENTER:
r.x += diffx/2;
r.y += diffy/2;
break;
case GBConstraints.NORTH:
r.x += diffx/2;
break;
case GBConstraints.NORTHEAST:
r.x += diffx;
break;
case GBConstraints.EAST:
r.x += diffx;
r.y += diffy/2;
break;
case GBConstraints.SOUTHEAST:
r.x += diffx;
r.y += diffy;
break;
case GBConstraints.SOUTH:
r.x += diffx/2;
r.y += diffy;
break;
case GBConstraints.SOUTHWEST:
r.y += diffy;
break;
case GBConstraints.WEST:
r.y += diffy/2;
break;
case GBConstraints.NORTHWEST:
break;
default:
/* JSTYLED */
throw new IllegalArgumentException(Global.getMsg("sunsoft.jws.visual.rt.awt.GBLayout.illegal__anchor__value.5"));
}
}
/**
* Figure out the minimum size of the
* parent based on the information retrieved from GetLayoutInfo.
*/
GBLayoutInfo info) {
int i, t;
t = 0;
t = 0;
return d;
}
/**
* Lays out the grid. Called directly from layoutContainer.
*/
ArrangeGrid(parent, true);
}
/**
* Lays out the grid, conditionally reshaping the children.
* The doReshape flag indicates whether or not
* the children should be reshaped.
*
* @see layoutContainerNoReshape
*/
int compindex;
Dimension d;
double weight;
/*
* If the parent has no slaves anymore, then don't do anything
* at all: just leave the parent's size as-is.
*/
return;
}
/*
* Pass #1: scan all the slaves to figure out the total amount
* of space needed.
*/
parentSize.height) {
}
layoutInfo = info;
/* BEGIN JSTYLED */
/*
* DEBUG
*
* DumpLayoutInfo(info);
* for (compindex = 0 ; compindex < components.length ; compindex++) {
* comp = components[compindex];
* if (!comp.isVisible())
* continue;
* constraints = lookupConstraints(comp);
* DumpConstraints(constraints);
* }
* System.out.println("minSize " + r.width + " " + r.height);
*/
/*
* If the current dimensions of the window don't match the desired
* dimensions, then adjust the minWidth and minHeight arrays
* according to the weights.
*/
/* END JSTYLED */
if (diffw != 0) {
weight = 0.0;
if (weight > 0.0) {
}
}
}
} else {
diffw = 0;
}
if (diffh != 0) {
weight = 0.0;
if (weight > 0.0) {
}
}
}
} else {
diffh = 0;
}
/*
* DEBUG
*
* System.out.println("Re-adjusted:");
* DumpLayoutInfo(info);
*/
/*
* Now do the actual layout of the slaves
* using the layout information
* that has been collected.
*/
if (diffw < 0)
if (diffh < 0)
switch (anchorx) {
case GBConstraints.CENTER:
case GBConstraints.NORTH:
case GBConstraints.SOUTH:
break;
case GBConstraints.WEST:
case GBConstraints.NORTHWEST:
case GBConstraints.SOUTHWEST:
break;
case GBConstraints.EAST:
case GBConstraints.NORTHEAST:
case GBConstraints.SOUTHEAST:
break;
default:
/* JSTYLED */
throw new IllegalArgumentException(Global.getMsg("sunsoft.jws.visual.rt.awt.GBLayout.illegal__anchor__value.6"));
}
switch (anchory) {
case GBConstraints.CENTER:
case GBConstraints.WEST:
case GBConstraints.EAST:
break;
case GBConstraints.NORTH:
case GBConstraints.NORTHWEST:
case GBConstraints.NORTHEAST:
break;
case GBConstraints.SOUTH:
case GBConstraints.SOUTHWEST:
case GBConstraints.SOUTHEAST:
break;
default:
/* JSTYLED */
throw new IllegalArgumentException(Global.getMsg("sunsoft.jws.visual.rt.awt.GBLayout.illegal__anchor__value.7"));
}
compindex++) {
continue;
r.width = 0;
for (i = constraints.tempX;
i++) {
}
r.height = 0;
for (i = constraints.tempY;
i++) {
}
/*
* If the window is too small to be interesting then
* unmap it. Otherwise configure it and then make sure
* it's mapped.
*/
if (doReshape)
} else {
if (doReshape)
}
}
}
}
}