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


Java XYPlot.getDataset方法代碼示例

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


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

示例1: _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

示例2: pushDataAndRendererIntoPlot

import org.jfree.chart.plot.XYPlot; //導入方法依賴的package包/類
private void pushDataAndRendererIntoPlot(XYPlot plot, int rangeAxisIdx, XYItemRenderer renderer, XYDataset dataset)
		throws ChartPlottimeException {
	if (dataset != null && renderer != null) {
		int datasetIdx = plot.getDatasetCount();
		if (datasetIdx > 0 && plot.getDataset(datasetIdx - 1) == null) {
			datasetIdx -= 1;
		}
		// push dataset and renderer into plot
		try {
			plot.setDataset(datasetIdx, dataset); // if Eclipse states that
													// dataset might not be
													// initialized, you did
													// not consider all
													// possibilities in the
													// condition block above
		} catch (RuntimeException e) {
			// probably this is because the domain axis contains values less
			// then zero and the scaling is logarithmic.
			// The shitty JFreeChart implementation does not throw a proper
			// exception stating what happened,
			// but just a RuntimeException with a string, so this is our
			// best guess:
			if (isProbablyZeroValuesOnLogScaleException(e)) {
				throw new ChartPlottimeException("gui.plotter.error.log_axis_contains_zero", "domain axis");
			} else {
				throw e;
			}
		}
		plot.mapDatasetToRangeAxis(datasetIdx, rangeAxisIdx);
		plot.setRenderer(datasetIdx, renderer);
	} else {
		ChartPlottimeException chartPlottimeException = new ChartPlottimeException(new PlotConfigurationError(
				"generic_plotter_error"));
		throw chartPlottimeException;
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:37,代碼來源:JFreeChartPlotEngine.java

示例3: _updateMainTraceInfoForCandlestick

import org.jfree.chart.plot.XYPlot; //導入方法依賴的package包/類
private boolean _updateMainTraceInfoForCandlestick(Point2D point) {
    if (point == null) {
        return false;
    }

    final ChartPanel chartPanel = this.chartJDialog.getChartPanel();
    // Top most plot.
    final XYPlot plot = this.chartJDialog.getPlot();

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

    // I also not sure why. This is what are being done in Mouse Listener Demo 4.
    //
    // Don't use it. It will cause us to lose precision.
    //final Point2D p2 = chartPanel.translateScreenToJava2D((Point)point);

    /* Try to get correct main chart area. */
    final Rectangle2D _plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();

    final ValueAxis domainAxis = plot.getDomainAxis();
    final RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    final RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();
    // Don't use it. It will cause us to lose precision.
    //final double coordinateX = domainAxis.java2DToValue(p2.getX(), _plotArea,
    //        domainAxisEdge);
    final double coordinateX = domainAxis.java2DToValue(point.getX(), _plotArea,
            domainAxisEdge);
    //double coordinateY = rangeAxis.java2DToValue(mousePoint2.getY(), plotArea,
    //        rangeAxisEdge);

    int low = 0;
    int high = defaultHighLowDataset.getItemCount(0) - 1;
    Date date = new Date((long)coordinateX);
    final long time = date.getTime();
    long bestDistance = Long.MAX_VALUE;
    int bestMid = 0;

    while (low <= high) {
        int mid = (low + high) >>> 1;

        final Date d = defaultHighLowDataset.getXDate(0, mid);
        final long search = d.getTime();
        final long cmp = search - time;

        if (cmp < 0) {
            low = mid + 1;
        }
        else if (cmp > 0) {
            high = mid - 1;
        }
        else {
            bestDistance = 0;
            bestMid = mid;
            break;
        }

        final long abs_cmp = Math.abs(cmp);
        if (abs_cmp < bestDistance) {
            bestDistance = abs_cmp;
            bestMid = mid;
        }
    }

    final double xValue = defaultHighLowDataset.getXDate(0, bestMid).getTime();
    final double yValue = defaultHighLowDataset.getCloseValue(0, bestMid);
    final double xJava2D = domainAxis.valueToJava2D(xValue, _plotArea, domainAxisEdge);
    final double yJava2D = rangeAxis.valueToJava2D(yValue, _plotArea, rangeAxisEdge);

    final int tmpIndex = bestMid;
    // translateJava2DToScreen will internally convert Point2D.Double to Point.
    final Point2D tmpPoint = chartPanel.translateJava2DToScreen(new Point2D.Double(xJava2D, yJava2D));
    this.mainDrawArea.setRect(_plotArea);

    if (this.mainDrawArea.contains(tmpPoint)) {
        // 0 indicates main plot.
        this.mainTraceInfo = TraceInfo.newInstance(tmpPoint, 0, 0, tmpIndex);
        return true;
    }
    return false;
}
 
開發者ID:lead4good,項目名稱:open-java-trade-manager,代碼行數:82,代碼來源:ChartLayerUI.java


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