TableLayout extends AbstractLayout { public Dimension2D getPreferredSize(Container container) { Info[] infos = getInfo(container); return new de.erichseifert.gral.graphics.Dimension2D.Double( infos[COLS].sizeSum + infos[COLS].gapSum + infos[COLS].insetsSum, infos[ROWS].sizeSum + infos[ROWS].gapSum + infos[ROWS].insetsSum ); } TableLayout(int cols, double gapH, double gapV);  TableLayout(int cols); void layout(Container container); Dimension2D getPreferredSize(Container container); int getColumns();  }
@Test public void testPreferredSizeVertical() { Layout layout = new TableLayout(1, GAP_X, GAP_Y); Dimension2D size = layout.getPreferredSize(container); assertEquals(COMP_WIDTH, size.getWidth(), DELTA); assertEquals(3.0*COMP_HEIGHT + 2.0*GAP_Y, size.getHeight(), DELTA); }
@Test public void testPreferredSizeHorizontal() { Layout layout = new TableLayout(3, GAP_X, GAP_Y); Dimension2D size = layout.getPreferredSize(container); assertEquals(3.0*COMP_WIDTH + 2.0*GAP_X, size.getWidth(), DELTA); assertEquals(COMP_HEIGHT, size.getHeight(), DELTA); }