sysModel.env
Interface ILocalEnv

All Known Subinterfaces:
ASquareEnv.ISquareLocalEnvironment
All Known Implementing Classes:
BoundedEnv.LocalEnvironment, NoGridEnv.LocalEnvironment, Test_GenericFish.TestAllWayLocalEnv, Test_GenericFish.TestNoWayLocalEnv, Test_GenericFish.TestOneWayLocalEnv, Test_GenericFish.TestTwoWayLocalEnv, UnboundedEnv.LocalEnvironment

public interface ILocalEnv

Interface of the environment local to a fish.

Author:
Mathias Ricken

Method Summary
 void drawFish(AFish fish, java.awt.Graphics2D g, java.awt.Component comp)
          Draw the fish on the graphics object.
 java.lang.Object execute(AGlobalEnv.ILocalEnvVisitor visitor, java.lang.Object param)
          Execute a visitor on this local environment.
 void removeFish(AFish fish)
          Remove the fish from the environment.
 void setState(ILocalEnvState state)
          Set state.
 java.lang.String toString()
          String representation of the local environment.
 java.lang.Object tryBreedFwd(AFish fish, ILambda blockedCmd, ILambda openCmd)
          Attempt to breed the fish forward, which may or may not be successful.
 java.lang.Object tryMoveFwd(AFish fish, ILambda blockedCmd, ILambda openCmd)
          Attempt to move the fish forward, which may or may not be successful.
 void turnRight(AFish fish, double radians)
          Turn the fish radians to the right.
 

Method Detail

tryMoveFwd

public java.lang.Object tryMoveFwd(AFish fish,
                                   ILambda blockedCmd,
                                   ILambda openCmd)
Attempt to move the fish forward, which may or may not be successful. The behavior in each case is defined by the visitor: - If the move cannot be executed, the blockedCmd lambda is applied. The parameter is not used and set to null. - If the move can be executed, the openCmd lambda is applied. The parameter is an ILambda that can to be executed to actually move the fish to the target location of this move. The ILambda ignores the input parameter and returns null.

Parameters:
fish - AFish to move
blockedCmd - lambda to apply if blocked
openCmd - lambda to apply if open
Returns:
return value of lambda executed

tryBreedFwd

public java.lang.Object tryBreedFwd(AFish fish,
                                    ILambda blockedCmd,
                                    ILambda openCmd)
Attempt to breed the fish forward, which may or may not be successful. The behavior in each case is defined by the visitor: - If the breeding cannot be executed, the blockedCmd lambda is applied. The parameter is not used and set to null. - If the breeding can be executed, the openCmd lambda is applied. The parameter is an ILambda that can to be executed to actually move the fish to the target location of this breeding. The ILambda ignores the input parameter and returns null.

Parameters:
fish - AFish to move
blockedCmd - lambda to apply if blocked
openCmd - lambda to apply if open
Returns:
return value of lambda executed

drawFish

public void drawFish(AFish fish,
                     java.awt.Graphics2D g,
                     java.awt.Component comp)
Draw the fish on the graphics object. The graphics object still has to be translated and rotated properly,

Parameters:
fish - AFish to drawFish
g - graphics object to drawFish on
comp - component to drawFish on

turnRight

public void turnRight(AFish fish,
                      double radians)
Turn the fish radians to the right.

Parameters:
fish - AFish to turn
radians - radians to turn

removeFish

public void removeFish(AFish fish)
Remove the fish from the environment.

Parameters:
fish - AFish to remove

execute

public java.lang.Object execute(AGlobalEnv.ILocalEnvVisitor visitor,
                                java.lang.Object param)
Execute a visitor on this local environment.

Parameters:
visitor - visitor to execute
param - visitor-specific parameter
Returns:
visitor-specific return value

toString

public java.lang.String toString()
String representation of the local environment. Should be "(x, y) (dx, dy)".

Returns:
string representation

setState

public void setState(ILocalEnvState state)
Set state.

Parameters:
state - new state