本文整理汇总了Java中org.jfree.data.time.TimeSeriesDataItem类的典型用法代码示例。如果您正苦于以下问题:Java TimeSeriesDataItem类的具体用法?Java TimeSeriesDataItem怎么用?Java TimeSeriesDataItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeSeriesDataItem类属于org.jfree.data.time包,在下文中一共展示了TimeSeriesDataItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSeries
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
@Override
public void addSeries(agentgui.ontology.DataSeries series){
org.jfree.data.time.TimeSeries newSeries = new org.jfree.data.time.TimeSeries(series.getLabel());
List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs();
for (int i = 0; i < valuePairs.size(); i++) {
TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i);
Simple_Long simpleLong = valuePair.getTimestamp();
Simple_Float simpleFloat = valuePair.getValue();
Long timeStampLong = simpleLong.getLongValue();
Float floatValue = simpleFloat.getFloatValue();
if (timeStampLong!=null) {
TimeSeriesDataItem newItem = new TimeSeriesDataItem(new FixedMillisecond(timeStampLong), floatValue);
newSeries.addOrUpdate(newItem);
}
}
this.getTimeSeriesCollection().addSeries(newSeries);
this.setChanged();
this.notifyObservers(ChartModel.EventType.SERIES_ADDED);
}
示例2: updateKey
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
/**
* Update the time stamp in all series that contain it
* @param oldKey The old time stamp
* @param newKey The new time stamp
*/
public void updateKey(Number oldKey, Number newKey) {
// --- Iterate over all series ------------------------------
for (int i=0; i < this.getSeriesCount(); i++) {
org.jfree.data.time.TimeSeries series = this.getSeries(i);
// Try to find a value pair with the old time stamp
TimeSeriesDataItem oldValuePair = series.getDataItem(new FixedMillisecond(oldKey.longValue()));
// If found, remove it and add a new one with the new time stamp and the old value
if(oldValuePair != null){
series.delete(new FixedMillisecond(oldKey.longValue()));
series.addOrUpdate(new FixedMillisecond(newKey.longValue()), oldValuePair.getValue());
}
}
}
示例3: editSeriesAddData
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
/**
* Edits the data series by adding data.
* @param series the series
* @param targetDataSeriesIndex the target data series index
*/
public void editSeriesAddData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException {
if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) {
// --- Get the series -------------------------
org.jfree.data.time.TimeSeries addToSeries = (org.jfree.data.time.TimeSeries) this.getSeries(targetDataSeriesIndex);
List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs();
for (int i = 0; i < valuePairs.size(); i++) {
TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i);
Simple_Long simpleLong = valuePair.getTimestamp();
Simple_Float simpleFloat = valuePair.getValue();
Long timeStampLong = simpleLong.getLongValue();
Float floatValue = simpleFloat.getFloatValue();
if (timeStampLong!=null) {
TimeSeriesDataItem newItem = new TimeSeriesDataItem(new FixedMillisecond(timeStampLong), floatValue);
addToSeries.addOrUpdate(newItem);
}
}
} else {
throw new NoSuchSeriesException();
}
}
示例4: editSeriesAddOrExchangeData
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
/**
* Edits the data series by adding or exchanging data.
* @param series the series
* @param targetDataSeriesIndex the target data series index
*/
public void editSeriesAddOrExchangeData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException {
if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) {
org.jfree.data.time.TimeSeries addToSeries = (org.jfree.data.time.TimeSeries) this.getSeries(targetDataSeriesIndex);
List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs();
for (int i = 0; i < valuePairs.size(); i++) {
TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i);
Simple_Long simpleLong = valuePair.getTimestamp();
Simple_Float simpleFloat = valuePair.getValue();
Long timeStampLong = simpleLong.getLongValue();
Float floatValue = simpleFloat.getFloatValue();
if (timeStampLong!=null) {
TimeSeriesDataItem newItem = new TimeSeriesDataItem(new FixedMillisecond(timeStampLong), floatValue);
addToSeries.addOrUpdate(newItem);
}
}
} else {
throw new NoSuchSeriesException();
}
}
示例5: getDataIndex
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的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;
}
示例6: testSetMaximumItemCount
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的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)));
}
示例7: testEquals
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
/**
* Test the equals() method.
*/
public void testEquals() {
TimeSeriesDataItem item1 = new TimeSeriesDataItem(
new Day(23, 9, 2001), 99.7
);
TimeSeriesDataItem item2 = new TimeSeriesDataItem(
new Day(23, 9, 2001), 99.7
);
assertTrue(item1.equals(item2));
assertTrue(item2.equals(item1));
item1.setValue(new Integer(5));
assertFalse(item1.equals(item2));
item2.setValue(new Integer(5));
assertTrue(item1.equals(item2));
}
示例8: testSetMaximumItemCount
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的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)));
}
示例9: add
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
public void add(final CalendarDateSeries<?> aSeries) {
final String tmpName = aSeries.getName();
final TimeSeries tmpSeries = new TimeSeries(tmpName);
for (final Entry<CalendarDate, ? extends Number> tmpEntry : aSeries.entrySet()) {
final CalendarDate tmpKey = tmpEntry.getKey();
final FixedMillisecond tmpPeriod = new FixedMillisecond(tmpKey.millis);
final Number tmpValue = tmpEntry.getValue();
final TimeSeriesDataItem tmpItem = new TimeSeriesDataItem(tmpPeriod, tmpValue);
tmpSeries.add(tmpItem);
}
myCollection.addSeries(tmpSeries);
ColourData tmpColour2 = aSeries.getColour();
if (tmpColour2 == null) {
tmpColour2 = ColourData.random();
aSeries.colour(tmpColour2);
}
final int tmpRgb = tmpColour2.getRGB();
final Color tmpColour = new Color(tmpRgb);
this.putColour(tmpName, tmpColour);
}
示例10: output
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
/**
* Outputs the given DataPoint to the current TimeSeries.
* @param dataPoint the DataPoint to output to the current TimeSeries.
*/
private void output( DataPoint dataPoint, String timeVariable )
throws InstantiationException, IllegalAccessException,
InvocationTargetException, InstantiationException
{
long timeValue = (long)dataPoint.getIndependentValue(timeVariable);
Object[] args = new Object[1];
args[0] = new Date( timeValue );
RegularTimePeriod period
= (RegularTimePeriod)timePeriodConstructor.newInstance(args);
double value = dataPoint.getDependentValue();
timeSeries.add( new TimeSeriesDataItem(period,value) );
}
示例11: getDataSet
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的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;
}
示例12: testEquals
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
/**
* Test the equals() method.
*/
public void testEquals() {
TimeSeriesDataItem item1 = new TimeSeriesDataItem(
new Day(23, 9, 2001), 99.7
);
TimeSeriesDataItem item2 = new TimeSeriesDataItem(
new Day(23, 9, 2001), 99.7
);
assertTrue(item1.equals(item2));
assertTrue(item2.equals(item1));
item1.setValue(new Integer(5));
assertFalse(item1.equals(item2));
item2.setValue(new Integer(5));
assertTrue(item1.equals(item2));
}
示例13: testSetMaximumItemCount
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的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);
}
示例14: testAddOrUpdate4
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
/**
* Some more checks for the addOrUpdate() method.
*/
public void testAddOrUpdate4() {
TimeSeries ts = new TimeSeries("S");
TimeSeriesDataItem overwritten = ts.addOrUpdate(new Year(2009), 20.09);
assertNull(overwritten);
overwritten = ts.addOrUpdate(new Year(2009), 1.0);
assertEquals(new Double(20.09), overwritten.getValue());
assertEquals(new Double(1.0), ts.getValue(new Year(2009)));
// changing the overwritten record shouldn't affect the series
overwritten.setValue(null);
assertEquals(new Double(1.0), ts.getValue(new Year(2009)));
TimeSeriesDataItem item = new TimeSeriesDataItem(new Year(2010), 20.10);
overwritten = ts.addOrUpdate(item);
assertNull(overwritten);
assertEquals(new Double(20.10), ts.getValue(new Year(2010)));
// changing the item that was added should not change the series
item.setValue(null);
assertEquals(new Double(20.10), ts.getValue(new Year(2010)));
}
示例15: buildBarTimeSeries
import org.jfree.data.time.TimeSeriesDataItem; //导入依赖的package包/类
@Override
public TimeSeries buildBarTimeSeries(String serieName, SortedMap<Date, BarChart> barSerie, TimeSeries lineSerie) {
TimeSeries timeSerie = new TimeSeries(serieName);
int cpt = 0;
//int gap = Math.max(1, barSerie.size()/208);
int gap = 1;
for (Date date : barSerie.keySet()) {
if (cpt % gap == 0) {
RegularTimePeriod period = new Day(date);
Number value = barSerie.get(date).getValue();
TimeSeriesDataItem item = new TimeSeriesDataItem(period, value);
timeSerie.add(item, false);
}
cpt++;
}
return timeSerie;
}