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


Java XYDataset類代碼示例

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


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

示例1: createPolarChart

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Creates a polar plot for the specified dataset (x-values interpreted as 
 * angles in degrees).  The chart object returned by this method uses a 
 * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for 
 * the radial axis.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param legend  legend required?
 * @param tooltips  tooltips required?
 * @param urls  URLs required?
 *
 * @return A chart.
 */
public static JFreeChart createPolarChart(String title,
                                          XYDataset dataset,
                                          boolean legend,
                                          boolean tooltips,
                                          boolean urls) {

    PolarPlot plot = new PolarPlot();
    plot.setDataset(dataset);
    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAxisLineVisible(false);
    rangeAxis.setTickMarksVisible(false);
    rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setAxis(rangeAxis);
    plot.setRenderer(new DefaultPolarItemRenderer());
    JFreeChart chart = new JFreeChart(
            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;

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

示例2: setDataset

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Sets a dataset for the plot.
 *
 * @param index  the dataset index.
 * @param dataset  the dataset (<code>null</code> permitted).
 */
public void setDataset(int index, XYDataset dataset) {
    XYDataset existing = getDataset(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    this.datasets.set(index, dataset);
    if (dataset != null) {
        dataset.addChangeListener(this);
    }

    // map dataset to main axis by default
    if (index >= this.domainAxisMap.size()) {
        this.domainAxisMap.set(index, new Integer(0));
    }
    if (index >= this.rangeAxisMap.size()) {
        this.rangeAxisMap.set(index, new Integer(0));
    }

    // send a dataset change event to self...
    DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
    datasetChanged(event);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:XYPlot.java

示例3: findRangeBounds

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Returns the range of values the renderer requires to display all the 
 * items from the specified dataset.
 * 
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (or <code>null</code> if the dataset is 
 *         <code>null</code> or empty).
 */
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset, 
                d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:StackedXYAreaRenderer2.java

示例4: testPowerRegression1b

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Checks the results of a power regression on sample dataset 1 AFTER converting it to
 * an XYSeries.
 */
public void testPowerRegression1b() {

    final double[][] data = createSampleData1();

    final XYSeries series = new XYSeries("Test");
    for (int i = 0; i < 11; i++) {
        series.add(data[i][0], data[i][1]);
    }
    final XYDataset ds = new XYSeriesCollection(series);
    final double[] result = Regression.getPowerRegression(ds, 0);

    assertEquals(0.91045813, result[0], 0.0000001);
    assertEquals(0.88918346, result[1], 0.0000001);

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

示例5: createChart

import org.jfree.data.xy.XYDataset; //導入依賴的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

示例6: plotTradeBubblesOnChart

import org.jfree.data.xy.XYDataset; //導入依賴的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

示例7: createMovingAverage

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Creates a new {@link XYDataset} containing the moving averages of each series in the
 * <code>source</code> dataset.
 *
 * @param source  the source dataset.
 * @param suffix  the string to append to source series names to create target series names.
 * @param period  the averaging period.
 * @param skip  the length of the initial skip period.
 *
 * @return The dataset.
 */
public static XYDataset createMovingAverage(XYDataset source, String suffix,
                                            double period, double skip) {

    // check arguments
    if (source == null) {
        throw new IllegalArgumentException(
            "MovingAverage.createMovingAverage(...) : null source (XYDataset)."
        );
    }
    
    final XYSeriesCollection result = new XYSeriesCollection();

    for (int i = 0; i < source.getSeriesCount(); i++) {
        final XYSeries s = createMovingAverage(source, i, source.getSeriesName(i) + suffix,
                                         period, skip);
        result.addSeries(s);
    }

    return result;

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

示例8: testReplaceDataset

import org.jfree.data.xy.XYDataset; //導入依賴的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,代碼來源:XYStepAreaChartTests.java

示例9: KeySignatureGraph

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
public KeySignatureGraph(String title, int one, int two) {
	super(title);
	XYDataset dataset = null;
	try {
		dataset = createDataset(one, two);
	} 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(500, 370));
	setContentPane(chartPanel);
	this.pack();
	RefineryUtilities.centerFrameOnScreen(this);
	this.setVisible(true);
	setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
}
 
開發者ID:cyberheartmi9,項目名稱:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代碼行數:18,代碼來源:KeySignatureGraph.java

示例10: createChart

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

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createXYAreaChart(
        "Area Chart",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        true             // urls
    );

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

示例11: start

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
@Override 
public void start(Stage stage) throws Exception {
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    ChartCanvas canvas = new ChartCanvas(chart);
    StackPane stackPane = new StackPane(); 
    stackPane.getChildren().add(canvas);  
    // Bind canvas size to stack pane size. 
    canvas.widthProperty().bind( stackPane.widthProperty()); 
    canvas.heightProperty().bind( stackPane.heightProperty());  
    stage.setScene(new Scene(stackPane)); 
    stage.setTitle("FXGraphics2DDemo1.java"); 
    stage.setWidth(700);
    stage.setHeight(390);
    stage.show();
}
 
開發者ID:jfree,項目名稱:jfree-fxdemos,代碼行數:17,代碼來源:FXGraphics2DDemo1.java

示例12: start

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
@Override 
public void start(Stage stage) throws Exception {
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset); 
    ChartViewer viewer = new ChartViewer(chart);
    stage.setScene(new Scene(viewer)); 
    stage.setTitle("JFreeChart: TimeSeriesFXDemo1.java"); 
    stage.setWidth(700);
    stage.setHeight(390);
    stage.show();
}
 
開發者ID:jfree,項目名稱:jfree-fxdemos,代碼行數:12,代碼來源:TimeSeriesChartFXDemo1.java

示例13: findRangeBounds

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Returns the range of values in the range for the dataset.  This method
 * is the partner for the {@link #findDomainBounds(XYDataset)} method.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *                         y-interval is taken into account.
 * 
 *
 * @return The range (possibly <code>null</code>).
 */
public static Range findRangeBounds(XYDataset dataset, 
                                    boolean includeInterval) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    Range result = null;
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        result = info.getRangeBounds(includeInterval);
    }
    else {
        result = iterateXYRangeBounds(dataset);
    }
    return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:DatasetUtilities.java

示例14: createXYDataset1

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Creates a dataset for testing.
 * 
 * @return A dataset.
 */
private XYDataset createXYDataset1() {
    XYSeries series1 = new XYSeries("S1");
    series1.add(1.0, 100.0);
    series1.add(2.0, 101.0);
    series1.add(3.0, 102.0);
    XYSeries series2 = new XYSeries("S2");
    series2.add(1.0, 103.0);
    series2.add(2.0, null);
    series2.add(3.0, 105.0);
    XYSeriesCollection result = new XYSeriesCollection();
    result.addSeries(series1);
    result.addSeries(series2);
    result.setIntervalWidth(0.0);
    return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:DatasetUtilitiesTests.java

示例15: createPolarChart

import org.jfree.data.xy.XYDataset; //導入依賴的package包/類
/**
 * Creates a polar plot for the specified dataset (x-values interpreted as angles in degrees).
 * <P>
 * The chart object returned by this method uses a {@link PolarPlot} instance as the
 * plot, with a {@link NumberAxis} for the radial axis.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param legend  legend required?
 * @param tooltips  tooltips required?
 * @param urls  URLs required?
 *
 * @return A chart.
 */
public static JFreeChart createPolarChart(String title,
                                          XYDataset dataset,
                                          boolean legend,
                                          boolean tooltips,
                                          boolean urls) {

    PolarPlot plot = new PolarPlot();
    plot.setDataset(dataset);
    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAxisLineVisible(false);
    rangeAxis.setTickMarksVisible(false);
    rangeAxis.setTickLabelInsets(new Insets(0, 0, 0, 0));
    plot.setRadialAxis(rangeAxis);
    plot.setRenderer(new DefaultPolarItemRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;

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


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