本文整理汇总了Java中org.jfree.chart.renderer.xy.StackedXYAreaRenderer2类的典型用法代码示例。如果您正苦于以下问题:Java StackedXYAreaRenderer2类的具体用法?Java StackedXYAreaRenderer2怎么用?Java StackedXYAreaRenderer2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StackedXYAreaRenderer2类属于org.jfree.chart.renderer.xy包,在下文中一共展示了StackedXYAreaRenderer2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDrawWithEmptyDataset
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Test chart drawing with an empty dataset to ensure that this special
* case doesn't cause any exceptions.
*/
public void testDrawWithEmptyDataset() {
boolean success = false;
JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
"y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYAreaRenderer2());
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例2: testFindRangeBounds
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的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()));
}
示例3: createChart
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Creates a sample chart.
*
* @param dataset the dataset for the chart.
*
* @return a sample chart.
*/
protected JFreeChart createChart(TableXYDataset dataset) {
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
chartTitle, // chart title
domainLabel, // domain axis label
rangeLabel, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
!legendPanelOn, // legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
plot.setRenderer(0, renderer);
renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
setXSummary(dataset);
return chart;
}
示例4: createChart
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Creates a sample chart.
*
* @param dataset the dataset for the chart.
*
* @return a sample chart.
*/
protected JFreeChart createChart(TableXYDataset dataset) {
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
chartTitle, // chart title
domainLabel, // domain axis label
rangeLabel, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
!legendPanelOn, // legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
plot.setRenderer(0, renderer);
renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
setXSummary(dataset);
return chart;
}
示例5: createChart
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return a chart.
*/
protected JFreeChart createChart(TableXYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
chartTitle, // chart title
domainLabel, // x axis label
rangeLabel, // y axis label
dataset, // data
PlotOrientation.VERTICAL,
!legendPanelOn, // include legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
plot.setRenderer(0, renderer);
return chart;
}
示例6: createLegend
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
protected JFreeChart createLegend(TableXYDataset dataset) {
// JFreeChart chart = ChartFactory.createAreaChart(
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
chartTitle, // chart title
domainLabel, // x axis label
rangeLabel, // y axis label
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
plot.setRenderer(0, renderer);
renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
return chart;
}
示例7: createTableXYAreaChart
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
private JFreeChart createTableXYAreaChart(String title, String xLabel, String yLabel, TableXYDataset dataset) {
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
title, // chart title
xLabel, // x axis label
yLabel, // y axis label
dataset, // data
orientation,
true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
// renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
plot.setRenderer(0, renderer);
return chart;
}
示例8: testDrawWithEmptyDataset
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Test chart drawing with an empty dataset to ensure that this special
* case doesn't cause any exceptions.
*/
public void testDrawWithEmptyDataset() {
boolean success = false;
JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
"y", new DefaultTableXYDataset(), true);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYAreaRenderer2());
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例9: testFindRangeBounds
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的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, 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()));
}
示例10: createStackedXYAreaChart
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Creates a stacked XY area plot. The chart object returned by this
* method uses an {@link XYPlot} instance as the plot, with a
* {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
* range axis, and a {@link StackedXYAreaRenderer2} as the renderer.
*
* @param title the chart title (<code>null</code> permitted).
* @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
* @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return A stacked XY area chart.
*/
public static JFreeChart createStackedXYAreaChart(String title,
String xAxisLabel, String yAxisLabel, TableXYDataset dataset,
boolean legend) {
NumberAxis xAxis = new NumberAxis(xAxisLabel);
xAxis.setAutoRangeIncludesZero(false);
xAxis.setLowerMargin(0.0);
xAxis.setUpperMargin(0.0);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
renderer.setOutline(true);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setRangeAxis(yAxis); // forces recalculation of the axis range
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
示例11: testEquals
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Test that the equals() method distinguishes all fields.
*/
public void testEquals() {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setRoundXCoordinates(!r1.getRoundXCoordinates());
assertFalse(r1.equals(r2));
r2.setRoundXCoordinates(r1.getRoundXCoordinates());
assertTrue(r1.equals(r2));
}
示例12: testHashcode
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Two objects that are equal are required to return the same hashCode.
*/
public void testHashcode() {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2();
assertTrue(r1.equals(r2));
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
示例13: testEquals
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Test that the equals() method distinguishes all fields.
*/
public void testEquals() {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setRoundXCoordinates(!r1.getRoundXCoordinates());
assertFalse(r1.equals(r2));
r2.setRoundXCoordinates(r1.getRoundXCoordinates());
assertTrue(r1.equals(r2));
}
示例14: testHashcode
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
/**
* Two objects that are equal are required to return the same hashCode.
*/
public void testHashcode() {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2();
assertTrue(r1.equals(r2));
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
示例15: fitnessGraph
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; //导入依赖的package包/类
public void fitnessGraph() {
final FitnessDistributionDataset dataset = new FitnessDistributionDataset(this.eventBus);
final JFreeChart chart = ChartFactory.createStackedXYAreaChart("Fitness distribution", "iteration", "distribution", dataset,
PlotOrientation.VERTICAL, true, true, false);
final StackedXYAreaRenderer2 stackedxyarearenderer2 = new StackedXYAreaRenderer2();
((XYPlot) chart.getPlot()).setRenderer(0, stackedxyarearenderer2);
final ChartPanel panel = new ChartPanel(chart);
final JFrame jFrame = new JFrame();
jFrame.setContentPane(panel);
jFrame.pack();
jFrame.setVisible(true);
}