private void setLow(PointInTime low) { if (Precision.MILLISECOND.equals(low.getPrecision())) { this.low = low.clone(); } else { this.low = low.promote().getLow(); } }
public Period toPeriod() { Period rslt = new Period( lowClosed ? low : low.addMilliseconds(1), highClosed ? high : high.subtractMilliseconds(1)); return rslt; }
private void setHigh(PointInTime high) { if (Precision.MILLISECOND.equals(high.getPrecision())) { this.high = high.clone(); } else { this.high = high.promote().getHigh(); if (isHighClosed()) { this.high = this.high.subtract(Period.millis(1)); } } }
/** * Returns an IntervalOfTime that has both endpoints closed. If the low endpoint is open it will * move it forward by one millisecond. If the high endpoint is closed, it will move it backward by * one millisecond. * * @return an IntervalOfTime with closed endpoints baed on the endpoints of this interval. */ public IntervalOfTime toClosed() { PointInTime t1 = getLow(); if (!isLowClosed()) { t1 = t1.addMilliseconds(1); } PointInTime t2 = getHigh(); if (!isHighClosed()) { t2 = t2.subtractMilliseconds(1); } return new IntervalOfTime(t1, t2, true, true); }
public IntervalOfTime( PointInTime low, PointInTime high, boolean lowClosed, boolean highClosed, boolean equalEndpointsAllowed) { if (high.equals(low) && !equalEndpointsAllowed) { throw new IllegalArgumentException( "The end point should be unequal to the low point in time when equalEndpointsAllowed is false"); } this.lowClosed = lowClosed; this.highClosed = highClosed; if (low.after(high)) { setLow(high); setHigh(low); } else { setLow(low); setHigh(high); } }
public static IntervalOfTime untilToday(ReadablePeriod p) { PointInTime today = PointInTime.today(); return new IntervalOfTime(today.subtract(p), today, true, true); }
public static IntervalOfTime untilNow(ReadablePeriod p) { PointInTime now = PointInTime.now(); return new IntervalOfTime(now.subtract(p), now, true, true); }
public static IntervalOfTime since(PointInTime t) { return new IntervalOfTime(t, PointInTime.now(), true, true); }
public static IntervalOfTime forTheNext(ReadablePeriod p) { PointInTime now = PointInTime.now(); return new IntervalOfTime(now, now.add(p), true, true); }
/** * Sets object with index <code>indexInST</code> to translate by <code>position</code> at time * <code>time</code>. * * @param indexInST The index of the spatial to change * @param time The time for the spatial to take this translation * @param position The position to take */ public void setPosition(int indexInST, float time, Vector3f position) { PointInTime toAdd = findTime(time); toAdd.setTranslation(indexInST, position); }
public static IntervalOfTime thisYear() { PointInTime today = PointInTime.today(); return new PointInTime(today.getYear()).promote(); }
public static IntervalOfTime today() { return PointInTime.today().promote(); }
public int hashCode() { return (highClosed ? 1 : 0) + (lowClosed ? 1 : 0) + (low != null ? low.hashCode() : 0) + (high != null ? high.hashCode() : 0); }
public boolean contains(PointInTime t) { return contains(t.promote()); }
@Override public void serialize(PointInTime t, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) { // Timestamp here actually means an array of values jgen.writeStartArray(); jgen.writeNumber(t.getYear()); if (t.isMonthSet()) jgen.writeNumber(t.getMonth()); if (t.isDateSet()) jgen.writeNumber(t.getDate()); if (t.isHourSet()) jgen.writeNumber(t.getHour()); if (t.isMinuteSet()) jgen.writeNumber(t.getMinute()); if (t.isSecondSet()) jgen.writeNumber(t.getSecond()); if (t.isMillisecondSet()) jgen.writeNumber(t.getMillisecond()); jgen.writeEndArray(); } else { jgen.writeString(t.toString()); } }
/** * Sets object with index <code>indexInST</code> to scale by <code>scale</code> at time <code>time * </code>. * * @param indexInST The index of the spatial to change * @param time The time for the spatial to take this scale * @param scale The scale to take */ public void setScale(int indexInST, float time, Vector3f scale) { PointInTime toAdd = findTime(time); toAdd.setScale(indexInST, scale); }
public PointInTime getCenter() { PointInTime center = getLow().clone(); return center.add(new Duration(getWidth().getMillis() / 2L)); }
public static IntervalOfTime yearToDate() { PointInTime now = PointInTime.now(); return new IntervalOfTime(new PointInTime(now.getYear()), now); }
public Period toPeriod(PeriodType periodType) { return new Period( lowClosed ? low : low.addMilliseconds(1), highClosed ? high : high.subtractMilliseconds(1), periodType); }
/** * Sets object with index <code>indexInST</code> to rotate by <code>rot</code> at time <code>time * </code>. * * @param indexInST The index of the spatial to change * @param time The time for the spatial to take this rotation * @param rot The rotation to take */ public void setRotation(int indexInST, float time, Quaternion rot) { PointInTime toAdd = findTime(time); toAdd.setRotation(indexInST, rot); }