caltool.view_ui
Class MonthlyAgendaDisplay

java.lang.Object
  extended by mvp.View
      extended by caltool.caltool_ui.CalendarToolWindow
          extended by caltool.view_ui.MonthlyAgendaDisplay
All Implemented Interfaces:
java.io.Serializable, java.util.Observer

public class MonthlyAgendaDisplay
extends CalendarToolWindow

Class MonthlyAgendaDisplay is the companion view of a MonthlyAgenda model. The fixed layout of the display is a three-part vertical box. The box contains a date banner, a row of header labels for the days of the week, and the seven-column grid for the days of the month. The size and layout of the days grid is computed dynamically by the update method, based on the data from the model.

See Also:
Serialized Form

Field Summary
protected  javax.swing.JPanel dateBanner
          The date banner at the top of the display.
protected  javax.swing.JPanel dayGrid
          The day grid.
protected  SmallDayViewDisplay[] days
          Array of day displays for convenient access by date number.
protected  javax.swing.JPanel daysOfWeek
          The days-of-the week labeling row.
protected  int defaultCellHeight
          Default constant for the height of one day display cell.
protected  int defaultCellWidth
          Default constant for the width of one day display cell.
protected  java.awt.Dimension defaultSize
          Initial default size of the day grid.
protected  int numberOfWeeks
          Number or weeks (hence display rows) in the current display.
protected  javax.swing.JPanel vbox
          Outermost box of the laid-out display.
 
Fields inherited from class caltool.caltool_ui.CalendarToolWindow
calToolUI
 
Fields inherited from class mvp.View
closeAdapter, editable, model, screen, shown, widget, window
 
Constructor Summary
MonthlyAgendaDisplay(mvp.Screen s, MonthlyAgenda monthlyAgenda, CalendarToolUI calToolUI)
          Construct this by constructing subpanels for the three parts of the display.
 
Method Summary
 java.awt.Component compose()
          Compose this as a vertical box, consisting of a date-banner row, a days-of-the-week labels row, and an empty days grid.
protected  javax.swing.JPanel composeDateBanner()
          Compose the date banner.
protected  javax.swing.JPanel greyDay()
          Build an empty grey-background, black-border day display.
 void update(java.util.Observable o, java.lang.Object arg)
          Display the model data in the appropriate daily positions.
 
Methods inherited from class caltool.caltool_ui.CalendarToolWindow
show
 
Methods inherited from class mvp.View
getModel, getWidget, getWindow, hide, isEditable, isShown, run, setEditable, setExitOnClose, setModel, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

days

protected SmallDayViewDisplay[] days
Array of day displays for convenient access by date number. This array contains references to the same day-display objects that are laid out in the day grid.


vbox

protected javax.swing.JPanel vbox
Outermost box of the laid-out display.


dateBanner

protected javax.swing.JPanel dateBanner
The date banner at the top of the display.


daysOfWeek

protected javax.swing.JPanel daysOfWeek
The days-of-the week labeling row.


dayGrid

protected javax.swing.JPanel dayGrid
The day grid.


numberOfWeeks

protected int numberOfWeeks
Number or weeks (hence display rows) in the current display.


defaultSize

protected java.awt.Dimension defaultSize
Initial default size of the day grid.


defaultCellHeight

protected final int defaultCellHeight
Default constant for the height of one day display cell.

See Also:
Constant Field Values

defaultCellWidth

protected final int defaultCellWidth
Default constant for the width of one day display cell.

See Also:
Constant Field Values
Constructor Detail

MonthlyAgendaDisplay

public MonthlyAgendaDisplay(mvp.Screen s,
                            MonthlyAgenda monthlyAgenda,
                            CalendarToolUI calToolUI)
Construct this by constructing subpanels for the three parts of the display. Also construct an array of 31 day displays. This array provides direct access to the individual day displays by date number, which is handy for referencing the companion day models directly. Compute the default size of the days grid to be 5 rows by 7 columns of a default-size day display. If there are 4 or 6 rows, then the default rows are taller or shorter than they are wide. This formating is per the requirements. Initialize the displayedOnce flag to false. The display is only set to the default size the first time it is displayed. After that, the display retains its size, including any resizing done by the user.

Method Detail

compose

public java.awt.Component compose()
Compose this as a vertical box, consisting of a date-banner row, a days-of-the-week labels row, and an empty days grid. The grid will be populated by update.

Overrides:
compose in class mvp.View

composeDateBanner

protected javax.swing.JPanel composeDateBanner()
Compose the date banner. For now it's a dummy label. In the full implementation, it will contain prev,next,today buttons and the current month/year.


update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Display the model data in the appropriate daily positions. The data are produced by firstDay and nextDay iterator methods. The display is a 7-column grid, with 4, 5, or 6 rows, depending on the configuration of the month. In the current implementation, the display is fully redrawn at each call to update, with no display efficiencies implemented. Possible display efficiencies that might be implemented include the following. (1) If the model data have not changed at all, no updating is performed. This is the presumably rare case where the user has executed a 'Goto Date' command for the current month. (2) If the number of weeks in the new model month is the same as the current model month, the row boxes are not reallocated.

Specified by:
update in interface java.util.Observer
Overrides:
update in class mvp.View

greyDay

protected javax.swing.JPanel greyDay()
Build an empty grey-background, black-border day display. A fresh one of these needs to be allocated for each use since JFC doesn't play reuses of a components in containers.