/** * Constructs an empty dataset, tied to a specific timezone. * * @param nSeries the number of series to be accommodated * @param nMoments the number of TimePeriods to be spanned * @param zone the timezone. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments, TimeZone zone) { this(nSeries, nMoments, new Millisecond(), zone); this.newestAt = nMoments - 1; }
/** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar ({@code null} not permitted). * * @since 1.0.3 */ @Override public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); }
/** * Returns the millisecond preceding this one. * * @return The millisecond preceding this one. */ @Override public RegularTimePeriod previous() { RegularTimePeriod result = null; if (this.millisecond != FIRST_MILLISECOND_IN_SECOND) { result = new Millisecond(this.millisecond - 1, getSecond()); } else { Second previous = (Second) getSecond().previous(); if (previous != null) { result = new Millisecond(LAST_MILLISECOND_IN_SECOND, previous); } } return result; }
Millisecond ms = new Millisecond(); System.out.println(ms.getStart().getTime()); System.out.println(ms.getEnd().getTime());
this.lastValue = this.lastValue * factor; final Millisecond now = new Millisecond(); this.series.add(new Millisecond(), this.lastValue); System.out.println("Current Time in Milliseconds = " + now.toString()+", Current Value : "+this.lastValue);
void updateAnnotation(RasterDataNode raster) { removeAnnotation(); final AbstractTimeSeries timeSeries = getTimeSeries(); TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(raster); if (timeCoding != null) { final ProductData.UTC startTime = timeCoding.getStartTime(); final Millisecond timePeriod = new Millisecond(startTime.getAsDate(), ProductData.UTC.UTC_TIME_ZONE, Locale.getDefault()); double millisecond = timePeriod.getFirstMillisecond(); Range valueRange = null; for (int i = 0; i < timeSeriesPlot.getRangeAxisCount(); i++) { valueRange = Range.combine(valueRange, timeSeriesPlot.getRangeAxis(i).getRange()); } if (valueRange != null) { XYAnnotation annotation = new XYLineAnnotation(millisecond, valueRange.getLowerBound(), millisecond, valueRange.getUpperBound()); timeSeriesPlot.addAnnotation(annotation, true); } } }
/** * Creates a millisecond. * * @param time the date-time ({@code null} not permitted). * @param zone the time zone ({@code null} not permitted). * @param locale the locale ({@code null} not permitted). * * @since 1.0.13 */ public Millisecond(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.millisecond = calendar.get(Calendar.MILLISECOND); this.second = (byte) calendar.get(Calendar.SECOND); this.minute = (byte) calendar.get(Calendar.MINUTE); this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); this.day = new Day(time, zone, locale); peg(calendar); }
/** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: * <p> * <code>http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf</code> * * @return A hashcode. */ public int hashCode() { int result = 17; result = 37 * result + this.millisecond; result = 37 * result + getSecond().hashCode(); return result; }
this.lastValue1 = this.lastValue1 * factor1; this.lastValue2 = this.lastValue2 * factor2; Millisecond now = new Millisecond(); System.out.println("Now = " + now.toString()); XYSeries series = dataset.getSeries(lastSeries); series.add(this.lastValue2, this.lastValue1);
/** * Creates a millisecond. * * @param time the date-time (<code>null</code> not permitted). * @param zone the time zone (<code>null</code> not permitted). * @param locale the locale (<code>null</code> not permitted). * * @since 1.0.13 */ public Millisecond(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.millisecond = calendar.get(Calendar.MILLISECOND); this.second = (byte) calendar.get(Calendar.SECOND); this.minute = (byte) calendar.get(Calendar.MINUTE); this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); this.day = new Day(time, zone, locale); peg(calendar); }
/** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: * <p> * {@code http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf} * * @return A hashcode. */ @Override public int hashCode() { int result = 17; result = 37 * result + this.millisecond; result = 37 * result + getSecond().hashCode(); return result; }
/** * Constructs an empty dataset, tied to a specific timezone. * * @param nSeries the number of series to be accommodated * @param nMoments the number of TimePeriods to be spanned * @param zone the timezone. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments, TimeZone zone) { this(nSeries, nMoments, new Millisecond(), zone); this.newestAt = nMoments - 1; }
/** * Returns the millisecond following this one. * * @return The millisecond following this one. */ @Override public RegularTimePeriod next() { RegularTimePeriod result = null; if (this.millisecond != LAST_MILLISECOND_IN_SECOND) { result = new Millisecond(this.millisecond + 1, getSecond()); } else { Second next = (Second) getSecond().next(); if (next != null) { result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next); } } return result; }
/** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (<code>null</code> not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); }
/** * Constructs a millisecond. * * @param millisecond the millisecond (0-999). * @param second the second. */ public Millisecond(int millisecond, Second second) { this.millisecond = millisecond; this.second = (byte) second.getSecond(); this.minute = (byte) second.getMinute().getMinute(); this.hour = (byte) second.getMinute().getHourValue(); this.day = second.getMinute().getDay(); peg(Calendar.getInstance()); }
/** * Constructs a dataset with capacity for N series, tied to default * timezone. * * @param nSeries the number of series to be accommodated. * @param nMoments the number of TimePeriods to be spanned. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments) { this(nSeries, nMoments, new Millisecond(), TimeZone.getDefault()); this.newestAt = nMoments - 1; }
/** * Returns the millisecond preceding this one. * * @return The millisecond preceding this one. */ public RegularTimePeriod previous() { RegularTimePeriod result = null; if (this.millisecond != FIRST_MILLISECOND_IN_SECOND) { result = new Millisecond(this.millisecond - 1, getSecond()); } else { Second previous = (Second) getSecond().previous(); if (previous != null) { result = new Millisecond(LAST_MILLISECOND_IN_SECOND, previous); } } return result; }
/** * Returns the last millisecond of the time period. * * @param calendar the calendar (<code>null</code> not permitted). * * @return The last millisecond of the time period. * * @throws NullPointerException if <code>calendar</code> is * <code>null</code>. */ public long getLastMillisecond(Calendar calendar) { return getFirstMillisecond(calendar); }
/** * Constructs a millisecond. * * @param millisecond the millisecond (0-999). * @param second the second. */ public Millisecond(int millisecond, Second second) { this.millisecond = millisecond; this.second = (byte) second.getSecond(); this.minute = (byte) second.getMinute().getMinute(); this.hour = (byte) second.getMinute().getHourValue(); this.day = second.getMinute().getDay(); peg(Calendar.getInstance()); }
/** * Constructs a dataset with capacity for N series, tied to default * timezone. * * @param nSeries the number of series to be accommodated. * @param nMoments the number of TimePeriods to be spanned. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments) { this(nSeries, nMoments, new Millisecond(), TimeZone.getDefault()); this.newestAt = nMoments - 1; }