/** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { BlockContainer c1 = new BlockContainer(new FlowArrangement()); BlockContainer c2 = new BlockContainer(new FlowArrangement()); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c2)); c1.setArrangement(new ColumnArrangement()); assertFalse(c1.equals(c2)); c2.setArrangement(new ColumnArrangement()); assertTrue(c1.equals(c2)); c1.add(new EmptyBlock(1.2, 3.4)); assertFalse(c1.equals(c2)); c2.add(new EmptyBlock(1.2, 3.4)); assertTrue(c1.equals(c2)); }
/** * This test is for a particular bug that arose just prior to the release * of JFreeChart 1.0.10. A BorderArrangement with LEFT, CENTRE and RIGHT * blocks that is too wide, by default, for the available space, wasn't * shrinking the centre block as expected. */ public void testBugX() { RectangleConstraint constraint = new RectangleConstraint( new Range(0.0, 200.0), new Range(0.0, 100.0)); BlockContainer container = new BlockContainer(new BorderArrangement()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(30.0, 6.0)); Size2D size = container.arrange(g2, constraint); assertEquals(60.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); container.clear(); container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(300.0, 6.0)); size = container.arrange(g2, constraint); assertEquals(200.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); }
private BlockContainer createTestContainer1() { Block b1 = new EmptyBlock(10, 11); Block b2 = new EmptyBlock(20, 22); Block b3 = new EmptyBlock(30, 33); BlockContainer result = new BlockContainer(new GridArrangement(1, 3)); result.add(b1); result.add(b2); result.add(b3); return result; }
/** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { BorderArrangement b1 = new BorderArrangement(); BorderArrangement b2 = new BorderArrangement(); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b1)); b1.add(new EmptyBlock(99.0, 99.0), null); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(99.0, 99.0), null); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); assertTrue(b1.equals(b2)); }
/** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_FF() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, new RectangleConstraint(200, 100)); assertEquals(200.0, s.getWidth(), EPSILON); assertEquals(100.0, s.getHeight(), EPSILON); }
/** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_FN() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(30.0)); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); }
/** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_FR() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, new RectangleConstraint(30.0, new Range(5.0, 10.0))); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); }
/** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_NN() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, RectangleConstraint.NONE); assertEquals(15.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); }