scheduler.view
Class CalendarView

java.lang.Object
  extended by scheduler.view.CalendarView

public class CalendarView
extends java.lang.Object


Field Summary
protected  java.util.ArrayList<CalColumn> calColumnList
          List of CalColumn for selected days in AF
protected  CalendarViewUI calViewUI
          The companion view object.
protected  int[] dayNumCol
          the number indicate number of col needed for that day more than 1 col means there is an overlapping calendar cell for that day
(package private) static java.lang.String[] daysList
           
protected  int endTime
          Time obj representing the time range in calendar view
protected  FilterOptions filterOptions
          FilterOptions for the view.
protected  java.util.ArrayList<ScheduleItem> friItem
          List contain all ScheduleItem for Friday
protected  java.util.ArrayList<CalColumn> fullColumnList
          List of CalColumn for EVERDAY, Mon - Sun
protected  java.util.ArrayList<ScheduleItem> monItem
          List contain all ScheduleItem for Monday
protected  int numDaysInWeek
          number of days in a weekly view or 1 for a daily view, indicate number of cols
protected  int numHour
          number of hours in a day, indicate number of rows
protected  java.util.ArrayList<ScheduleItem> satItem
          List contain all ScheduleItem for Saturday
protected  Schedule schedule
          The Schedule to be drawn.
protected  java.util.ArrayList<ScheduleItem> siList
          List of Selected ScheduleItem
protected  int startTime
          Time obj representing the time range in calendar view
protected  java.util.ArrayList<ScheduleItem> sunItem
          List contain all ScheduleItem for Sunday
protected  java.util.ArrayList<ScheduleItem> thuItem
          List contain all ScheduleItem for Thursday
(package private) static java.lang.String[] timeList
           
protected  int totalNumCol
          Number of Column needed
protected  java.util.ArrayList<ScheduleItem> tueItem
          List contain all ScheduleItem for Tuesday
protected  View view
          The parent view.
protected  java.util.ArrayList<ScheduleItem> wedItem
          List contain all ScheduleItem for Wednesday
 
Constructor Summary
CalendarView()
          Constructor for testing the getDayInt method
CalendarView(Schedule schedule)
          Construct this class using its parent view object.
 
Method Summary
protected  int calcNumDaysInWeek()
          Calculate number of column to display in calendar view If daily view is selected, this method will return 1
protected  int calcTime(int i)
          Converting a time object to an int which correspond to the String of time, timeList
protected  int calcTime(Time t)
          Converting a time object to an int which correspond to the String of time, timeList
 void callCreateCalCell()
          Calling createCalCell() for EVERY DAY.
 int countHour(Time startHr, Time endHr)
          Count how many hours are in between the first parameter and the 2nd param.
 void createCalCell(DaysInWeek.Day d, java.util.ArrayList<ScheduleItem> list, int ind)
          create CalCell object containing scheduleItem(s) for the particular CalColumn in fullColumnList determined from ind parameter.
protected  void createCourseSchedule()
          create siList for the selected scheduleItems for course view
protected  void createInstructorSchedule()
          create siList for the selected scheduleItems for instructor view
protected  void createLocationSchedule()
          create siList for the selected scheduleItems for location view
 void createSchedule()
          create siList for the selected scheduleItems
 java.util.ArrayList<CalColumn> getCalColumnList()
          return the calColumnList which contains a list of CalColumn obj for each column/day in the calendar view.
 CalendarViewUI getCalViewUI()
          return the CalendarViewUI obj
 int getDayInt(DaysInWeek.Day d)
          return the day for daily calendar view in integer format Pre: d != null && (d == MON || d == TUE || d == WED || d == THU || d == FRI || d == SAT || d == SUN) Post: return == 0 if d == MON retirn == 1 if d == TUE return == 2 if d == WED return == 3 if d == THU return == 4 if d == FRI return == 5 if d == SAT return == 6 if d == SUN return == -1 if d== null or invalid
static int getDayIntTest(DaysInWeek.Day d)
          For testing return the day for daily calendar view in integer format Pre: d != null && (d == MON || d == TUE || d == WED || d == THU || d == FRI || d == SAT || d == SUN) Post: return == 0 if d == MON retirn == 1 if d == TUE return == 2 if d == WED return == 3 if d == THU return == 4 if d == FRI return == 5 if d == SAT return == 6 if d == SUN return == -1 if d== null or invalid
 int[] getDayNumCol()
          Return dayNumCol array
 int getEndTimeInt()
          Return the end time in integer
 int getNumDaysInWeek()
          Return the current numDaysInWeek
 int getNumHourTotal()
          Return the number of hours
 java.util.ArrayList<ScheduleItem> getSchedule()
          return the list ofScheduleItem containing selected the scheduleItems
 int getStartTimeInt()
          Return the start time in integer
 int getTotalNumCol()
          Return totalNumCol
 void printCalendarView()
          Print the Calendar View
 void sortScheduleItem()
          categorize EVERY scheduleItem in Schedule by days then in each day category, group each item by its start time and end time.
 void update()
          Update Calendar View components when View received observable notification
 void updateCalColumn()
          Adding CalColumn object to the calColumnList if that column(day) is selected in AF
 void updateData()
          update numDaysInWeek, startTime, endTime, and numHour corresponding to the Advanced Filter settings and user's selections
 void updateLabel()
          Update the JLabel for each Calendar Cell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schedule

protected Schedule schedule
The Schedule to be drawn.


siList

protected java.util.ArrayList<ScheduleItem> siList
List of Selected ScheduleItem


view

protected View view
The parent view.


calViewUI

protected CalendarViewUI calViewUI
The companion view object.


filterOptions

protected FilterOptions filterOptions
FilterOptions for the view.


numDaysInWeek

protected int numDaysInWeek
number of days in a weekly view or 1 for a daily view, indicate number of cols


startTime

protected int startTime
Time obj representing the time range in calendar view


endTime

protected int endTime
Time obj representing the time range in calendar view


numHour

protected int numHour
number of hours in a day, indicate number of rows


calColumnList

protected java.util.ArrayList<CalColumn> calColumnList
List of CalColumn for selected days in AF


fullColumnList

protected java.util.ArrayList<CalColumn> fullColumnList
List of CalColumn for EVERDAY, Mon - Sun


monItem

protected java.util.ArrayList<ScheduleItem> monItem
List contain all ScheduleItem for Monday


tueItem

protected java.util.ArrayList<ScheduleItem> tueItem
List contain all ScheduleItem for Tuesday


wedItem

protected java.util.ArrayList<ScheduleItem> wedItem
List contain all ScheduleItem for Wednesday


thuItem

protected java.util.ArrayList<ScheduleItem> thuItem
List contain all ScheduleItem for Thursday


friItem

protected java.util.ArrayList<ScheduleItem> friItem
List contain all ScheduleItem for Friday


satItem

protected java.util.ArrayList<ScheduleItem> satItem
List contain all ScheduleItem for Saturday


sunItem

protected java.util.ArrayList<ScheduleItem> sunItem
List contain all ScheduleItem for Sunday


dayNumCol

protected int[] dayNumCol
the number indicate number of col needed for that day more than 1 col means there is an overlapping calendar cell for that day


totalNumCol

protected int totalNumCol
Number of Column needed


daysList

static final java.lang.String[] daysList

timeList

static final java.lang.String[] timeList
Constructor Detail

CalendarView

public CalendarView()
Constructor for testing the getDayInt method


CalendarView

public CalendarView(Schedule schedule)
Construct this class using its parent view object.

Method Detail

createSchedule

public void createSchedule()
create siList for the selected scheduleItems


createCourseSchedule

protected void createCourseSchedule()
create siList for the selected scheduleItems for course view


createInstructorSchedule

protected void createInstructorSchedule()
create siList for the selected scheduleItems for instructor view


createLocationSchedule

protected void createLocationSchedule()
create siList for the selected scheduleItems for location view


update

public void update()
Update Calendar View components when View received observable notification


updateLabel

public void updateLabel()
Update the JLabel for each Calendar Cell


updateCalColumn

public void updateCalColumn()
Adding CalColumn object to the calColumnList if that column(day) is selected in AF


callCreateCalCell

public void callCreateCalCell()
Calling createCalCell() for EVERY DAY. NOT ALL ScheduleItem will be added to the CalCell


createCalCell

public void createCalCell(DaysInWeek.Day d,
                          java.util.ArrayList<ScheduleItem> list,
                          int ind)
create CalCell object containing scheduleItem(s) for the particular CalColumn in fullColumnList determined from ind parameter. NOT ALL ScheduleItem will be added to the CalCell

Parameters:
list - - list of scheduleItem for particular column/day
ind - - the column number or index in fullColumnList

printCalendarView

public void printCalendarView()
Print the Calendar View


sortScheduleItem

public void sortScheduleItem()
categorize EVERY scheduleItem in Schedule by days then in each day category, group each item by its start time and end time. Store the sorted ScheduleItem in "'day'Item" ArrayList


updateData

public void updateData()
update numDaysInWeek, startTime, endTime, and numHour corresponding to the Advanced Filter settings and user's selections


countHour

public int countHour(Time startHr,
                     Time endHr)
Count how many hours are in between the first parameter and the 2nd param. 1 hour is equal to 2 counts

Parameters:
startHr - - the beginning of the hour
endHr - - the ending of the hour
Returns:
number of hours between the 2 given hours.

calcNumDaysInWeek

protected int calcNumDaysInWeek()
Calculate number of column to display in calendar view If daily view is selected, this method will return 1

Returns:
the number of column needed

calcTime

protected int calcTime(int i)
Converting a time object to an int which correspond to the String of time, timeList

Parameters:
i - - 0 if converting for start time, 1 for end time
Returns:
index of timeList representing the given time

calcTime

protected int calcTime(Time t)
Converting a time object to an int which correspond to the String of time, timeList

Parameters:
t - - the time object to be converted
Returns:
index of timeList representing the given time

getDayInt

public int getDayInt(DaysInWeek.Day d)
return the day for daily calendar view in integer format Pre: d != null && (d == MON || d == TUE || d == WED || d == THU || d == FRI || d == SAT || d == SUN) Post: return == 0 if d == MON retirn == 1 if d == TUE return == 2 if d == WED return == 3 if d == THU return == 4 if d == FRI return == 5 if d == SAT return == 6 if d == SUN return == -1 if d== null or invalid

Returns:
the day for daily calendar view in integer

getDayIntTest

public static int getDayIntTest(DaysInWeek.Day d)
For testing return the day for daily calendar view in integer format Pre: d != null && (d == MON || d == TUE || d == WED || d == THU || d == FRI || d == SAT || d == SUN) Post: return == 0 if d == MON retirn == 1 if d == TUE return == 2 if d == WED return == 3 if d == THU return == 4 if d == FRI return == 5 if d == SAT return == 6 if d == SUN return == -1 if d== null or invalid

Returns:
the day for daily calendar view in integer

getCalColumnList

public java.util.ArrayList<CalColumn> getCalColumnList()
return the calColumnList which contains a list of CalColumn obj for each column/day in the calendar view. Each CalColumn contains a list of CalCell representing each cell in the calendar view.

Returns:
list of CalColumn obj

getSchedule

public java.util.ArrayList<ScheduleItem> getSchedule()
return the list ofScheduleItem containing selected the scheduleItems

Returns:
a list of scheduleItem

getCalViewUI

public CalendarViewUI getCalViewUI()
return the CalendarViewUI obj

Returns:
the CalendarViewUI obj

getNumDaysInWeek

public int getNumDaysInWeek()
Return the current numDaysInWeek

Returns:
numDaysInWeek

getStartTimeInt

public int getStartTimeInt()
Return the start time in integer

Returns:
start time

getEndTimeInt

public int getEndTimeInt()
Return the end time in integer

Returns:
end time

getNumHourTotal

public int getNumHourTotal()
Return the number of hours

Returns:
number of hours

getDayNumCol

public int[] getDayNumCol()
Return dayNumCol array

Returns:
dayNumCol

getTotalNumCol

public int getTotalNumCol()
Return totalNumCol

Returns:
totalNumCol