本文整理汇总了Java中org.jfree.data.xy.TableXYDataset类的典型用法代码示例。如果您正苦于以下问题:Java TableXYDataset类的具体用法?Java TableXYDataset怎么用?Java TableXYDataset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableXYDataset类属于org.jfree.data.xy包,在下文中一共展示了TableXYDataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFindStackedRangeExtent
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Tests that the stacked range extent returns the expected result.
*/
public void testFindStackedRangeExtent() {
// first the category datasets...
CategoryDataset d1 = createCategoryDataset1();
Range r = DatasetUtilities.findStackedRangeExtent(d1);
assertEquals(0.0, r.getLowerBound(), EPSILON);
assertEquals(15.0, r.getUpperBound(), EPSILON);
d1 = createCategoryDataset2();
r = DatasetUtilities.findStackedRangeExtent(d1);
assertEquals(-2.0, r.getLowerBound(), EPSILON);
assertEquals(2.0, r.getUpperBound(), EPSILON);
// then the XYDatasets...
TableXYDataset d2 = createTableXYDataset1();
r = DatasetUtilities.findStackedRangeExtent(d2);
assertEquals(-2.0, r.getLowerBound(), EPSILON);
assertEquals(2.0, r.getUpperBound(), EPSILON);
}
示例2: testFindDomainBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
public void testFindDomainBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset,
PlotOrientation.VERTICAL, false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.3));
assertTrue(bounds.contains(0.5));
assertTrue(bounds.contains(2.5));
assertFalse(bounds.contains(2.8));
}
示例3: testFindRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
plot.setRenderer(renderer);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
// try null argument
assertNull(renderer.findRangeBounds(null));
// try empty dataset
assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
示例4: testFindRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(false);
Range bounds = rangeAxis.getRange();
assertFalse(bounds.contains(1.0));
assertTrue(bounds.contains(2.0));
assertTrue(bounds.contains(5.0));
assertFalse(bounds.contains(6.0));
}
示例5: createTableXYDataset1
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Creates a sample dataset for testing purposes.
*
* @return A sample dataset.
*/
private TableXYDataset createTableXYDataset1() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(1.0, 1.0);
s1.add(2.0, 2.0);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(1.0, -2.0);
s2.add(2.0, -1.0);
dataset.addSeries(s2);
return dataset;
}
示例6: findRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Returns the range of values the renderer requires to display all the
* items from the specified dataset.
*
* @param dataset the dataset (<code>null</code> permitted).
*
* @return The range (or <code>null</code> if the dataset is
* <code>null</code> or empty).
*/
public Range findRangeBounds(XYDataset dataset) {
if (dataset == null) {
return null;
}
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
TableXYDataset d = (TableXYDataset) dataset;
int itemCount = d.getItemCount();
for (int i = 0; i < itemCount; i++) {
double[] stackValues = getStackValues((TableXYDataset) dataset,
d.getSeriesCount(), i);
min = Math.min(min, stackValues[0]);
max = Math.max(max, stackValues[1]);
}
if (min == Double.POSITIVE_INFINITY) {
return null;
}
return new Range(min, max);
}
示例7: getStackValues
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Calculates the stacked values (one positive and one negative) of all
* series up to, but not including, <code>series</code> for the specified
* item. It returns [0.0, 0.0] if <code>series</code> is the first series.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param series the series index.
* @param index the item index.
*
* @return An array containing the cumulative negative and positive values
* for all series values up to but excluding <code>series</code>
* for <code>index</code>.
*/
private double[] getStackValues(TableXYDataset dataset,
int series, int index) {
double[] result = new double[2];
for (int i = 0; i < series; i++) {
double v = dataset.getYValue(i, index);
if (!Double.isNaN(v)) {
if (v >= 0.0) {
result[1] += v;
}
else {
result[0] += v;
}
}
}
return result;
}
示例8: testFindRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
@Test
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageUtils.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
plot.setRenderer(renderer);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
// try null argument
assertNull(renderer.findRangeBounds(null));
// try empty dataset
assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
示例9: testFindDomainBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
@Test
public void testFindDomainBounds() {
TableXYDataset dataset
= RendererXYPackageUtils.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset,
PlotOrientation.VERTICAL, false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.3));
assertTrue(bounds.contains(0.5));
assertTrue(bounds.contains(2.5));
assertFalse(bounds.contains(2.8));
}
示例10: testFindRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
@Test
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageUtils.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(false);
Range bounds = rangeAxis.getRange();
assertFalse(bounds.contains(1.0));
assertTrue(bounds.contains(2.0));
assertTrue(bounds.contains(5.0));
assertFalse(bounds.contains(6.0));
}
示例11: createTableXYDataset1
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Creates a sample dataset for testing purposes.
*
* @return A sample dataset.
*/
private TableXYDataset createTableXYDataset1() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(1.0, 1.0);
s1.add(2.0, 2.0);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(1.0, -2.0);
s2.add(2.0, -1.0);
dataset.addSeries(s2);
return dataset;
}
示例12: findRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Returns the range of values the renderer requires to display all the
* items from the specified dataset.
*
* @param dataset the dataset (<code>null</code> permitted).
*
* @return The range (or <code>null</code> if the dataset is
* <code>null</code> or empty).
*/
@Override
public Range findRangeBounds(XYDataset dataset) {
if (dataset == null) {
return null;
}
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
TableXYDataset d = (TableXYDataset) dataset;
int itemCount = d.getItemCount();
for (int i = 0; i < itemCount; i++) {
double[] stackValues = getStackValues((TableXYDataset) dataset,
d.getSeriesCount(), i);
min = Math.min(min, stackValues[0]);
max = Math.max(max, stackValues[1]);
}
if (min == Double.POSITIVE_INFINITY) {
return null;
}
return new Range(min, max);
}
示例13: getStackValues
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Calculates the stacked values (one positive and one negative) of all
* series up to, but not including, <code>series</code> for the specified
* item. It returns [0.0, 0.0] if <code>series</code> is the first series.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param series the series index.
* @param index the item index.
*
* @return An array containing the cumulative negative and positive values
* for all series values up to but excluding <code>series</code>
* for <code>index</code>.
*/
private double[] getStackValues(TableXYDataset dataset,
int series, int index) {
double[] result = new double[2];
for (int i = 0; i < series; i++) {
double v = dataset.getYValue(i, index);
if (!Double.isNaN(v)) {
if (v >= 0.0) {
result[1] += v;
}
else {
result[0] += v;
}
}
}
return result;
}
示例14: findRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Returns the range of values the renderer requires to display all the
* items from the specified dataset.
*
* @param dataset the dataset (<code>null</code> permitted).
*
* @return The range (<code>null</code> if the dataset is <code>null</code>
* or empty).
*/
@Override
public Range findRangeBounds(XYDataset dataset) {
if (dataset != null) {
if (this.renderAsPercentages) {
return new Range(0.0, 1.0);
}
else {
return DatasetUtilities.findStackedRangeBounds(
(TableXYDataset) dataset);
}
}
else {
return null;
}
}
示例15: findRangeBounds
import org.jfree.data.xy.TableXYDataset; //导入依赖的package包/类
/**
* Returns the range of values the renderer requires to display all the
* items from the specified dataset.
*
* @param dataset the dataset ({@code null} permitted).
*
* @return The range (or {@code null} if the dataset is {@code null} or
* empty).
*/
@Override
public Range findRangeBounds(XYDataset dataset) {
if (dataset == null) {
return null;
}
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
TableXYDataset d = (TableXYDataset) dataset;
int itemCount = d.getItemCount();
for (int i = 0; i < itemCount; i++) {
double[] stackValues = getStackValues((TableXYDataset) dataset,
d.getSeriesCount(), i);
min = Math.min(min, stackValues[0]);
max = Math.max(max, stackValues[1]);
}
if (min == Double.POSITIVE_INFINITY) {
return null;
}
return new Range(min, max);
}