本文整理汇总了Java中org.jfree.data.xy.XYDataItem.getYValue方法的典型用法代码示例。如果您正苦于以下问题:Java XYDataItem.getYValue方法的具体用法?Java XYDataItem.getYValue怎么用?Java XYDataItem.getYValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.xy.XYDataItem
的用法示例。
在下文中一共展示了XYDataItem.getYValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeRegressionData
import org.jfree.data.xy.XYDataItem; //导入方法依赖的package包/类
private XYIntervalSeries computeRegressionData(double xStart, double xEnd) {
if (scatterpointsDataset.getItemCount(0) > 1) {
final double[] coefficients = Regression.getOLSRegression(scatterpointsDataset, 0);
final Function2D curve = new LineFunction2D(coefficients[0], coefficients[1]);
final XYSeries regressionData = DatasetUtilities.sampleFunction2DToSeries(curve, xStart, xEnd, 100, "regression line");
final XYIntervalSeries xyIntervalRegression = new XYIntervalSeries(regressionData.getKey());
for (int i = 0; i < regressionData.getItemCount(); i++) {
XYDataItem item = regressionData.getDataItem(i);
final double x = item.getXValue();
final double y = item.getYValue();
xyIntervalRegression.add(x, x, x, y, y, y);
}
return xyIntervalRegression;
} else {
Dialogs.showInformation("Unable to compute regression line.\n" +
"At least 2 values are needed to compute regression coefficients.");
return null;
}
}
示例2: getValueAt
import org.jfree.data.xy.XYDataItem; //导入方法依赖的package包/类
@Override
public Double getValueAt(final Dataset dataset, final int index,
final double tNow, NumberAxis rangeA)
{
final XYSeriesCollection tsc = (XYSeriesCollection) dataset;
final XYSeries series = tsc.getSeries(index);
@SuppressWarnings("unchecked")
final List<XYDataItem> items = series.getItems();
// ok, get ready to interpolate the value
Double previousY = null;
Double nextY = null;
Double previousX = null;
Double nextX = null;
// loop through the data
for (final XYDataItem thisItem : items)
{
// does this class as a previous value?
if (thisItem.getX().doubleValue() < tNow)
{
// ok, it's before use the previous
previousY = thisItem.getYValue();
previousX = thisItem.getXValue();
}
else
{
// ok, we've passed it. stop
nextY = thisItem.getYValue();
nextX = thisItem.getXValue();
break;
}
}
// have we found values?
final Double interpolated;
if (previousY != null && nextY != null)
{
// ok, interpolate the time (X)
final double proportion = (tNow - previousX) / (nextX - previousX);
// ok, now generate interpolate the value to use
interpolated = previousY + proportion * (nextY - previousY);
}
else
{
interpolated = null;
}
return interpolated;
}