Package net.sf.mrailsim.rails

Examples of net.sf.mrailsim.rails.Node


  }

  private void newTrackEntered( Track newTrack, Node node ) {
    // TODO Look more tracks ahead!
    Track nextTrack = null;
    Node nextNode = null;
    try {
      nextNode = newTrack.getOutgoingNode( node );
      nextTrack = nextNode.getOtherTrack( newTrack );
    } catch (Exception e) {
      // TODO Handle right
      e.printStackTrace();
      System.exit( 2 );
    }
View Full Code Here


   * @param nodeIdAtBack  node id the back of the train is looking at
   */
  // TODO: change nodeIdAtBack by nodeItAtFront - where the front looks at
  public void putTrain( Train train, long trackId, long nodeIdAtBack ) {
    Track track = Game.trackManager.getTrack( trackId );
    Node node = Game.nodeManager.getNode( nodeIdAtBack );
   
    try {
      // TODO: remove this in final release and handle correct
      if ( train.getLength() > track.getLength() ) {
        throw new Exception( "train too long" );
      }
      // TODO: remove this in final release and handle correct
      if ( train.getTrainGroup() != null ) {
        throw new Exception( "train already in traingroup" );
      }
    } catch( Exception e ) {
      e.printStackTrace();
      System.exit( 2 );
    }
   
    TrainGroup trainGroup = allocateNewTrainGroup();
   
    trainGroup.add( train );
   
    Node headsNode = null;
    try {
      headsNode = track.getOutgoingNode( node );
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

   
    position.increaseDistance( distanceMoving );
   
    while ( position.getDistance() > position.getTrack().getLength() ) {
      Track nextTrack = null;
      Node nextNode = null;
      Track oldTrack = position.getTrack();
      Node oldNode = position.getNode();
     
      try {
        nextNode = position.getTrack().getOutgoingNode( position.getNode() );
        nextTrack = nextNode.getOtherTrack( position.getTrack() );
      } catch (Exception e) {
View Full Code Here

    position.reduceDistance( distanceMoving );
   
    while ( position.getDistance() < 0 ) {
      Track nextTrack = null;
      Node nextNode = null;
      Track oldTrack = position.getTrack();
      Node oldNode = position.getNode();
     
      try {
        nextTrack = oldNode.getOtherTrack( position.getTrack() );
        nextNode = nextTrack.getOutgoingNode( position.getNode() );
      } catch (Exception e) {
        e.printStackTrace();
        System.exit( 2 );
      }
View Full Code Here

     
      Set<Node> nodes = list.keySet();
      Iterator<Node> iterator = nodes.iterator();
     
      while ( iterator.hasNext() ) {
        Node node = iterator.next();
        Track track = list.get( node );
        addLookaheads( amount, track, node );
      }
    }
View Full Code Here

TOP

Related Classes of net.sf.mrailsim.rails.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.