本文整理汇总了Java中org.jfree.data.time.TimeSeries.getDataItem方法的典型用法代码示例。如果您正苦于以下问题:Java TimeSeries.getDataItem方法的具体用法?Java TimeSeries.getDataItem怎么用?Java TimeSeries.getDataItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.time.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.getDataItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataIndex
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
private int getDataIndex(TimeSeries timeSeries, Day targetDay) {
int low = 0;
int high = timeSeries.getItemCount() - 1;
while (low <= high) {
int mid = (low + high) >>> 1;
final TimeSeriesDataItem timeSeriesDataItem = timeSeries.getDataItem(mid);
final Day searchDay = (Day)timeSeriesDataItem.getPeriod();
final long cmp = searchDay.compareTo(targetDay);
if (cmp < 0) {
low = mid + 1;
}
else if (cmp > 0) {
high = mid - 1;
}
else {
return mid;
}
}
return -1;
}
示例2: testSetMaximumItemCount
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Test the setMaximumItemCount() method to ensure that it removes items from the series
* if necessary.
*/
public void testSetMaximumItemCount() {
TimeSeries s1 = new TimeSeries("S1", Year.class);
s1.add(new Year(2000), 13.75);
s1.add(new Year(2001), 11.90);
s1.add(new Year(2002), null);
s1.add(new Year(2005), 19.32);
s1.add(new Year(2007), 16.89);
assertTrue(s1.getItemCount() == 5);
s1.setMaximumItemCount(3);
assertTrue(s1.getItemCount() == 3);
TimeSeriesDataItem item = s1.getDataItem(0);
assertTrue(item.getPeriod().equals(new Year(2002)));
}
示例3: testSetMaximumItemCount
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Test the setMaximumItemCount() method to ensure that it removes items
* from the series if necessary.
*/
public void testSetMaximumItemCount() {
TimeSeries s1 = new TimeSeries("S1", Year.class);
s1.add(new Year(2000), 13.75);
s1.add(new Year(2001), 11.90);
s1.add(new Year(2002), null);
s1.add(new Year(2005), 19.32);
s1.add(new Year(2007), 16.89);
assertTrue(s1.getItemCount() == 5);
s1.setMaximumItemCount(3);
assertTrue(s1.getItemCount() == 3);
TimeSeriesDataItem item = s1.getDataItem(0);
assertTrue(item.getPeriod().equals(new Year(2002)));
}
示例4: getDataSet
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* A helper function to convert data points (from startIndex to
* endIndex) of a (JFreeChart) TimeSeries object into an
* OpenForecast DataSet.
* @param series the series of data points stored as a JFreeChart
* TimeSeries object.
* @param startIndex the index of the first data point required from the
* series.
* @param endIndex the index of the last data point required from the
* series.
* @return an OpenForecast DataSet representing the data points extracted
* from the TimeSeries.
*/
private DataSet getDataSet( TimeSeries series,
int startIndex, int endIndex )
{
DataSet dataSet = new DataSet();
if ( endIndex > series.getItemCount() )
endIndex = series.getItemCount();
for ( int i=startIndex; i<endIndex; i++ )
{
TimeSeriesDataItem dataPair = series.getDataItem(i);
DataPoint dp = new Observation( dataPair.getValue().doubleValue() );
dp.setIndependentValue( "t", i );
dataSet.add( dp );
}
return dataSet;
}
示例5: testSetMaximumItemCount
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Test the setMaximumItemCount() method to ensure that it removes items
* from the series if necessary.
*/
public void testSetMaximumItemCount() {
TimeSeries s1 = new TimeSeries("S1");
s1.add(new Year(2000), 13.75);
s1.add(new Year(2001), 11.90);
s1.add(new Year(2002), null);
s1.add(new Year(2005), 19.32);
s1.add(new Year(2007), 16.89);
assertTrue(s1.getItemCount() == 5);
s1.setMaximumItemCount(3);
assertTrue(s1.getItemCount() == 3);
TimeSeriesDataItem item = s1.getDataItem(0);
assertTrue(item.getPeriod().equals(new Year(2002)));
assertEquals(16.89, s1.getMinY(), EPSILON);
assertEquals(19.32, s1.getMaxY(), EPSILON);
}
示例6: testGetDataItem2
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Some checks for the getDataItem(RegularTimePeriod) method.
*/
public void testGetDataItem2() {
TimeSeries series = new TimeSeries("S", Year.class);
assertNull(series.getDataItem(new Year(2006)));
// try a null argument
boolean pass = false;
try {
/* TimeSeriesDataItem item = */ series.getDataItem(null);
}
catch (IllegalArgumentException e) {
pass = true;
}
assertTrue(pass);
}
示例7: testGetDataItem2
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Some checks for the getDataItem(RegularTimePeriod) method.
*/
public void testGetDataItem2() {
TimeSeries series = new TimeSeries("S");
assertNull(series.getDataItem(new Year(2006)));
// try a null argument
boolean pass = false;
try {
/* TimeSeriesDataItem item = */ series.getDataItem(null);
}
catch (IllegalArgumentException e) {
pass = true;
}
assertTrue(pass);
}
示例8: createDataset
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/** Create the dataset used for the plot. */
private TimeTableXYDataset createDataset() {
TimeTableXYDataset dataset = new TimeTableXYDataset();
for (SeriesDescriptor seriesDesriptor : seriesList) {
String seriesTitle = seriesDesriptor.seriesTitle;
TimeSeries timeSeries = createTimeSeries(seriesTitle,
seriesDesriptor.series);
for (int i = 0; i < timeSeries.getItemCount(); ++i) {
TimeSeriesDataItem di = timeSeries.getDataItem(i);
dataset.add(di.getPeriod(), di.getValue().doubleValue(),
seriesTitle);
}
}
return dataset;
}
示例9: validate
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
@Override
public TimeSeries validate(TimeSeries timeSeries, String sourceName, TimeSeriesType type) throws ParseException {
String qualifiedSourceName = createQualifiedSourcename(sourceName, type);
final Symbol symbol = namespace.resolveSymbol(qualifiedSourceName);
if (symbol == null) {
throw new ParseException("No variable for identifier '" + qualifiedSourceName + "' registered.");
}
final String expression = getExpressionFor(qualifiedSourceName);
if (expression == null || expression.trim().isEmpty()) {
return timeSeries;
}
final Variable variable = (Variable) symbol;
final Term term = parser.parse(expression, namespace);
final int seriesCount = timeSeries.getItemCount();
final TimeSeries validatedSeries = new TimeSeries(timeSeries.getKey());
for (int i = 0; i < seriesCount; i++) {
final TimeSeriesDataItem dataItem = timeSeries.getDataItem(i);
final Number value = dataItem.getValue();
variable.assignD(null, value.doubleValue());
if (term.evalB(null)) {
validatedSeries.add(dataItem);
}
}
return validatedSeries;
}