|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractCollection | +--java.util.AbstractList | +--elge.agent.VectorRepresentation | +--elge.world.MatrixRepresentation
This representation holds agent in a matrix with x,y coordinates. It extends the VetorRepresentation which is xml storable.
Field Summary |
Fields inherited from class elge.agent.VectorRepresentation |
agents, propertySupport |
Fields inherited from class java.util.AbstractList |
modCount |
Fields inherited from interface elge.agent.AgentRepresentation |
PROP_DIMENSION |
Constructor Summary | |
MatrixRepresentation()
Creates default isntance of dimension 100,100. |
|
MatrixRepresentation(Dimension dim)
Creates a new instance of MatrixRepresentation with a size. |
|
MatrixRepresentation(int width,
int height)
Creates a new instance of MatrixRepresentation with a size. |
Method Summary | |
void |
add(int index,
Object a)
Inserts the specified element at the specified position in this list (optional operation). |
boolean |
add(Object a)
Ensures that this collection contains the specified element (optional operation). |
Point |
correctPosition(Point p)
|
Point |
createDefaultPosition()
|
Dimension |
getDimension()
Returns the matrix size. |
Point |
checkPosition(Point p)
Checks if the position is acceptable. |
boolean |
move(MoveableAgent a,
Point p)
Tries to move the agent to a new position. if the position is not acceptable, false is returned and position is not changed. |
void |
remove(Agent a)
|
Point |
rndPosition()
Generates position somewhere within the representation dimension. |
Point |
rndRelPosition(Point from,
double radius)
Like rndPosition, but it generates relativee from point from with max distance to point radius. |
void |
setDimension(Dimension d)
Sets new dimension of the matrix |
Point |
setPosition(MoveableAgent a,
Point p)
Sets the position for the agent. |
void |
vetoableChange(PropertyChangeEvent evt)
This method gets called when a constrained property is changed. |
Methods inherited from class elge.agent.VectorRepresentation |
addAll, addAll, addPropertyChangeListener, clear, contains, containsAll, get, getDimenstion, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removePropertyChangeListener, retainAll, set, size, subList, toArray, toArray |
Methods inherited from class java.util.AbstractList |
equals, hashCode, removeRange |
Methods inherited from class java.util.AbstractCollection |
toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
equals, hashCode |
Constructor Detail |
public MatrixRepresentation()
public MatrixRepresentation(int width, int height)
width
- width of the matrixheight
- height of the matrixpublic MatrixRepresentation(Dimension dim)
dim
- The size of the matrixMethod Detail |
public void add(int index, Object a)
VectorRepresentation
add
in interface List
add
in class VectorRepresentation
index
- index at which the specified element is to be inserted.a
- element to be inserted.public boolean add(Object a)
VectorRepresentation
Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.
If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.
add
in interface List
add
in class VectorRepresentation
a
- element whose presence in this collection is to be ensured.
public Point createDefaultPosition()
public void remove(Agent a)
public Point rndPosition()
rndPosition
in interface AgentRepresentation
rndPosition
in class VectorRepresentation
public Point rndRelPosition(Point from, double radius)
rndRelPosition
in interface AgentRepresentation
rndRelPosition
in class VectorRepresentation
from
- Point to generate from.radius
- max distance to generate the point from the from
point
from
in dinstance of radius
.public void setDimension(Dimension d)
setDimension
in interface AgentRepresentation
setDimension
in class VectorRepresentation
d
- Size of the matrixpublic Dimension getDimension()
getDimension
in interface AgentRepresentation
getDimension
in class VectorRepresentation
public Point checkPosition(Point p)
checkPosition
in interface MoveableMatrix
public Point correctPosition(Point p)
public boolean move(MoveableAgent a, Point p)
move
in interface MoveableMatrix
public Point setPosition(MoveableAgent a, Point p)
setPosition
in interface MoveableMatrix
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
vetoableChange
in interface VetoableChangeListener
evt
- a PropertyChangeEvent
object describing the
event source and the property that has changed.
PropertyVetoException
- if the recipient wishes the property
change to be rolled back.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |