Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

PCalDayInfo net::sf::linuxorg::pcal::MainWindow::refreshCalendar ( Date  new_date,
Calendar  calendar,
boolean  need_to_rebuild 
) [inline, private]

This is an internal method which refresh the calendar widget

Parameters:
new_date- the target date to be shown
calendar- the target date in a form of calendar
need_to_rebuild- if true - the calendar needs to be rebuilt
Returns:
- the day information record for the target date

Definition at line 1067 of file MainWindow.java.

References net::sf::linuxorg::pcal::engine::Engine::dateDiff(), net::sf::linuxorg::pcal::engine::Engine::existsDateNote(), getDayColors(), and net::sf::linuxorg::pcal::engine::Engine::getDayInfo().

Referenced by jumpToDate().

                                           {
            PCalDayInfo target_day_info = null;
            if(!need_to_rebuild) {
                  //this is the same month - just set a new position
                  target_day_pos = Engine.dateDiff(calCurrentStartDate, new_date);
                  target_day_info = PCalendar.engine.getDayInfo(calendar.getTime());
            } else {
                  calendarDays.clear();

                  int next_month = calendar.get(Calendar.MONTH)+1;
                  if(next_month == 12) next_month = 0;

                  //find the first day of week which contains the <Month> 1 date
                  int firstDayOfWeek = calendar.getFirstDayOfWeek();
                  calendar.set(Calendar.DAY_OF_MONTH, 1);
                  while(calendar.get(Calendar.DAY_OF_WEEK)!=firstDayOfWeek) {
                        calendar.add(Calendar.DATE, -1);
                  }

                  calCurrentStartDate = calendar.getTime();

                  boolean neighbor_month = true;

                  while(!((calendar.get(Calendar.DAY_OF_WEEK)==firstDayOfWeek)&&
                              (calendar.get(Calendar.MONTH) == next_month))
                  ) {
                        int current_day_of_month = calendar.get(Calendar.DAY_OF_MONTH); 
                        if(current_day_of_month==1) neighbor_month=!neighbor_month;

                        if(neighbor_month) {
                              // this is preceding or succeeding month dates
                              // paint in grey
                              calendarDays.add(new DayRenderInfo(String.valueOf(current_day_of_month),
                                          DEFAULT_INACTIVE_MONTH_FG_COLOR,
                                          DEFAULT_INACTIVE_MONTH_BG_COLOR,
                                          PCalendar.engine.existsDateNote(calendar.getTime())));                        
                        } else {
                              // this is a current month date
                              // show in all colors
                              PCalDayInfo current_day_info = 
                                    PCalendar.engine.getDayInfo(calendar.getTime());
                              if(calendar.getTime().equals(new_date)) {
                                    target_day_info = current_day_info;
                                    target_day_pos = calendarDays.size(); 
                              }

                              Color[] dateColors = getDayColors(current_day_info);

                              calendarDays.add(new DayRenderInfo(String.valueOf(current_day_of_month),
                                          dateColors[1],
                                          dateColors[0],
                                          PCalendar.engine.existsDateNote(calendar.getTime())));
                        }
                        calendar.add(Calendar.DATE, 1);
                  }

                  calendar.setTime(new_date);
            }
            return target_day_info;
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index