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


Java XYSeriesCollection.setAutoWidth方法代碼示例

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


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

示例1: createXYSeriesCollection

import org.jfree.data.xy.XYSeriesCollection; //導入方法依賴的package包/類
/**
 * @param valueSource
 * @param plotInstance
 * @param autoWidthFraction
 *            If this value is greater than 0, an auto width for the intervals is calculated
 *            such that the intervals nearest to each other touch. This value is then multiplied
 *            with the value of autoWidthFtraction. If unset, the intervals have width 0.
 * @param allowDuplicates
 * @param sortByDomain
 *            if true, the data is sorted by domain values (useful for bar and area charts)
 * @return
 * @throws ChartPlottimeException
 */
public static XYSeriesCollection createXYSeriesCollection(ValueSource valueSource, PlotInstance plotInstance,
		double autoWidthFraction, boolean allowDuplicates, boolean sortByDomain) throws ChartPlottimeException {
	XYSeriesCollection xyDataset = new XYSeriesCollection();
	if (autoWidthFraction > 0) {
		xyDataset.setAutoWidth(true);
	} else {
		xyDataset.setAutoWidth(false);
		xyDataset.setIntervalWidth(0);
	}

	ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
	assertMaxValueCountNotExceededOrThrowException(valueSourceData);
	GroupCellSeriesData dataForAllGroupCells = valueSourceData.getSeriesDataForAllGroupCells();

	// Loop over group cells and add data to dataset
	for (GroupCellKeyAndData groupCellKeyAndData : dataForAllGroupCells) {
		GroupCellKey groupCellKey = groupCellKeyAndData.getKey();
		GroupCellData groupCellData = groupCellKeyAndData.getData();

		String seriesName = generateSeriesName(valueSource, groupCellKey,
				plotInstance.getCurrentPlotConfigurationClone());

		XYSeries series = new XYSeries(seriesName, sortByDomain, allowDuplicates);
		Map<PlotDimension, double[]> dataForUsageType = groupCellData.getDataForUsageType(SeriesUsageType.MAIN_SERIES);
		int rowCount = dataForUsageType.get(PlotDimension.DOMAIN).length;
		double[] xValues = dataForUsageType.get(PlotDimension.DOMAIN);
		double[] yValues = dataForUsageType.get(PlotDimension.VALUE);

		try {
			// Loop over rows and add data to series
			for (int row = 0; row < rowCount; ++row) {
				double x = xValues[row];
				double y = yValues[row];
				if (!Double.isNaN(x)) {
					series.add(x, y);
				}

			}
		} catch (SeriesException e) {
			throw new ChartPlottimeException("duplicate_value", valueSource.toString(), PlotDimension.DOMAIN.getName());
		}

		xyDataset.addSeries(series);
	}
	// intervals should not touch each other, so decrease auto width.
	if (xyDataset.getIntervalWidth() > 0) {
		xyDataset.setIntervalWidth(xyDataset.getIntervalWidth() * autoWidthFraction);
	}
	return xyDataset;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:64,代碼來源:ChartDatasetFactory.java


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