edu.brook.ascape.model
Class ScapeVector

java.lang.Object
  |
  +--edu.brook.ascape.model.AscapeObject
        |
        +--edu.brook.ascape.model.Agent
              |
              +--edu.brook.ascape.model.Cell
                    |
                    +--edu.brook.ascape.model.CellOccupant
                          |
                          +--edu.brook.ascape.model.Scape
                                |
                                +--edu.brook.ascape.model.ScapeGraph
                                      |
                                      +--edu.brook.ascape.model.ScapeVector

public class ScapeVector
extends ScapeGraph
implements ScapeMutable

A one-dimensional variable-size collection of agents providing services described for scape. Provides some methods that delegate for java.util.Vector.

Since:
1.0
Version:
1.9
See Also:
Serialized Form

Field Summary
static int ESTIMATED_MAXIMUM_SIZE
          The estimated maximum size a typical vector will be.
 java.util.Vector vector
          The actual vecotr representation of the scape.
 
Fields inherited from class edu.brook.ascape.model.ScapeGraph
extent
 
Fields inherited from class edu.brook.ascape.model.Scape
AGENT_ORDER, agentsPerIteration, ALL_AGENTS, autoCreate, cellsRequestUpdates, COLLECT_STATS_RULE, collectStats, COMPLETE_TOUR, copyrightAndCredits, CREATE_RULE, CREATE_SCAPE_RULE, dataGroup, demoModelClasses, demoModelNames, description, drawFeatureObservable, drawFeatures, earliestPeriod, executionOrder, executionStyle, geometry, home, INITIAL_RULES_RULE, initialRules, INTERNAL_START_RULE, ITERATE_SCAPE_RULE, iteration, latestPeriod, membersActive, PAUSE_RULE, paused, period, periodName, prototypeAgent, REPEATED_DRAW, restartAfterAutoStop, RESUME_RULE, RULE_ORDER, rules, running, scapeListeners, selfView, standardOutView, START_RULE, startOnOpen, startPeriod, step, STOP_RULE, stopPeriod, updatedListeners, updatedMembers, version
 
Fields inherited from class edu.brook.ascape.model.CellOccupant
MOVE_RANDOM_LOCATION_RULE, PLAY_HOST_RULE, PLAY_NEIGHBORS_RULE, PLAY_OTHER, RANDOM_WALK_AVAILABLE_RULE, RANDOM_WALK_RULE
 
Fields inherited from class edu.brook.ascape.model.Cell
cellsNear, coordinate, neighbors, thisUpdate
 
Fields inherited from class edu.brook.ascape.model.Agent
DEATH_RULE, deleteMarker, FISSIONING_RULE, FORCE_DIE_RULE, FORCE_FISSION_RULE, FORCE_MOVE_RULE, INITIALIZE_RULE, initialized, ITERATE_AND_UPDATE_RULE, ITERATE_RULE, METABOLISM_RULE, MOVEMENT_RULE, UPDATE_RULE
 
Fields inherited from class edu.brook.ascape.model.AscapeObject
ARBITRARY_SEED, count, name, scape
 
Constructor Summary
ScapeVector()
          Constructs a scape vector.
ScapeVector(java.lang.String name, Cell prototypeAgent)
          Constructs a two-dimensional vector of provided geometry and extent, populated with clones of provided agent.
ScapeVector(java.lang.String name, Cell prototypeAgent, Coordinate1DDiscrete extent)
          Constructs a two-dimensional vector of provided geometry and extent, populated with clones of provided agent.
 
Method Summary
 void addAgent(Agent agent)
          Adds the supplied agent to this vector.
 void addAgent(Agent agent, boolean isParent)
          Adds the supplied agent to this vector.
 void addElement(Agent agent)
          Adds the supplied agent to this vector.
 java.lang.Object clone()
          Clones the scape.
 boolean contains(Agent a)
          Does the agent exist in this Scape?
 int countWithin(Cell origin, Conditional condition, boolean includeOrigin, double maximumDistance)
           
 void createScape()
          Populate the scape with instances of its protoype agent.
 void deleteSweep()
           
 java.util.Enumeration elements()
          Returns an enumeration of all agents.
 Cell findNearestCell(Cell origin, Conditional condition)
           
 Cell findNearestCell(Cell origin, Conditional condition, boolean includeOrigin)
           
 Cell findNearestCell(Cell origin, Conditional condition, boolean includeOrigin, double maximumDistance)
           
 Cell findRandomCell()
          Returns a cell randomly selected from the vector.
 CoordinateDiscrete findRandomCoordinate()
          Returns a coordinate randomly selected from the vector's space.
 Agent[] getAgents()
          Returns all agents in the scape as an array.
 Cell getCell(CoordinateDiscrete coordinate)
          Returns the cell existing at the specified coordinate.
 Cell getCell(int xPosition)
          Returns the cell existing at the specified coordinate.
 Cell[] getCells()
          Returns all agents in the scape as an array of cells (use this method to avoid coercion of memebers to Cell.)
 Cell[] getCellsNear(Cell centralAgent, int distance, boolean includeSelf)
          Returns cells that are near the provided cell.
 int getDistance(Cell origin, Cell target)
           
 int getSize()
          Returns the size, or number of cells, of this ScapeVector.
 boolean hasWithin(Cell origin, Conditional condition, boolean includeOrigin, double maximumDistance)
           
 boolean isMutable()
          Is the scape mutable, that is, can it change its structure at runtime? Returns true for this vector.
 ScapeIterator iterator()
           
 Agent newAgent()
          Creates a new cell in this vector by cloning the prototype agent, and initializes it.
 ScapeIterator randomIterator()
           
 boolean removeAgent(Agent agent)
          Removes the supplied agent from this vector.
 void removeAllAgents()
          Removes the supplied agent from this vector.
 void removeAllElements()
          Removes the supplied agent from this vector.
 boolean removeElement(Agent agent)
          Removes the supplied agent from this vector.
 void setCell(CoordinateDiscrete coordinate, Cell cell)
          Sets the cell at the specified coordinate to the supplied cell.
 void setExtent(CoordinateDiscrete extent)
          Sets the size of the vector, filling with clones of prototype agent.
 void setGeometry(Geometry geometry)
          Sets the geometry of this scape.
 void setSize(int size)
          Sets the size of the vector, filling with clones of prototype agent.
 void testSizeConsistency()
           
 
Methods inherited from class edu.brook.ascape.model.ScapeGraph
executeOnMembers, findAvailable, findAvailable, findCells, findCells, findMaximumCell, findMaximumWithin, findOccupants, findOccupants, findRandomCell, findRandomCells, findRandomCells, findRandomUnoccupiedCell, findRandomUnoccupiedCell, getExtent
 
Methods inherited from class edu.brook.ascape.model.Scape
addDrawFeature, addInitialRule, addInitialRule, addRule, addRule, addScapeListener, addStatCollector, addStatCollectors, addView, addView, addView, addViews, addViews, addViews, close, closeAndOpenNew, closeAndOpenNewFinally, closeFinally, contentsToString, createOrder, createSelfView, createViews, execute, execute, executeOnMembers, executeOnMembers, executeOnMembers, executeOnRoot, executeOnRoot, exit, getAgentsNear, getAgentsPerIteration, getAllScapes, getCollectStats, getCustomizer, getData, getDescription, getDrawFeatures, getDrawFeaturesObservable, getExecutionOrder, getExecutionStyle, getGeometry, getHome, getInitialRules, getIteration, getName, getPeriod, getPeriodDescription, getPeriodName, getPrototypeAgent, getRoot, getRules, getStandardOutView, getStartPeriod, getStatCollectors, getStopPeriod, initialize, isAllViewsUpdated, isAutoCreate, isCellsRequestUpdates, isMembersActive, isPaused, isRoot, isRunning, isStartOnOpen, isValidPeriod, isViewSelf, iterateScape, listenerOrMemberUpdated, listenerUpdated, main, memberUpdated, notifyViews, onSetup, onStart, onStop, onUpdate, open, open, open, open, open, parseSettingArgs, pause, quit, quitFinally, randomizeOrder, removeScapeListener, requestRestart, respondControl, restart, resume, retrieveAllAccessors, retrieveAllAccessorsOrdered, run, save, save, save, setAgentsPerIteration, setAutoCreate, setAutoRestart, setCellsRequestUpdates, setCollectStats, setCollectStats, setCustomizer, setDescription, setEarliestPeriod, setExecutionOrder, setExecutionStyle, setHome, setInternalPaused, setInternalRunning, setLatestPeriod, setMembersActive, setPaused, setPeriodName, setPrototypeAgent, setRunning, setStartOnOpen, setStartPeriod, setStopPeriod, setViewSelf, start, stop, toString, waitForViewsUpdate
 
Methods inherited from class edu.brook.ascape.model.CellOccupant
die, getAvailableNeighboringCells, getCellsNearOnHost, getHostCell, getHostScape, getNeighborsOnHost, leave, moveAway, moveTo, moveToRandomLocation, moveToward, randomWalk, randomWalkAvailable, setHostScape
 
Methods inherited from class edu.brook.ascape.model.Cell
countNeighbors, countWithin, findMaximumWithin, findNearestCell, findNearestCell, findNearestCell, findRandomNeighbor, getCellsNear, getCoordinate, getDistance, getNeighbors, getNeighbors, getNetwork, getOccupant, hasWithin, isAvailable, isUpdateNeeded, removeOccupant, requestUpdate, requestUpdateNext, setCoordinate, setNeighbors, setNetwork, setOccupant
 
Methods inherited from class edu.brook.ascape.model.Agent
death, deathCondition, execute, execute, fission, fissionCondition, fissioning, getColor, getColor, getImage, getImage, getModel, isDelete, isInitialized, iterate, markForDeletion, metabolism, move, movement, movementCondition, play, scapeCreated, update
 
Methods inherited from class edu.brook.ascape.model.AscapeObject
getRandom, getRandomSeed, getScape, randomInRange, randomInRange, randomIs, randomToLimit, reseed, setName, setRandom, setRandomSeed, setScape
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vector

public java.util.Vector vector
The actual vecotr representation of the scape.

ESTIMATED_MAXIMUM_SIZE

public static int ESTIMATED_MAXIMUM_SIZE
The estimated maximum size a typical vector will be.
Constructor Detail

ScapeVector

public ScapeVector()
Constructs a scape vector.

ScapeVector

public ScapeVector(java.lang.String name,
                   Cell prototypeAgent,
                   Coordinate1DDiscrete extent)
Constructs a two-dimensional vector of provided geometry and extent, populated with clones of provided agent.
Parameters:
name - a descriptive name for the scape
prototypeAgent - the agent whose clones will be used to populate this scape
extent - a coordinate describing the size of this scape

ScapeVector

public ScapeVector(java.lang.String name,
                   Cell prototypeAgent)
Constructs a two-dimensional vector of provided geometry and extent, populated with clones of provided agent.
Parameters:
name - a descriptive name for the scape
prototypeAgent - the agent whose clones will be used to populate this scape
Method Detail

setGeometry

public void setGeometry(Geometry geometry)
Sets the geometry of this scape. Must of course be one-dimensional.
Parameters:
gometry - the basic geometry of this scape
Overrides:
setGeometry in class Scape

setExtent

public void setExtent(CoordinateDiscrete extent)
Sets the size of the vector, filling with clones of prototype agent. It is an error to set extent while a scape is running. (On request, this could change for instances of ScapeVector.)
Parameters:
extent - a coordinate describing the size of this scape
Overrides:
setExtent in class ScapeGraph

isMutable

public final boolean isMutable()
Is the scape mutable, that is, can it change its structure at runtime? Returns true for this vector.
Overrides:
isMutable in class Scape

setSize

public void setSize(int size)
Sets the size of the vector, filling with clones of prototype agent. It is an error to set extent while a scape is running. (On request, this could change for instances of ScapeVector.)
Parameters:
extent - a coordinate describing the size of this scape

createScape

public void createScape()
Populate the scape with instances of its protoype agent. Creates cells up to extent and fills them with clones of prototype agent. Geometry, extent, and prototype agent should all be set before calling this method, but it is not neccesary to set extent before initializing a vector.
Overrides:
createScape in class Scape

getCell

public Cell getCell(int xPosition)
Returns the cell existing at the specified coordinate.

setCell

public void setCell(CoordinateDiscrete coordinate,
                    Cell cell)
Sets the cell at the specified coordinate to the supplied cell.
Overrides:
setCell in class ScapeGraph

getCell

public Cell getCell(CoordinateDiscrete coordinate)
Returns the cell existing at the specified coordinate.
Overrides:
getCell in class ScapeGraph

findRandomCell

public Cell findRandomCell()
Returns a cell randomly selected from the vector.
Overrides:
findRandomCell in class ScapeGraph

findRandomCoordinate

public CoordinateDiscrete findRandomCoordinate()
Returns a coordinate randomly selected from the vector's space.
Overrides:
findRandomCoordinate in class ScapeGraph

iterator

public ScapeIterator iterator()
Overrides:
iterator in class Scape

randomIterator

public ScapeIterator randomIterator()
Overrides:
randomIterator in class Scape

testSizeConsistency

public void testSizeConsistency()

deleteSweep

public void deleteSweep()
Specified by:
deleteSweep in interface ScapeMutable

contains

public boolean contains(Agent a)
Does the agent exist in this Scape?

getSize

public int getSize()
Returns the size, or number of cells, of this ScapeVector.
Overrides:
getSize in class ScapeGraph

newAgent

public Agent newAgent()
Creates a new cell in this vector by cloning the prototype agent, and initializes it.

addElement

public void addElement(Agent agent)
Adds the supplied agent to this vector.
Parameters:
agent - the agent to add

addAgent

public void addAgent(Agent agent)
Adds the supplied agent to this vector.
Parameters:
agent - the agent to add

addAgent

public void addAgent(Agent agent,
                     boolean isParent)
Adds the supplied agent to this vector.
Parameters:
agent - the agent to add
isParent - should this scape be made the pareent scape of the agent?

removeElement

public boolean removeElement(Agent agent)
Removes the supplied agent from this vector. Alias for removeAgent, allowing interchangability with Vector.

removeAgent

public boolean removeAgent(Agent agent)
Removes the supplied agent from this vector.
Specified by:
removeAgent in interface ScapeMutable

removeAllElements

public void removeAllElements()
Removes the supplied agent from this vector. Alias for removeAllAgents, allowing interchangability with Vector.

removeAllAgents

public void removeAllAgents()
Removes the supplied agent from this vector.

elements

public java.util.Enumeration elements()
Returns an enumeration of all agents.

getCellsNear

public Cell[] getCellsNear(Cell centralAgent,
                           int distance,
                           boolean includeSelf)
Returns cells that are near the provided cell.
Parameters:
centralAgent - the agent to find cells near
distance - the distance to form centralCells to return cells
should - supplied agent be included in the return set
Overrides:
getCellsNear in class ScapeGraph

findNearestCell

public Cell findNearestCell(Cell origin,
                            Conditional condition)
Overrides:
findNearestCell in class ScapeGraph

findNearestCell

public Cell findNearestCell(Cell origin,
                            Conditional condition,
                            boolean includeOrigin)
Overrides:
findNearestCell in class ScapeGraph

findNearestCell

public Cell findNearestCell(Cell origin,
                            Conditional condition,
                            boolean includeOrigin,
                            double maximumDistance)
Overrides:
findNearestCell in class ScapeGraph

hasWithin

public boolean hasWithin(Cell origin,
                         Conditional condition,
                         boolean includeOrigin,
                         double maximumDistance)
Overrides:
hasWithin in class ScapeGraph

countWithin

public int countWithin(Cell origin,
                       Conditional condition,
                       boolean includeOrigin,
                       double maximumDistance)
Overrides:
countWithin in class ScapeGraph

getDistance

public int getDistance(Cell origin,
                       Cell target)
Overrides:
getDistance in class ScapeGraph

getCells

public Cell[] getCells()
Returns all agents in the scape as an array of cells (use this method to avoid coercion of memebers to Cell.)
Overrides:
getCells in class ScapeGraph

getAgents

public Agent[] getAgents()
Returns all agents in the scape as an array.
Overrides:
getAgents in class Scape

clone

public java.lang.Object clone()
Clones the scape. Shallow copy, creates a new empty backing vector.
Overrides:
clone in class Scape

(c) 1998-2000 The Brookings Insitution
Webpage