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


Java JFreeChart類代碼示例

本文整理匯總了Java中org.jfree.chart.JFreeChart的典型用法代碼示例。如果您正苦於以下問題:Java JFreeChart類的具體用法?Java JFreeChart怎麽用?Java JFreeChart使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JFreeChart類屬於org.jfree.chart包,在下文中一共展示了JFreeChart類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: MultiLineChart

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
public MultiLineChart(final String title, List<Users> tpaverficationUserList) {
	super(title);
	this.tpaverficationUserList = tpaverficationUserList;
	XYDataset dataset = null;
	try {
		dataset = createDataset();
	} catch (Exception e) {
		System.out.println("MultiLineChart -- Constructor" + e);
	}
	final JFreeChart chart = createChart(dataset);
	final ChartPanel chartPanel = new ChartPanel(chart);
	chartPanel.setPreferredSize(new java.awt.Dimension(700, 470));
	setContentPane(chartPanel);
	this.pack();
	RefineryUtilities.centerFrameOnScreen(this);
	this.setVisible(true);

}
 
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:19,代碼來源:MultiLineChart.java

示例3: testXYAutoRange1

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Checks that the auto-range for the domain axis on an XYPlot is
 * working as expected.
 */
public void testXYAutoRange1() {
    XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 1.0);
    series.add(2.0, 2.0);
    series.add(3.0, 3.0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Test", 
        "X",
        "Y",
        dataset,
        PlotOrientation.VERTICAL,
        false, 
        false,
        false
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(0.9, axis.getLowerBound(), EPSILON);    
    assertEquals(3.1, axis.getUpperBound(), EPSILON);    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:NumberAxisTests.java

示例4: createChart

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
@Override
public JFreeChart createChart(Element element, ChartSource source) {
    Attribute key = source.getAttributeProperty(PIE_ATTRIBUTE_KEY);
    Attribute value = source.getAttributeProperty(PIE_ATTRIBUTE_VALUE);
    if ((key == null) || (value == null))
        throw new ChartNotSetupedException();
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (Element element2 : source.getElements()) {
        Object v1 = engine.getAttribute(element2, key);
        Object v2 = engine.getAttribute(element2, value);
        if ((v1 != null) && (v2 != null))
            dataset.setValue(toString(v1), toDouble(v2));
    }
    return ChartFactory.createPieChart(element.getName(), dataset, true,
            true, false);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:17,代碼來源:PieChartDataPlugin.java

示例5: testDrawWithNullInfo

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultStatisticalCategoryDataset dataset 
            = new DefaultStatisticalCategoryDataset();
        dataset.add(1.0, 2.0, "S1", "C1");
        dataset.add(3.0, 4.0, "S1", "C2");
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                new StatisticalLineAndShapeRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:StatisticalLineAndShapeRendererTests.java

示例6: linePlot

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
public JFreeChart linePlot(String xLabel, String yLabel){
    int numDatasets = dataset.size();
    JFreeChart result = ChartFactory.createXYLineChart(
chartTitle, // chart title
xLabel, // x axis label
yLabel, // y axis label
dataset.get(0), // data
PlotOrientation.VERTICAL, 
true, // include legend
true, // tooltips
false // urls
    );
    XYPlot plot = result.getXYPlot();
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
    for(int i=1;i<numDatasets;i++){
        plot.setDataset(i,dataset.get(i));
        //XYItemRenderer renderer = plot.getRenderer(i-0);
        //plot.setRenderer(i, new XYLineAndShapeRenderer(false, true));
        plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
        plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
    }

    return result;
}
 
開發者ID:PacktPublishing,項目名稱:Neural-Network-Programming-with-Java-SecondEdition,代碼行數:26,代碼來源:Chart.java

示例7: createChart

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Creates a sample chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(IntervalXYDataset dataset,String s) {
    final JFreeChart chart = ChartFactory.createXYBarChart(
        "Histogram Plot: "+s,
        "Keyword index", 
        false,
        "frequency", 
        dataset,
        PlotOrientation.VERTICAL,
        true,
        true,
        false
    );
    
    XYPlot plot = (XYPlot) chart.getPlot();
    final IntervalMarker target = new IntervalMarker(400.0, 700.0);
    //target.setLabel("Target Range");
    target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    target.setLabelAnchor(RectangleAnchor.LEFT);
    target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    target.setPaint(new Color(222, 222, 255, 128));
    plot.addRangeMarker(target, Layer.BACKGROUND);
    return chart;    
}
 
開發者ID:Subarno,項目名稱:SentimentAnalysisJava,代碼行數:31,代碼來源:HistogramExample.java

示例8: main

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Starting point for the demonstration application.
 *
 * @param args  ignored.
 */
public static void main(String[] args) {
    final JFreeChart chart = createChart(createDataset());
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(600, 300);
    shell.setLayout(new FillLayout());
    shell.setText("Time series demo for jfreechart running with SWT");
    ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true);
    frame.setDisplayToolTips(true);
    frame.setHorizontalAxisTrace(false);
    frame.setVerticalAxisTrace(false);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:SWTTimeSeriesDemo.java

示例9: ChartTab

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
	 * Constructor
	 * @param chart The chart to be displayed
	 */
	public ChartTab(JFreeChart chart, ChartEditorJPanel parent) {
		
		this.parent = parent;
		
		// --- Create and configure the chart panel ---
		this.chartPanel = new ChartPanel(chart);
		this.chartPanel.setBackground(Color.WHITE);								// Component background
		this.chartPanel.getChart().getPlot().setBackgroundPaint(Color.WHITE);		// Chart background
		this.chartPanel.getChart().getXYPlot().setDomainGridlinePaint(Color.BLACK);
		this.chartPanel.getChart().getXYPlot().setRangeGridlinePaint(Color.BLACK);
		
		// --- Create the tool bar --------------------
		this.rebuildVisibilityToolBar();
		
		// --- Add components to the panel ------------
		this.setLayout(new BorderLayout());
		this.add(this.chartPanel, BorderLayout.CENTER);
		this.add(this.getJToolBarSeriesVisibility(), BorderLayout.SOUTH);
		
//		parent.getDataModel().getChartSettingModel().addObserver(this);
		
	}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:27,代碼來源:ChartTab.java

示例10: testDrawWithNullInfo

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        double[][] starts = new double[][] {{0.1, 0.2, 0.3}, 
                {0.3, 0.4, 0.5}};
        double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}};
        DefaultIntervalCategoryDataset dataset 
            = new DefaultIntervalCategoryDataset(starts, ends);        
        IntervalBarRenderer renderer = new IntervalBarRenderer();
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                renderer);
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:IntervalBarRendererTests.java

示例11: 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

示例12: createLineChart

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Create a line chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createLineChart() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    // create the chart...
    return ChartFactory.createLineChart(
        "Line Chart",
        "Domain", "Range",
        dataset,
        PlotOrientation.HORIZONTAL,
        true,     // include legend
        true,
        true
    );

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

示例13: testDrawWithNullInfo

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (particularly by code in the renderer).
 */
public void testDrawWithNullInfo() {
    boolean success = false;
    try {
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.addValue(1.0, "S1", "C1");
        dataset.addValue(2.0, "S1", "C2");
        dataset.addValue(3.0, "S2", "C1");
        dataset.addValue(4.0, "S2", "C2");
        GroupedStackedBarRenderer renderer 
            = new GroupedStackedBarRenderer();
        CategoryPlot plot = new CategoryPlot(dataset, 
                new CategoryAxis("Category"), new NumberAxis("Value"), 
                renderer);
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:GroupedStackedBarRendererTests.java

示例14: 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

示例15: createChart

import org.jfree.chart.JFreeChart; //導入依賴的package包/類
/**
 * Create a stacked bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    // create the chart...
    return ChartFactory.createStackedAreaChart(
        "Stacked Area Chart",  // chart title
        "Domain", "Range",
        dataset,      // data
        PlotOrientation.HORIZONTAL,
        true,         // include legend
        true,
        true
    );

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


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