Methods Summary |
---|
public void | addLayoutComponent(java.lang.String name, java.awt.Component comp)Adds the specified component with the specified constraint
to the layout; required by LayoutManager but not used.
throw new IllegalArgumentException(
"Don't use add(component, constraint) with CircleLayout");
|
protected java.awt.Dimension | computelayoutSize(java.awt.Container parent)Compute the size of the whole mess. Serves as the guts of
preferredLayoutSize() and minimumLayoutSize().
// Pass the sums back as the actual size.
// XXX finish this!
return new Dimension(300, 300); // width == height!
|
public void | layoutContainer(java.awt.Container parent)Lays out the container in the specified panel.
Component[] components = parent.getComponents();
points = new Point[components.length];
Dimension totalSize = parent.getSize();
int dx = totalSize.width / 2;
int dy = totalSize.height / 2;
// make one quick pass to get max(PreferredSize.width[1..n]
int width = 0, height = 0;
for (int i=0; i < components.length; i++) {
width = Math.max(width, components[i].getPreferredSize().width);
height = Math.max(height, components[i].getPreferredSize().height);
}
int componentPad = Math.max(width, height) / 2;
int PAD = 10;
// Assumed to be regular (circle, not ellipse).
int radius = dx - componentPad - PAD;
int degreesPer = 360 / components.length;
int angle = startAtTop ? 0 : degreesPer/2;
for (int i=0; i < components.length; i++, angle += degreesPer) {
Component c = components[i];
Dimension d = c.getPreferredSize();
double theta = Math.toRadians(angle);
int x = (int)(Math.sin(theta) * radius);
int y = (int)(Math.cos(theta) * radius);
Debug.println("layout", c.getClass().getName() +
" " + angle + ", " + theta +
", x=" + x + ", y=" + y);
c.setBounds(dx + x - (d.width/2), dy + y - (d.height/2),
d.width, d.height);
}
|
public java.awt.Dimension | minimumLayoutSize(java.awt.Container parent)Find the minimum Dimension for the
specified container given the components therein.
return computelayoutSize(parent);
|
public java.awt.Dimension | preferredLayoutSize(java.awt.Container parent)Calculates the preferred size dimensions for the specified panel
given the components in the specified parent container.
// System.out.println("preferredLayoutSize");
return computelayoutSize(parent);
|
public void | removeLayoutComponent(java.awt.Component comp)Removes the specified component from the layout;
required by LayoutManager, but does nothing.
// nothing to do
|