private Dimension getLayoutSize(Container parent, boolean minimum) {
		synchronized(parent.getTreeLock()) {
			Insets insets = parent.getInsets();
			int w = 0;
			int h = 0;
			Component comps[] = parent.getComponents();
			int comp = 0;
			for(int i = 0;(i < rows) && (comp < comps.length);i++) {
				for(int j = 0;(j < cols) && (comp < comps.length);j++) {
					int rowSpan = spans[i][j][0];
					int colSpan = spans[i][j][1];
					boolean isSource = rowSpan != 0 && colSpan != 0;
					if(isSource) {
						Dimension d;
						if(minimum)
							d = comps[comp++].getMinimumSize();
						else
							d = comps[comp++].getPreferredSize();
						if(w < d.width / colSpan) {
							w = d.width / colSpan;
						}
						if(h < d.height / rowSpan) {
							h = d.height / rowSpan;
						}
					}
				}
			}
			// @formatter:off
			return new Dimension(
				insets.left + insets.right + cols * w + (cols - 1) * colGap,
				insets.top + insets.bottom + rows * h + (rows - 1) * rowGap);
			// @formatter:on
		}
	}