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