@Override
    public Dimension getPrefferedSize(WidgetContainer container) {
        synchronized (container.getRootLock()) {
            Iterator<Widget> iter = container.getChildren().iterator();
            final Inset inset = container.getInset();
            int componentWidth = 0;
            int componentHeight = 0;
            while (iter.hasNext()) {
                Widget cur = iter.next();
                if (!cur.isVisible())
                    continue;
                switch (flowType) {
                    case HORIZONTAL_FLOW:
                        componentWidth += cur.getWidth() + (iter.hasNext() ? spacer : 0);
                        componentHeight = Math.max(componentHeight, cur.getHeight());
                        break;
                    case VERTICAL_FLOW:
                        componentHeight += cur.getHeight() + (iter.hasNext() ? spacer : 0);
                        componentWidth = Math.max(componentWidth, cur.getWidth());
                        break;
                }
            }
            return new Dimension(inset.getHorizontalTotal() + componentWidth, inset.getVerticalTotal() + componentHeight);
        }
    }