jfreerails.client.renderer
Class BuildTrackController

java.lang.Object
  extended by jfreerails.client.renderer.BuildTrackController
All Implemented Interfaces:
GameModel

public class BuildTrackController
extends java.lang.Object
implements GameModel

This class provides methods to change the proposed track and save it to the real world. TODO jfreerails.client.renderer is not the most logical place for this class.

Author:
MystiqueAgent, Luke

Field Summary
private  boolean buildNewTrack
           
private  java.util.List<ImPoint> builtTrack
           
private  boolean isBuildTrackSuccessful
           
private static java.util.logging.Logger LOGGER
           
private  ModelRoot modelRoot
           
private  Step[] path
           
private  TrackPathFinder path4newTrackFinder
           
private  PathOnTrackFinder pathOnExistingTrackFinder
           
private  FreerailsPrincipal principal
           
private  ReadOnlyWorld realWorld
           
private  SoundManager soundManager
           
private  ImPoint startPoint
           
private  ImPoint targetPoint
           
private  boolean visible
           
private  WorldDiffs worldDiffs
           
 
Constructor Summary
BuildTrackController(ReadOnlyWorld readOnlyWorld, ModelRoot modelRoot)
          BuildTrackRenderer
 
Method Summary
private  BuildTrackStrategy getBts()
          Utility method that gets the BuildTrackStrategy from the model root.
private  TrackMoveProducer.BuildMode getBuildMode()
           
private  ImPoint getCursorPosition()
          Utility method that gets the cursor position from the model root.
 void hide()
          Hides and cancels any proposed track.
 boolean isBuilding()
          returns true if the track is being build - it is iff the build track is shown
 boolean isBuildTrackSuccessful()
          Returns true if all the track pieces can be successfully built.
private  void moveCursorMoreTiles(java.util.List<ImPoint> track)
          Moves cursor which causes track to be built on the worldDiff object.
private  MoveStatus moveCursorMoreTiles(java.util.List<ImPoint> track, TrackMoveProducer trackBuilder)
          uses trackBuilder if not null -- otherwise uses own buildTrack method - that is applied on worldDifferences
private  MoveStatus planBuildingTrack(ImPoint point, Step vector)
          Attempts to building track from the specified point in the specified direction on the worldDiff object.
private  void reset()
          Cancels any proposed track and resets the path finder.
(package private)  int searchStatus()
           
private  void setCursorMessage(java.lang.String s)
          Utility method that sets the CURSOR_MESSAGE property on the model root.
 void setProposedTrack(ImPoint to, TrackMoveProducer trackBuilder)
          Sets the proposed track: from the current cursor position to the specified point.
private  void setTargetPoint(ImPoint newTargetPoint)
           
private  void setVisible(boolean show)
           
private  void setWorldDiffs(WorldDiffs worldDiffs)
           
 void show()
           
 void update()
           
private  void updateSearch()
          Updates the search, if the search is completed, the proposed track is shown.
 void updateUntilComplete()
           
 ImPoint updateWorld(TrackMoveProducer trackBuilder)
          Saves track into real world
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

buildNewTrack

private boolean buildNewTrack

builtTrack

private java.util.List<ImPoint> builtTrack

isBuildTrackSuccessful

private boolean isBuildTrackSuccessful

modelRoot

private final ModelRoot modelRoot

path

private Step[] path

path4newTrackFinder

private TrackPathFinder path4newTrackFinder

pathOnExistingTrackFinder

private PathOnTrackFinder pathOnExistingTrackFinder

principal

private FreerailsPrincipal principal

realWorld

private ReadOnlyWorld realWorld

soundManager

private SoundManager soundManager

startPoint

private ImPoint startPoint

targetPoint

private ImPoint targetPoint

visible

private boolean visible

worldDiffs

private WorldDiffs worldDiffs
Constructor Detail

BuildTrackController

public BuildTrackController(ReadOnlyWorld readOnlyWorld,
                            ModelRoot modelRoot)
BuildTrackRenderer

Parameters:
readOnlyWorld - ReadOnlyWorld
Method Detail

getBts

private BuildTrackStrategy getBts()
Utility method that gets the BuildTrackStrategy from the model root.


getCursorPosition

private ImPoint getCursorPosition()
Utility method that gets the cursor position from the model root.


hide

public void hide()
Hides and cancels any proposed track.


isBuilding

public boolean isBuilding()
returns true if the track is being build - it is iff the build track is shown

Returns:
boolean

isBuildTrackSuccessful

public boolean isBuildTrackSuccessful()
Returns true if all the track pieces can be successfully built.


moveCursorMoreTiles

private void moveCursorMoreTiles(java.util.List<ImPoint> track)
Moves cursor which causes track to be built on the worldDiff object.


moveCursorMoreTiles

private MoveStatus moveCursorMoreTiles(java.util.List<ImPoint> track,
                                       TrackMoveProducer trackBuilder)
uses trackBuilder if not null -- otherwise uses own buildTrack method - that is applied on worldDifferences

Parameters:
track - List
trackBuilder - TrackMoveProducer

planBuildingTrack

private MoveStatus planBuildingTrack(ImPoint point,
                                     Step vector)
Attempts to building track from the specified point in the specified direction on the worldDiff object.


reset

private void reset()
Cancels any proposed track and resets the path finder.


searchStatus

int searchStatus()

setCursorMessage

private void setCursorMessage(java.lang.String s)
Utility method that sets the CURSOR_MESSAGE property on the model root.


setProposedTrack

public void setProposedTrack(ImPoint to,
                             TrackMoveProducer trackBuilder)
Sets the proposed track: from the current cursor position to the specified point.


setTargetPoint

private void setTargetPoint(ImPoint newTargetPoint)
Parameters:
newTargetPoint - The m_targetPoint to set.

setVisible

private void setVisible(boolean show)

setWorldDiffs

private void setWorldDiffs(WorldDiffs worldDiffs)

show

public void show()

update

public void update()
Specified by:
update in interface GameModel

updateUntilComplete

public void updateUntilComplete()

updateSearch

private void updateSearch()
Updates the search, if the search is completed, the proposed track is shown.


getBuildMode

private TrackMoveProducer.BuildMode getBuildMode()

updateWorld

public ImPoint updateWorld(TrackMoveProducer trackBuilder)
Saves track into real world