*/
public Dimension minimumLayoutSize(Container target) {
Dimension size;
synchronized(this) {
checkContainer(target);
checkRequests();
size = new Dimension(xTotal.minimum, yTotal.minimum);
}
Insets insets = target.getInsets();
size.width = (int) Math.min((long) size.width + (long) insets.left + (long) insets.right, Integer.MAX_VALUE);
size.height = (int) Math.min((long) size.height + (long) insets.top + (long) insets.bottom, Integer.MAX_VALUE);
return size;
}
/**
* Returns the maximum dimensions the target container can use
* to lay out the components it contains.
*
* @param target the container that needs to be laid out
* @return the dimenions >= 0 && <= Integer.MAX_VALUE
* @exception AWTError if the target isn't the container specified to the
* BoxLayout constructor
* @see #preferredLayoutSize
* @see #minimumLayoutSize
*/
public Dimension maximumLayoutSize(Container target) {
Dimension size;
synchronized(this) {
checkContainer(target);
checkRequests();
size = new Dimension(xTotal.maximum, yTotal.maximum);
}
Insets insets = target.getInsets();
size.width = (int) Math.min((long) size.width + (long) insets.left + (long) insets.right, Integer.MAX_VALUE);
size.height = (int) Math.min((long) size.height + (long) insets.top + (long) insets.bottom, Integer.MAX_VALUE);
return size;
}
/**
* Returns the alignment along the X axis for the container.
* If the box is horizontal, the default
* alignment will be returned. Otherwise, the alignment needed
* to place the children along the X axis will be returned.
*
* @param target the container
* @return the alignment >= 0.0f && <= 1.0f
* @exception AWTError if the target isn't the container specified to the
* BoxLayout constructor
*/
public synchronized float getLayoutAlignmentX(Container target) {
checkContainer(target);
checkRequests();
return xTotal.alignment;
}
/**
* Returns the alignment along the Y axis for the container.
* If the box is vertical, the default
* alignment will be returned. Otherwise, the alignment needed
* to place the children along the Y axis will be returned.
*
* @param target the container
* @return the alignment >= 0.0f && <= 1.0f
* @exception AWTError if the target isn't the container specified to the
* BoxLayout constructor
*/
public synchronized float getLayoutAlignmentY(Container target) {
checkContainer(target);
checkRequests();
return yTotal.alignment;
}
/**
* Called by the AWT <!-- XXX CHECK! --> when the specified container
* needs to be laid out.
*
* @param target the container to lay out
*
* @exception AWTError if the target isn't the container specified to the
* BoxLayout constructor
*/
public void layoutContainer(Container target) {
checkContainer(target);
int nChildren = target.getComponentCount();
int[] xOffsets = new int[nChildren];
int[] xSpans = new int[nChildren];
int[] yOffsets = new int[nChildren];
int[] ySpans = new int[nChildren];
Dimension alloc = target.getSize();
Insets in = target.getInsets();
alloc.width -= in.left + in.right;
alloc.height -= in.top + in.bottom;
// Resolve axis to an absolute value (either X_AXIS or Y_AXIS)
ComponentOrientation o = target.getComponentOrientation();
int absoluteAxis = resolveAxis( axis, o );
boolean ltr = (absoluteAxis != axis) ? o.isLeftToRight() : true;
=4= |