当前位置: 首页>>代码示例>>Java>>正文


Java BarRenderer.setIncludeBaseInRange方法代码示例

本文整理汇总了Java中org.jfree.chart.renderer.category.BarRenderer.setIncludeBaseInRange方法的典型用法代码示例。如果您正苦于以下问题:Java BarRenderer.setIncludeBaseInRange方法的具体用法?Java BarRenderer.setIncludeBaseInRange怎么用?Java BarRenderer.setIncludeBaseInRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.chart.renderer.category.BarRenderer的用法示例。


在下文中一共展示了BarRenderer.setIncludeBaseInRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAutoRange4

import org.jfree.chart.renderer.category.BarRenderer; //导入方法依赖的package包/类
/**
 * A check for the interaction between the 'autoRangeIncludesZero' flag
 * and the base setting in the BarRenderer.
 */
public void testAutoRange4() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createBarChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    BarRenderer br = (BarRenderer) plot.getRenderer();
    br.setIncludeBaseInRange(false);
    assertEquals(95.0, axis.getLowerBound(), EPSILON);    
    assertEquals(205.0, axis.getUpperBound(), EPSILON);    
    
    br.setIncludeBaseInRange(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(210.0, axis.getUpperBound(), EPSILON);    
    
    axis.setAutoRangeIncludesZero(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(210.0, axis.getUpperBound(), EPSILON);    
    
    br.setIncludeBaseInRange(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(210.0, axis.getUpperBound(), EPSILON);    

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(1050.0, axis.getUpperBound(), EPSILON);
    
    br.setIncludeBaseInRange(false);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(1050.0, axis.getUpperBound(), EPSILON);
    
    axis.setAutoRangeIncludesZero(false);
    assertEquals(895.0, axis.getLowerBound(), EPSILON);    
    assertEquals(1005.0, axis.getUpperBound(), EPSILON);        
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:48,代码来源:NumberAxisTests.java

示例2: testAutoRange4

import org.jfree.chart.renderer.category.BarRenderer; //导入方法依赖的package包/类
/**
 * A check for the interaction between the 'autoRangeIncludesZero' flag
 * and the base setting in the BarRenderer.
 */
@Test
public void testAutoRange4() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createBarChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    BarRenderer br = (BarRenderer) plot.getRenderer();
    br.setIncludeBaseInRange(false);
    assertEquals(95.0, axis.getLowerBound(), EPSILON);
    assertEquals(205.0, axis.getUpperBound(), EPSILON);

    br.setIncludeBaseInRange(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);
    assertEquals(210.0, axis.getUpperBound(), EPSILON);

    axis.setAutoRangeIncludesZero(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);
    assertEquals(210.0, axis.getUpperBound(), EPSILON);

    br.setIncludeBaseInRange(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);
    assertEquals(210.0, axis.getUpperBound(), EPSILON);

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);
    assertEquals(1050.0, axis.getUpperBound(), EPSILON);

    br.setIncludeBaseInRange(false);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);
    assertEquals(1050.0, axis.getUpperBound(), EPSILON);

    axis.setAutoRangeIncludesZero(false);
    assertEquals(895.0, axis.getLowerBound(), EPSILON);
    assertEquals(1005.0, axis.getUpperBound(), EPSILON);
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:49,代码来源:NumberAxisTest.java


注:本文中的org.jfree.chart.renderer.category.BarRenderer.setIncludeBaseInRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。