Search in sources :

Example 6 with FixedMillisecond

use of org.jfree.data.time.FixedMillisecond in project nimbus by nimbus-org.

the class TimeSeriesCollectionFactoryService method addTimeSeries.

/**
 * TimeSeriesに値を追加する。<p>
 *
 * @param series TimeSeries
 * @param date 日付
 * @param value 値
 * @param periodType TimePeriodタイプ
 * @param inOut メソッドコールの入出力で必要なデータを保持したクラス
 * @return TimeSeries
 */
protected TimeSeries addTimeSeries(TimeSeries series, Date date, double value, int periodType, long period, Holder inOut, boolean isAddOrUpdate) {
    switch(collateDataType) {
        case COLLATE_DATA_TYPE_START:
        case COLLATE_DATA_TYPE_END:
        case COLLATE_DATA_TYPE_AVERAGE:
        case COLLATE_DATA_TYPE_SUM:
            date = createCollateDate(date, period);
            break;
        case COLLATE_DATA_TYPE_ALL:
        case COLLATE_DATA_TYPE_OHLC:
        default:
            break;
    }
    RegularTimePeriod regTimePeriod = null;
    switch(periodType) {
        case PERIOD_MILLISECOND:
            regTimePeriod = new Millisecond(date);
            break;
        case PERIOD_FIXEDMILLISECOND:
            regTimePeriod = new FixedMillisecond(date);
            break;
        case PERIOD_SECOND:
            regTimePeriod = new Second(date);
            break;
        case PERIOD_MINUTE:
            regTimePeriod = new Minute(date);
            break;
        case PERIOD_HOUR:
            regTimePeriod = new Hour(date);
            break;
        case PERIOD_DAY:
            regTimePeriod = new Day(date);
            break;
        case PERIOD_WEEK:
            regTimePeriod = new Week(date);
            break;
        case PERIOD_MONTH:
            regTimePeriod = new Month(date);
            break;
        case PERIOD_QUARTER:
            regTimePeriod = new Quarter(date);
            break;
        case PERIOD_YEAR:
            regTimePeriod = new Year(date);
            break;
        default:
    }
    if (isAddOrUpdate) {
        series.addOrUpdate(regTimePeriod, value);
    } else {
        series.add(regTimePeriod, value);
    }
    if (inOut.lastDate == null) {
        inOut.lastDate = (Date) date.clone();
    } else {
        inOut.lastDate.setTime(date.getTime());
    }
    inOut.lastValue = value;
    return series;
}
Also used : Quarter(org.jfree.data.time.Quarter) FixedMillisecond(org.jfree.data.time.FixedMillisecond) Millisecond(org.jfree.data.time.Millisecond) Month(org.jfree.data.time.Month) FixedMillisecond(org.jfree.data.time.FixedMillisecond) Second(org.jfree.data.time.Second) Minute(org.jfree.data.time.Minute) Year(org.jfree.data.time.Year) Hour(org.jfree.data.time.Hour) RegularTimePeriod(org.jfree.data.time.RegularTimePeriod) Day(org.jfree.data.time.Day) Week(org.jfree.data.time.Week)

Aggregations

FixedMillisecond (org.jfree.data.time.FixedMillisecond)6 TimeSeries (org.jfree.data.time.TimeSeries)5 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)3 TimeSeriesDataItem (org.jfree.data.time.TimeSeriesDataItem)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 JFreeChart (org.jfree.chart.JFreeChart)1 LogarithmicAxis (org.jfree.chart.axis.LogarithmicAxis)1 ValueAxis (org.jfree.chart.axis.ValueAxis)1 XYPlot (org.jfree.chart.plot.XYPlot)1 SeriesException (org.jfree.data.general.SeriesException)1 Day (org.jfree.data.time.Day)1 Hour (org.jfree.data.time.Hour)1 Millisecond (org.jfree.data.time.Millisecond)1 Minute (org.jfree.data.time.Minute)1 Month (org.jfree.data.time.Month)1 Quarter (org.jfree.data.time.Quarter)1