jfreerails.world.track
Class TrackConfiguration

java.lang.Object
  extended by jfreerails.world.track.TrackConfiguration
All Implemented Interfaces:
java.io.Serializable, FlatTrackTemplate, FreerailsSerializable

public final class TrackConfiguration
extends java.lang.Object
implements FlatTrackTemplate

An instance of this class represents one of the possible track configurations in a map square - the combinations of directions in which track can be laid. Instances of this class cannot be created and must be obtained via the static methods herein.

Author:
Luke
See Also:
Serialized Form

Field Summary
private  int configuration
           
private static java.util.ArrayList<TrackConfiguration> flatTrackConfigurations
           
private  int length
           
static int LENGTH_OF_STRAIGHT_TRACK_PIECE
           
private static long serialVersionUID
           
 
Constructor Summary
private TrackConfiguration(int configuration)
           
 
Method Summary
static TrackConfiguration add(FlatTrackTemplate c, FlatTrackTemplate v)
           
 boolean contains(FlatTrackTemplate ftt)
           
 boolean contains(int trackTemplate)
           
 boolean equals(java.lang.Object o)
           
static TrackConfiguration from9bitTemplate(int i)
           
 int get8bitTemplate()
           
 int get9bitTemplate()
           
static TrackConfiguration getFlatInstance(Step v)
           
static TrackConfiguration getFlatInstance(java.lang.String trackTemplate)
           
 int getLength()
          Returns the length of track used in this configuration.
 java.util.Iterator getPossibleConfigurationsIterator()
           
 int getTrackGraphicsID()
           
 int hashCode()
           
private  java.lang.Object readResolve()
           
private static java.util.ArrayList<TrackConfiguration> setupConfigurations()
           
static int stringTemplate2Int(java.lang.String templateString)
           
static TrackConfiguration subtract(FlatTrackTemplate c, FlatTrackTemplate v)
           
 java.lang.String toString()
          Returns a String representing this configuration, for example "north, south".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

flatTrackConfigurations

private static final java.util.ArrayList<TrackConfiguration> flatTrackConfigurations

LENGTH_OF_STRAIGHT_TRACK_PIECE

public static final int LENGTH_OF_STRAIGHT_TRACK_PIECE
See Also:
Constant Field Values

length

private final int length

configuration

private final int configuration
Constructor Detail

TrackConfiguration

private TrackConfiguration(int configuration)
Method Detail

add

public static TrackConfiguration add(FlatTrackTemplate c,
                                     FlatTrackTemplate v)
Returns:
the superposition of two track templates

from9bitTemplate

public static TrackConfiguration from9bitTemplate(int i)

getFlatInstance

public static TrackConfiguration getFlatInstance(Step v)

getFlatInstance

public static TrackConfiguration getFlatInstance(java.lang.String trackTemplate)

setupConfigurations

private static java.util.ArrayList<TrackConfiguration> setupConfigurations()

stringTemplate2Int

public static int stringTemplate2Int(java.lang.String templateString)

subtract

public static TrackConfiguration subtract(FlatTrackTemplate c,
                                          FlatTrackTemplate v)
Returns:
the TrackConfiguration representing the track section c minus the track sections represented by v.

contains

public boolean contains(FlatTrackTemplate ftt)
Specified by:
contains in interface FlatTrackTemplate
Parameters:
ftt - the FlatTrackTemplate which may be a subset of this FlatTrackTemplate.
Returns:
true if the vectors represented by this FlatTrackTemplate are a superset of the vectors of the specified FlatTrackTemplate

contains

public boolean contains(int trackTemplate)

get8bitTemplate

public int get8bitTemplate()

get9bitTemplate

public int get9bitTemplate()
Specified by:
get9bitTemplate in interface FlatTrackTemplate
Returns:
an int representing this track configuration.

getLength

public int getLength()
Returns the length of track used in this configuration. Used to calculate the cost of building track.


getPossibleConfigurationsIterator

public java.util.Iterator getPossibleConfigurationsIterator()

getTrackGraphicsID

public int getTrackGraphicsID()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

readResolve

private java.lang.Object readResolve()
                              throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException

toString

public java.lang.String toString()
Returns a String representing this configuration, for example "north, south".

Overrides:
toString in class java.lang.Object