// TODO Optimize
return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
}
public void layout() {
Accordion accordion = (Accordion)getComponent();
int width = getWidth();
int height = getHeight();
int contentWidth = Math.max(width - (padding.left + padding.right + 2), 0);
// Determine the content height
int panelHeight = 0;
int contentHeight = 0;
if (selectionChangeTransition == null) {
panelHeight = height;
for (PanelHeader panelHeader : panelHeaders) {
panelHeader.setSize(width, panelHeader.getPreferredHeight(width));
panelHeight -= (panelHeader.getHeight() - 1);
}
panelHeight = Math.max(panelHeight - 1, 0);
contentHeight = Math.max(panelHeight - (padding.top + padding.bottom), 0);
} else {
panelHeight = selectionChangeTransition.selectedPanel.getHeight()
+ (padding.top + padding.bottom);
}
// Lay out the components
Accordion.PanelSequence panels = accordion.getPanels();
int panelY = 0;
for (int i = 0, n = panels.getLength(); i < n; i++) {
Component panel = panels.get(i);
PanelHeader panelHeader = panelHeaders.get(i);
panelHeader.setLocation(0, panelY);
panelY += (panelHeader.getHeight() - 1);
if (selectionChangeTransition == null) {
Component selectedPanel = accordion.getSelectedPanel();
if (panel == selectedPanel) {
panel.setVisible(true);
panel.setSize(contentWidth, contentHeight);