Beispiel #1
0
 public boolean equals(Object obj) {
   if (!(obj instanceof IntervalOfTime)) return false;
   IntervalOfTime i = (IntervalOfTime) obj;
   return isLowClosed() == i.isLowClosed()
       && isHighClosed() == i.isHighClosed()
       && getLow().equals(i.getLow())
       && getHigh().equals(i.getHigh());
 }
Beispiel #2
0
 public Object clone() {
   try {
     IntervalOfTime i = (IntervalOfTime) super.clone();
     i.low = i.low.clone();
     i.high = i.high.clone();
     return i;
   } catch (CloneNotSupportedException e) {
     return null; // should never occur
   }
 }
Beispiel #3
0
 public static IntervalOfTime intersection(IntervalOfTime i1, IntervalOfTime i2) {
   if (i1.getLow().before(i2.getLow())) {
     if (i2.getLow().after(i1.getHigh())) {
       return null;
     }
     return new IntervalOfTime(i2.getLow(), i1.getHigh());
   }
   if (i1.getLow().after(i2.getHigh())) {
     return null;
   }
   return new IntervalOfTime(i1.getLow(), i2.getHigh());
 }
Beispiel #4
0
 public static IntervalOfTime convexHull(IntervalOfTime i1, IntervalOfTime i2) {
   PointInTime t1;
   PointInTime t2;
   boolean lowClosed;
   boolean highClosed;
   if (i1.low.before(i2.low)) {
     t1 = i1.low;
     lowClosed = i1.isLowClosed();
   } else {
     t1 = i2.low;
     lowClosed = i2.isLowClosed();
   }
   if (i1.high.after(i2.high)) {
     t2 = i1.high;
     highClosed = i1.isHighClosed();
   } else {
     t2 = i2.high;
     highClosed = i2.isHighClosed();
   }
   return new IntervalOfTime(t1, t2, lowClosed, highClosed);
 }
Beispiel #5
0
 public boolean contains(IntervalOfTime i) {
   return getLow().before(i.getLow()) && getHigh().after(i.getLow());
 }