/** * Returns the month preceding this one. Note that the returned * {@link Month} is "pegged" using the default time-zone, irrespective of * the time-zone used to peg of the current month (which is not recorded * anywhere). See the {@link #peg(Calendar)} method. * * @return The month preceding this one. */ @Override public RegularTimePeriod previous() { Month result; if (this.month != MonthConstants.JANUARY) { result = new Month(this.month - 1, this.year); } else { if (this.year > 1900) { result = new Month(MonthConstants.DECEMBER, this.year - 1); } else { result = null; } } return result; }
/** * Returns the month preceding this one. Note that the returned * {@link Month} is "pegged" using the default time-zone, irrespective of * the time-zone used to peg of the current month (which is not recorded * anywhere). See the {@link #peg(Calendar)} method. * * @return The month preceding this one. */ public RegularTimePeriod previous() { Month result; if (this.month != MonthConstants.JANUARY) { result = new Month(this.month - 1, this.year); } else { if (this.year > 1900) { result = new Month(MonthConstants.DECEMBER, this.year - 1); } else { result = null; } } return result; }
/** * Returns the month following this one. Note that the returned * {@link Month} is "pegged" using the default time-zone, irrespective of * the time-zone used to peg of the current month (which is not recorded * anywhere). See the {@link #peg(Calendar)} method. * * @return The month following this one. */ public RegularTimePeriod next() { Month result; if (this.month != MonthConstants.DECEMBER) { result = new Month(this.month + 1, this.year); } else { if (this.year < 9999) { result = new Month(MonthConstants.JANUARY, this.year + 1); } else { result = null; } } return result; }
/** * Returns the month following this one. Note that the returned * {@link Month} is "pegged" using the default time-zone, irrespective of * the time-zone used to peg of the current month (which is not recorded * anywhere). See the {@link #peg(Calendar)} method. * * @return The month following this one. */ @Override public RegularTimePeriod next() { Month result; if (this.month != MonthConstants.DECEMBER) { result = new Month(this.month + 1, this.year); } else { if (this.year < 9999) { result = new Month(MonthConstants.JANUARY, this.year + 1); } else { result = null; } } return result; }
public TimePeriod toTimePeriod(Calendar cal) { return new Month(cal.getTime()); } };
/** * Creates a dataset, consisting of two series of monthly data. * * @return The dataset. */ private static XYDataset createDataset() { TimeSeries s1 = new TimeSeries("L&G European Index Trust", Month.class); s1.add(new Month(2, 2001), 0); s1.add(new Month(3, 2001), 4); s1.add(new Month(4, 2001), 3); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.setDomainIsPointsInTime(true); return dataset; }
s1.add(new Month(2, 2001), 181.8); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1);
private RegularTimePeriod determineTimeInterval(Date date, StyleProperties styleProperties) { if (styleProperties.getProperties() .containsKey(Style.PARAMETER_INTERVAL)) { String interval = styleProperties.getProperties() .get(Style.PARAMETER_INTERVAL); if (interval.equals(Style.VALUE_INTERVAL_BY_HOUR)) { return new Hour(date); } else if (interval.equals(Style.VALUE_INTERVAL_BY_DAY)) { return new Day(date); } else if (interval.equals(Style.VALUE_INTERVAL_BY_MONTH)) { return new Month(date); } } return new Week(date); }
private RegularTimePeriod determineTimeInterval(Date date, StyleProperties styleProperties) { if (styleProperties.getProperties().containsKey("interval")) { String interval = styleProperties.getProperties().get("interval"); if (interval.equals("byHour")) { return new Hour(date); } else if (interval.equals("byDay")) { return new Day(date); } else if (interval.equals("byMonth")) { return new Month(date); } } return new Week(date); }
period = new Hour(time); } else if (intervalSize == Calendar.MONTH) { period = new Month(time);
protected RegularTimePeriod getRtp(Date d) { RegularTimePeriod rtp; switch(ofxTimePeriod) { case Hour: rtp = new Hour(d);break; case Day: rtp = new Day(d);break; case Month: rtp = new Month(d);break; default: rtp = new Hour(d);break; } return rtp; }
/** * Creates the TimePeriod to be displayed in the TimeSeries graph for the * specified time step. * * @param timeType the time range type to be displayed * @param year the year to be displayed * @param timeStep the current time step in the graph * @return the created TimePeriod for the current time step */ private RegularTimePeriod createTimePeriodForTimeStep(TimeRangeType timeType, int year, int timeStep) { switch (timeType) { case LAST_12_MONTHS: LocalDate now = LocalDate.now(); int tempMonth = now.getMonthValue() + timeStep - 1; int tempYear = now.getYear() - 1 + tempMonth / 12; return new Month(tempMonth % 12 + 1, tempYear); case MONTHS_OF_YEAR: return new Month(timeStep + 1, year); case WEEKS_OF_YEAR: // Workaround for a JFreeChart problem: use the Year instead // of Week class for the botton axis, otherwise there will be // format problems on the axis (the first week is often "52") int tempWeekNr = timeStep + 1; return new Year(1900 + tempWeekNr); case LAST_10_YEARS: return new Year(year - 9 + timeStep); default: throw new IllegalArgumentException("Unknow TimeRangeType!"); } }
protected RegularTimePeriod getRtp(Date d) { RegularTimePeriod rtp; switch(ofxTimePeriod) { case Hour: rtp = new Hour(d);break; case Day: rtp = new Day(d);break; case Month: rtp = new Month(d);break; default: rtp = new Hour(d);break; } return rtp; }
public synchronized static RegularTimePeriod getRtp(OfxChartTimePeriod ofxTimePeriod, Date d) { RegularTimePeriod rtp; switch(ofxTimePeriod) { case Hour: rtp = new Hour(d);break; case Day: rtp = new Day(d);break; case Month: rtp = new Month(d);break; default: rtp = new Hour(d);break; } return rtp; }
period = new Month(c.getTime());
break; case 2: //Month dataset.addOrUpdate(new Month((Date)dcell) , new Double(ncell.toString())); break; case 3: //Week
break; case (DateTickUnit.MONTH) : result = calculateDateForPosition(new Month(time, this.timeZone, this.locale), position); break;
/** * Corrects the given tick date for the position setting. * * @param time the tick date/time. * @param unit the tick unit. * @param position the tick position. * * @return The adjusted time. */ private Date correctTickDateForPosition(Date time, DateTickUnit unit, DateTickMarkPosition position) { Date result = time; if (unit.getUnitType().equals(DateTickUnitType.MONTH)) { result = calculateDateForPosition(new Month(time, this.timeZone, this.locale), position); } else if (unit.getUnitType().equals(DateTickUnitType.YEAR)) { result = calculateDateForPosition(new Year(time, this.timeZone, this.locale), position); } return result; }
private IntervalXYDataset getMonthlyLoginsDataSet() { List<ServerWideStatsRecord> totalLogins = getMonthlyTotalLogins(); List<ServerWideStatsRecord> uniqueLogins = getMonthlyUniqueLogins(); if (totalLogins == null || uniqueLogins == null) { return null; } TimeSeries s1 = new TimeSeries (msgs.getString ("legend_logins"), Month.class); TimeSeries s2 = new TimeSeries (msgs.getString ("legend_unique_logins"), Month.class); for (ServerWideStatsRecord login : totalLogins) { Month month = new Month ((Date) login.get (0)); s1.add (month, (Long) login.get (1)); } for (ServerWideStatsRecord login : uniqueLogins) { Month month = new Month ((Date) login.get (0)); s2.add (month, (Long) login.get (1)); } TimeSeriesCollection dataset = new TimeSeriesCollection (); dataset.addSeries (s1); dataset.addSeries (s2); return dataset; }
private IntervalXYDataset getMonthlySiteUserDataSet () { List<ServerWideStatsRecord> siteCreatedDeletedList = getSiteCreatedDeletedStats ("monthly"); TimeSeriesCollection dataset = new TimeSeriesCollection (); if (siteCreatedDeletedList != null) { TimeSeries s1 = new TimeSeries (msgs.getString ("legend_site_created"), Month.class); TimeSeries s2 = new TimeSeries (msgs.getString ("legend_site_deleted"), Month.class); for (ServerWideStatsRecord login : siteCreatedDeletedList) { Month month = new Month ((Date) login.get (0)); s1.add (month, (Long) login.get (1)); s2.add (month, (Long) login.get (2)); } dataset.addSeries (s1); dataset.addSeries (s2); } List<ServerWideStatsRecord> newUserList = getNewUserStats ("monthly"); if (newUserList != null) { TimeSeries s3 = new TimeSeries (msgs.getString ("legend_new_user"), Month.class); for (ServerWideStatsRecord login : newUserList) { Month month = new Month ((Date) login.get (0)); s3.add (month, (Long) login.get (1)); } dataset.addSeries (s3); } return dataset; }