* This runs in a background thread and handles the animation loop.
*/
@Override
public void run()
{
final RobotModelMaster model = this.robot.getRobotModelMaster();
this.view.setRobotPosition(this.view.getCellCenterInner(model.getCurrentLocation()),
model.getDirection().getRadians());
this.view.invalidateAllCells();
this.view.setRobotPathModel(model.getRobotPathModel());
this.setViewAttributes();
while (this.currentState != AnimationStates.Stopped && this.robot.isRobotDone() == false)
{
try
{
//Get the robots current position.
final Point srcLocation = this.view.getCellCenterInner(model.getCurrentLocation());
final Direction srcDirection = model.getDirection();
final double srcRotation = srcDirection.getRadians();
robot.nextStep(); //Move robot.
//Get the robots new position.
final Point destLocation = this.view.getCellCenterInner(model.getCurrentLocation());
final Direction destDirection = model.getDirection();
//Set our new rotation based on which way we turned.
final double destRotation;
if (srcDirection.getLeft() == destDirection)
destRotation = srcRotation - Math.PI / 2;
else if (srcDirection.getRight() == destDirection)