Methods Summary |
---|
public void | addLayoutComponent(java.lang.String name, java.awt.Component comp)Adds the specified component to the layout. Used by
this class to know when to invalidate layout.
invalidateLayout(comp.getParent());
|
public void | addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)Adds the specified component to the layout, using the specified
constraint object. Used by this class to know when to invalidate
layout.
invalidateLayout(comp.getParent());
|
void | checkContainer(java.awt.Container target)
if (this.target != target) {
throw new AWTError("OverlayLayout can't be shared");
}
|
void | checkRequests()
if (xChildren == null || yChildren == null) {
// The requests have been invalidated... recalculate
// the request information.
int n = target.getComponentCount();
xChildren = new SizeRequirements[n];
yChildren = new SizeRequirements[n];
for (int i = 0; i < n; i++) {
Component c = target.getComponent(i);
Dimension min = c.getMinimumSize();
Dimension typ = c.getPreferredSize();
Dimension max = c.getMaximumSize();
xChildren[i] = new SizeRequirements(min.width, typ.width,
max.width,
c.getAlignmentX());
yChildren[i] = new SizeRequirements(min.height, typ.height,
max.height,
c.getAlignmentY());
}
xTotal = SizeRequirements.getAlignedSizeRequirements(xChildren);
yTotal = SizeRequirements.getAlignedSizeRequirements(yChildren);
}
|
public float | getLayoutAlignmentX(java.awt.Container target)Returns the alignment along the x axis for the container.
checkContainer(target);
checkRequests();
return xTotal.alignment;
|
public float | getLayoutAlignmentY(java.awt.Container target)Returns the alignment along the y axis for the container.
checkContainer(target);
checkRequests();
return yTotal.alignment;
|
public void | invalidateLayout(java.awt.Container target)Indicates a child has changed its layout related information,
which causes any cached calculations to be flushed.
checkContainer(target);
xChildren = null;
yChildren = null;
xTotal = null;
yTotal = null;
|
public void | layoutContainer(java.awt.Container target)Called by the AWT when the specified container needs to be laid out.
checkContainer(target);
checkRequests();
int nChildren = target.getComponentCount();
int[] xOffsets = new int[nChildren];
int[] xSpans = new int[nChildren];
int[] yOffsets = new int[nChildren];
int[] ySpans = new int[nChildren];
// determine the child placements
Dimension alloc = target.getSize();
Insets in = target.getInsets();
alloc.width -= in.left + in.right;
alloc.height -= in.top + in.bottom;
SizeRequirements.calculateAlignedPositions(alloc.width, xTotal,
xChildren, xOffsets,
xSpans);
SizeRequirements.calculateAlignedPositions(alloc.height, yTotal,
yChildren, yOffsets,
ySpans);
// flush changes to the container
for (int i = 0; i < nChildren; i++) {
Component c = target.getComponent(i);
c.setBounds(in.left + xOffsets[i], in.top + yOffsets[i],
xSpans[i], ySpans[i]);
}
|
public java.awt.Dimension | maximumLayoutSize(java.awt.Container target)Returns the maximum dimensions needed to lay out the components
contained in the specified target container. Recomputes the
layout if it has been invalidated, and factors in the inset setting
returned by getInset .
checkContainer(target);
checkRequests();
Dimension size = new Dimension(xTotal.maximum, yTotal.maximum);
Insets insets = target.getInsets();
size.width += insets.left + insets.right;
size.height += insets.top + insets.bottom;
return size;
|
public java.awt.Dimension | minimumLayoutSize(java.awt.Container target)Returns the minimum dimensions needed to lay out the components
contained in the specified target container. Recomputes the layout
if it has been invalidated, and factors in the current inset setting.
checkContainer(target);
checkRequests();
Dimension size = new Dimension(xTotal.minimum, yTotal.minimum);
Insets insets = target.getInsets();
size.width += insets.left + insets.right;
size.height += insets.top + insets.bottom;
return size;
|
public java.awt.Dimension | preferredLayoutSize(java.awt.Container target)Returns the preferred dimensions for this layout given the components
in the specified target container. Recomputes the layout if it
has been invalidated. Factors in the current inset setting returned
by getInsets().
checkContainer(target);
checkRequests();
Dimension size = new Dimension(xTotal.preferred, yTotal.preferred);
Insets insets = target.getInsets();
size.width += insets.left + insets.right;
size.height += insets.top + insets.bottom;
return size;
|
public void | removeLayoutComponent(java.awt.Component comp)Removes the specified component from the layout. Used by
this class to know when to invalidate layout.
invalidateLayout(comp.getParent());
|