當前位置: 首頁>>代碼示例>>Java>>正文


Java JFreeChart.draw方法代碼示例

本文整理匯總了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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:MeterChartTests.java

示例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);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:20,代碼來源:ROCChartPlotter.java

示例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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:PieChart3DTests.java

示例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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:PieChart3DTests.java

示例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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:StackedXYAreaRenderer2Tests.java

示例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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:SpiderWebPlotTests.java

示例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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:XYPlotTests.java

示例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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:XYPlotTests.java

示例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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:CategoryPlotTests.java

示例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);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:42,代碼來源:BoxAndWhiskerRendererTests.java

示例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);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:43,代碼來源:BoxAndWhiskerRendererTests.java


注:本文中的org.jfree.chart.JFreeChart.draw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。