本文整理汇总了Java中org.jfree.data.category.DefaultCategoryDataset.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultCategoryDataset.setValue方法的具体用法?Java DefaultCategoryDataset.setValue怎么用?Java DefaultCategoryDataset.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.category.DefaultCategoryDataset
的用法示例。
在下文中一共展示了DefaultCategoryDataset.setValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDefaultCategoryDataset
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
public static DefaultCategoryDataset createDefaultCategoryDataset(Vector<Serie> series, String[] categories) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (Serie serie : series) {
String name = serie.getName();
Vector<Object> data = serie.getData();
if (data != null && categories != null && data.size() == categories.length) {
for (int index = 0; index < data.size(); index++) {
String value = data.get(index) == null ? "" : data.get(index).toString();
if (isPercent(value)) {
value = value.substring(0, value.length() - 1);
}
if (isNumber(value)) {
dataset.setValue(Double.parseDouble(value), name, categories[index]);
}
}
}
}
return dataset;
}
示例2: testAutoRange1
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation.
*/
public void testAutoRange1() {
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
);
NumberAxis axis = (NumberAxis) chart.getCategoryPlot().getRangeAxis();
// range should be 0.0 - 210.0
assertTrue(same(axis.getLowerBound(), 0.0, 0.00001));
assertTrue(same(axis.getUpperBound(), 210.0, 0.00001));
}
示例3: testAutoRange2
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation.
*/
public void testAutoRange2() {
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
);
NumberAxis axis = (NumberAxis) chart.getCategoryPlot().getRangeAxis();
axis.setAutoRangeIncludesZero(false);
// range should be 100.0 - 205.0
assertTrue(same(axis.getLowerBound(), 95.0, 0.00001));
assertTrue(same(axis.getUpperBound(), 205.0, 0.00001));
}
示例4: testEquals
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
final DefaultCategoryDataset d1 = new DefaultCategoryDataset();
d1.setValue(23.4, "R1", "C1");
final DefaultCategoryDataset d2 = new DefaultCategoryDataset();
d2.setValue(23.4, "R1", "C1");
assertTrue(d1.equals(d2));
assertTrue(d2.equals(d1));
d1.setValue(36.5, "R1", "C2");
assertFalse(d1.equals(d2));
d2.setValue(36.5, "R1", "C2");
assertTrue(d1.equals(d2));
d1.setValue(null, "R1", "C1");
assertFalse(d1.equals(d2));
d2.setValue(null, "R1", "C1");
assertTrue(d1.equals(d2));
}
示例5: testAutoRange1
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation looking at a
* NumberAxis used as the range axis for a CategoryPlot.
*/
public void testAutoRange1() {
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();
assertEquals(axis.getLowerBound(), 0.0, EPSILON);
assertEquals(axis.getUpperBound(), 210.0, EPSILON);
}
示例6: testAutoRange3
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation looking at a
* NumberAxis used as the range axis for a CategoryPlot. In this
* case, the 'autoRangeIncludesZero' flag is set to false AND the
* original dataset is replaced with a new dataset.
*/
public void testAutoRange3() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(100.0, "Row 1", "Column 1");
dataset.setValue(200.0, "Row 1", "Column 2");
JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
"Value", dataset, PlotOrientation.VERTICAL, false, false,
false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);
assertEquals(axis.getLowerBound(), 95.0, EPSILON);
assertEquals(axis.getUpperBound(), 205.0, 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(axis.getLowerBound(), 895.0, EPSILON);
assertEquals(axis.getUpperBound(), 1005.0, EPSILON);
}
示例7: testGetRowCount
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* Some tests for the getRowCount() method.
*/
public void testGetRowCount() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
assertTrue(d.getRowCount() == 0);
d.addValue(1.0, "R1", "C1");
assertTrue(d.getRowCount() == 1);
d.addValue(1.0, "R2", "C1");
assertTrue(d.getRowCount() == 2);
d.addValue(2.0, "R2", "C1");
assertTrue(d.getRowCount() == 2);
// a row of all null values is still counted...
d.setValue(null, "R2", "C1");
assertTrue(d.getRowCount() == 2);
}
示例8: testGetColumnCount
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* Some tests for the getColumnCount() method.
*/
public void testGetColumnCount() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
assertTrue(d.getColumnCount() == 0);
d.addValue(1.0, "R1", "C1");
assertTrue(d.getColumnCount() == 1);
d.addValue(1.0, "R1", "C2");
assertTrue(d.getColumnCount() == 2);
d.addValue(2.0, "R1", "C2");
assertTrue(d.getColumnCount() == 2);
// a column of all null values is still counted...
d.setValue(null, "R1", "C2");
assertTrue(d.getColumnCount() == 2);
}
示例9: testEquals
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
DefaultCategoryDataset d1 = new DefaultCategoryDataset();
d1.setValue(23.4, "R1", "C1");
DefaultCategoryDataset d2 = new DefaultCategoryDataset();
d2.setValue(23.4, "R1", "C1");
assertTrue(d1.equals(d2));
assertTrue(d2.equals(d1));
d1.setValue(36.5, "R1", "C2");
assertFalse(d1.equals(d2));
d2.setValue(36.5, "R1", "C2");
assertTrue(d1.equals(d2));
d1.setValue(null, "R1", "C1");
assertFalse(d1.equals(d2));
d2.setValue(null, "R1", "C1");
assertTrue(d1.equals(d2));
}
示例10: testAutoRange3
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation.
*/
public void testAutoRange3() {
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
);
NumberAxis axis = (NumberAxis) chart.getCategoryPlot().getRangeAxis();
axis.setAutoRangeIncludesZero(false);
// range should be 100.0 - 205.0
assertTrue(same(axis.getLowerBound(), 95.0, 0.00001));
assertTrue(same(axis.getUpperBound(), 205.0, 0.00001));
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(900.0, "Row 1", "Column 1");
dataset2.setValue(1000.0, "Row 1", "Column 2");
chart.getCategoryPlot().setDataset(dataset2);
assertTrue(same(axis.getLowerBound(), 895.0, 0.00001));
assertTrue(same(axis.getUpperBound(), 1005.0, 0.00001));
}
示例11: testAutoRange2
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation looking at a
* NumberAxis used as the range axis for a CategoryPlot. In this
* case, the 'autoRangeIncludesZero' flag is set to false.
*/
public void testAutoRange2() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(100.0, "Row 1", "Column 1");
dataset.setValue(200.0, "Row 1", "Column 2");
JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
"Value", dataset, PlotOrientation.VERTICAL, false, false,
false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);
assertEquals(axis.getLowerBound(), 95.0, EPSILON);
assertEquals(axis.getUpperBound(), 205.0, EPSILON);
}
示例12: testAutoRange4
import org.jfree.data.category.DefaultCategoryDataset; //导入方法依赖的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);
}