public abstract class AbstractMatrix extends NetPuzlObject implements Matrix
Modifier and Type | Field and Description |
---|---|
private java.util.Set<Agent> |
agents
The Agents contained in this Matrix
|
private Cell[][] |
grid
The two dimensional grid of Cells contained in this Matrix
|
private java.util.List<Key> |
keys
The Keys contained in this Matrix
|
private SayFunction |
sayFunction
The function that processes spoken commands for this Matrix
|
Constructor and Description |
---|
AbstractMatrix(ObjID objID,
Attributes attributes,
java.util.Map<ObjID,NetPuzlObject> cache)
Constructs an AbstractMatrix with the given parameters
|
Modifier and Type | Method and Description |
---|---|
void |
addAgent(Agent agent)
Adds an Agent to this Matrix
|
void |
addKey(Key key)
Adds a Key to this Matrix
|
void |
addToken(Token token)
Adds a Token to this Matrix
|
void |
clearAgents()
Clears the Agents in this Matrix
|
void |
clearKeys()
Clears the List of Keys in this Matrix
|
void |
clearTokens()
Removes all Tokens from this Matrix's grid
|
boolean |
contains(NetPuzlObject npo)
Determines if this Matrix contains the given NetPuzlObject
|
boolean |
containsImage(Image image)
Determines if this Matrix contains the given Image
|
boolean |
containsToken(Token token)
Determines if this Matrix contains the given Token
|
TSet |
createSetTag()
Overrides createSetTag because our Matrices do not use energy
|
java.util.List<TSet> |
createSetTags()
Creates setTtags for this Matrix and its Tokens, Keys, and Agents to be
sent to a client
|
java.util.List<TSet> |
createTokenSetTags()
Creates set Tags for this Matrix's Tokens to be sent to a client
|
void |
doSpokenCommand(java.lang.String text)
Performs the command spoken to this Matrix
|
java.lang.String |
fullToString()
This shows the full toString object
|
int |
getAgentCount()
Gets the number of Agents in this Matrix.
|
java.util.Iterator<Agent> |
getAgentIterator()
Gets an iterator over the elements in the container for agents.
|
java.util.Set<Agent> |
getAgents()
Gets the Set of Agents in this Matrix
|
Cell[][] |
getGrid()
A method used for testing that returns a reference to the 2-dimensional
cell array or grid.
|
Cell |
getGridCell(int i,
int j)
This method returns a particular Cell in the grid from the specified
coordinates.
|
int |
getHeight()
This method is used to get how tall the matrix is.
|
int |
getImageCount()
Gets the number of Images from this Matrix, including images from the
Matrix's Agents and Tokens
|
int |
getKeyCount()
Gets the number of Keys from this Matrix.
|
java.util.Iterator<Key> |
getKeyIterator()
Gets an iterator over the elements in the container for keys.
|
SayFunction |
getSayFunction()
Gets the function that processes spoken commands for this Matrix
|
AbstractMatrix |
getThis()
Gets this Matrix for use in anonymous classes
|
int |
getTokenCount()
Gets the number of Tokens in this Matrix
|
java.util.List<Token> |
getTokens()
Gets the List of Tokens from this Matrix's grid
|
int |
getWidth()
This method is used to get how wide the matrix is.
|
boolean |
hasSpokenCommand()
Determines if this Matrix has a function to process spoken commands
|
void |
initCells()
Initializes the Cells contained in this Matrix to their associated x and
y coordinates
|
void |
removeAgent(Agent agent)
Removes an agent from this Matrix
|
void |
removeKey(Key key)
Removes a key from this Matrix
|
void |
removeToken(Token token)
Removes a Token from this Matrix
|
void |
sendHearTagToMatrix(NetPuzlObject from,
NetPuzlObject to,
java.lang.String text)
Sends a 'hear' Tag from one NetPuzlObject to another to be broadcast to
all Agents in this Matrix
|
void |
sendHearTagToNPO(NetPuzlClientProxy proxy,
NetPuzlObject from,
NetPuzlObject to,
java.lang.String text)
Sends a 'hear' Tag from one NetPuzlObject to another to be broadcast to
the Agent involved
|
void |
sendToAgentsInMatrix(Tag tag)
Sends a tag to all Agents in this Matrix
|
void |
setGrid(Cell[][] newGrid)
A method used for testing that forces the grid to be the one that is
given as a parameter.
|
void |
setGridCell(int i,
int j,
Cell cell)
A method used for testing that simply lets you set a Cell in the grid.
|
void |
setSayFunction(SayFunction sayFunction)
Sets the function that processes spoken commands for this Matrix
|
java.lang.String |
toString()
A simple String representation of this NetPuzlObject
|
getAttributes, getObjID, setAttributes
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAttributes, getObjID
private java.util.Set<Agent> agents
private java.util.List<Key> keys
private Cell[][] grid
private SayFunction sayFunction
public AbstractMatrix(ObjID objID, Attributes attributes, java.util.Map<ObjID,NetPuzlObject> cache)
objID
- The object ID of this Matrixattributes
- The Attributes of this Matrixcache
- The Map to cache this Matrix inpublic void addAgent(Agent agent)
Matrix
addAgent
in interface Matrix
agent
- The Agent to add to this MatrixMatrix.addAgent(com.putable.common.matrix.Agent)
public void addKey(Key key)
Matrix
addKey
in interface Matrix
key
- The Key to add to this MatrixMatrix.addKey(com.putable.common.matrix.Key)
public void addToken(Token token)
Matrix
addToken
in interface Matrix
token
- The Token to add to this MatrixMatrix.addToken(com.putable.common.matrix.Token)
public void clearAgents()
Matrix
clearAgents
in interface Matrix
Matrix.clearAgents()
public void clearKeys()
Matrix
clearKeys
in interface Matrix
Matrix.clearKeys()
public void clearTokens()
Matrix
clearTokens
in interface Matrix
Matrix.clearTokens()
public boolean contains(NetPuzlObject npo)
Matrix
contains
in interface Matrix
npo
- The NetPuzlObject to check for in this MatrixMatrix.contains(com.putable.common.matrix.NetPuzlObject)
public boolean containsImage(Image image)
Matrix
containsImage
in interface Matrix
image
- The Image to check for in this MatrixMatrix.containsImage(com.putable.common.matrix.Image)
public boolean containsToken(Token token)
Matrix
containsToken
in interface Matrix
token
- The Token to check for in this MatrixMatrix.containsToken(com.putable.common.matrix.Token)
public TSet createSetTag()
createSetTag
in interface Matrix
createSetTag
in class NetPuzlObject
NetPuzlObject.createSetTag()
public java.util.List<TSet> createSetTags()
Matrix
createSetTags
in interface Matrix
Matrix.createSetTags()
public java.util.List<TSet> createTokenSetTags()
Matrix
createTokenSetTags
in interface Matrix
Matrix.createTokenSetTags()
public void doSpokenCommand(java.lang.String text)
Matrix
doSpokenCommand
in interface Matrix
text
- The command spoken to this MatrixMatrix.doSpokenCommand(java.lang.String)
public int getAgentCount()
Matrix
getAgentCount
in interface Matrix
Matrix.getAgentCount()
public java.util.Iterator<Agent> getAgentIterator()
Matrix
getAgentIterator
in interface Matrix
Matrix.getAgentIterator()
public java.util.Set<Agent> getAgents()
Matrix
getAgents
in interface Matrix
Matrix.getAgents()
public Cell[][] getGrid()
Matrix
getGrid
in interface Matrix
Matrix.getGrid()
public Cell getGridCell(int i, int j)
Matrix
getGridCell
in interface Matrix
i
- The column of the cell you want.j
- The row of the Cell you want.Matrix.getGridCell(int, int)
public int getHeight()
Matrix
getHeight
in interface Matrix
Matrix.getHeight()
public int getImageCount()
Matrix
getImageCount
in interface Matrix
Matrix.getImageCount()
public int getKeyCount()
Matrix
getKeyCount
in interface Matrix
Matrix.getKeyCount()
public java.util.Iterator<Key> getKeyIterator()
Matrix
getKeyIterator
in interface Matrix
Matrix.getKeyIterator()
public SayFunction getSayFunction()
Matrix
getSayFunction
in interface Matrix
Matrix.getSayFunction()
public AbstractMatrix getThis()
Matrix
getThis
in interface Matrix
Matrix.getThis()
public int getTokenCount()
Matrix
getTokenCount
in interface Matrix
Matrix.getTokenCount()
public java.util.List<Token> getTokens()
Matrix
getTokens
in interface Matrix
Matrix.getTokens()
public int getWidth()
Matrix
getWidth
in interface Matrix
Matrix.getWidth()
public boolean hasSpokenCommand()
Matrix
hasSpokenCommand
in interface Matrix
Matrix.hasSpokenCommand()
public void initCells()
Matrix
initCells
in interface Matrix
Matrix.initCells()
public void removeAgent(Agent agent)
Matrix
removeAgent
in interface Matrix
agent
- The Agent to remove from this MatrixMatrix.removeAgent(com.putable.common.matrix.Agent)
public void removeKey(Key key)
Matrix
removeKey
in interface Matrix
key
- Key to remove from this MatrixMatrix.removeKey(com.putable.common.matrix.Key)
public void removeToken(Token token)
Matrix
removeToken
in interface Matrix
token
- The Token to remove from this MatrixMatrix.removeToken(com.putable.common.matrix.Token)
public void sendHearTagToMatrix(NetPuzlObject from, NetPuzlObject to, java.lang.String text)
Matrix
sendHearTagToMatrix
in interface Matrix
from
- The NetPuzlObject to send the Tag fromto
- The NetPuzlObject to send the Tag totext
- The message contained in the TagMatrix.sendHearTagToMatrix(NetPuzlObject
from, NetPuzlObject to, String text)
public void sendHearTagToNPO(NetPuzlClientProxy proxy, NetPuzlObject from, NetPuzlObject to, java.lang.String text)
Matrix
sendHearTagToNPO
in interface Matrix
proxy
- The client proxy to send the Tag tofrom
- The NetPuzlObject to send the Tag fromto
- The NetPuzlObject to send the Tag totext
- The message contained in the TagMatrix.sendHearTagToNPO(NetPuzlClientProxy
proxy, NetPuzlObject from, NetPuzlObject to, String text)
public void sendToAgentsInMatrix(Tag tag)
Matrix
sendToAgentsInMatrix
in interface Matrix
tag
- The tag to send to all Agents in this MatrixMatrix.sendToAgentsInMatrix(Tag tag)
public void setGrid(Cell[][] newGrid)
Matrix
setGrid
in interface Matrix
newGrid
- What the old grid should look like.Matrix.setGrid(com.putable.common.matrix.Cell[][])
public void setGridCell(int i, int j, Cell cell)
Matrix
setGridCell
in interface Matrix
i
- What column.j
- What row.cell
- What to set the grid location to.Matrix.setGridCell(int, int,
com.putable.common.matrix.Cell)
public void setSayFunction(SayFunction sayFunction)
Matrix
setSayFunction
in interface Matrix
sayFunction
- The function that processes spoken commands to set
this Matrix toMatrix.setSayFunction(com.putable.common.matrix.SayFunction)
public java.lang.String fullToString()
fullToString
in class NetPuzlObject
public java.lang.String toString()
NetPuzlObject
toString
in interface Matrix
toString
in class NetPuzlObject
Matrix.toString()