本文整理汇总了Java中org.jfree.chart.JFreeChart.draw方法的典型用法代码示例。如果您正苦于以下问题:Java JFreeChart.draw方法的具体用法?Java JFreeChart.draw怎么用?Java JFreeChart.draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.JFreeChart
的用法示例。
在下文中一共展示了JFreeChart.draw方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDrawWithNullInfo
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* Draws the chart with a single range. At one point, this caused a null
* pointer exception (fixed now).
*/
public void testDrawWithNullInfo() {
boolean success = false;
MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0));
plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0)));
JFreeChart chart = new JFreeChart(plot);
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: paintDeviationChart
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
public void paintDeviationChart(Graphics graphics, int width, int height) {
prepareData();
JFreeChart chart = createChart(this.dataset);
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
}
Rectangle2D drawRect = new Rectangle2D.Double(0, 0, width, height);
chart.draw((Graphics2D) graphics, drawRect);
}
示例3: testNullValueInDataset
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* Tests that no exceptions are thrown when there is a <code>null</code> value in the dataset.
*/
public void testNullValueInDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Section 1", 10.0);
dataset.setValue("Section 2", 11.0);
dataset.setValue("Section 3", null);
JFreeChart chart = createPieChart3D(dataset);
boolean success = false;
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 (Throwable t) {
success = false;
}
assertTrue(success);
}
示例4: testNullValueInDataset
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* Tests that no exceptions are thrown when there is a <code>null</code>
* value in the dataset.
*/
public void testNullValueInDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Section 1", 10.0);
dataset.setValue("Section 2", 11.0);
dataset.setValue("Section 3", null);
JFreeChart chart = createPieChart3D(dataset);
boolean success = false;
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 (Throwable t) {
success = false;
}
assertTrue(success);
}
示例5: testDrawWithEmptyDataset
import org.jfree.chart.JFreeChart; //导入方法依赖的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);
}
示例6: testDrawWithNullInfo
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* Draws the chart with a null info object to make sure that no exceptions
* are thrown.
*/
public void testDrawWithNullInfo() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(35.0, "S1", "C1");
dataset.addValue(45.0, "S1", "C2");
dataset.addValue(55.0, "S1", "C3");
dataset.addValue(15.0, "S1", "C4");
dataset.addValue(25.0, "S1", "C5");
SpiderWebPlot plot = new SpiderWebPlot(dataset);
JFreeChart chart = new JFreeChart(plot);
boolean success = false;
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);
}
示例7: test1654215
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* A test for bug 1654215 (where a renderer is added to the plot without
* a corresponding dataset and it throws an exception at drawing time).
*/
public void test1654215() {
DefaultXYDataset dataset = new DefaultXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(1, new XYLineAndShapeRenderer());
boolean success = false;
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) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例8: testDrawRangeGridlines
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* A test for drawing range grid lines when there is no primary renderer.
* In 1.0.4, this is throwing a NullPointerException.
*/
public void testDrawRangeGridlines() {
DefaultXYDataset dataset = new DefaultXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(null);
boolean success = false;
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) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例9: test1654215
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* A test for bug 1654215 (where a renderer is added to the plot without
* a corresponding dataset and it throws an exception at drawing time).
*/
public void test1654215() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setRenderer(1, new LineAndShapeRenderer());
boolean success = false;
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) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例10: testBug1572478Vertical
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* A check for bug 1572478 (for the vertical orientation).
*/
public void testBug1572478Vertical() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset() {
public Number getQ1Value(int row, int column) {
return null;
}
public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
return null;
}
};
List values = new ArrayList();
values.add(new Double(1.0));
values.add(new Double(10.0));
values.add(new Double(100.0));
dataset.add(values, "row", "column");
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
new NumberAxis("y"), new BoxAndWhiskerRenderer());
JFreeChart chart = new JFreeChart(plot);
boolean success = false;
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,
new ChartRenderingInfo());
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例11: testBug1572478Horizontal
import org.jfree.chart.JFreeChart; //导入方法依赖的package包/类
/**
* A check for bug 1572478 (for the horizontal orientation).
*/
public void testBug1572478Horizontal() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset() {
public Number getQ1Value(int row, int column) {
return null;
}
public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
return null;
}
};
List values = new ArrayList();
values.add(new Double(1.0));
values.add(new Double(10.0));
values.add(new Double(100.0));
dataset.add(values, "row", "column");
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
new NumberAxis("y"), new BoxAndWhiskerRenderer());
plot.setOrientation(PlotOrientation.HORIZONTAL);
JFreeChart chart = new JFreeChart(plot);
boolean success = false;
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,
new ChartRenderingInfo());
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}