Package repast.simphony.space.projection
Class DefaultProjection<T>
- java.lang.Object
-
- repast.simphony.space.projection.DefaultProjection<T>
-
- All Implemented Interfaces:
Projection<T>
- Direct Known Subclasses:
AbstractContinuousSpace
,AbstractGrid
,DefaultGeography
,JungNetwork
,Projected3DGrid
,Projected3DSpace
public class DefaultProjection<T> extends Object implements Projection<T>
- Version:
- $Revision$ $Date$
- Author:
- Nick Collier
-
-
Field Summary
Fields Modifier and Type Field Description protected List<ProjectionListener>
listeners
protected String
name
-
Constructor Summary
Constructors Constructor Description DefaultProjection(String name)
Creates a projection with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProjectionListener(ProjectionListener listener)
Adds listener for this projection.boolean
evaluate(ProjectionPredicate predicate)
Evaluate this Projection against the specified Predicate.protected void
fireProjectionEvent(ProjectionEvent evt)
Sends the specified evt to all the projection listeners.String
getName()
Gets the name of this projection.Collection<ProjectionListener>
getProjectionListeners()
Gets all the listeners for this projection.boolean
removeProjectionListener(ProjectionListener listener)
Removes a listener from the this projection.
-
-
-
Field Detail
-
name
protected String name
-
listeners
protected List<ProjectionListener> listeners
-
-
Constructor Detail
-
DefaultProjection
public DefaultProjection(String name)
Creates a projection with the specified name.- Parameters:
name
- the name of the projection
-
-
Method Detail
-
addProjectionListener
public void addProjectionListener(ProjectionListener listener)
Adds listener for this projection.- Specified by:
addProjectionListener
in interfaceProjection<T>
- Parameters:
listener
- the listener to add.
-
removeProjectionListener
public boolean removeProjectionListener(ProjectionListener listener)
Removes a listener from the this projection.- Specified by:
removeProjectionListener
in interfaceProjection<T>
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was succesfully removed, otherwise false
-
fireProjectionEvent
protected void fireProjectionEvent(ProjectionEvent evt)
Sends the specified evt to all the projection listeners.- Parameters:
evt
- the evt to send
-
getProjectionListeners
public Collection<ProjectionListener> getProjectionListeners()
Gets all the listeners for this projection.- Specified by:
getProjectionListeners
in interfaceProjection<T>
- Returns:
- an iterable over all the listeners for this projection.
-
evaluate
public boolean evaluate(ProjectionPredicate predicate)
Evaluate this Projection against the specified Predicate. This typically involves a double dispatch where the Projection calls back to the predicate, passing itself.- Specified by:
evaluate
in interfaceProjection<T>
- Parameters:
predicate
-- Returns:
- true if the predicate evaluates to true, otherwise false. False can also mean that the predicate is not applicable to this Projection. For example, a linked type predicate evaluated against a grid projection.
-
getName
public String getName()
Gets the name of this projection.- Specified by:
getName
in interfaceProjection<T>
- Returns:
- the name of this Projection.
-
-