Package org.jdesktop.swing.calendar

Examples of org.jdesktop.swing.calendar.DateSpan


   *
   */
  public ContribIntervals() {
    super(new Comparator(){
      public int compare(Object o1, Object o2) {
        DateSpan d1=(DateSpan)o1; //Only want to compare DateSpan no need to use instanceof
        DateSpan d2=(DateSpan)o2;
        if (d1.getStart()<d2.getStart()||(d1.getStart()==d2.getStart()&&d1.getEnd()<d2.getEnd())) return -1;
        else if (d1.getStart()>d2.getStart()||(d1.getStart()==d2.getStart()&&d1.getEnd()>d2.getEnd())) return 1;
        else return 0;
      }
    });
  }
View Full Code Here


    super(c);
  }


  protected DateSpan createInterval(long start,long end) {
    return new DateSpan(start,end);
  }
View Full Code Here

  protected DateSpan createInterval(long start,long end) {
    return new DateSpan(start,end);
  }
  protected DateSpan mergeIntervals(DateSpan i1,DateSpan i2) {
    return new DateSpan(Math.min(i1.getStart(),i2.getStart()),Math.max(i1.getEnd(),i2.getEnd()));
  }
View Full Code Here

    return new DateSpan(Math.min(i1.getStart(),i2.getStart()),Math.max(i1.getEnd(),i2.getEnd()));
  }


  public boolean add(Object o) {
    DateSpan toAdd=(DateSpan)o;
    SortedSet set=headSet(o);
    if (set.size()>0){
      DateSpan interval=(DateSpan)set.last();
      if (interval.getEnd()>=toAdd.getStart())
        toAdd=mergeIntervals(toAdd,interval);
    }

    set=tailSet(o);
    if (set.size()>0){
      DateSpan interval=(DateSpan)set.first();
      if (toAdd.getEnd()>=interval.getStart())
        toAdd=mergeIntervals(toAdd,interval);
    }
    return super.add(toAdd);
  }
View Full Code Here

    return (size()==0)?-1:((DateSpan)first()).getStart();
  }

  public boolean containsDate(long date){
    for (Iterator i=iterator();i.hasNext();){ //a more optimized version can be found
      DateSpan interval=(DateSpan)i.next();
      if (interval.getStart()<=date&&date<=interval.getEnd()) return true;
    }
    return false;
  }
View Full Code Here

  }

  void eliminateWeekdayDuplicates(boolean weekDays[]) {
    Calendar cal = calendarInstance();
    for (Iterator i=iterator();i.hasNext();){ //a more optimized version can be found
      DateSpan interval=(DateSpan)i.next();
      cal.setTimeInMillis(interval.getStart());
      int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK) -1;

      // remove any days which correspond to a selected week day
      for (int d = 0; d < 7; d++) {
        if (weekDays[d] && d == dayOfWeek) {
View Full Code Here

      return;
    }
    if (!control && !shift)
      clearSelection();

    DateSpan selection;
    if (selected <= WEEKDAY_OFFSET) { //hk
      int weekDayNum = (int) (-selected  + WEEKDAY_OFFSET);
      selectWeekDay(weekDayNum);
      _asKirkWouldSay_FIRE = true;
      return;
    } else {
      if (_pivotDate == -1 || (!shift))
        selection = new DateSpan(selected, selected);
      else
        selection = new DateSpan(Math.min(_pivotDate, selected), Math.max(
            _pivotDate, selected));
    }

    select(selection);
View Full Code Here

        else return 0;
      }
    });
    if (c!=null)
      for (Iterator i=c.iterator();i.hasNext();){
        DateSpan d=(DateSpan)i.next();
        if (super.add(new CalendarInterval(d.getStart(),d.getEnd())));
      }
  }
View Full Code Here

TOP

Related Classes of org.jdesktop.swing.calendar.DateSpan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.