01: package jimm.datavision.gui;
02:
03: import java.awt.*;
04:
05: /**
06: * A layout manager for {@link SectionWidget}s' contents.
07: *
08: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
09: */
10: class SectionLayout implements LayoutManager {
11:
12: /**
13: * Adds the specified component with the specified name to the layout.
14: *
15: * @param name the component name
16: * @param comp the component to be added
17: */
18: public void addLayoutComponent(String name, Component comp) {
19: }
20:
21: /**
22: * Removes the specified component from the layout.
23: *
24: * @param comp the component to be removed
25: */
26: public void removeLayoutComponent(Component comp) {
27: }
28:
29: /**
30: * Calculates the preferred size dimensions for the specified panel given
31: * the components in the specified parent container.
32: *
33: * @param parent the component to be laid out
34: * @see #minimumLayoutSize
35: */
36: public Dimension preferredLayoutSize(Container parent) {
37: return minimumLayoutSize(parent);
38: }
39:
40: /**
41: * Calculates the minimum size dimensions for the specified panel given the
42: * components in the specified parent container.
43: *
44: * @param parent the component to be laid out
45: * @see #preferredLayoutSize
46: */
47: public Dimension minimumLayoutSize(Container parent) {
48: return parent.getPreferredSize();
49: }
50:
51: /**
52: * Lays out the container in the specified panel.
53: *
54: * @param parent the component which needs to be laid out
55: */
56: public void layoutContainer(Container parent) {
57: SectionWidget sw = (SectionWidget) parent;
58: int height = sw.getSectionHeight();
59: Component[] components = parent.getComponents();
60:
61: // LHS name label
62: components[0].setBounds(0, 0, SectionWidget.LHS_WIDTH, height);
63:
64: // Fields
65: components[1].setBounds(SectionWidget.LHS_WIDTH, 0, sw
66: .getPaperWidth(), height);
67:
68: // Resizer dragger bar
69: components[2].setBounds(0, height, sw.getTotalWidth(),
70: SectionResizer.HEIGHT);
71: }
72:
73: }
|