All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ejmf.toolkit.multiplayer.TrackModel

java.lang.Object
   |
   +----com.sun.java.swing.table.AbstractTableModel
           |
           +----ejmf.toolkit.multiplayer.TrackModel

public class TrackModel
extends AbstractTableModel
A model of a collection of Tracks. This model is specifically designed to serve as a model for a JTable.

The model maintains information about Tracks in a TrackList.

Objects interested in changes to model can register as a TrackModelListener. When a change occurs in the model, listeners are notified with a TrackModelEvent delivered to their trackModelUpdate method. There are four types of TrackModel events: assignment, playing time change, start time change, and deassignment.

See Also:
AbstractTableModel, JTable, TrackList, TrackModelEvent

Constructor Index

 o TrackModel(String[], TrackList)
Create a TrackModel with table column names and a TrackList.

Method Index

 o addTrackModelListener(TrackModelListener)
Add a TrackModelListener
 o assignTrack(Player, MediaLocator)
Populate a Track with information about a Player.
 o assignTrack(String, double, double)
Assign a new Track.
 o clear()
Deassign all Tracks in TrackList maintained by TrackModel.
 o deassignTrack(int)
Deassign Track at index in the TrackModel.
 o deassignTrack(Player)
Deassign Track associated with Player in the TrackModel.
 o fireTableCellUpdated(int, int)
Fire an event in response to update of table cell.
 o fireTrackModelUpdate(TrackModelEvent)
Notify all listeners of a Track update.
 o getAvailableTrack()
Get next Track that does not have a Player associated with it.
 o getColumnClass(int)
Return Class stored within a column.
 o getColumnCount()
Since we extend AbstractTableModel, we override getColumnCount.
 o getColumnName(int)
Since we extend AbstractTableModel, we override getColumnName.
 o getNumberOfAssignedTracks()
Report number of tracks that are currently assigned.
 o getNumberOfAvailableTracks()
Report number of tracks currently available or unassigned.
 o getNumberOfTracks()
Report total number of tracks managed by this model.
 o getRowCount()
Since we extend AbstractTableModel, we override getRowCount.
 o getTrack(int)
Return Track at index specified by argument.
 o getTrackList()
Return TrackList associated with TrackModel.
 o getValueAt(int, int)
Return value within a cell identified by arguments.
 o isCellEditable(int, int)
Report that start time and playing time columns are editable.
 o read(File)
Read contents of a MIX file and assign Tracks.
 o removeTrackModelListener(TrackModelListener)
Remove TrackModelListener identified by argument
 o setMediaLocator(int, MediaLocator)
Set the media locator for the Track at index.
 o setPlayer(int, Player)
Initialize the Player assoicated with a Track.
 o setPlayingTime(int, double)
Set the playing time of the index Track.
 o setPlayingTime(int, String)
Set the playing time of the index Track.
 o setStartTime(int, double)
Set the start time of the index Track.
 o setStartTime(int, String)
Set the start time of the index Track.
 o setValueAt(Object, int, int)
Set the value in the table in the cell at (row, column).
 o write(ExtensionFilter, File)
Generate output for current Tracks.

Constructors

 o TrackModel
 public TrackModel(String columnNames[],
                   TrackList trackList)
Create a TrackModel with table column names and a TrackList.

Parameters:
columnNames - A String[] identifying table columns
trackList - A TrackList

Methods

 o getTrackList
 public TrackList getTrackList()
Return TrackList associated with TrackModel.

 o getTrack
 public Track getTrack(int index)
Return Track at index specified by argument.

Parameters:
index - Index into TrackList.
Returns:
a Track at index passed as argument
 o assignTrack
 public void assignTrack(Player player,
                         MediaLocator ml)
Populate a Track with information about a Player.

Parameters:
player - Player whose media is maintained by this track.
ml - MediaLocator associated with Player.
 o assignTrack
 public void assignTrack(String fileName,
                         double stTime,
                         double plTime) throws IllegalArgumentException, IOException, NoPlayerException
Assign a new Track. Suppress update notification of obj.

Parameters:
fileName - media file name from which Player will be built.
stTime - Offset at which media begins to play.
plTime - Length of time media is played.
Throws: IOException
thrown if DataSource can not be connected to.
Throws: NoPlayerException
thrown if no handler exists for Player
Throws: IllegalArgumentException
thrown if file name argument can not be converted to media locator.
 o deassignTrack
 public void deassignTrack(int index)
Deassign Track at index in the TrackModel.

Parameters:
index - Index of Track to be deassigned.
 o deassignTrack
 public void deassignTrack(Player player)
Deassign Track associated with Player in the TrackModel.

Parameters:
player - Player from which Track is derived.
 o clear
 public void clear()
Deassign all Tracks in TrackList maintained by TrackModel.

 o setMediaLocator
 public void setMediaLocator(int index,
                             MediaLocator ml)
Set the media locator for the Track at index.

Parameters:
index - Index of Track.
ml - New MediaLocator value.
 o setPlayingTime
 public void setPlayingTime(int index,
                            String seconds)
Set the playing time of the index Track.

Parameters:
index - Track number.
seconds - A String representing a seconds value.
 o setPlayingTime
 public void setPlayingTime(int index,
                            double seconds)
Set the playing time of the index Track.

Parameters:
index - Track number.
seconds - A double representing a seconds value.
 o setStartTime
 public void setStartTime(int index,
                          String seconds)
Set the start time of the index Track.

Parameters:
index - Track number.
seconds - A String representing a seconds value.
 o setStartTime
 protected void setStartTime(int index,
                             double seconds)
Set the start time of the index Track.

Parameters:
index - Track number.
seconds - A double representing a seconds value.
 o setPlayer
 public void setPlayer(int index,
                       Player player)
Initialize the Player assoicated with a Track.

Parameters:
index - Index of Track with which Player is to be associated.
player - Player to associated with Track.
 o getAvailableTrack
 public int getAvailableTrack()
Get next Track that does not have a Player associated with it.

Returns:
The index of available Track.
 o getNumberOfAvailableTracks
 public int getNumberOfAvailableTracks()
Report number of tracks currently available or unassigned.

Returns:
The number of available Tracks
 o getNumberOfTracks
 public int getNumberOfTracks()
Report total number of tracks managed by this model.

Returns:
number of Tracks managed by model.
 o getNumberOfAssignedTracks
 public int getNumberOfAssignedTracks()
Report number of tracks that are currently assigned.

Returns:
number of Tracks currently assigned a Player
 o fireTableCellUpdated
 protected void fireTableCellUpdated(int row,
                                     int col)
Fire an event in response to update of table cell. Simply calls corresponding super method.

Overrides:
fireTableCellUpdated in class AbstractTableModel
See Also:
AbstractTableModel;
 o getColumnCount
 public int getColumnCount()
Since we extend AbstractTableModel, we override getColumnCount.

Overrides:
getColumnCount in class AbstractTableModel
See Also:
AbstractTableModel;
 o getColumnName
 public String getColumnName(int index)
Since we extend AbstractTableModel, we override getColumnName.

Overrides:
getColumnName in class AbstractTableModel
See Also:
AbstractTableModel;
 o isCellEditable
 public boolean isCellEditable(int row,
                               int col)
Report that start time and playing time columns are editable.

Parameters:
row - Identifies a Track within TrackModel
col - Identifies a field within a Track.
Returns:
true if start time or playing time column is identified by col.
Overrides:
isCellEditable in class AbstractTableModel
See Also:
AbstractTableModel;
 o getRowCount
 public int getRowCount()
Since we extend AbstractTableModel, we override getRowCount. The row count is the number of Tracks in TrackModel.

Returns:
The number of Tracks in TrackModel.
Overrides:
getRowCount in class AbstractTableModel
See Also:
AbstractTableModel;
 o getValueAt
 public Object getValueAt(int row,
                          int col)
Return value within a cell identified by arguments.

Parameters:
row - Identifies a Track within TrackModel
col - Identifies a field within a Track.
Overrides:
getValueAt in class AbstractTableModel
See Also:
AbstractTableModel;
 o setValueAt
 public void setValueAt(Object aValue,
                        int row,
                        int col)
Set the value in the table in the cell at (row, column).

Parameters:
aValue - The value to place in the cell.
row - The row index of the cell.
col - The column index of the cell.
Overrides:
setValueAt in class AbstractTableModel
See Also:
AbstractTableModel;
 o getColumnClass
 public Class getColumnClass(int col)
Return Class stored within a column.

Parameters:
col - A column index.
Overrides:
getColumnClass in class AbstractTableModel
See Also:
AbstractTableModel;
 o write
 public void write(ExtensionFilter ff,
                   File trackFile)
Generate output for current Tracks. Type of ExtensionFilter determines format of output. HTMLFileFilter generates a series of PARAM tags. Each PARAM looks like: where n is 0..n-1. Otherwise, a Mix file is generated.

 o read
 public int read(File trackFile)
Read contents of a MIX file and assign Tracks.

Parameters:
trackFile - A File reference of a MIX file.
Returns:
0 if file is successfully read, -1 otherwise.
 o addTrackModelListener
 public void addTrackModelListener(TrackModelListener tml)
Add a TrackModelListener

Parameters:
tml - A TrackModelListener
 o removeTrackModelListener
 public void removeTrackModelListener(TrackModelListener tml)
Remove TrackModelListener identified by argument

Parameters:
tml - A TrackModelListener
 o fireTrackModelUpdate
 protected void fireTrackModelUpdate(TrackModelEvent tme)
Notify all listeners of a Track update.

Parameters:
tme - The event the occurred on the Track.

All Packages  Class Hierarchy  This Package  Previous  Next  Index