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