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, setAttributesclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAttributes, getObjIDprivate 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)
MatrixaddAgent in interface Matrixagent - The Agent to add to this MatrixMatrix.addAgent(com.putable.common.matrix.Agent)public void addKey(Key key)
MatrixaddKey in interface Matrixkey - The Key to add to this MatrixMatrix.addKey(com.putable.common.matrix.Key)public void addToken(Token token)
MatrixaddToken in interface Matrixtoken - The Token to add to this MatrixMatrix.addToken(com.putable.common.matrix.Token)public void clearAgents()
MatrixclearAgents in interface MatrixMatrix.clearAgents()public void clearKeys()
MatrixclearKeys in interface MatrixMatrix.clearKeys()public void clearTokens()
MatrixclearTokens in interface MatrixMatrix.clearTokens()public boolean contains(NetPuzlObject npo)
Matrixcontains in interface Matrixnpo - The NetPuzlObject to check for in this MatrixMatrix.contains(com.putable.common.matrix.NetPuzlObject)public boolean containsImage(Image image)
MatrixcontainsImage in interface Matriximage - The Image to check for in this MatrixMatrix.containsImage(com.putable.common.matrix.Image)public boolean containsToken(Token token)
MatrixcontainsToken in interface Matrixtoken - The Token to check for in this MatrixMatrix.containsToken(com.putable.common.matrix.Token)public TSet createSetTag()
createSetTag in interface MatrixcreateSetTag in class NetPuzlObjectNetPuzlObject.createSetTag()public java.util.List<TSet> createSetTags()
MatrixcreateSetTags in interface MatrixMatrix.createSetTags()public java.util.List<TSet> createTokenSetTags()
MatrixcreateTokenSetTags in interface MatrixMatrix.createTokenSetTags()public void doSpokenCommand(java.lang.String text)
MatrixdoSpokenCommand in interface Matrixtext - The command spoken to this MatrixMatrix.doSpokenCommand(java.lang.String)public int getAgentCount()
MatrixgetAgentCount in interface MatrixMatrix.getAgentCount()public java.util.Iterator<Agent> getAgentIterator()
MatrixgetAgentIterator in interface MatrixMatrix.getAgentIterator()public java.util.Set<Agent> getAgents()
MatrixgetAgents in interface MatrixMatrix.getAgents()public Cell[][] getGrid()
MatrixgetGrid in interface MatrixMatrix.getGrid()public Cell getGridCell(int i, int j)
MatrixgetGridCell in interface Matrixi - The column of the cell you want.j - The row of the Cell you want.Matrix.getGridCell(int, int)public int getHeight()
MatrixgetHeight in interface MatrixMatrix.getHeight()public int getImageCount()
MatrixgetImageCount in interface MatrixMatrix.getImageCount()public int getKeyCount()
MatrixgetKeyCount in interface MatrixMatrix.getKeyCount()public java.util.Iterator<Key> getKeyIterator()
MatrixgetKeyIterator in interface MatrixMatrix.getKeyIterator()public SayFunction getSayFunction()
MatrixgetSayFunction in interface MatrixMatrix.getSayFunction()public AbstractMatrix getThis()
MatrixgetThis in interface MatrixMatrix.getThis()public int getTokenCount()
MatrixgetTokenCount in interface MatrixMatrix.getTokenCount()public java.util.List<Token> getTokens()
MatrixgetTokens in interface MatrixMatrix.getTokens()public int getWidth()
MatrixgetWidth in interface MatrixMatrix.getWidth()public boolean hasSpokenCommand()
MatrixhasSpokenCommand in interface MatrixMatrix.hasSpokenCommand()public void initCells()
MatrixinitCells in interface MatrixMatrix.initCells()public void removeAgent(Agent agent)
MatrixremoveAgent in interface Matrixagent - The Agent to remove from this MatrixMatrix.removeAgent(com.putable.common.matrix.Agent)public void removeKey(Key key)
MatrixremoveKey in interface Matrixkey - Key to remove from this MatrixMatrix.removeKey(com.putable.common.matrix.Key)public void removeToken(Token token)
MatrixremoveToken in interface Matrixtoken - The Token to remove from this MatrixMatrix.removeToken(com.putable.common.matrix.Token)public void sendHearTagToMatrix(NetPuzlObject from, NetPuzlObject to, java.lang.String text)
MatrixsendHearTagToMatrix in interface Matrixfrom - 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)
MatrixsendHearTagToNPO in interface Matrixproxy - 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)
MatrixsendToAgentsInMatrix in interface Matrixtag - The tag to send to all Agents in this MatrixMatrix.sendToAgentsInMatrix(Tag tag)public void setGrid(Cell[][] newGrid)
MatrixsetGrid in interface MatrixnewGrid - What the old grid should look like.Matrix.setGrid(com.putable.common.matrix.Cell[][])public void setGridCell(int i,
int j,
Cell cell)
MatrixsetGridCell in interface Matrixi - 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)
MatrixsetSayFunction in interface MatrixsayFunction - 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 NetPuzlObjectpublic java.lang.String toString()
NetPuzlObjecttoString in interface MatrixtoString in class NetPuzlObjectMatrix.toString()