當前位置: 首頁>>代碼示例>>Java>>正文


Java TimeSeries類代碼示例

本文整理匯總了Java中org.jfree.data.time.TimeSeries的典型用法代碼示例。如果您正苦於以下問題:Java TimeSeries類的具體用法?Java TimeSeries怎麽用?Java TimeSeries使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TimeSeries類屬於org.jfree.data.time包,在下文中一共展示了TimeSeries類的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;
}
 
開發者ID:Fanping,項目名稱:iveely.ml,代碼行數:23,代碼來源:ChartUtils.java

示例2: 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;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:XYPlotTests.java

示例3: 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);
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:20,代碼來源:JFreeChartTest.java

示例4: addSeries

import org.jfree.data.time.TimeSeries; //導入依賴的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);
	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:26,代碼來源:TimeSeriesChartModel.java

示例5: updateKey

import org.jfree.data.time.TimeSeries; //導入依賴的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());
		}
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:23,代碼來源:TimeSeriesChartModel.java

示例6: editSeriesAddData

import org.jfree.data.time.TimeSeries; //導入依賴的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();
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:29,代碼來源:TimeSeriesChartModel.java

示例7: editSeriesAddOrExchangeData

import org.jfree.data.time.TimeSeries; //導入依賴的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();			
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:28,代碼來源:TimeSeriesChartModel.java

示例8: editSeriesExchangeData

import org.jfree.data.time.TimeSeries; //導入依賴的package包/類
/**
 * Edits the data series by exchanging data.
 * @param series the series
 * @param targetDataSeriesIndex the target data series index
 */
public void editSeriesExchangeData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException {

	if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) {
		org.jfree.data.time.TimeSeries exchangeSeries = (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) {
				try {
					exchangeSeries.update(new FixedMillisecond(timeStampLong), floatValue);
				} catch (SeriesException se) {
					// --- Nothing to do here, just take the next value ---
				}
			}
		}

	} else {
		throw new NoSuchSeriesException();			
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:31,代碼來源:TimeSeriesChartModel.java

示例9: editSeriesRemoveData

import org.jfree.data.time.TimeSeries; //導入依賴的package包/類
/**
 * Edits the data series by remove data.
 * @param series the series
 * @param targetDataSeriesIndex the target data series index
 */
public void editSeriesRemoveData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException {

	if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) {
		org.jfree.data.time.TimeSeries removeSeries = (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();
			Long timeStampLong = simpleLong.getLongValue();
			if (timeStampLong!=null) {
				removeSeries.delete(new FixedMillisecond(timeStampLong));
			}
		}

	} else {
		throw new NoSuchSeriesException();			
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:24,代碼來源:TimeSeriesChartModel.java

示例10: 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;
}
 
開發者ID:lead4good,項目名稱:open-java-trade-manager,代碼行數:24,代碼來源:ChartLayerUI.java

示例11: 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);
  }
 
開發者ID:lead4good,項目名稱:open-java-trade-manager,代碼行數:41,代碼來源:ChartJDialog.java

示例12: createIndicatorPlot

import org.jfree.data.time.TimeSeries; //導入依賴的package包/類
private XYDataset createIndicatorPlot(String name, Double[] plot)
{
	final TimeSeries series = new TimeSeries(name);
	///*
	for (int i = 0; i < chartDatas.size(); i++) 
	{
           series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),plot[i]);
       }
	/*
	for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) 
	{
           series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
       }
	*/
       return new TimeSeriesCollection(series);
}
 
開發者ID:lead4good,項目名稱:open-java-trade-manager,代碼行數:17,代碼來源:ChartJDialog.java

示例13: 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);
            Double value = 0.0;
            if (industryInfos != null) {
                for (IndustryInfo industryInfo : industryInfos) {
                    value = value + industryInfo.getTotal() / 10000;
                    timeseries.add(new Day(DateUtil.parse(String.valueOf(industryInfo.getDate()), DateUtil.DATE_FORMAT_DAY_SHORT)), value);
                }
            }
            timeseriescollection.addSeries(timeseries);
        }
    }
    return timeseriescollection;
}
 
開發者ID:leon66666,項目名稱:financehelper,代碼行數:20,代碼來源:IndustryTimeSeriesChart.java

示例14: 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;
}
 
開發者ID:leon66666,項目名稱:financehelper,代碼行數:22,代碼來源:IndustryRiseChart.java

示例15: testRemoveSeries

import org.jfree.data.time.TimeSeries; //導入依賴的package包/類
/**
 * Tests the remove series method.
 */
public void testRemoveSeries() {

    final TimeSeriesCollection c1 = new TimeSeriesCollection();

    final TimeSeries s1 = new TimeSeries("Series 1");
    final TimeSeries s2 = new TimeSeries("Series 2");
    final TimeSeries s3 = new TimeSeries("Series 3");
    final TimeSeries s4 = new TimeSeries("Series 4");

    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);

    c1.removeSeries(s3);

    final TimeSeries s = c1.getSeries(2);
    final boolean b1 = s.equals(s4);
    assertTrue(b1);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:TimeSeriesCollectionTests.java


注:本文中的org.jfree.data.time.TimeSeries類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。