Class Projected3DSpace<T>
java.lang.Object
repast.simphony.space.projection.DefaultProjection<T>
repast.simphony.visualization.editor.space.Projected3DSpace<T>
- All Implemented Interfaces:
ContinuousSpace<T>,Projection<T>,ProjectionListener
public class Projected3DSpace<T>
extends DefaultProjection<T>
implements ContinuousSpace<T>, ProjectionListener
A space that reprojects a 3D continuous space into a 2D grid. This is intended
to be used with editing code in visualization and such will not
work correctly if used as a regular projection.
- Author:
- Nick Collier
-
Field Summary
Fields inherited from class repast.simphony.space.projection.DefaultProjection
listeners, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroys this Projected3DSpace by doing any necessary clean up.getAdder()Gets the adder used by this space to add new objects.intGets the dimensions of the space.double[]getDisplacement(NdPoint point1, NdPoint point2) Returns the displacement between the NdPoints point1 and point2.doublegetDistance(NdPoint point1, NdPoint point2) Gets the the euclidian distance between the NdPoints point1 and point2.doublegetDistanceSq(NdPoint point1, NdPoint point2) Gets the square of the euclidian distance between the NdPoints point1 and point2.intintgetLocation(Object obj) Gets the location of the specified object.getObjectAt(double... location) Gets the object at the specified location.Gets all the object currently in the space.getObjectsAt(double... location) Gets all the objects at the specified location.Retrieves the rule being used for controlling what happens at or beyond the borders of the space.getRandomObjectAt(double... location) Gets a random object from among those at the specified location.booleanTrue if this space is periodic (in the sense that moving off one border makes you appear on the other one), otherwise false.moveByDisplacement(T object, double... displacement) Moves the specified object from its current location by the specified amount.moveByVector(T object, double distance, double... anglesInRadians) Moves the specifed object the specified distance from its current position along the specified angle.booleanMoves the specified object from its current location into the new location.voidInvoked when a projection event occurs.voidsetAdder(ContinuousAdder<T> adder) Sets the adder used by this space to add new objects.voidSets the rule to use for controlling what happens at or beyond the borders of the space.intsize()Gets the number of objects currently in the space.Methods inherited from class repast.simphony.space.projection.DefaultProjection
addProjectionListener, evaluate, fireProjectionEvent, getName, getProjectionListeners, removeProjectionListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface repast.simphony.space.projection.Projection
addProjectionListener, evaluate, getName, getProjectionListeners, removeProjectionListener
-
Constructor Details
-
Projected3DSpace
-
-
Method Details
-
getIndex1
public int getIndex1() -
getIndex2
public int getIndex2() -
getConstantIndex
public int getConstantIndex() -
getDimensions
Gets the dimensions of the space.- Specified by:
getDimensionsin interfaceContinuousSpace<T>- Returns:
- the dimensions of the space.
-
setAdder
Sets the adder used by this space to add new objects.- Specified by:
setAdderin interfaceContinuousSpace<T>- Parameters:
adder- the adder
-
getAdder
Gets the adder used by this space to add new objects.- Specified by:
getAdderin interfaceContinuousSpace<T>- Returns:
- the adder used by this space to add new objects.
-
moveTo
Moves the specified object from its current location into the new location. The object must previously have been introduced into the space. Objects are introduced into the space by adding them to the context of which this space is a projection.- Specified by:
moveToin interfaceContinuousSpace<T>- Parameters:
object-newLocation-- Returns:
- true if the move was successful, otherwise false.
- Throws:
SpatialException- if the object is not already in the space or if the number of dimensions in the location does not agree with the number in the space.
-
getLocation
Gets the location of the specified object.- Specified by:
getLocationin interfaceContinuousSpace<T>- Parameters:
obj-- Returns:
- the location of the specified object or null if the object is not in the space.
-
size
public int size()Gets the number of objects currently in the space. This does NOT include any objects that may have been added, but have NOT been moved to a space location.- Specified by:
sizein interfaceContinuousSpace<T>- Returns:
- the number of objects currently in the space. This does NOT include any objects that may have been added, but have NOT been moved to a space location.
-
getPointTranslator
Retrieves the rule being used for controlling what happens at or beyond the borders of the space. Unsupported operation.- Specified by:
getPointTranslatorin interfaceContinuousSpace<T>- Returns:
- the rule for handling out of bounds coordinates
-
setPointTranslator
Sets the rule to use for controlling what happens at or beyond the borders of the space. Unsupported operation.- Specified by:
setPointTranslatorin interfaceContinuousSpace<T>- Parameters:
rule- the rule for handling out of bounds coordinates
-
getObjects
Gets all the object currently in the space. This does NOT include any objects that may have been added, but have NOT been moved to a space location.- Specified by:
getObjectsin interfaceContinuousSpace<T>- Returns:
- an iteratable over all the object currently in the space. This does NOT include any objects that may have been added, but have NOT been moved to a space location.
-
getObjectAt
Gets the object at the specified location.- Specified by:
getObjectAtin interfaceContinuousSpace<T>- Parameters:
location-- Returns:
- the object at the specified location.
-
getObjectsAt
Gets all the objects at the specified location. For a multi occupancy space this will be all the objects at that location. For a single occupancy space this will be the single object at that location.- Specified by:
getObjectsAtin interfaceContinuousSpace<T>- Parameters:
location-- Returns:
- the object at the specified location.
-
getRandomObjectAt
Gets a random object from among those at the specified location. If this is a single occupancy space this will return the single object at that location, if any. Unsupported operation.- Specified by:
getRandomObjectAtin interfaceContinuousSpace<T>- Parameters:
location-- Returns:
- the object at the specified location.
-
moveByDisplacement
Moves the specified object from its current location by the specified amount. For examplemoveByDisplacement(object, 3, -2, 1)will move the object by 3 along the x-axis, -2 along the y and 1 along the z. The displacement argument can be less than the number of dimensions in the space. Unsupported operation.- Specified by:
moveByDisplacementin interfaceContinuousSpace<T>- Parameters:
object- the object to movedisplacement- the amount to move the object- Returns:
- the new location if the move was successful, otherwise null
- Throws:
SpatialException- if the object is not already in the space or if the number of dimensions in the displacement greater than the number of grid dimensions.
-
moveByVector
Moves the specifed object the specified distance from its current position along the specified angle. Unsupported operation.- Specified by:
moveByVectorin interfaceContinuousSpace<T>- Parameters:
object- the object to movedistance- the distance to moveanglesInRadians- the angle to move along- Returns:
- the new location or null if the move is not successful
- Throws:
SpatialException- if the object is not already in the space or if the number of angles is greater than the number of dimensions- See Also:
-
isPeriodic
public boolean isPeriodic()True if this space is periodic (in the sense that moving off one border makes you appear on the other one), otherwise false.- Specified by:
isPeriodicin interfaceContinuousSpace<T>- Returns:
- true if this space is periodic, otherwise false.
-
destroy
public void destroy()Destroys this Projected3DSpace by doing any necessary clean up. -
projectionEventOccurred
Invoked when a projection event occurs. This forwards on projection events fired by the 3D space to any listeners of this space.- Specified by:
projectionEventOccurredin interfaceProjectionListener<T>- Parameters:
evt- the object describing the event
-
getDistance
Gets the the euclidian distance between the NdPoints point1 and point2. If the points do not have the same dimension then this returns Double.NaN- Specified by:
getDistancein interfaceContinuousSpace<T>- Parameters:
point1- the first pointpoint2- the second point- Returns:
- the euclidian distance between the NdPoints point1 and point2. If the points do not have the same dimension then this returns Double.NaN
-
getDistanceSq
Gets the square of the euclidian distance between the NdPoints point1 and point2. If the points do not have the same dimension then this returns Double.NaN- Specified by:
getDistanceSqin interfaceContinuousSpace<T>- Parameters:
point1- the first pointpoint2- the second point- Returns:
- the square of the euclidian distance between the NdPoints point1 and point2. If the points do not have the same dimension then this returns Double.NaN
-
getDisplacement
Returns the displacement between the NdPoints point1 and point2. If the points do not have the same dimension then this returns null- Specified by:
getDisplacementin interfaceContinuousSpace<T>- Parameters:
point1- the first pointpoint2- the second point- Returns:
- the displacement between the NdPoints point1 and point2. If the points do not have the same dimension then this returns null
-