jfreerails.controller
Class CalcCargoSupplyRateAtStation

java.lang.Object
  extended by jfreerails.controller.CalcCargoSupplyRateAtStation

public class CalcCargoSupplyRateAtStation
extends java.lang.Object

This class probes the tiles adjacent to a station for what cargo they supply, demand, and convert and then returns a vector of these rates.

Author:
Scott Bennett, Luke Created: 9th May 2003

Field Summary
private  int[] converts
           
private  int[] demand
           
private static java.util.logging.Logger logger
           
private static int PREREQUISITE_FOR_DEMAND
          The threshold that demand for a cargo must exceed before the station demands the cargo.
private  int stationRadius
           
private  java.util.Vector<CargoElementObject> supplies
           
private  ReadOnlyWorld w
           
private  int x
           
private  int y
           
 
Constructor Summary
CalcCargoSupplyRateAtStation(ReadOnlyWorld world, int X, int Y)
          Call this constructor if the station already exists.
CalcCargoSupplyRateAtStation(ReadOnlyWorld world, int X, int Y, int trackRuleNo)
          Call this constructor if the station does not exist yet.
 
Method Summary
 StationModel calculations(StationModel station)
          Process each existing station, updating what is supplied to it.
private static int findTrackRule(int xx, int yy, ReadOnlyWorld w)
           
 ConvertedAtStation getConversion()
           
 Demand4Cargo getDemand()
           
private  void incrementSupplyAndDemand(int i, int j)
           
private  void populateSuppliesVector()
           
 java.util.Vector<CargoElementObject> scanAdjacentTiles()
           
private  void updateSupplyRate(int type, int rate)
           
 
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

PREREQUISITE_FOR_DEMAND

private static final int PREREQUISITE_FOR_DEMAND
The threshold that demand for a cargo must exceed before the station demands the cargo.

See Also:
Constant Field Values

converts

private final int[] converts

demand

private final int[] demand

supplies

private final java.util.Vector<CargoElementObject> supplies

w

private final ReadOnlyWorld w

x

private int x

y

private int y

stationRadius

private int stationRadius
Constructor Detail

CalcCargoSupplyRateAtStation

public CalcCargoSupplyRateAtStation(ReadOnlyWorld world,
                                    int X,
                                    int Y,
                                    int trackRuleNo)
Call this constructor if the station does not exist yet.

Parameters:
trackRuleNo - the station type.

CalcCargoSupplyRateAtStation

public CalcCargoSupplyRateAtStation(ReadOnlyWorld world,
                                    int X,
                                    int Y)
Call this constructor if the station already exists.

Method Detail

getConversion

public ConvertedAtStation getConversion()

getDemand

public Demand4Cargo getDemand()

incrementSupplyAndDemand

private void incrementSupplyAndDemand(int i,
                                      int j)

populateSuppliesVector

private void populateSuppliesVector()

scanAdjacentTiles

public java.util.Vector<CargoElementObject> scanAdjacentTiles()

findTrackRule

private static int findTrackRule(int xx,
                                 int yy,
                                 ReadOnlyWorld w)

updateSupplyRate

private void updateSupplyRate(int type,
                              int rate)

calculations

public StationModel calculations(StationModel station)
Process each existing station, updating what is supplied to it.

Parameters:
station - A StationModel object to be processed