本文整理汇总了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);
}
示例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);
}