org.ascape.model.space
Class Continuous2D

java.lang.Object
  extended by org.ascape.model.space.CollectionSpace
      extended by org.ascape.model.space.Continuous2D
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, Continuous, Mutable, Space, RandomFunctions
Direct Known Subclasses:
Globe

public class Continuous2D
extends CollectionSpace
implements Continuous

A space containing a population of agents that exist within some continuous space. Note that this space is also an instance of CollectionSpace so it will not work to check for continuous scapes by doing something like !instanceof Discrete.

Since:
2.0
Version:
3.0
Author:
Miles Parker
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.ascape.model.space.CollectionSpace
CollectionSpace.ClosestDataPoint, CollectionSpace.ConditionalIterator, CollectionSpace.CSIterator, CollectionSpace.CSMutableIterator, CollectionSpace.ListMutableRandomIterator, CollectionSpace.ListRandomIterator, CollectionSpace.MutableSubIterator, CollectionSpace.SubIterator
 
Field Summary
 
Fields inherited from class org.ascape.model.space.CollectionSpace
collection, ESTIMATED_MAXIMUM_SIZE, extent, geometry
 
Constructor Summary
Continuous2D()
          Constructs a continuous two-dimensional space (plane or torous).
Continuous2D(Coordinate2DContinuous extent)
          Constructs a continuous two-dimensional space (plane or torous).
 
Method Summary
 double calculateDistance(Coordinate origin, Coordinate target)
          Returns the shortest distance between one Location and another.
 Coordinate calculateRelativePosition(Coordinate origin, Coordinate target)
          Returns the shortest relative position of two agents.
 Coordinate calculateRelativePosition(Location origin, Location target)
          Returns the shortest relative position of two agents.
 void coordinateSweep()
          A no-op; overrides the base collection's behavior so that agents do not have their coorinates changed.
 double distancePerIteration(double velocity)
          Distance per iteration.
 Coordinate findRandomCoordinate()
          Returns a coordinate randomly selected from the collection's space.
 int getSize()
          Return the number of agents in the space.
 void moveAway(Location origin, Coordinate target, double distance)
          Moves an agent from its original coordinate away from the target coordinate.
 void moveToward(Location origin, Coordinate target, double distance)
          Moves an agent from its original coordinate towards its target coordinate.
 void normalize(Coordinate coor)
          Converts the coordiante into the boundaries of the space.
 void populate()
          Populate.
 void setSize(int size)
          Sets the number of agents in the space.
 
Methods inherited from class org.ascape.model.space.CollectionSpace
add, add, addAll, calculateDistance, clear, clone, conditionalIterator, conditionalIterator, construct, contains, containsAll, countWithin, createOrder, createSpatialConditional, deleteSweep, filter, find, findMaximum, findMaximum, findMaximumWithin, findMinimum, findMinimum, findMinimumWithin, findNearest, findNearest, findRandom, findRandom, findRandom, findRandom, findRandomWithin, findWithin, get, getContext, getExtent, getGeometry, getRandom, hasWithin, initialize, isDeleteSweepNeeded, isEmpty, isMutable, isPeriodic, iterator, iteratorCount, iteratorToList, newLocation, newLocation, randomInRange, randomInRange, randomIs, randomizeOrder, randomToLimit, remove, removeAll, retainAll, safeIterator, safeIterator, safeIterators, safeRandomIterator, set, setContext, setExtent, setExtent, setGeometry, setPeriodic, setRandom, size, toArray, toArray, toList, withinIterator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ascape.model.space.Mutable
clear, deleteSweep, isDeleteSweepNeeded, newLocation, newLocation, remove
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

Continuous2D

public Continuous2D()
Constructs a continuous two-dimensional space (plane or torous).


Continuous2D

public Continuous2D(Coordinate2DContinuous extent)
Constructs a continuous two-dimensional space (plane or torous).

Parameters:
extent - a coordinate describing the size of this space
Method Detail

coordinateSweep

public void coordinateSweep()
A no-op; overrides the base collection's behavior so that agents do not have their coorinates changed.


populate

public void populate()
Description copied from interface: Space
Populate.

Specified by:
populate in interface Space
Overrides:
populate in class CollectionSpace

calculateDistance

public double calculateDistance(Coordinate origin,
                                Coordinate target)
Returns the shortest distance between one Location and another.

Specified by:
calculateDistance in interface Space
Overrides:
calculateDistance in class CollectionSpace
Parameters:
origin - one Location
target - another Location
Returns:
the double

calculateRelativePosition

public Coordinate calculateRelativePosition(Location origin,
                                            Location target)
Returns the shortest relative position of two agents.

Parameters:
origin - one Location
target - another Location
Returns:
the coordinate

calculateRelativePosition

public Coordinate calculateRelativePosition(Coordinate origin,
                                            Coordinate target)
Returns the shortest relative position of two agents.

Parameters:
origin - one Location
target - another Location
Returns:
the coordinate

distancePerIteration

public double distancePerIteration(double velocity)
Description copied from interface: Continuous
Distance per iteration.

Specified by:
distancePerIteration in interface Continuous
Parameters:
velocity - the velocity
Returns:
the double

findRandomCoordinate

public Coordinate findRandomCoordinate()
Description copied from class: CollectionSpace
Returns a coordinate randomly selected from the collection's space.

Specified by:
findRandomCoordinate in interface Continuous
Specified by:
findRandomCoordinate in interface Space
Overrides:
findRandomCoordinate in class CollectionSpace
Returns:
the coordinate

moveToward

public void moveToward(Location origin,
                       Coordinate target,
                       double distance)
Moves an agent from its original coordinate towards its target coordinate.

Specified by:
moveToward in interface Continuous
Specified by:
moveToward in interface Space
Overrides:
moveToward in class CollectionSpace
Parameters:
origin - the origin coordinate
target - the target coordinate
distance - the maximum distance that can be traveled

moveAway

public void moveAway(Location origin,
                     Coordinate target,
                     double distance)
Moves an agent from its original coordinate away from the target coordinate.

Specified by:
moveAway in interface Space
Overrides:
moveAway in class CollectionSpace
Parameters:
origin - the origin coordinate
target - the target coordinate
distance - the maximum distance that can be traveled

normalize

public void normalize(Coordinate coor)
Converts the coordiante into the boundaries of the space. If the cooridnate is out of bounds, adds or substracts the bounds as appropriate to bring the coordinate into a common sapce mod boundary.

Specified by:
normalize in interface Continuous
Parameters:
coor - the Coordinate to normalize

setSize

public void setSize(int size)
Sets the number of agents in the space.

Specified by:
setSize in interface Space
Overrides:
setSize in class CollectionSpace
Parameters:
size - the size

getSize

public int getSize()
Return the number of agents in the space.

Specified by:
getSize in interface Space
Overrides:
getSize in class CollectionSpace
Returns:
the size


Copyright © 1998-2008 The Brookings Institution, NuTech Solutions, Metascape, LLC All Rights Reserved.