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
-
columnUnit
- The column unit.
-
criticalDate
- The critical date.
-
DAY_FORMAT
- Formatter string for days.
-
dayColumnFormat
- Formatter day columns.
-
dayWeekRowFormat
- Formatter for days of week in rows.
-
grid
- The time grid that includes vectors of TimeSlice objects.
-
gridColumnCount
- The grid column count.
-
gridEndDate
- The grid end date.
-
gridIncrement
- The grid column increment.
-
gridRowCount
- The grid row count.
-
gridStartDate
- The grid start date.
-
HOUR_FORMAT
- Formatter string for hours.
-
hourColumnFormat
- Formatter for hours in columns.
-
hourDayRowFormat
- Formatter for hours of day in rows.
-
initialGridStartDate
- The initial value for the start date.
-
markers
- The markers.
-
MINUTE_FORMAT
- Formatter string for minutes.
-
minuteColumnFormat
- Formatter for minutes in columns.
-
MONTH_FORMAT
- Formatter string for months.
-
monthColumnFormat
- Formatter string for months in columns.
-
rowUnit
- The row unit.
-
timeSlices
- The time slices.
-
WEEK_FORMAT
- Formatter string for weeks.
-
weekColumnFormat
- Formatter for weeks in columns.
-
windowColumnCount
- The window column count.
-
windowRowCount
- The window row count.
-
windowStartColumn
- The window start column.
-
windowStartRow
- The window start row.
-
YEAR_FORMAT
- Formatter string for years.
-
yearColumnFormat
- Formatter for years in columns.
-
TimeGrid()
- Creates and initializes a new time grid.
-
addModelListener(MatrixModelListener)
- Adds a model event listener to this model.
-
addTimeSlice(TimeSlice)
- Adds the given time slice to the existing time slices.
-
addTimeSlices(Vector)
- Adds the given time slices to the existing time slices.
-
calculateGridColumnCount()
- Determines the grid width from the grid start and end dates and the
column unit.
-
calculateGridRowCount()
- Determines the grid height from the grid column and row units.
-
dateToColumn(long)
- Returns the grid column that corresponds to the given date.
-
dateToRow(long)
- Returns the grid row that corresponds to the given date.
-
find(Object)
- Returns the storage location of the passed data object.
-
get(int, int)
- Returns data object at row and column.
-
getColumnCount()
- Returns count of columns.
-
getColumnHeader(int)
- Returns the header of the given column.
-
getColumnUnit()
- Gets the column unit.
-
getCriticalDate()
- Gets the critical date.
-
getDate(int, int)
- Returns the date that corresponds to the given window column and row.
-
getGranularityString()
- Returns the string representing the granularity of the grid.
-
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.
-
getGridColumnCount()
- Gets the grid column count.
-
getGridEndDate()
- Gets the grid end date.
-
getGridIncrement()
- Gets the grid column increment.
-
getGridRowCount()
- Gets the grid row count.
-
getGridStartDate()
- Gets the grid start date.
-
getInitialGridStartDate()
- Gets initial value for the start date.
-
getMarkers()
- Gets the markers.
-
getRowCount()
- Returns count of rows.
-
getRowHeader(int)
- Returns the header of the given row.
-
getRowUnit()
- Gets the row unit.
-
getTimeSlices()
- Returns the time slices.
-
getUnitAsMilliseconds(int)
- Returns the given time unit's value in milliseconds.
-
getUnitColumnFormat(int)
- Returns a SimpleDateFormat object to be used when formatting column
headers.
-
getUnitRowFormat(int)
- Returns a SimpleDateFormat object to be used when formatting row
headers.
-
getUnitString(int)
- Returns a string representation of the given time unit.
-
getWindowColumnCount()
- Gets the window column count.
-
getWindowRowCount()
- Gets the window row count.
-
getWindowStartColumn()
- Gets the window start column.
-
getWindowStartRow()
- Gets the window start row.
-
rebuildGrid()
- Allocates new grid and sortes all time slices to it by calling
setLocations(...).
-
removeModelListener(MatrixModelListener)
- Removes a model event listener from this model.
-
removeTimeSlices(Vector)
- Removes the given time slices from the existing time slices.
-
resetGrid()
- Removes all time slices from the grid and then rebuilds it.
-
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.
-
setColumnUnit(int)
- Sets the column unit.
-
setCriticalDate(long)
- Sets the critical date.
-
setGranularity(int, int)
- Sets the time grid granularity to the given column and row time unit
values.
-
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.
-
setGridColumnCount(int)
- Sets the grid column count.
-
setGridEndDate(long)
- Sets the grid end date, adjusts the grid column count accordingly, and
rebuilds the grid.
-
setGridIncrement(int)
- Sets the grid column increment.
-
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.
-
setGridLocations(Vector)
- Calls setGridLocations(TimeSlice ts) for each time slice in the given
vector.
-
setGridRowCount(int)
- Sets the grid row count.
-
setGridStartDate(long)
- Sets the grid start date, adjusts the grid column count accordingly, and
rebuilds the grid.
-
setInitialGridStartDate(long)
- Sets initial value for the start date.
-
setMarkers(Vector)
- Sets the markers.
-
setRowUnit(int)
- Sets the row unit.
-
setTimeSlices(Vector)
- Sets the time slices.
-
setWindow(int)
- Moves the window by setting its start column to the given column.
-
setWindow(int, int, int, int)
- Sets the window's start column and row as well as its width and height.
-
setWindowColumnCount(int)
- Sets the window column count.
-
setWindowRowCount(int)
- Sets the window row count.
-
setWindowStartColumn(int)
- Sets the window start column.
-
setWindowStartRow(int)
- Sets the window start row.
columnUnit
private int columnUnit
- The column unit. See getColumnUnit() for valid time unit values.
- See Also:
- getColumnUnit
criticalDate
private long criticalDate
- The critical date.
DAY_FORMAT
private static final String DAY_FORMAT
- Formatter string for days.
dayColumnFormat
private SimpleDateFormat dayColumnFormat
- Formatter day columns.
dayWeekRowFormat
private SimpleDateFormat dayWeekRowFormat
- Formatter for days of week in rows.
grid
private Vector grid[][]
- The time grid that includes vectors of TimeSlice objects.
gridColumnCount
private int gridColumnCount
- The grid column count.
gridEndDate
private long gridEndDate
- The grid end date.
gridIncrement
private int gridIncrement
- The grid column increment.
gridRowCount
private int gridRowCount
- The grid row count.
gridStartDate
private long gridStartDate
- The grid start date.
HOUR_FORMAT
private static final String HOUR_FORMAT
- Formatter string for hours.
hourColumnFormat
private SimpleDateFormat hourColumnFormat
- Formatter for hours in columns.
hourDayRowFormat
private SimpleDateFormat hourDayRowFormat
- Formatter for hours of day in rows.
initialGridStartDate
private long initialGridStartDate
- The initial value for the start date.
markers
private Vector markers
- The markers.
MINUTE_FORMAT
private static final String MINUTE_FORMAT
- Formatter string for minutes.
minuteColumnFormat
private SimpleDateFormat minuteColumnFormat
- Formatter for minutes in columns.
MONTH_FORMAT
private static final String MONTH_FORMAT
- Formatter string for months.
monthColumnFormat
private SimpleDateFormat monthColumnFormat
- Formatter string for months in columns.
rowUnit
private int rowUnit
- The row unit. See getColumnUnit() for valid time unit values.
- See Also:
- getColumnUnit
timeSlices
private Vector timeSlices
- The time slices. Vector of TimeSlice objects.
WEEK_FORMAT
private static final String WEEK_FORMAT
- Formatter string for weeks.
weekColumnFormat
private SimpleDateFormat weekColumnFormat
- Formatter for weeks in columns.
windowColumnCount
private int windowColumnCount
- The window column count.
windowRowCount
private int windowRowCount
- The window row count.
windowStartColumn
private int windowStartColumn
- The window start column.
windowStartRow
private int windowStartRow
- The window start row.
YEAR_FORMAT
private static final String YEAR_FORMAT
- Formatter string for years.
yearColumnFormat
private SimpleDateFormat yearColumnFormat
- Formatter for years in columns.
TimeGrid
public TimeGrid()
- Creates and initializes a new time grid.
addModelListener
public void addModelListener(MatrixModelListener listener)
- Adds a model event listener to this model.
- Parameters:
- listener - The MatrixModelListener to add.
addTimeSlice
public void addTimeSlice(TimeSlice ts)
- Adds the given time slice to the existing time slices.
addTimeSlices
public void addTimeSlices(Vector slices)
- Adds the given time slices to the existing time slices.
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.
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.
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.
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.
getColumnCount
public int getColumnCount()
- Returns count of columns.
- Returns:
- The number of columns in this container.
getColumnHeader
public String getColumnHeader(int i)
- Returns the header of the given column.
- Parameters:
- i - The column index.
- Returns:
- The header string.
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
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.
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.
getGridColumnCount
public int getGridColumnCount()
- Gets the grid column count.
getGridEndDate
public long getGridEndDate()
- Gets the grid end date.
getGridIncrement
public int getGridIncrement()
- Gets the grid column increment.
getGridRowCount
public int getGridRowCount()
- Gets the grid row count.
getGridStartDate
public long getGridStartDate()
- Gets the grid start date.
getInitialGridStartDate
public long getInitialGridStartDate()
- Gets initial value for the start date. Call
timeGrid.resetGrid(timeGrid.getInitialGridStartDate())
to reset
the grid to initial start date.
getMarkers
public Vector getMarkers()
- Gets the markers.
getRowCount
public int getRowCount()
- Returns count of rows.
- Returns:
- The number of rows in this container.
getRowHeader
public String getRowHeader(int i)
- Returns the header of the given row.
- Parameters:
- i - The row index.
- Returns:
- The header string.
getRowUnit
public int getRowUnit()
- Gets the row unit. See getColumnUnit() for valid time unit values.
- Returns:
- The unit as milliseconds.
- See Also:
- getColumnUnit
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
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
getWindowColumnCount
public int getWindowColumnCount()
- Gets the window column count.
getWindowRowCount
public int getWindowRowCount()
- Gets the window row count.
getWindowStartColumn
public int getWindowStartColumn()
- Gets the window start column.
getWindowStartRow
public int getWindowStartRow()
- Gets the window start row.
removeModelListener
public void removeModelListener(MatrixModelListener listener)
- Removes a model event listener from this model.
- Parameters:
- listener - The MatrixModelListener to remove.
removeTimeSlices
public void removeTimeSlices(Vector ts)
- Removes the given time slices from the existing time slices.
resetGrid
public void resetGrid()
- Removes all time slices from the grid and then rebuilds it.
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.
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
setGridEndDate
public void setGridEndDate(long d)
- Sets the grid end date, adjusts the grid column count accordingly, and
rebuilds the grid.
setGridIncrement
public void setGridIncrement(int i)
- Sets the grid column increment.
setGridStartDate
public void setGridStartDate(long d)
- Sets the grid start date, adjusts the grid column count accordingly, and
rebuilds the grid.
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.
setMarkers
public void setMarkers(Vector m)
- Sets the markers.
setWindow
public void setWindow(int startColumn)
- Moves the window by setting its start column to the given column.
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.
calculateGridColumnCount
protected int calculateGridColumnCount()
- Determines the grid width from the grid start and end dates and the
column unit.
calculateGridRowCount
protected int calculateGridRowCount()
- Determines the grid height from the grid column and row units.
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
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
rebuildGrid
protected void rebuildGrid()
- Allocates new grid and sortes all time slices to it by calling
setLocations(...).
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.
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.
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.
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.
getTimeSlices
private Vector getTimeSlices()
- Returns the time slices.
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
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.
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.
setGridColumnCount
private void setGridColumnCount(int cc)
- Sets the grid column count.
setGridRowCount
private void setGridRowCount(int rc)
- Sets the grid row count.
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
setTimeSlices
private void setTimeSlices(Vector ts)
- Sets the time slices.
setWindowColumnCount
private void setWindowColumnCount(int cc)
- Sets the window column count.
setWindowRowCount
private void setWindowRowCount(int rc)
- Sets the window row count.
setWindowStartColumn
private void setWindowStartColumn(int c)
- Sets the window start column.
setWindowStartRow
private void setWindowStartRow(int r)
- Sets the window start row.
All Packages Class Hierarchy This Package Previous Next Index