当前位置: 首页>>代码示例>>Java>>正文


Java XYPlot类代码示例

本文整理汇总了Java中org.jfree.chart.plot.XYPlot的典型用法代码示例。如果您正苦于以下问题:Java XYPlot类的具体用法?Java XYPlot怎么用?Java XYPlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XYPlot类属于org.jfree.chart.plot包,在下文中一共展示了XYPlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createWindPlot

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Creates a wind plot with default settings.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the x-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag that controls whether or not a legend is created.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A wind plot.
 *
 */
public static JFreeChart createWindPlot(String title,
                                        String xAxisLabel,
                                        String yAxisLabel,
                                        WindDataset dataset,
                                        boolean legend,
                                        boolean tooltips,
                                        boolean urls) {

    ValueAxis xAxis = new DateAxis(xAxisLabel);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setRange(-12.0, 12.0);

    WindItemRenderer renderer = new WindItemRenderer();
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:40,代码来源:ChartFactory.java

示例2: linePlot

import org.jfree.chart.plot.XYPlot; //导入依赖的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

示例3: createCandlestickChart

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> 
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> 
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    return chart;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:ChartFactory.java

示例4: drawItem

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the plot is being drawn.
 * @param info  collects info about the drawing.
 * @param plot  the plot (can be used to obtain standard color 
 *              information etc).
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot 
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2, 
                     XYItemRendererState state,
                     Rectangle2D dataArea,
                     PlotRenderingInfo info,
                     XYPlot plot, 
                     ValueAxis domainAxis, 
                     ValueAxis rangeAxis,
                     XYDataset dataset, 
                     int series, 
                     int item,
                     CrosshairState crosshairState,
                     int pass) {

    PlotOrientation orientation = plot.getOrientation();

    if (orientation == PlotOrientation.HORIZONTAL) {
        drawHorizontalItem(g2, dataArea, info, plot, domainAxis, rangeAxis,
                dataset, series, item, crosshairState, pass);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        drawVerticalItem(g2, dataArea, info, plot, domainAxis, rangeAxis,
                dataset, series, item, crosshairState, pass);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:44,代码来源:XYBoxAndWhiskerRenderer.java

示例5: updateYFieldValue

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Updates the preselected y-value.
 */
private void updateYFieldValue() {
	// update preselected y value because range axis has been changed
	if (mousePosition != null) {
		Rectangle2D plotArea = engine.getChartPanel().getScreenDataArea();
		if (engine.getChartPanel().getChart().getPlot() instanceof XYPlot) {
			XYPlot plot = (XYPlot) engine.getChartPanel().getChart().getPlot();

			// calculate y value
			for (int i = 0; i < plot.getRangeAxisCount(); i++) {
				ValueAxis config = plot.getRangeAxis(i);
				if (config != null && config.getLabel() != null) {
					if (config.getLabel().equals(String.valueOf(rangeAxisSelectionCombobox.getSelectedItem()))) {
						double chartY = config.java2DToValue(mousePosition.getY(), plotArea, plot.getRangeAxisEdge());
						yField.setText(String.valueOf(chartY));
					}
				}
			}
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:AddParallelLineDialog.java

示例6: _getPointForCandlestick

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
private Point2D.Double _getPointForCandlestick(int plotIndex, int seriesIndex, int dataIndex) {
    final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
    final XYPlot plot = this.chartJDialog.getPlot(plotIndex);
    final ValueAxis domainAxis = plot.getDomainAxis();
    final RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    final RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();

    final org.jfree.data.xy.DefaultHighLowDataset defaultHighLowDataset = (org.jfree.data.xy.DefaultHighLowDataset)plot.getDataset(seriesIndex);

    if (dataIndex >= defaultHighLowDataset.getItemCount(0)) {
        /* Not ready yet. */
        return null;
    }

    final double xValue = defaultHighLowDataset.getXDate(0, dataIndex).getTime();
    final double yValue = defaultHighLowDataset.getCloseValue(0, dataIndex);
    final Rectangle2D plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(plotIndex).getDataArea();
    final double xJava2D = domainAxis.valueToJava2D(xValue, plotArea, domainAxisEdge);
    final double yJava2D = rangeAxis.valueToJava2D(yValue, plotArea, rangeAxisEdge);
    // Use Double version, to avoid from losing precision.
    return new Point2D.Double(xJava2D, yJava2D);
}
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:24,代码来源:ChartLayerUI.java

示例7: plotTradeBubblesOnChart

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
  {
  	final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
      final XYPlot plot = (XYPlot) main_plot;
      
  	final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
	switch(j)
	{
	case 0:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
		break;
	case 1:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
		break;
	case 2:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
		break;
	case 3:
		series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
		break;
	}
	
}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) 
{
          series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
      }
*/
XYDataset dataSet = new TimeSeriesCollection(series);

plot.setDataset(k, dataSet);
  	XYItemRenderer ir = new XYShapeRenderer();
  	//ir.s
  	
  	plot.setRenderer(k, ir);
  }
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:41,代码来源:ChartJDialog.java

示例8: drawItem

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Draws the visual representation of a single data item.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the area within which the data is being drawn.
 * @param info  collects information about the drawing.
 * @param plot  the plot (can be used to obtain standard color 
 *              information etc).
 * @param domainAxis  the domain (horizontal) axis.
 * @param rangeAxis  the range (vertical) axis.
 * @param dataset  the dataset.
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 * @param crosshairState  crosshair information for the plot 
 *                        (<code>null</code> permitted).
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2,
                     XYItemRendererState state,
                     Rectangle2D dataArea,
                     PlotRenderingInfo info,
                     XYPlot plot,
                     ValueAxis domainAxis,
                     ValueAxis rangeAxis,
                     XYDataset dataset,
                     int series,
                     int item,
                     CrosshairState crosshairState,
                     int pass) {

    if (pass == 0) {
        drawItemPass0(g2, dataArea, info, plot, domainAxis, rangeAxis, 
                dataset, series, item, crosshairState);
    }
    else if (pass == 1) {
        drawItemPass1(g2, dataArea, info, plot, domainAxis, rangeAxis, 
                dataset, series, item, crosshairState);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:42,代码来源:XYDifferenceRenderer.java

示例9: restrictValueToDataArea

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Helper method which returns a value if it lies
 * inside the visible dataArea and otherwise the corresponding
 * coordinate on the border of the dataArea. The PlotOrientation
 * is taken into account. 
 * Useful to avoid possible sun.dc.pr.PRException: endPath: bad path
 * which occurs when trying to draw lines/shapes which in large part
 * lie outside of the visible dataArea.
 * 
 * @param value the value which shall be 
 * @param dataArea  the area within which the data is being drawn.
 * @param plot  the plot (can be used to obtain standard color information etc).
 * @return <code>double</code> value inside the data area.
 */
protected static double restrictValueToDataArea(double value, 
                                                XYPlot plot, 
                                                Rectangle2D dataArea) {
    double min = 0;
    double max = 0;
    if (plot.getOrientation() == PlotOrientation.VERTICAL) {
        min = dataArea.getMinY();
        max = dataArea.getMaxY();
    } 
    else if (plot.getOrientation() ==  PlotOrientation.HORIZONTAL) {
        min = dataArea.getMinX();
        max = dataArea.getMaxX();
    }       
    if (value < min) {
        value = min;
    }
    else if (value > max) {
        value = max;
    }
    return value;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:XYStepAreaRenderer.java

示例10: createChart

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
private JFreeChart createChart(final XYDataset dataset) {
	final JFreeChart chart = ChartFactory.createXYLineChart(
			"MONA STORAGE GRAPH", "KeyGeneration per users ",
			"KeyGenerating size in Bytes", dataset,
			PlotOrientation.VERTICAL, true, true, false);
	chart.setBackgroundPaint(Color.white);
	final XYPlot plot1 = chart.getXYPlot();
	plot1.setBackgroundPaint(Color.lightGray);
	plot1.setDomainGridlinePaint(Color.white);
	plot1.setRangeGridlinePaint(Color.white);

	final XYPlot plot2 = chart.getXYPlot();
	plot2.setBackgroundPaint(Color.lightGray);
	plot2.setDomainGridlinePaint(Color.white);
	plot2.setRangeGridlinePaint(Color.white);

	final XYPlot plot3 = chart.getXYPlot();
	plot3.setBackgroundPaint(Color.lightGray);
	plot3.setDomainGridlinePaint(Color.white);
	plot3.setRangeGridlinePaint(Color.white);

	return chart;
}
 
开发者ID:cyberheartmi9,项目名称:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代码行数:24,代码来源:KeyStorageGraph.java

示例11: testReplaceDataset

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(10.0, 10.0);
    series1.add(20.0, 20.0);
    series1.add(30.0, 30.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    XYPlot plot = (XYPlot) this.chart.getPlot();
    plot.setDataset(dataset);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around 10: "
               + range.getLowerBound(), range.getLowerBound() <= 10);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:ScatterPlotTests.java

示例12: draw

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
/**
 * Draws the annotation.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis) {

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), 
                                                              orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), 
                                                            orientation);
    float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    Rectangle2D area = new Rectangle2D.Double(j2DX - this.width / 2.0,
                                              j2DY - this.height / 2.0,
                                              this.width, this.height);
    this.drawable.draw(g2, area);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:XYDrawableAnnotation.java

示例13: inicializacionJFreeChart

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
public void inicializacionJFreeChart(String title, String xAxisLabel, String yAxisLabel,
		                             PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {    	
    chart1 = ChartFactory.createXYLineChart(
    			title,      // chart title Titulo local del grafico
    			xAxisLabel,                      // x axis label
    			yAxisLabel,                      // y axis label
    			null,                  // data
    			orientation,
    			legend,                     // include legend
    			tooltips,                     // tooltips
    			urls                     // urls
            );        
    
    // get a reference to the plot for further customisation...
 XYPlot   plot = chart1.getXYPlot();
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:17,代码来源:VisualizacionJfreechart.java

示例14: createChart

import org.jfree.chart.plot.XYPlot; //导入依赖的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

示例15: addBuySellSignals

import org.jfree.chart.plot.XYPlot; //导入依赖的package包/类
private static void addBuySellSignals(TimeSeries series, Strategy strategy, XYPlot plot) {
	// Running the strategy
	TimeSeriesManager seriesManager = new TimeSeriesManager(series);
	List<Trade> trades = seriesManager.run(strategy).getTrades();
	// Adding markers to plot
	for (Trade trade : trades) {
		// Buy signal
		double buySignalTickTime = new Minute(
				Date.from(series.getTick(trade.getEntry().getIndex()).getEndTime().toInstant()))
						.getFirstMillisecond();
		Marker buyMarker = new ValueMarker(buySignalTickTime);
		buyMarker.setPaint(Color.GREEN);
		buyMarker.setLabel("B");
		plot.addDomainMarker(buyMarker);
		// Sell signal
		double sellSignalTickTime = new Minute(
				Date.from(series.getTick(trade.getExit().getIndex()).getEndTime().toInstant()))
						.getFirstMillisecond();
		Marker sellMarker = new ValueMarker(sellSignalTickTime);
		sellMarker.setPaint(Color.RED);
		sellMarker.setLabel("S");
		plot.addDomainMarker(sellMarker);
	}
}
 
开发者ID:jnidzwetzki,项目名称:crypto-bot,代码行数:25,代码来源:Chart.java


注:本文中的org.jfree.chart.plot.XYPlot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。