Java 类org.jfree.chart.renderer.category.LevelRenderer 实例源码

项目:parabuild-ci    文件:LevelRendererTests.java   
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));

    r1.setItemMargin(0.123);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.123);
    assertTrue(r1.equals(r2));

    r1.setMaximumItemWidth(0.234);
    assertFalse(r1.equals(r2));
    r2.setMaximumItemWidth(0.234);
    assertTrue(r1.equals(r2));

}
项目:parabuild-ci    文件:LevelRendererTests.java   
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(1.0, "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                new LevelRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:nabs    文件:LevelRendererTests.java   
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));

    r1.setItemMargin(0.123);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.123);
    assertTrue(r1.equals(r2));

    r1.setMaximumItemWidth(0.234);
    assertFalse(r1.equals(r2));
    r2.setMaximumItemWidth(0.234);
    assertTrue(r1.equals(r2));

}
项目:nabs    文件:LevelRendererTests.java   
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(1.0, "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                new LevelRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:astor    文件:LevelRendererTests.java   
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));

    r1.setItemMargin(0.123);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.123);
    assertTrue(r1.equals(r2));

    r1.setMaximumItemWidth(0.234);
    assertFalse(r1.equals(r2));
    r2.setMaximumItemWidth(0.234);
    assertTrue(r1.equals(r2));

}
项目:astor    文件:LevelRendererTests.java   
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(1.0, "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset,
                new CategoryAxis("Category"), new NumberAxis("Value"),
                new LevelRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:astor    文件:LevelRendererTests.java   
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
    dataset0.addValue(21.0, "R1", "C1");
    dataset0.addValue(22.0, "R2", "C1");
    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
    dataset1.addValue(23.0, "R3", "C1");
    dataset1.addValue(24.0, "R4", "C1");
    dataset1.addValue(25.0, "R5", "C1");
    LevelRenderer r = new LevelRenderer();
    CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, dataset1);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("R5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
项目:parabuild-ci    文件:LevelRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:parabuild-ci    文件:LevelRendererTests.java   
/**
 * Checks that the two renderers are equal but independent of one another.
 * 
 * @param r1  renderer 1.
 * @param r2  renderer 2.
 * 
 * @return A boolean.
 */
private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) {

    // should be equal...
    boolean b0 = r1.equals(r2);

    // and independent...
    r1.setItemMargin(0.0);
    boolean b1 = !r1.equals(r2);
    r2.setItemMargin(0.0);
    boolean b2 = r1.equals(r2);

    return b0 && b1 && b2;

}
项目:nabs    文件:LevelRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:nabs    文件:LevelRendererTests.java   
/**
 * Checks that the two renderers are equal but independent of one another.
 * 
 * @param r1  renderer 1.
 * @param r2  renderer 2.
 * 
 * @return A boolean.
 */
private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) {

    // should be equal...
    boolean b0 = r1.equals(r2);

    // and independent...
    r1.setItemMargin(0.0);
    boolean b1 = !r1.equals(r2);
    r2.setItemMargin(0.0);
    boolean b2 = r1.equals(r2);

    return b0 && b1 && b2;

}
项目:astor    文件:LevelRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:astor    文件:LevelRendererTests.java   
/**
 * Checks that the two renderers are equal but independent of one another.
 *
 * @param r1  renderer 1.
 * @param r2  renderer 2.
 *
 * @return A boolean.
 */
private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) {

    // should be equal...
    boolean b0 = r1.equals(r2);

    // and independent...
    r1.setItemMargin(0.0);
    boolean b1 = !r1.equals(r2);
    r2.setItemMargin(0.0);
    boolean b2 = r1.equals(r2);

    return b0 && b1 && b2;

}
项目:jasperreports    文件:LevelRenderCustomizer.java   
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
    if (jfc.getPlot() instanceof CategoryPlot)
    {
        CategoryPlot plot = (CategoryPlot)jfc.getPlot();

        ItemsCounter itemsCounter = new CategoryCounter(plot);

        Integer seriesIndex = 
            CustomizerUtil.resolveIndex(
                this, 
                itemsCounter,
                new CategorySeriesNameProvider(plot)
                );
        if (seriesIndex != null)
        {
            LevelRenderer levelRenderer = new LevelRenderer();

            Double itemMargin = getDoubleProperty(PROPERTY_ITEM_MARIGN);
            if (itemMargin != null)
            {
                levelRenderer.setItemMargin(itemMargin);
            }
            Double maxItemWidth = getDoubleProperty(PROPERTY_MAX_ITEM_WIDTH);
            if (maxItemWidth != null)
            {
                levelRenderer.setMaximumItemWidth(maxItemWidth);
            }

            if (seriesIndex == -1)
            {
                for (int i = 0; i < itemsCounter.getCount(); i++)
                {
                    plot.setRenderer(seriesIndex, levelRenderer);
                }
            }
            else
            {
                plot.setRenderer(seriesIndex, levelRenderer);
            }
        }
    }
}
项目:astor    文件:LevelRendererTests.java   
/**
 * Check that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    LevelRenderer r1 = new LevelRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}