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


Java JFreeChart.getPlot方法代碼示例

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


在下文中一共展示了JFreeChart.getPlot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createChart

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:PieChartDemo1.java

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

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

示例4: testFindRangeBounds

import org.jfree.chart.JFreeChart; //導入方法依賴的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()));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:StackedXYAreaRenderer2Tests.java

示例5: testFindRangeBounds

import org.jfree.chart.JFreeChart; //導入方法依賴的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));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:19,代碼來源:XYLineAndShapeRendererTests.java

示例6: chartMouseMoved

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
@Override
public void chartMouseMoved(ChartMouseEventFX event) {
    Rectangle2D dataArea = this.chartViewer.getCanvas().getRenderingInfo().getPlotInfo().getDataArea();
    JFreeChart chart = event.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    ValueAxis xAxis = plot.getDomainAxis();
    double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, 
            RectangleEdge.BOTTOM);
    // make the crosshairs disappear if the mouse is out of range
    if (!xAxis.getRange().contains(x)) { 
        x = Double.NaN;                  
    }
    double y = DatasetUtils.findYValue(plot.getDataset(), 0, x);
    this.xCrosshair.setValue(x);
    this.yCrosshair.setValue(y);
}
 
開發者ID:jfree,項目名稱:jfree-fxdemos,代碼行數:17,代碼來源:CrosshairOverlayFXDemo1.java

示例7: createChart

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
 * Creates a chart.
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(
        "Legal & General Unit Trust Prices",  // title
        "Date",             // x-axis label
        "Price Per Unit",   // y-axis label
        dataset,            // data
        true,               // create legend?
        true,               // generate tooltips?
        false               // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    
    return chart;

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

示例8: createNumericalChart

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
private JFreeChart createNumericalChart() {
	JFreeChart chart;
	XYDataset dataset = createNumericalDataSet();
	// create the chart...
	String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
	chart = ChartFactory.createXYLineChart(null, // chart title
			domainName, // x axis label
			RANGE_AXIS_NAME, // y axis label
			dataset, // data
			PlotOrientation.VERTICAL, true, // include legend
			true, // tooltips
			false // urls
			);

	DeviationRenderer renderer = new DeviationRenderer(true, false);
	Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	if (dataset.getSeriesCount() == 1) {
		renderer.setSeriesStroke(0, stroke);
		renderer.setSeriesPaint(0, Color.RED);
		renderer.setSeriesFillPaint(0, Color.RED);
	} else {
		for (int i = 0; i < dataset.getSeriesCount(); i++) {
			renderer.setSeriesStroke(i, stroke);
			Color color = getColorProvider().getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
			renderer.setSeriesPaint(i, color);
			renderer.setSeriesFillPaint(i, color);
		}
	}
	renderer.setAlpha(0.12f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRenderer(renderer);

	return chart;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:36,代碼來源:DistributionPlotter.java

示例9: addChart

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 */
private void addChart() {
    JFreeChart chart = ChartFactory.createBarChart3D(getTitle(),
            null, "Time" + unitSuffix(),
            dataset, PlotOrientation.VERTICAL,
            true, true, false);
    chart.addProgressListener(locker);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(dataset);
    
    mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart));
}
 
開發者ID:vimerzhao,項目名稱:gchisto,代碼行數:18,代碼來源:MetricChartPanel.java

示例10: showChart

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
public void showChart() {
	/**
	 * Building chart datasets
	 */
	TimeSeriesCollection dataset = new TimeSeriesCollection();
	dataset.addSeries(
			buildChartTimeSeries(timeSeries, new ClosePriceIndicator(timeSeries), symbol));

	dataset.addSeries(
			buildChartTimeSeries(timeSeries, new EMAIndicator(new ClosePriceIndicator(timeSeries), 5), "EMA5"));
	
	dataset.addSeries(
			buildChartTimeSeries(timeSeries, new EMAIndicator(new ClosePriceIndicator(timeSeries), 10), "EMA10"));
	
	dataset.addSeries(
			buildChartTimeSeries(timeSeries, new EMAIndicator(new ClosePriceIndicator(timeSeries), 40), "EMA40"));
	
	/**
	 * Creating the chart
	 */
	JFreeChart chart = ChartFactory.createTimeSeriesChart("BTC", // title
			"Date", // x-axis label
			"Price", // y-axis label
			dataset, // data
			true, // create legend?
			true, // generate tooltips?
			false // generate URLs?
	);
	XYPlot plot = (XYPlot) chart.getPlot();
	DateAxis axis = (DateAxis) plot.getDomainAxis();
	axis.setDateFormatOverride(new SimpleDateFormat("MM-dd-yyyy HH:mm"));
	

	addBuySellSignals(timeSeries, strategy, plot);
	
	displayChart(chart);
}
 
開發者ID:jnidzwetzki,項目名稱:crypto-bot,代碼行數:38,代碼來源:Chart.java

示例11: setPlotBackgroundColor

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
private void setPlotBackgroundColor(Color backgroundColor) {
	JFreeChart chart = getCurrentChart();
	if (chart != null) {
		Plot plot = chart.getPlot();
		if (plot instanceof CategoryPlot) {
			CategoryPlot categoryPlot = (CategoryPlot) plot;
			categoryPlot.setBackgroundPaint(backgroundColor);
		} else {
			XYPlot xyPlot = (XYPlot) plot;
			xyPlot.setBackgroundPaint(backgroundColor);
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:14,代碼來源:JFreeChartPlotEngine.java

示例12: plotOrientationChanged

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
private void plotOrientationChanged(PlotOrientation orientation) {
	JFreeChart chart = getCurrentChart();
	if (chart != null) {
		Plot plot = chart.getPlot();
		if (plot instanceof CategoryPlot) {
			CategoryPlot categoryPlot = (CategoryPlot) plot;
			categoryPlot.setOrientation(orientation);
		} else if (plot instanceof XYPlot) {
			XYPlot xyPlot = (XYPlot) plot;
			xyPlot.setOrientation(orientation);
		}
	}

}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:15,代碼來源:JFreeChartPlotEngine.java

示例13: testFindRangeBounds

import org.jfree.chart.JFreeChart; //導入方法依賴的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();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:16,代碼來源:StackedXYAreaRendererTests.java

示例14: createPolarChart

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
private JFreeChart createPolarChart(final XYDataset dataset,String chartName) {
       if(chartName == null)
          chartName=FunctionToPlot;
        final JFreeChart chRt = ChartFactory.createPolarChart(
            chartName, dataset, true, true, false
        ); 
        final PolarPlot plot = (PolarPlot) chRt.getPlot();
        final DefaultPolarItemRenderer renderer = (DefaultPolarItemRenderer) plot.getRenderer();
        renderer.setShapesVisible(false);
//renderer.setShapesFilled(false);
       // renderer.setSeriesFilled(0, false);
        return chRt;
    }
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:14,代碼來源:plrPlt.java

示例15: TimeSeriesChart

import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
public TimeSeriesChart() {
    XYDataset xydataset = createDataset();
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General單位信托基金價格", "日期", "價格", xydataset, true, true, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    frame1 = new ChartPanel(jfreechart, true);
    dateaxis.setLabelFont(new Font("黑體", Font.BOLD, 14));         //水平底部標題
    dateaxis.setTickLabelFont(new Font("宋體", Font.BOLD, 12));  //垂直標題
    ValueAxis rangeAxis = xyplot.getRangeAxis();//獲取柱狀
    rangeAxis.setLabelFont(new Font("黑體", Font.BOLD, 15));
    jfreechart.getLegend().setItemFont(new Font("黑體", Font.BOLD, 15));
    jfreechart.getTitle().setFont(new Font("宋體", Font.BOLD, 20));//設置標題字體

}
 
開發者ID:leon66666,項目名稱:financehelper,代碼行數:16,代碼來源:TimeSeriesChart.java


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