当前位置: 首页>>代码示例>>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;未经允许,请勿转载。