Java Code Examples for org.jfree.chart.block.BlockContainer#clear()

The following examples show how to use org.jfree.chart.block.BlockContainer#clear() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BorderArrangementTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);


}