rails.algorithms
Class NetworkVertex

java.lang.Object
  extended by rails.algorithms.NetworkVertex
All Implemented Interfaces:
java.lang.Comparable<NetworkVertex>

public final class NetworkVertex
extends java.lang.Object
implements java.lang.Comparable<NetworkVertex>


Nested Class Summary
static class NetworkVertex.StationType
           
static class NetworkVertex.ValueOrder
           
static class NetworkVertex.VertexType
           
 
Field Summary
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
NetworkVertex(MapHex hex, int side)
          constructor for side on mapHex
NetworkVertex(MapHex hex, Station station)
          constructor for station on mapHex
NetworkVertex(PublicCompanyI company)
          constructor for public company hq
 
Method Summary
(package private)  void addToRevenueCalculator(RevenueCalculator rc, int vertexId)
           
 int compareTo(NetworkVertex otherVertex)
           
static NetworkVertex duplicateVertex(org.jgrapht.graph.SimpleGraph<NetworkVertex,NetworkEdge> graph, NetworkVertex vertex, java.lang.String newIdentifier, boolean addOldVertexAsHidden)
          creates a new virtual vertex with identical properties and links
 City getCity()
           
 java.lang.String getCityName()
           
 MapHex getHex()
           
 java.lang.String getIdentifier()
           
 int getSide()
           
 Station getStation()
           
 NetworkVertex.StationType getStationType()
           
 NetworkVertex.VertexType getType()
           
 int getValue()
           
 int getValueByTrain(NetworkTrain train)
           
static NetworkVertex getVertexByIdentifier(java.util.Collection<NetworkVertex> vertices, java.lang.String identifier)
           
static java.awt.Rectangle getVertexMapCoverage(HexMap map, java.util.Collection<NetworkVertex> vertices)
           
static java.awt.geom.Point2D getVertexPoint2D(HexMap map, NetworkVertex vertex)
           
static java.util.Set<NetworkVertex> getVerticesByHex(java.util.Collection<NetworkVertex> vertices, MapHex hex)
          Returns all vertices for a specified hex
static java.util.Set<NetworkVertex> getVerticesByHexes(java.util.Collection<NetworkVertex> vertices, java.util.Collection<MapHex> hexes)
          Filters all vertices from a collection of vertices that lay in a specified collection of hexes
static NetworkVertex getVirtualVertex(NetworkVertex.VertexType type, java.lang.String name)
          factory method for virtual vertex
static void initAllRailsVertices(java.util.Collection<NetworkVertex> vertices, PublicCompanyI company, PhaseI phase)
           
 void initRailsVertex(PublicCompanyI company)
          Initialize for rails vertexes
 boolean isHQ()
           
 boolean isMajor()
           
 boolean isMinor()
           
 boolean isOfType(NetworkVertex.VertexType vertexType, NetworkVertex.StationType stationType)
           
 boolean isSide()
           
 boolean isSink()
           
 boolean isStation()
           
 boolean isVirtual()
           
static int maxVertexValue(java.util.Collection<NetworkVertex> vertices)
          Returns the maximum positive value (lower bound zero)
static int numberOfVertexType(java.util.Collection<NetworkVertex> vertices, NetworkVertex.VertexType vertexType, NetworkVertex.StationType stationType)
          Returns the number of specified vertex type in a vertex collection If station then specify station type
static boolean replaceVertex(org.jgrapht.graph.SimpleGraph<NetworkVertex,NetworkEdge> graph, NetworkVertex oldVertex, NetworkVertex newVertex)
          replaces one vertex by another for a network graph copies all edges
 NetworkVertex setCityName(java.lang.String locationName)
           
 void setRailsVertexValue(PhaseI phase)
           
 NetworkVertex setSink(boolean sink)
           
 NetworkVertex setStationType(NetworkVertex.StationType stationType)
           
 NetworkVertex setValue(int value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log
Constructor Detail

NetworkVertex

public NetworkVertex(MapHex hex,
                     Station station)
constructor for station on mapHex


NetworkVertex

public NetworkVertex(MapHex hex,
                     int side)
constructor for side on mapHex


NetworkVertex

public NetworkVertex(PublicCompanyI company)
constructor for public company hq

Method Detail

getVirtualVertex

public static NetworkVertex getVirtualVertex(NetworkVertex.VertexType type,
                                             java.lang.String name)
factory method for virtual vertex


addToRevenueCalculator

void addToRevenueCalculator(RevenueCalculator rc,
                            int vertexId)

getIdentifier

public java.lang.String getIdentifier()

isVirtual

public boolean isVirtual()

isStation

public boolean isStation()

isSide

public boolean isSide()

isHQ

public boolean isHQ()

getType

public NetworkVertex.VertexType getType()

isMajor

public boolean isMajor()

isMinor

public boolean isMinor()

getStationType

public NetworkVertex.StationType getStationType()

setStationType

public NetworkVertex setStationType(NetworkVertex.StationType stationType)

getValue

public int getValue()

getValueByTrain

public int getValueByTrain(NetworkTrain train)

setValue

public NetworkVertex setValue(int value)

isSink

public boolean isSink()

setSink

public NetworkVertex setSink(boolean sink)

getCityName

public java.lang.String getCityName()

setCityName

public NetworkVertex setCityName(java.lang.String locationName)

getHex

public MapHex getHex()

getStation

public Station getStation()

getCity

public City getCity()

getSide

public int getSide()

isOfType

public boolean isOfType(NetworkVertex.VertexType vertexType,
                        NetworkVertex.StationType stationType)

initRailsVertex

public void initRailsVertex(PublicCompanyI company)
Initialize for rails vertexes


setRailsVertexValue

public void setRailsVertexValue(PhaseI phase)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(NetworkVertex otherVertex)
Specified by:
compareTo in interface java.lang.Comparable<NetworkVertex>

initAllRailsVertices

public static void initAllRailsVertices(java.util.Collection<NetworkVertex> vertices,
                                        PublicCompanyI company,
                                        PhaseI phase)

maxVertexValue

public static int maxVertexValue(java.util.Collection<NetworkVertex> vertices)
Returns the maximum positive value (lower bound zero)


numberOfVertexType

public static int numberOfVertexType(java.util.Collection<NetworkVertex> vertices,
                                     NetworkVertex.VertexType vertexType,
                                     NetworkVertex.StationType stationType)
Returns the number of specified vertex type in a vertex collection If station then specify station type


duplicateVertex

public static NetworkVertex duplicateVertex(org.jgrapht.graph.SimpleGraph<NetworkVertex,NetworkEdge> graph,
                                            NetworkVertex vertex,
                                            java.lang.String newIdentifier,
                                            boolean addOldVertexAsHidden)
creates a new virtual vertex with identical properties and links


replaceVertex

public static boolean replaceVertex(org.jgrapht.graph.SimpleGraph<NetworkVertex,NetworkEdge> graph,
                                    NetworkVertex oldVertex,
                                    NetworkVertex newVertex)
replaces one vertex by another for a network graph copies all edges


getVerticesByHexes

public static java.util.Set<NetworkVertex> getVerticesByHexes(java.util.Collection<NetworkVertex> vertices,
                                                              java.util.Collection<MapHex> hexes)
Filters all vertices from a collection of vertices that lay in a specified collection of hexes


getVerticesByHex

public static java.util.Set<NetworkVertex> getVerticesByHex(java.util.Collection<NetworkVertex> vertices,
                                                            MapHex hex)
Returns all vertices for a specified hex


getVertexByIdentifier

public static NetworkVertex getVertexByIdentifier(java.util.Collection<NetworkVertex> vertices,
                                                  java.lang.String identifier)

getVertexPoint2D

public static java.awt.geom.Point2D getVertexPoint2D(HexMap map,
                                                     NetworkVertex vertex)

getVertexMapCoverage

public static java.awt.Rectangle getVertexMapCoverage(HexMap map,
                                                      java.util.Collection<NetworkVertex> vertices)