application
Class Schedule

java.lang.Object
  extended by java.util.Observable
      extended by application.Schedule
All Implemented Interfaces:
java.awt.print.Pageable, java.awt.print.Printable, java.io.Serializable, java.util.Observer, Constants

public class Schedule
extends java.util.Observable
implements Constants, java.io.Serializable, java.awt.print.Printable, java.awt.print.Pageable, java.util.Observer

The Schedule maintains the data for a particular Schedule being manipulated by the application. Uses Singleton model. When someone asks for it, the method will either create a new one or give the existing one.

See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_FILE_NAME
           
 
Fields inherited from interface resources.Constants
BUILDING, COURSE, COURSE_FIELD, COURSE_NUMBER, LASTNAME, NAME, PROF_DOUBLE_BOOKED, ROOM, ROOM_DOUBLE_BOOKED, SECTION_NUMBER
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Method Summary
 void addBook(Textbook book)
           
 void addClassroom(Classroom classroom)
          Adds a Classroom to the document
 void addCourse(Course course)
          Adds a Course to the document
 void addProfessor(Professor prof)
          Adds an Professor to the document
 void addSchedCourse(SchedCourse schedCourse)
          Adds a SchedCourse to the document
 void addTimeSlot(TimeSlot timeSlot)
          Adds a TimeSlot to the document
 void changed()
           
 void exportCsv(java.io.File outCsv)
          Put the schedule in a file that can be read by Excel
 void findConflicts()
          update the conflicts Vector
 java.util.ArrayList getBooks()
           
 boolean getChanged()
           
 java.util.ArrayList getClassrooms()
          Gets the class rooms.
 java.util.ArrayList getConflicts()
          Gets the Conflicts.
 java.util.ArrayList getCourses()
          Gets the Courses.
 java.lang.String getDirectory()
           
 int getNumberOfPages()
           
 java.awt.print.PageFormat getPageFormat(int pageIndex)
           
 java.awt.print.Printable getPrintable(int pageIndex)
           
 java.util.ArrayList getProfessors()
          Gets the instructors.
 java.util.ArrayList getSchedCourses()
          Gets the Scheduled Courses.
static Schedule getSchedule()
          Allows access to the schedule to anyone who wants it without needing to pass it around as a parameter.
 java.lang.String getScheduleName()
           
 Summary getSummary()
           
 java.util.ArrayList getTimeSlots()
          Gets the time slots.
 int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex)
          Print some text schedcourses on each page
 void removeBook(Textbook book)
           
 void removeClassroom(Classroom classroom)
          Removes a Classroom from the document
 void removeCourse(Course course)
          Removes a Course from the document
 void removeProfessor(Professor prof)
          Removes a Professor from the document
 void removeSchedCourse(SchedCourse schedCourse)
          Removes a SchedCourse from the document
 void removeTimeSlot(TimeSlot timeSlot)
          Removes a TimeSlot from the document
 void resetSchedule(Schedule localSchedule, java.lang.String name)
           
 void setBooks(java.util.ArrayList books)
           
 void setChanged(boolean b)
           
 void setClassrooms(java.util.ArrayList classrooms)
           
 void setCourses(java.util.ArrayList courses)
           
 void setDirectory(java.lang.String directory)
          Sets the directory for the document
 void setProfessors(java.util.ArrayList professors)
           
 void setSchedCourses(java.util.ArrayList schedCourses)
           
 void setScheduleName(java.lang.String scheduleName)
           
 void setTimeSlots(java.util.ArrayList timeSlots)
           
 void sort(int key)
           
 void update(java.util.Observable self, java.lang.Object obj)
          Any time the schedule changes, we will set a changed flag.
 java.lang.String updated()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FILE_NAME

public static final java.lang.String DEFAULT_FILE_NAME
See Also:
Constant Field Values
Method Detail

update

public void update(java.util.Observable self,
                   java.lang.Object obj)
Any time the schedule changes, we will set a changed flag. The schedule will be an observer of itself.

Specified by:
update in interface java.util.Observer

setChanged

public void setChanged(boolean b)

getChanged

public boolean getChanged()

updated

public java.lang.String updated()

resetSchedule

public void resetSchedule(Schedule localSchedule,
                          java.lang.String name)

getSchedule

public static Schedule getSchedule()
Allows access to the schedule to anyone who wants it without needing to pass it around as a parameter.


getScheduleName

public java.lang.String getScheduleName()

setScheduleName

public void setScheduleName(java.lang.String scheduleName)

getDirectory

public java.lang.String getDirectory()

setDirectory

public void setDirectory(java.lang.String directory)
Sets the directory for the document

Parameters:
String - directory the directory

getProfessors

public java.util.ArrayList getProfessors()
Gets the instructors.

Returns:
a Vector specifying the instructors

setProfessors

public void setProfessors(java.util.ArrayList professors)

getClassrooms

public java.util.ArrayList getClassrooms()
Gets the class rooms.

Returns:
a Vector specifying the class rooms.

setClassrooms

public void setClassrooms(java.util.ArrayList classrooms)

getCourses

public java.util.ArrayList getCourses()
Gets the Courses.

Returns:
Vector specifying the course sections.

setCourses

public void setCourses(java.util.ArrayList courses)

getTimeSlots

public java.util.ArrayList getTimeSlots()
Gets the time slots.

Returns:
Vector specifying the course sections.

setTimeSlots

public void setTimeSlots(java.util.ArrayList timeSlots)

getBooks

public java.util.ArrayList getBooks()

setBooks

public void setBooks(java.util.ArrayList books)

getSchedCourses

public java.util.ArrayList getSchedCourses()
Gets the Scheduled Courses.

Returns:
Vector specifying the scheduled courses.

setSchedCourses

public void setSchedCourses(java.util.ArrayList schedCourses)

getConflicts

public java.util.ArrayList getConflicts()
Gets the Conflicts.

Returns:
Vector specifying the conflicts.

getSummary

public Summary getSummary()

addProfessor

public void addProfessor(Professor prof)
Adds an Professor to the document

Parameters:
Professor - to be added

removeProfessor

public void removeProfessor(Professor prof)
Removes a Professor from the document

Parameters:
Professor - to be removed

addClassroom

public void addClassroom(Classroom classroom)
Adds a Classroom to the document

Parameters:
Classroom - to be added

removeClassroom

public void removeClassroom(Classroom classroom)
Removes a Classroom from the document

Parameters:
Classroom - to be removed

addTimeSlot

public void addTimeSlot(TimeSlot timeSlot)
Adds a TimeSlot to the document

Parameters:
TimeSlot - to be added

removeTimeSlot

public void removeTimeSlot(TimeSlot timeSlot)
Removes a TimeSlot from the document

Parameters:
TimeSlot - to be removed

addCourse

public void addCourse(Course course)
Adds a Course to the document

Parameters:
Course - to be added

removeCourse

public void removeCourse(Course course)
Removes a Course from the document

Parameters:
Course - to be removed

addBook

public void addBook(Textbook book)

removeBook

public void removeBook(Textbook book)

addSchedCourse

public void addSchedCourse(SchedCourse schedCourse)
Adds a SchedCourse to the document

Parameters:
SchedCourse - to be added

removeSchedCourse

public void removeSchedCourse(SchedCourse schedCourse)
Removes a SchedCourse from the document

Parameters:
SchedCourse - to be removed

sort

public void sort(int key)

changed

public void changed()

findConflicts

public void findConflicts()
update the conflicts Vector


exportCsv

public void exportCsv(java.io.File outCsv)
               throws java.io.IOException
Put the schedule in a file that can be read by Excel

Throws:
java.io.IOException

print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
Print some text schedcourses on each page

Specified by:
print in interface java.awt.print.Printable

getNumberOfPages

public int getNumberOfPages()
Specified by:
getNumberOfPages in interface java.awt.print.Pageable

getPrintable

public java.awt.print.Printable getPrintable(int pageIndex)
Specified by:
getPrintable in interface java.awt.print.Pageable

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
Specified by:
getPageFormat in interface java.awt.print.Pageable