Class TileSet

java.lang.Object
  extended by TileSet
All Implemented Interfaces:
java.io.Serializable

public class TileSet
extends java.lang.Object
implements java.io.Serializable

This class contains all the information relating to a tile set as well as the tiles themselves.

See Also:
Serialized Form

Field Summary
(package private)  boolean allowPrintArrangement
          true if the set allows users to print.
(package private)  java.lang.String arrangementComment
          Arrangement comments for the tile set.
(package private)  javax.swing.ImageIcon blankTileImage
          ImageIcon used for blank tiles.
(package private)  java.lang.String desc
          The description and/or instructions of the tile set.
(package private)  int gridNumTilesTall
          Number of tiles the grid should support vertically.
(package private)  int gridNumTilesWide
          Number of tiles the grid should support horizontally.
(package private)  int maxBlankTiles
          Max number of blank tiles allowed by the set.
(package private)  int maxUnusedTiles
          Max number of unused tiles allowed by the set.
(package private)  boolean missingTiles
          true if missing tiles are enabled.
(package private)  java.lang.String name
          The name of the tile set.
(package private)  int numBlankTiles
          Current number of blank tiles in use.
(package private)  int numMissingTiles
          Number of tiles to randomly leave out when the set loads.
(package private)  int numOfTiles
          Number of tiles currently in the set.
(package private)  boolean reqArrangementComment
          true if the set requires arrangement comments.
(package private)  boolean reqBlankDesc
          true if the set requires descriptions for blank tiles.
(package private)  boolean reqBlankName
          true if the set requires names for blank tiles.
(package private)  boolean reqUnusedDesc
          true if the set requires descriptions for unused tiles.
private static long serialVersionUID
           
(package private)  java.util.ArrayList summaryTiles
          The list of summary tiles.
(package private)  java.util.ArrayList tile
          The list of tiles in the set.
(package private)  int tileHeight
          Height of the tiles in gridSquares (20x20 pixels each).
(package private)  int tileHeightInPixels
          Height of the tiles in pixels.
(package private)  int tileWidth
          Width of the tiles in gridSquares (20x20 pixels each).
(package private)  int tileWidthInPixels
          Width of the tiles in pixels.
(package private)  boolean unlimitedBlanks
          true if the set allows unlimited blank tiles.
(package private)  boolean unlimitedUnused
          true if the set allows unlimited unused tiles.
 
Constructor Summary
TileSet(int tileCount, int gridSquareSize, int pixWidth, int pixHeight)
          Constructor for the TileSet class.
 
Method Summary
 boolean AddBlankIsAllowed()
          Returns true if the user is allowed to add at least one more blank tile to the set.
 int AddBlankTile(java.lang.String name, java.lang.String desc, java.awt.Component obs)
          Adds a blank tile to the tileset.
 void addBlankTileAt(int loc, java.lang.String name, java.lang.String desc, Grid theGrid, TileBin theTileBin)
          Adds a blank tile at a specific position in the tile list.
 boolean canUseBlankTiles()
          Returns true if the set supports the ability to add blank tiles.
 javax.swing.ImageIcon createBlankTileImage(java.lang.String name, java.awt.Component obs)
          Creates an ImageIcon to be used for a blank tile.
 boolean deleteBlankTile(int tileID, Grid theGrid, TileBin theTileBin)
          Deletes a blank tile.
 int getGridHeight()
          Returns the height of the grid in pixels required by the set.
 int getGridWidth()
          Returns the width of the grid in pixels required by the set.
 int getMaxBlank()
          Returns the max number of blank tiles allowed by the set.
 int getNumBlank()
          Returns the number of blank tiles currently being used.
 int getNumOfTiles()
          Returns the number of tiles in the set.
 java.awt.Rectangle getTileBoundsInGrid()
          Returns a bounding rectangle containing every tile in the grid.
 int getTileHeight()
          Returns the height of the tiles in GridSquares (20x20 pixels each)
 int getTileHeightInPixels()
          Returns the height of the tiles in pixels.
 int getTileWidth()
          Returns the width of the tiles in GridSquares (20x20 pixels each)
 int getTileWidthInPixels()
          Returns the width of the tiles in pixels.
 void prepForPlayback()
          Removes all blank tiles from the tile set.
 void resetIDs()
          Resets the TileIDs of every tile in the list to match thier current location in the list.
 void setBlankImage(javax.swing.ImageIcon newBlank)
          Sets the ImageIcon used as the blank tile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

name

java.lang.String name
The name of the tile set.


desc

java.lang.String desc
The description and/or instructions of the tile set.


numOfTiles

int numOfTiles
Number of tiles currently in the set. Doesn't count the initial dummy tile.


tile

java.util.ArrayList tile
The list of tiles in the set. Stores Tiles. The first tile is a dummy tile.


summaryTiles

java.util.ArrayList summaryTiles
The list of summary tiles. Stores SummaryEntrys.


tileWidthInPixels

int tileWidthInPixels
Width of the tiles in pixels.


tileHeightInPixels

int tileHeightInPixels
Height of the tiles in pixels.


tileWidth

int tileWidth
Width of the tiles in gridSquares (20x20 pixels each).


tileHeight

int tileHeight
Height of the tiles in gridSquares (20x20 pixels each).


blankTileImage

javax.swing.ImageIcon blankTileImage
ImageIcon used for blank tiles.


gridNumTilesWide

int gridNumTilesWide
Number of tiles the grid should support horizontally.


gridNumTilesTall

int gridNumTilesTall
Number of tiles the grid should support vertically.


reqBlankDesc

boolean reqBlankDesc
true if the set requires descriptions for blank tiles.


reqBlankName

boolean reqBlankName
true if the set requires names for blank tiles.


unlimitedBlanks

boolean unlimitedBlanks
true if the set allows unlimited blank tiles.


maxBlankTiles

int maxBlankTiles
Max number of blank tiles allowed by the set.


numBlankTiles

int numBlankTiles
Current number of blank tiles in use.


reqUnusedDesc

boolean reqUnusedDesc
true if the set requires descriptions for unused tiles.


unlimitedUnused

boolean unlimitedUnused
true if the set allows unlimited unused tiles.


maxUnusedTiles

int maxUnusedTiles
Max number of unused tiles allowed by the set.


reqArrangementComment

boolean reqArrangementComment
true if the set requires arrangement comments.


arrangementComment

java.lang.String arrangementComment
Arrangement comments for the tile set.


allowPrintArrangement

boolean allowPrintArrangement
true if the set allows users to print.


missingTiles

boolean missingTiles
true if missing tiles are enabled.


numMissingTiles

int numMissingTiles
Number of tiles to randomly leave out when the set loads.

Constructor Detail

TileSet

public TileSet(int tileCount,
               int gridSquareSize,
               int pixWidth,
               int pixHeight)
Constructor for the TileSet class. Initializes all fields to default values. Also sets the tile width and height fields to proper values based on the passed in parameters.

Parameters:
tileCount - Initial number of tiles
gridSquareSize - Size of grid squares (should be 20x20 pixels)
pixWidth - Width of tiles in pixels
pixHeight - Height of tiles in pixels
Method Detail

AddBlankIsAllowed

public boolean AddBlankIsAllowed()
Returns true if the user is allowed to add at least one more blank tile to the set.

Returns:
true if the user is allowed to add at least one more blank tile to the set. Returns false otherwise.

canUseBlankTiles

public boolean canUseBlankTiles()
Returns true if the set supports the ability to add blank tiles.

Returns:
true if the set supports the ability to add blank tiles.

createBlankTileImage

public javax.swing.ImageIcon createBlankTileImage(java.lang.String name,
                                                  java.awt.Component obs)
Creates an ImageIcon to be used for a blank tile. This function copies the blankTileImage for the set and then draws the tile's name at the top of the image. Names with lengths longer than the image are cut off at the edge of the image.

Parameters:
name - Name to be drawn on the image
obs - ImageObserver object
Returns:
ImageIcon of the blankTileImage with the passed in name drawn at its top.

AddBlankTile

public int AddBlankTile(java.lang.String name,
                        java.lang.String desc,
                        java.awt.Component obs)
Adds a blank tile to the tileset.

Parameters:
name - Name of the blank tile
desc - Description of the blank tile
obs - Component to be used as the ImageObserver when creating the blank tile's image. Any visible component should work.
Returns:
Integer representing the TileID of the new tile

addBlankTileAt

public void addBlankTileAt(int loc,
                           java.lang.String name,
                           java.lang.String desc,
                           Grid theGrid,
                           TileBin theTileBin)
Adds a blank tile at a specific position in the tile list. This is needed for playback mode when reversing through a log which has had a blank tile deleted when other blank tiles were added after it.

Parameters:
loc - Location in the TileSet to add the blank tile
name - Name of the blank tile
desc - Description of the blank tile
theGrid - The Grid object
theTileBin - The TileBin object

deleteBlankTile

public boolean deleteBlankTile(int tileID,
                               Grid theGrid,
                               TileBin theTileBin)
Deletes a blank tile. The tile is removed from the set as well as removed from the grid or tilebin if it is in either.

Parameters:
tileID - TileID of the tile to delete
theGrid - The Grid object
theTileBin - The TileBin ojbect
Returns:
true if the tile was deleted; false if it was not a blank tile.

getNumOfTiles

public int getNumOfTiles()
Returns the number of tiles in the set. This does not count the dummy tile.

Returns:
The number of tiles in the set not counting the dummy tile

getTileWidthInPixels

public int getTileWidthInPixels()
Returns the width of the tiles in pixels.

Returns:
The width of the tiles in pixels

getTileHeightInPixels

public int getTileHeightInPixels()
Returns the height of the tiles in pixels.

Returns:
The height of the tiles in pixels

getTileWidth

public int getTileWidth()
Returns the width of the tiles in GridSquares (20x20 pixels each)

Returns:
The width of the tiles in GridSquares (20x20 pixels each)

getTileHeight

public int getTileHeight()
Returns the height of the tiles in GridSquares (20x20 pixels each)

Returns:
The height of the tiles in GridSquares (20x20 pixels each)

setBlankImage

public void setBlankImage(javax.swing.ImageIcon newBlank)
Sets the ImageIcon used as the blank tile.

Parameters:
newBlank - ImageIcon to use as the blank tile image

getGridWidth

public int getGridWidth()
Returns the width of the grid in pixels required by the set.

Returns:
The width of the grid in pixles required by the set.

getGridHeight

public int getGridHeight()
Returns the height of the grid in pixels required by the set.

Returns:
The height of the grid in pixles required by the set.

getNumBlank

public int getNumBlank()
Returns the number of blank tiles currently being used.

Returns:
The number of blank tiles currently being used.

getMaxBlank

public int getMaxBlank()
Returns the max number of blank tiles allowed by the set.

Returns:
The max number of blank tiles allowed by the set.

prepForPlayback

public void prepForPlayback()
Removes all blank tiles from the tile set. Blank tiles need to be removed before playback since they are added by the playback system during the playback of log files.


resetIDs

public void resetIDs()
Resets the TileIDs of every tile in the list to match thier current location in the list.


getTileBoundsInGrid

public java.awt.Rectangle getTileBoundsInGrid()
Returns a bounding rectangle containing every tile in the grid.

Returns:
A Rectangle that contains every tile in the grid. The units of measure for this Rectangle are in gridSquares (20x20 pixels each)