本文整理汇总了Java中org.jfree.data.time.TimeSeries.getItemCount方法的典型用法代码示例。如果您正苦于以下问题:Java TimeSeries.getItemCount方法的具体用法?Java TimeSeries.getItemCount怎么用?Java TimeSeries.getItemCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.time.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.getItemCount方法的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: getForecastData
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
public static TimeSeries getForecastData(TimeSeries observationData, int forcastperc) {
TimeSeries fcdataset = new TimeSeries("Time Series Forecast");
if (observationData.isEmpty() == true)
return fcdataset;
int size = observationData.getItemCount();
long fcsize = size + Math.round( (double)size * ((double)forcastperc/100)); // new data set
try {
fcdataset = observationData.createCopy(0,size-1);
for (int i=size; i < fcsize; i++) {
RegularTimePeriod nexttp = fcdataset.getNextTimePeriod();
fcdataset.add(nexttp,0.00D);
}
} catch (Exception e) {
System.out.println("Exception:" + e.getLocalizedMessage());
System.out.println("Could not create forecasted data sample");
return fcdataset;
}
return fcdataset;
}
示例3: addData
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/** Add a data item to the end of a series */
public void addData(String name, double value){
//System.out.println("TimeGraphPanel: Adding data " + name + "=" + value);
TimeSeries series = null;
if(hiddenSeries.containsKey(name))
series = hiddenSeries.get(name);
else{
TimeSeriesCollection dataset = (TimeSeriesCollection)chart.getXYPlot().getDataset(0);
int id = seriesIds.get(name);
series = dataset.getSeries(id);
}
if(series.getItemCount() == 0){
series.add(new Week(startTime), value);
}
else{
//System.out.println("TimeGraphPanel: seriesDescription = " + series.getDomainDescription());
series.add(series.getNextTimePeriod(), value);
}
}
示例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: calculateDifferenz
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Calculates difference between actual date and date the forecast ends (end of year). Is used for forecast.
*
* @param planned Timeperiod of forecast.
* @param is Timeperiod until real values exist.
* @return Returns number of time elements between the end of the two timeperiods.
*/
private double calculateDifferenz(TimeSeries planned,TimeSeries is){
double factor=0;
int invalidValues=0;
for(int i=0;i<is.getItemCount();i++){
if(planned.getItemCount()>i&&planned.getValue(i).doubleValue()!=0){
factor+=is.getValue(i).doubleValue()/planned.getValue(i).doubleValue();
}else{
invalidValues++;
}
}
if(is.getItemCount()!=0&&is.getItemCount()-invalidValues!=0){
factor/=(is.getItemCount()-invalidValues);
}else{
factor=1;
}
return factor;
}
示例6: getValue
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
private Number getValue(int plotIndex, int seriesIndex, int dataIndex) {
final TimeSeries timeSeries = this.getTimeSeries(plotIndex, seriesIndex);
if (timeSeries == null) {
return null;
}
if (dataIndex >= timeSeries.getItemCount()) {
/* Not ready yet. */
return null;
}
return timeSeries.getDataItem(dataIndex).getValue();
}
示例7: TimeSeriesBuilder
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Constructs a new TimeSeriesBuilder that reads its input from the given
* TimeSeries object. This builder defaults the of the independent, time
* variable to be the class name of the RegularTimePeriod used in the
* TimeSeries. For example, if a series of org.jfree.data.time.Day objects
* are used, then the name of the independent variable will default to
* "Day" (without the quotes).
*
* See the class description for more information.
* @param timeSeries the TimeSeries object containing data to be used to
* build the DataSet.
* @throws IllegalArgumentException if the TimeSeries is empty.
*/
public TimeSeriesBuilder( TimeSeries timeSeries )
{
if ( timeSeries.getItemCount() <= 0 )
throw new IllegalArgumentException("TimeSeries cannot be empty.");
this.timeSeries = timeSeries;
// Use base name of TimePeriod class, as name of time variable
RegularTimePeriod timePeriod = timeSeries.getTimePeriod(0);
String name = timePeriod.getClass().getName();
name = name.substring( name.lastIndexOf(".")+1 );
addVariable( name );
}
示例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;
}