本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}