All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tc.calendar.TimeGrid

java.lang.Object
   |
   +----tc.calendar.TimeGrid

public class TimeGrid
extends Object
implements MatrixModel
TimeGrid is an adapter that represents a vector of TimeSlice objects as a grid (MatrixModel). The grid can be used as a model for the CalendarPanel user interface component.

Version:
0.30, 1998/04/01
Author:
FRED development team, Antti Viljamaa, Jukka Viljamaa
See Also:
TimeSlice, CalendarPanel

Variable Index

 o columnUnit
The column unit.
 o criticalDate
The critical date.
 o DAY_FORMAT
Formatter string for days.
 o dayColumnFormat
Formatter day columns.
 o dayWeekRowFormat
Formatter for days of week in rows.
 o grid
The time grid that includes vectors of TimeSlice objects.
 o gridColumnCount
The grid column count.
 o gridEndDate
The grid end date.
 o gridIncrement
The grid column increment.
 o gridRowCount
The grid row count.
 o gridStartDate
The grid start date.
 o HOUR_FORMAT
Formatter string for hours.
 o hourColumnFormat
Formatter for hours in columns.
 o hourDayRowFormat
Formatter for hours of day in rows.
 o initialGridStartDate
The initial value for the start date.
 o markers
The markers.
 o MINUTE_FORMAT
Formatter string for minutes.
 o minuteColumnFormat
Formatter for minutes in columns.
 o MONTH_FORMAT
Formatter string for months.
 o monthColumnFormat
Formatter string for months in columns.
 o rowUnit
The row unit.
 o timeSlices
The time slices.
 o WEEK_FORMAT
Formatter string for weeks.
 o weekColumnFormat
Formatter for weeks in columns.
 o windowColumnCount
The window column count.
 o windowRowCount
The window row count.
 o windowStartColumn
The window start column.
 o windowStartRow
The window start row.
 o YEAR_FORMAT
Formatter string for years.
 o yearColumnFormat
Formatter for years in columns.

Constructor Index

 o TimeGrid()
Creates and initializes a new time grid.

Method Index

 o addModelListener(MatrixModelListener)
Adds a model event listener to this model.
 o addTimeSlice(TimeSlice)
Adds the given time slice to the existing time slices.
 o addTimeSlices(Vector)
Adds the given time slices to the existing time slices.
 o calculateGridColumnCount()
Determines the grid width from the grid start and end dates and the column unit.
 o calculateGridRowCount()
Determines the grid height from the grid column and row units.
 o dateToColumn(long)
Returns the grid column that corresponds to the given date.
 o dateToRow(long)
Returns the grid row that corresponds to the given date.
 o find(Object)
Returns the storage location of the passed data object.
 o get(int, int)
Returns data object at row and column.
 o getColumnCount()
Returns count of columns.
 o getColumnHeader(int)
Returns the header of the given column.
 o getColumnUnit()
Gets the column unit.
 o getCriticalDate()
Gets the critical date.
 o getDate(int, int)
Returns the date that corresponds to the given window column and row.
 o getGranularityString()
Returns the string representing the granularity of the grid.
 o getGrid()
Gets the actual two dimensional array of vectors of time slices to where the time slices are sorted to be displayed in the CalendarPanel.
 o getGridColumnCount()
Gets the grid column count.
 o getGridEndDate()
Gets the grid end date.
 o getGridIncrement()
Gets the grid column increment.
 o getGridRowCount()
Gets the grid row count.
 o getGridStartDate()
Gets the grid start date.
 o getInitialGridStartDate()
Gets initial value for the start date.
 o getMarkers()
Gets the markers.
 o getRowCount()
Returns count of rows.
 o getRowHeader(int)
Returns the header of the given row.
 o getRowUnit()
Gets the row unit.
 o getTimeSlices()
Returns the time slices.
 o getUnitAsMilliseconds(int)
Returns the given time unit's value in milliseconds.
 o getUnitColumnFormat(int)
Returns a SimpleDateFormat object to be used when formatting column headers.
 o getUnitRowFormat(int)
Returns a SimpleDateFormat object to be used when formatting row headers.
 o getUnitString(int)
Returns a string representation of the given time unit.
 o getWindowColumnCount()
Gets the window column count.
 o getWindowRowCount()
Gets the window row count.
 o getWindowStartColumn()
Gets the window start column.
 o getWindowStartRow()
Gets the window start row.
 o rebuildGrid()
Allocates new grid and sortes all time slices to it by calling setLocations(...).
 o removeModelListener(MatrixModelListener)
Removes a model event listener from this model.
 o removeTimeSlices(Vector)
Removes the given time slices from the existing time slices.
 o resetGrid()
Removes all time slices from the grid and then rebuilds it.
 o resetGrid(long)
Removes all time slices from the grid, sets the start date to the given date, adjusts the grid size to the grid increment value, and then rebuilds the grid.
 o setColumnUnit(int)
Sets the column unit.
 o setCriticalDate(long)
Sets the critical date.
 o setGranularity(int, int)
Sets the time grid granularity to the given column and row time unit values.
 o setGrid(Vector[][])
Sets the actual two dimensional array of vectors of time slices to where the time slices are sorted to be displayed in the CalendarPanel.
 o setGridColumnCount(int)
Sets the grid column count.
 o setGridEndDate(long)
Sets the grid end date, adjusts the grid column count accordingly, and rebuilds the grid.
 o setGridIncrement(int)
Sets the grid column increment.
 o setGridLocations(TimeSlice)
Sets the given time slice to all those locations in the grid (the two dimensional array of vectors of time slices) that are covered by the given time slice.
 o setGridLocations(Vector)
Calls setGridLocations(TimeSlice ts) for each time slice in the given vector.
 o setGridRowCount(int)
Sets the grid row count.
 o setGridStartDate(long)
Sets the grid start date, adjusts the grid column count accordingly, and rebuilds the grid.
 o setInitialGridStartDate(long)
Sets initial value for the start date.
 o setMarkers(Vector)
Sets the markers.
 o setRowUnit(int)
Sets the row unit.
 o setTimeSlices(Vector)
Sets the time slices.
 o setWindow(int)
Moves the window by setting its start column to the given column.
 o setWindow(int, int, int, int)
Sets the window's start column and row as well as its width and height.
 o setWindowColumnCount(int)
Sets the window column count.
 o setWindowRowCount(int)
Sets the window row count.
 o setWindowStartColumn(int)
Sets the window start column.
 o setWindowStartRow(int)
Sets the window start row.

Variables

 o columnUnit
 private int columnUnit
The column unit. See getColumnUnit() for valid time unit values.

See Also:
getColumnUnit
 o criticalDate
 private long criticalDate
The critical date.

 o DAY_FORMAT
 private static final String DAY_FORMAT
Formatter string for days.

 o dayColumnFormat
 private SimpleDateFormat dayColumnFormat
Formatter day columns.

 o dayWeekRowFormat
 private SimpleDateFormat dayWeekRowFormat
Formatter for days of week in rows.

 o grid
 private Vector grid[][]
The time grid that includes vectors of TimeSlice objects.

 o gridColumnCount
 private int gridColumnCount
The grid column count.

 o gridEndDate
 private long gridEndDate
The grid end date.

 o gridIncrement
 private int gridIncrement
The grid column increment.

 o gridRowCount
 private int gridRowCount
The grid row count.

 o gridStartDate
 private long gridStartDate
The grid start date.

 o HOUR_FORMAT
 private static final String HOUR_FORMAT
Formatter string for hours.

 o hourColumnFormat
 private SimpleDateFormat hourColumnFormat
Formatter for hours in columns.

 o hourDayRowFormat
 private SimpleDateFormat hourDayRowFormat
Formatter for hours of day in rows.

 o initialGridStartDate
 private long initialGridStartDate
The initial value for the start date.

 o markers
 private Vector markers
The markers.

 o MINUTE_FORMAT
 private static final String MINUTE_FORMAT
Formatter string for minutes.

 o minuteColumnFormat
 private SimpleDateFormat minuteColumnFormat
Formatter for minutes in columns.

 o MONTH_FORMAT
 private static final String MONTH_FORMAT
Formatter string for months.

 o monthColumnFormat
 private SimpleDateFormat monthColumnFormat
Formatter string for months in columns.

 o rowUnit
 private int rowUnit
The row unit. See getColumnUnit() for valid time unit values.

See Also:
getColumnUnit
 o timeSlices
 private Vector timeSlices
The time slices. Vector of TimeSlice objects.

 o WEEK_FORMAT
 private static final String WEEK_FORMAT
Formatter string for weeks.

 o weekColumnFormat
 private SimpleDateFormat weekColumnFormat
Formatter for weeks in columns.

 o windowColumnCount
 private int windowColumnCount
The window column count.

 o windowRowCount
 private int windowRowCount
The window row count.

 o windowStartColumn
 private int windowStartColumn
The window start column.

 o windowStartRow
 private int windowStartRow
The window start row.

 o YEAR_FORMAT
 private static final String YEAR_FORMAT
Formatter string for years.

 o yearColumnFormat
 private SimpleDateFormat yearColumnFormat
Formatter for years in columns.

Constructors

 o TimeGrid
 public TimeGrid()
Creates and initializes a new time grid.

Methods

 o addModelListener
 public void addModelListener(MatrixModelListener listener)
Adds a model event listener to this model.

Parameters:
listener - The MatrixModelListener to add.
 o addTimeSlice
 public void addTimeSlice(TimeSlice ts)
Adds the given time slice to the existing time slices.

 o addTimeSlices
 public void addTimeSlices(Vector slices)
Adds the given time slices to the existing time slices.

 o dateToColumn
 public int dateToColumn(long d)
Returns the grid column that corresponds to the given date.

Parameters:
d - The date as milliseconds from the start of 1970.
Returns:
The corresponding column in the grid.
 o dateToRow
 public int dateToRow(long d)
Returns the grid row that corresponds to the given date.

Parameters:
d - The date as milliseconds from the start of 1970.
Returns:
The corresponding row in the grid.
 o find
 public MatrixLocation find(Object data)
Returns the storage location of the passed data object.

Parameters:
data - The data object to search this container for.
Returns:
The address of the requested data object, or null if not found.
 o get
 public Object get(int row,
                   int column)
Returns data object at row and column.

Parameters:
row - The row address of the data object to get.
column - The column address of the data object to get.
Returns:
The requested data object.
 o getColumnCount
 public int getColumnCount()
Returns count of columns.

Returns:
The number of columns in this container.
 o getColumnHeader
 public String getColumnHeader(int i)
Returns the header of the given column.

Parameters:
i - The column index.
Returns:
The header string.
 o getColumnUnit
 public int getColumnUnit()
Gets the column unit. The valid time units are denoted by the following constants defined in class java.util.Calendar: YEAR, MONTH, WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_YEAR, DAY_OF_MONTH, DAY_OF_WEEK, HOUR_OF_DAY, and MINUTE.

See Also:
Calendar
 o getDate
 public long getDate(int windowColumn,
                     int windowRow)
Returns the date that corresponds to the given window column and row.

Parameters:
windowColumn - The window column index.
windowRow - The window row index.
Returns:
The date as milliseconds from the start of 1970.
 o getGranularityString
 public String getGranularityString()
Returns the string representing the granularity of the grid. This string is output in the 0th column in the 0th row in CalendarPanel. The format of the string is "/".

Parameters:
windowColumn - The window column index.
windowRow - The window row index.
Returns:
The date as milliseconds from the start of 1970.
 o getGridColumnCount
 public int getGridColumnCount()
Gets the grid column count.

 o getGridEndDate
 public long getGridEndDate()
Gets the grid end date.

 o getGridIncrement
 public int getGridIncrement()
Gets the grid column increment.

 o getGridRowCount
 public int getGridRowCount()
Gets the grid row count.

 o getGridStartDate
 public long getGridStartDate()
Gets the grid start date.

 o getInitialGridStartDate
 public long getInitialGridStartDate()
Gets initial value for the start date. Call timeGrid.resetGrid(timeGrid.getInitialGridStartDate()) to reset the grid to initial start date.

 o getMarkers
 public Vector getMarkers()
Gets the markers.

 o getRowCount
 public int getRowCount()
Returns count of rows.

Returns:
The number of rows in this container.
 o getRowHeader
 public String getRowHeader(int i)
Returns the header of the given row.

Parameters:
i - The row index.
Returns:
The header string.
 o getRowUnit
 public int getRowUnit()
Gets the row unit. See getColumnUnit() for valid time unit values.

Returns:
The unit as milliseconds.
See Also:
getColumnUnit
 o getUnitAsMilliseconds
 public long getUnitAsMilliseconds(int unit)
Returns the given time unit's value in milliseconds. See getColumnUnit() for valid time unit values.

Parameters:
unit - The time unit.
Returns:
The unit as milliseconds.
See Also:
getColumnUnit
 o getUnitString
 public String getUnitString(int unit)
Returns a string representation of the given time unit. See getColumnUnit() for valid time unit values.

Parameters:
unit - The time unit.
Returns:
The name of the given time unit as a string.
See Also:
getColumnUnit
 o getWindowColumnCount
 public int getWindowColumnCount()
Gets the window column count.

 o getWindowRowCount
 public int getWindowRowCount()
Gets the window row count.

 o getWindowStartColumn
 public int getWindowStartColumn()
Gets the window start column.

 o getWindowStartRow
 public int getWindowStartRow()
Gets the window start row.

 o removeModelListener
 public void removeModelListener(MatrixModelListener listener)
Removes a model event listener from this model.

Parameters:
listener - The MatrixModelListener to remove.
 o removeTimeSlices
 public void removeTimeSlices(Vector ts)
Removes the given time slices from the existing time slices.

 o resetGrid
 public void resetGrid()
Removes all time slices from the grid and then rebuilds it.

 o resetGrid
 public void resetGrid(long start)
Removes all time slices from the grid, sets the start date to the given date, adjusts the grid size to the grid increment value, and then rebuilds the grid.

 o setGranularity
 public void setGranularity(int columnUnit,
                            int rowUnit)
Sets the time grid granularity to the given column and row time unit values. See getColumnUnit() for valid time unit values. Note also that rowUnit must be smaller than columnUnit.

Parameters:
columnUnit - The time unit of columns.
rowUnit - The time unit of rows.
See Also:
getColumnUnit
 o setGridEndDate
 public void setGridEndDate(long d)
Sets the grid end date, adjusts the grid column count accordingly, and rebuilds the grid.

 o setGridIncrement
 public void setGridIncrement(int i)
Sets the grid column increment.

 o setGridStartDate
 public void setGridStartDate(long d)
Sets the grid start date, adjusts the grid column count accordingly, and rebuilds the grid.

 o setInitialGridStartDate
 public void setInitialGridStartDate(long l)
Sets initial value for the start date. Call timeGrid.resetGrid(timeGrid.getInitialGridStartDate()) to reset the grid to initial start date.

 o setMarkers
 public void setMarkers(Vector m)
Sets the markers.

 o setWindow
 public void setWindow(int startColumn)
Moves the window by setting its start column to the given column.

 o setWindow
 public void setWindow(int startColumn,
                       int startRow,
                       int width,
                       int height)
Sets the window's start column and row as well as its width and height.

 o calculateGridColumnCount
 protected int calculateGridColumnCount()
Determines the grid width from the grid start and end dates and the column unit.

 o calculateGridRowCount
 protected int calculateGridRowCount()
Determines the grid height from the grid column and row units.

 o getUnitColumnFormat
 protected SimpleDateFormat getUnitColumnFormat(int unit)
Returns a SimpleDateFormat object to be used when formatting column headers. The selection depends on the given time unit. See getColumnUnit() for valid time unit values.

Parameters:
unit - The column's time unit.
Returns:
The formatter for columns.
See Also:
getColumnUnit
 o getUnitRowFormat
 protected SimpleDateFormat getUnitRowFormat(int unit)
Returns a SimpleDateFormat object to be used when formatting row headers. The selection depends on the given row time unit and the column unit. See getColumnUnit() for valid time unit values.

Parameters:
unit - The row's time unit.
Returns:
The formatter for rows.
See Also:
getColumnUnit
 o rebuildGrid
 protected void rebuildGrid()
Allocates new grid and sortes all time slices to it by calling setLocations(...).

 o setGridLocations
 protected void setGridLocations(TimeSlice ts)
Sets the given time slice to all those locations in the grid (the two dimensional array of vectors of time slices) that are covered by the given time slice. The sorting depends on the start and end times of the given time slice and the granularity (column and row units) of the grid.

 o setGridLocations
 protected void setGridLocations(Vector ts)
Calls setGridLocations(TimeSlice ts) for each time slice in the given vector. Assumes that all objects in the vector are of class TimeSlice.

 o getCriticalDate
 private long getCriticalDate()
Gets the critical date. The critical date is the old start date of the grid when it is expanded backwards in time or old end date if it is expanded forwards in time. The critical date is used in filtering out those time slices that are already in the grid from the time slices that are to be added to the grid.

 o getGrid
 private Vector[][] getGrid()
Gets the actual two dimensional array of vectors of time slices to where the time slices are sorted to be displayed in the CalendarPanel.

 o getTimeSlices
 private Vector getTimeSlices()
Returns the time slices.

 o setColumnUnit
 private void setColumnUnit(int cu)
Sets the column unit. See getColumnUnit() for valid time unit values.

Parameters:
unit - The column's time unit.
See Also:
getColumnUnit
 o setCriticalDate
 private void setCriticalDate(long d)
Sets the critical date. The critical date is the old start date of the grid when it is expanded backwards in time or old end date if it is expanded forwards in time. The critical date is used in filtering out those time slices that are already in the grid from the time slices that are to be added to the grid.

 o setGrid
 private void setGrid(Vector g[][])
Sets the actual two dimensional array of vectors of time slices to where the time slices are sorted to be displayed in the CalendarPanel.

 o setGridColumnCount
 private void setGridColumnCount(int cc)
Sets the grid column count.

 o setGridRowCount
 private void setGridRowCount(int rc)
Sets the grid row count.

 o setRowUnit
 private void setRowUnit(int cu)
Sets the row unit. See getColumnUnit() for valid time unit values.

Parameters:
unit - The row's time unit.
See Also:
getColumnUnit
 o setTimeSlices
 private void setTimeSlices(Vector ts)
Sets the time slices.

 o setWindowColumnCount
 private void setWindowColumnCount(int cc)
Sets the window column count.

 o setWindowRowCount
 private void setWindowRowCount(int rc)
Sets the window row count.

 o setWindowStartColumn
 private void setWindowStartColumn(int c)
Sets the window start column.

 o setWindowStartRow
 private void setWindowStartRow(int r)
Sets the window start row.


All Packages  Class Hierarchy  This Package  Previous  Next  Index