本文整理汇总了Java中org.jfree.data.time.TimeSeries.add方法的典型用法代码示例。如果您正苦于以下问题:Java TimeSeries.add方法的具体用法?Java TimeSeries.add怎么用?Java TimeSeries.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.time.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTimeseries
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
public static TimeSeries createTimeseries(String category, Vector<Object[]> dateValues) {
TimeSeries timeseries = new TimeSeries(category);
if (dateValues != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (Object[] objects : dateValues) {
Date date = null;
try {
date = dateFormat.parse(objects[0].toString());
} catch (ParseException e) {
}
String sValue = objects[1].toString();
double dValue = 0;
if (date != null && isNumber(sValue)) {
dValue = Double.parseDouble(sValue);
timeseries.add(new Day(date), dValue);
}
}
}
return timeseries;
}
示例2: testSerialization4
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Serialize a time seroes chart, restore it, and check for equality.
*/
@Test
public void testSerialization4() {
RegularTimePeriod t = new Day();
TimeSeries series = new TimeSeries("Series 1");
series.add(t, 36.4);
t = t.next();
series.add(t, 63.5);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
"Value", dataset);
JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
assertEquals(c1, c2);
}
示例3: createDataset1
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Creates a sample dataset.
*
* @return Series 1.
*/
private IntervalXYDataset createDataset1() {
// create dataset 1...
TimeSeries series1 = new TimeSeries("Series 1", Day.class);
series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);
TimeSeriesCollection collection = new TimeSeriesCollection(series1);
return collection;
}
示例4: plotTradeBubblesOnChart
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
{
final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
final XYPlot plot = (XYPlot) main_plot;
final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
switch(j)
{
case 0:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
break;
case 1:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
break;
case 2:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
break;
case 3:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
break;
}
}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++)
{
series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
}
*/
XYDataset dataSet = new TimeSeriesCollection(series);
plot.setDataset(k, dataSet);
XYItemRenderer ir = new XYShapeRenderer();
//ir.s
plot.setRenderer(k, ir);
}
示例5: createDailyTimeSeries1
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Creates a sample series.
*
* @return A sample series.
*/
private TimeSeries createDailyTimeSeries1() {
TimeSeries series = new TimeSeries("Series 1", Day.class);
series.add(new Day(11, MonthConstants.AUGUST, 2003), 11.2);
series.add(new Day(13, MonthConstants.AUGUST, 2003), 13.8);
series.add(new Day(17, MonthConstants.AUGUST, 2003), 14.1);
series.add(new Day(18, MonthConstants.AUGUST, 2003), 12.7);
series.add(new Day(19, MonthConstants.AUGUST, 2003), 16.5);
series.add(new Day(20, MonthConstants.AUGUST, 2003), 15.6);
series.add(new Day(25, MonthConstants.AUGUST, 2003), 19.8);
series.add(new Day(27, MonthConstants.AUGUST, 2003), 10.7);
series.add(new Day(28, MonthConstants.AUGUST, 2003), 14.3);
return series;
}
示例6: createDataset
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
private XYDataset createDataset(List<String> industrys) {
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
if (industrys != null) {
for (String industry : industrys) {
TimeSeries timeseries = new TimeSeries(industry + "涨跌统计",
org.jfree.data.time.Day.class);
List<IndustryInfo> industryInfos = industryInfoDao.get(industry);
BigDecimal value = new BigDecimal(0);
if (industryInfos != null) {
for (IndustryInfo industryInfo : industryInfos) {
if (industryInfo.getRise() != null) {
value = value.add(industryInfo.getRise());
}
timeseries.add(new Day(DateUtil.parse(String.valueOf(industryInfo.getDate()), DateUtil.DATE_FORMAT_DAY_SHORT)), value);
}
}
timeseriescollection.addSeries(timeseries);
}
}
return timeseriescollection;
}
示例7: 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)));
}
示例8: add
import org.jfree.data.time.TimeSeries; //导入方法依赖的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);
}
示例9: createDataset
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Creates a sample dataset.
*
* @param name the dataset name.
* @param base the starting value.
* @param start the starting period.
* @param count the number of values to generate.
*
* @return The dataset.
*/
private static XYDataset createDataset(String name, double base,
RegularTimePeriod start, int count) {
TimeSeries series = new TimeSeries(name);
RegularTimePeriod period = start;
double value = base;
for (int i = 0; i < count; i++) {
series.add(period, value);
period = period.next();
value = value * (1 + (Math.random() - 0.495) / 10.0);
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
return dataset;
}
示例10: testSerialization4
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Serialize a time seroes chart, restore it, and check for equality.
*/
@Test
public void testSerialization4() {
RegularTimePeriod t = new Day();
TimeSeries series = new TimeSeries("Series 1");
series.add(t, 36.4);
t = t.next();
series.add(t, 63.5);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
"Value", dataset);
JFreeChart c2 = (JFreeChart) TestUtils.serialised(c1);
assertEquals(c1, c2);
}
示例11: createDataset1
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Creates a sample dataset.
*
* @return Series 1.
*/
private IntervalXYDataset createDataset1() {
// create dataset 1...
TimeSeries series1 = new TimeSeries("Series 1");
series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);
TimeSeriesCollection collection = new TimeSeriesCollection(series1);
return collection;
}
示例12: 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;
}
示例13: createDatasetNumberRequestsTampered
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
private IntervalXYDataset createDatasetNumberRequestsTampered()
{
Date currentDate;
long currentMsTs;
final TimeSeries series = new TimeSeries( "Sent Tampered Requests per Second" );
if ( model.getMapLogEntryIntervalTampered() != null )
{
for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalTampered().entrySet() )
{
// Create TS from model.startTime and log.getIntervalNumber();
currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber();
currentDate = new Date( currentMsTs );
series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) );
}
}
final TimeSeriesCollection dataset = new TimeSeriesCollection( series );
dataset.setXPosition( TimePeriodAnchor.MIDDLE );
return dataset;
}
示例14: 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);
}
}
示例15: testGetIndex
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Some checks for the getIndex() method.
*/
public void testGetIndex() {
TimeSeries series = new TimeSeries("Series");
assertEquals(-1, series.getIndex(new Month(1, 2003)));
series.add(new Month(1, 2003), 45.0);
assertEquals(0, series.getIndex(new Month(1, 2003)));
assertEquals(-1, series.getIndex(new Month(12, 2002)));
assertEquals(-2, series.getIndex(new Month(2, 2003)));
series.add(new Month(3, 2003), 55.0);
assertEquals(-1, series.getIndex(new Month(12, 2002)));
assertEquals(0, series.getIndex(new Month(1, 2003)));
assertEquals(-2, series.getIndex(new Month(2, 2003)));
assertEquals(1, series.getIndex(new Month(3, 2003)));
assertEquals(-3, series.getIndex(new Month(4, 2003)));
}