Class Record

java.lang.Object
  extended by Record

public class Record
extends java.lang.Object

This class handles the recording of moves and saving of log files. Moves are stored in a linked list and are written to a file all at once when saveLog() is called.

See Also:
LogFile, LogEntry

Field Summary
(package private)  boolean isRecording
          true if the record object is currently recording
(package private)  java.util.Iterator mlIterator
          Iterator for the list of log entries
(package private)  java.util.LinkedList moveList
          A list of LogEntries
(package private)  java.util.Calendar nowCalendar
          Current calender object
(package private)  CLIPFrame parentFrame
          The frame that the application runs in
(package private)  java.util.Calendar startCalendar
          Calender object from the time recording was started
(package private)  long timeLast
          Stores the time that the last move occured at
(package private)  long timeNow
          Stores the current time
(package private)  long timeStart
          Stores the time at which the recording began
 
Constructor Summary
Record(CLIPFrame parentF)
          Constructor sets the frame object and creates a new move list.
 
Method Summary
 boolean isRecording()
          Returns true if recording is turned on.
 void printList()
          A debug function that prints the list of moves to the console.
 void recordAddBlankTile(int tileID, java.lang.String name, java.lang.String desc)
          This records an 'add blank tile' move.
 void recordAddBlankTileToGrid(int tileID, java.lang.String name, java.lang.String desc, int x, int y)
          This records an 'add blank tile in grid' move.
 void recordEditBlankTile(int tileID, java.lang.String name, java.lang.String desc, java.lang.String oldName, java.lang.String oldDesc)
          This records an 'edit blank tile' move.
 void recordLoadLog(long tStart, long tEnd)
          Records a 'load' move.
 void recordMove(int type, int tileID, int xOld, int yOld, int xNew, int yNew)
          This records a 'move' type entry defined by the parameters.
 void recordRemoveBlankTile(int moveType, int tileID, java.lang.String name, java.lang.String desc, int oldX, int oldY)
          This records a 'remove blank tile' move.
 void recordSaveLog()
          Records a 'save' move.
 void recordTileBinWidthChange(int oldX, int newX)
          This records a 'tilebin width change' move.
 boolean saveLog(java.lang.String fPath)
          This function saves a log file at the specified path.
private  void setTimes(LogEntry theMove)
          Generates the elapsed time and previous move time then sets them for the passed in LogEntry.
 void startRecording()
          Starts recording and sets the start time.
 void stopRecording()
          Stops recording.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isRecording

boolean isRecording
true if the record object is currently recording


startCalendar

java.util.Calendar startCalendar
Calender object from the time recording was started


nowCalendar

java.util.Calendar nowCalendar
Current calender object


timeStart

long timeStart
Stores the time at which the recording began


timeLast

long timeLast
Stores the time that the last move occured at


timeNow

long timeNow
Stores the current time


moveList

java.util.LinkedList moveList
A list of LogEntries

See Also:
LogEntry

mlIterator

java.util.Iterator mlIterator
Iterator for the list of log entries


parentFrame

CLIPFrame parentFrame
The frame that the application runs in

Constructor Detail

Record

public Record(CLIPFrame parentF)
Constructor sets the frame object and creates a new move list.

Method Detail

isRecording

public boolean isRecording()
Returns true if recording is turned on.

Returns:
true if recording is turned on; returns false otherwise.

startRecording

public void startRecording()
Starts recording and sets the start time.


stopRecording

public void stopRecording()
Stops recording.


printList

public void printList()
A debug function that prints the list of moves to the console. This uses the print() function of a LogEntry.

See Also:
LogEntry.print()

setTimes

private void setTimes(LogEntry theMove)
Generates the elapsed time and previous move time then sets them for the passed in LogEntry.

Parameters:
theMove - The LogEntry to set the times for

recordMove

public void recordMove(int type,
                       int tileID,
                       int xOld,
                       int yOld,
                       int xNew,
                       int yNew)
This records a 'move' type entry defined by the parameters. The four move types are grid to grid, grid to tilebin, tilebin to grid, and tilebin to tilebin.

Parameters:
type - The type of the move
tileID - ID of the tile moved
xOld - Old X position of the tile
yOld - Old Y position of the tile
xNew - New X position of the tile
yNew - New Y position of the tile

recordAddBlankTile

public void recordAddBlankTile(int tileID,
                               java.lang.String name,
                               java.lang.String desc)
This records an 'add blank tile' move. It is assumed that the tile is added to the tilebin.

Parameters:
tileID - ID of the added tile
name - Name of the added tile
desc - Description of the added tile

recordAddBlankTileToGrid

public void recordAddBlankTileToGrid(int tileID,
                                     java.lang.String name,
                                     java.lang.String desc,
                                     int x,
                                     int y)
This records an 'add blank tile in grid' move. It is assumed that the tile is added to the grid.

Parameters:
tileID - ID of the tile to add
name - Name of the tile to add
desc - Description of the tile to add
x - X Location of the added tile
y - Y Location of the added tile

recordEditBlankTile

public void recordEditBlankTile(int tileID,
                                java.lang.String name,
                                java.lang.String desc,
                                java.lang.String oldName,
                                java.lang.String oldDesc)
This records an 'edit blank tile' move.

Parameters:
tileID - Tile ID of the edited tile
name - Name of the edited tile
desc - Description of the edited tile
oldName - Old name of the edited tile
oldDesc - Old description of the edited tile

recordRemoveBlankTile

public void recordRemoveBlankTile(int moveType,
                                  int tileID,
                                  java.lang.String name,
                                  java.lang.String desc,
                                  int oldX,
                                  int oldY)
This records a 'remove blank tile' move. This function is used for both removal from the grid and removal from the tilebin. A move type parameter is passed in so it knows which remove type it is.

Parameters:
moveType - Type of removal (from grid or tilebin)
tileID - ID of the removed tile
name - Name of the removed tile
desc - Description of the removed tile
oldX - Old X position of the removed tile
oldY - Old Y position of the removed tile
See Also:
LogEntry

recordTileBinWidthChange

public void recordTileBinWidthChange(int oldX,
                                     int newX)
This records a 'tilebin width change' move. Tilebin width changes are recorded so that if a person arranges tiles in the tilebin, the viewer of the log can make since of the arrangement since they will both be looking at a tilebin of the same width.

Parameters:
oldX - Old width of the tilebin (in # of tiles wide)
newX - New width of the tilebin (in # of tiles wide)

recordSaveLog

public void recordSaveLog()
Records a 'save' move. This is used to display a save type entry in the move description label during playback.


recordLoadLog

public void recordLoadLog(long tStart,
                          long tEnd)
Records a 'load' move. This is used to display a load type entry in the move description label during playback. Previous load time is the amount of time between when the log was saved and when it was loaded. The log start time becomes the current time minus the currently elapsed time of the log.

Parameters:
tStart - Start time of the log
tEnd - End time of the log (save time)

saveLog

public boolean saveLog(java.lang.String fPath)
This function saves a log file at the specified path. It first records a 'save' type entry. It then creates a LogFile object, adds the current TileSet and the move list to it, then outputs the log with zip compression.

Parameters:
fPath - Path and name of file to save
Returns:
truefalse on failure.
See Also:
LogFile, TileSet