Class Train

    • Constructor Detail

      • Train

        public Train​(java.lang.String id,
                     java.lang.String name)
      • Train

        public Train​(org.jdom2.Element e)
        Construct this Entry from XML. This member has to remain synchronized with the detailed DTD in operations-trains.dtd
        Parameters:
        e - Consist XML element
    • Method Detail

      • getId

        public java.lang.String getId()
        Description copied from interface: Identifiable
        Get the identity of the object.
        Specified by:
        getId in interface Identifiable
        Returns:
        the identity
      • setName

        public void setName​(java.lang.String name)
        Sets the name of this train, normally a short name that can fit within the train icon.
        Parameters:
        name - the train's name.
      • toString

        public java.lang.String toString()
        Get's a train's name
        Overrides:
        toString in class java.lang.Object
        Returns:
        train's name
      • getName

        public java.lang.String getName()
        Get's a train's name
        Returns:
        train's name
      • getTableRowColorName

        public java.lang.String getTableRowColorName()
        Returns:
        The name of the color when highlighting the train's row
      • getTableRowColorNameReset

        public java.lang.String getTableRowColorNameReset()
        Returns:
        The name of the train row color when the train is reset
      • getTableRowColor

        public java.awt.Color getTableRowColor()
        Returns:
        The color when highlighting the train's row
      • getDepartureTime

        public java.lang.String getDepartureTime()
        Get's train's departure time
        Returns:
        train's departure time in the String format hh:mm
      • getFormatedDepartureTime

        public java.lang.String getFormatedDepartureTime()
        Get's train's departure time in 12hr or 24hr format
        Returns:
        train's departure time in the String format hh:mm or hh:mm(AM/PM)
      • getDepartTimeMinutes

        public int getDepartTimeMinutes()
        Get train's departure time in minutes from midnight for sorting
        Returns:
        int hh*60+mm
      • setDepartureTime

        public void setDepartureTime​(java.lang.String hour,
                                     java.lang.String minute)
      • getExpectedArrivalTime

        public java.lang.String getExpectedArrivalTime​(RouteLocation routeLocation)
        Gets the expected time when this train will arrive at the location rl. Expected arrival time is based on the number of car pick up and set outs for this train. TODO Doesn't provide expected arrival time if train is in route, instead provides relative time. If train is at or has passed the location return -1.
        Parameters:
        routeLocation - The RouteLocation.
        Returns:
        expected arrival time in minutes (append AM or PM if 12 hour format)
      • setRequirements

        public void setRequirements​(int requires)
        Set train requirements. If NO_CABOOSE_OR_FRED, then train doesn't require a caboose or car with FRED.
        Parameters:
        requires - NO_CABOOSE_OR_FRED, CABOOSE, FRED
      • getRequirements

        public int getRequirements()
        Get a train's requirements with regards to the last car in the train.
        Returns:
        NONE CABOOSE FRED
      • getRoute

        public Route getRoute()
        Gets the train's route
        Returns:
        train's route
      • getTrainRouteName

        public java.lang.String getTrainRouteName()
        Get's the train's route name.
        Returns:
        Train's route name.
      • getTrainDepartsName

        public java.lang.String getTrainDepartsName()
        Get the train's departure location's name
        Returns:
        train's departure location's name
      • getTrainTerminatesName

        public java.lang.String getTrainTerminatesName()
        Get train's final location's name
        Returns:
        train's final location's name
      • getTrainBlockingOrder

        public java.util.List<RouteLocationgetTrainBlockingOrder()
        Returns the order the train should be blocked.
        Returns:
        routeLocations for this train.
      • setCurrentLocation

        protected void setCurrentLocation​(RouteLocation location)
        Set train's current route location
        Parameters:
        location - The current RouteLocation.
      • getCurrentLocationName

        public java.lang.String getCurrentLocationName()
        Get train's current location name
        Returns:
        Train's current route location name
      • getNextLocationName

        public java.lang.String getNextLocationName()
        Get the train's next location name
        Returns:
        Train's next route location name
      • getNextLocationName

        public java.lang.String getNextLocationName​(int number)
        Get a location name in a train's route from the current train's location. A number of "1" means get the next location name in a train's route.
        Parameters:
        number - The stop number, must be greater than 0
        Returns:
        Name of the location that is the number of stops away from the train's current location.
      • setStatusCode

        public void setStatusCode​(int code)
        Set the train's machine readable status. Calls update train table row color.
        Parameters:
        code - machine readable
      • getStatus

        public java.lang.String getStatus()
        Get train's status in the default locale.
        Returns:
        Human-readable status
      • getStatus

        public java.lang.String getStatus​(java.util.Locale locale)
        Get train's status in the specified locale.
        Parameters:
        locale - The Locale.
        Returns:
        Human-readable status
      • getStatus

        public java.lang.String getStatus​(java.util.Locale locale,
                                          int code)
        Get the human-readable status for the requested status code.
        Parameters:
        locale - The Locale.
        code - requested status
        Returns:
        Human-readable status
      • isTrainEnRoute

        public boolean isTrainEnRoute()
        Used to determine if train has departed the first location in the train's route
        Returns:
        true if train has departed
      • isLocalSwitcher

        public boolean isLocalSwitcher()
        Used to determine if train is a local switcher serving one location. Note the train can have more than location in its route, but all location names must be "same". See TrainCommon.splitString(String name) for the definition of the "same" name.
        Returns:
        true if local switcher
      • isTurn

        public boolean isTurn()
      • isOnlyPassengerCars

        public boolean isOnlyPassengerCars()
        Used to determine if train is carrying only passenger cars.
        Returns:
        true if only passenger cars have been assigned to this train.
      • addTrainSkipsLocation

        public void addTrainSkipsLocation​(java.lang.String routelocationId)
        Train will skip the RouteLocation
        Parameters:
        routelocationId - RouteLocation Id
      • isLocationSkipped

        public boolean isLocationSkipped​(java.lang.String locationId)
        Determines if this train skips a location (doesn't service the location).
        Parameters:
        locationId - The route location id.
        Returns:
        true if the train will not service the location.
      • getTypeNames

        protected java.lang.String[] getTypeNames()
        Get's the type names of rolling stock this train will service
        Returns:
        The type names for cars and or engines
      • setTypeNames

        protected void setTypeNames​(java.lang.String[] types)
        Set the type of cars or engines this train will service, see types in Cars and Engines.
        Parameters:
        types - The type names for cars and or engines
      • addTypeName

        public void addTypeName​(java.lang.String type)
        Add a car or engine type name that this train will service.
        Parameters:
        type - The new type name to service.
      • deleteTypeName

        public void deleteTypeName​(java.lang.String type)
      • isTypeNameAccepted

        public boolean isTypeNameAccepted​(java.lang.String type)
        Returns true if this train will service the type of car or engine.
        Parameters:
        type - The car or engine type name.
        Returns:
        true if this train will service the particular type.
      • replaceType

        protected void replaceType​(java.lang.String oldType,
                                   java.lang.String newType)
      • getCarRoadOption

        public java.lang.String getCarRoadOption()
        Get how this train deals with car road names.
        Returns:
        ALL_ROADS INCLUDE_ROADS EXCLUDE_ROADS
      • setCarRoadOption

        public void setCarRoadOption​(java.lang.String option)
        Set how this train deals with car road names.
        Parameters:
        option - ALL_ROADS INCLUDE_ROADS EXCLUDE_ROADS
      • setCarRoadNames

        protected void setCarRoadNames​(java.lang.String[] roads)
      • getCarRoadNames

        public java.lang.String[] getCarRoadNames()
        Provides a list of car road names that the train will either service or exclude. See setCarRoadOption
        Returns:
        Array of sorted road names as Strings
      • addCarRoadName

        public boolean addCarRoadName​(java.lang.String road)
        Add a car road name that the train will either service or exclude. See setCarRoadOption
        Parameters:
        road - The string road name.
        Returns:
        true if road name was added, false if road name wasn't in the list.
      • deleteCarRoadName

        public boolean deleteCarRoadName​(java.lang.String road)
        Delete a car road name that the train will either service or exclude. See setRoadOption
        Parameters:
        road - The string road name to delete.
        Returns:
        true if road name was removed, false if road name wasn't in the list.
      • isCarRoadNameAccepted

        public boolean isCarRoadNameAccepted​(java.lang.String road)
        Determine if train will service a specific road name for a car.
        Parameters:
        road - the road name to check.
        Returns:
        true if train will service this road name.
      • getCabooseRoadOption

        public java.lang.String getCabooseRoadOption()
        Get how this train deals with caboose road names.
        Returns:
        ALL_ROADS INCLUDE_ROADS EXCLUDE_ROADS
      • setCabooseRoadOption

        public void setCabooseRoadOption​(java.lang.String option)
        Set how this train deals with caboose road names.
        Parameters:
        option - ALL_ROADS INCLUDE_ROADS EXCLUDE_ROADS
      • getCabooseRoadNames

        public java.lang.String[] getCabooseRoadNames()
        Provides a list of caboose road names that the train will either service or exclude. See setCabooseRoadOption
        Returns:
        Array of sorted road names as Strings
      • addCabooseRoadName

        public boolean addCabooseRoadName​(java.lang.String road)
        Add a caboose road name that the train will either service or exclude. See setCabooseRoadOption
        Parameters:
        road - The string road name.
        Returns:
        true if road name was added, false if road name wasn't in the list.
      • deleteCabooseRoadName

        public boolean deleteCabooseRoadName​(java.lang.String road)
        Delete a caboose road name that the train will either service or exclude. See setRoadOption
        Parameters:
        road - The string road name to delete.
        Returns:
        true if road name was removed, false if road name wasn't in the list.
      • isCabooseRoadNameAccepted

        public boolean isCabooseRoadNameAccepted​(java.lang.String road)
        Determine if train will service a specific road name for a caboose.
        Parameters:
        road - the road name to check.
        Returns:
        true if train will service this road name.
      • getLocoRoadOption

        public java.lang.String getLocoRoadOption()
        Get how this train deals with locomotive road names.
        Returns:
        ALL_ROADS INCLUDE_ROADS EXCLUDE_ROADS
      • setLocoRoadOption

        public void setLocoRoadOption​(java.lang.String option)
        Set how this train deals with locomotive road names.
        Parameters:
        option - ALL_ROADS INCLUDE_ROADS EXCLUDE_ROADS
      • setLocoRoadNames

        protected void setLocoRoadNames​(java.lang.String[] roads)
      • getLocoRoadNames

        public java.lang.String[] getLocoRoadNames()
        Provides a list of engine road names that the train will either service or exclude. See setLocoRoadOption
        Returns:
        Array of sorted road names as Strings
      • addLocoRoadName

        public boolean addLocoRoadName​(java.lang.String road)
        Add a engine road name that the train will either service or exclude. See setLocoRoadOption
        Parameters:
        road - The string road name.
        Returns:
        true if road name was added, false if road name wasn't in the list.
      • deleteLocoRoadName

        public boolean deleteLocoRoadName​(java.lang.String road)
        Delete a engine road name that the train will either service or exclude. See setLocoRoadOption
        Parameters:
        road - The string road name to delete.
        Returns:
        true if road name was removed, false if road name wasn't in the list.
      • isLocoRoadNameAccepted

        public boolean isLocoRoadNameAccepted​(java.lang.String road)
        Determine if train will service a specific road name for an engine.
        Parameters:
        road - the road name to check.
        Returns:
        true if train will service this road name.
      • replaceRoad

        protected void replaceRoad​(java.lang.String oldRoad,
                                   java.lang.String newRoad)
      • getLoadOption

        public java.lang.String getLoadOption()
        Gets the car load option for this train.
        Returns:
        ALL_LOADS INCLUDE_LOADS EXCLUDE_LOADS
      • setLoadOption

        public void setLoadOption​(java.lang.String option)
        Set how this train deals with car loads
        Parameters:
        option - ALL_LOADS INCLUDE_LOADS EXCLUDE_LOADS
      • setLoadNames

        protected void setLoadNames​(java.lang.String[] loads)
      • getLoadNames

        public java.lang.String[] getLoadNames()
        Provides a list of loads that the train will either service or exclude. See setLoadOption
        Returns:
        Array of load names as Strings
      • addLoadName

        public boolean addLoadName​(java.lang.String load)
        Add a load that the train will either service or exclude. See setLoadOption
        Parameters:
        load - The string load name.
        Returns:
        true if load name was added, false if load name wasn't in the list.
      • deleteLoadName

        public boolean deleteLoadName​(java.lang.String load)
        Delete a load name that the train will either service or exclude. See setLoadOption
        Parameters:
        load - The string load name.
        Returns:
        true if load name was removed, false if load name wasn't in the list.
      • isLoadNameAccepted

        public boolean isLoadNameAccepted​(java.lang.String load)
        Determine if train will service a specific load name.
        Parameters:
        load - the load name to check.
        Returns:
        true if train will service this load.
      • isLoadNameAccepted

        public boolean isLoadNameAccepted​(java.lang.String load,
                                          java.lang.String type)
        Determine if train will service a specific load and car type.
        Parameters:
        load - the load name to check.
        type - the type of car used to carry the load.
        Returns:
        true if train will service this load.
      • setOwnerOption

        public void setOwnerOption​(java.lang.String option)
        Set how this train deals with car owner names
        Parameters:
        option - ALL_OWNERS INCLUDE_OWNERS EXCLUDE_OWNERS
      • setOwnerNames

        protected void setOwnerNames​(java.lang.String[] owners)
      • getOwnerNames

        public java.lang.String[] getOwnerNames()
        Provides a list of owner names that the train will either service or exclude. See setOwnerOption
        Returns:
        Array of owner names as Strings
      • addOwnerName

        public boolean addOwnerName​(java.lang.String owner)
        Add a owner name that the train will either service or exclude. See setOwnerOption
        Parameters:
        owner - The string representing the owner's name.
        Returns:
        true if owner name was added, false if owner name wasn't in the list.
      • deleteOwnerName

        public boolean deleteOwnerName​(java.lang.String owner)
        Delete a owner name that the train will either service or exclude. See setOwnerOption
        Parameters:
        owner - The string representing the owner's name.
        Returns:
        true if owner name was removed, false if owner name wasn't in the list.
      • isOwnerNameAccepted

        public boolean isOwnerNameAccepted​(java.lang.String owner)
        Determine if train will service a specific owner name.
        Parameters:
        owner - the owner name to check.
        Returns:
        true if train will service this owner name.
      • replaceOwner

        protected void replaceOwner​(java.lang.String oldName,
                                    java.lang.String newName)
      • setBuiltStartYear

        public void setBuiltStartYear​(java.lang.String year)
        Only rolling stock built in or after this year will be used.
        Parameters:
        year - A string representing a year.
      • setBuiltEndYear

        public void setBuiltEndYear​(java.lang.String year)
        Only rolling stock built in or before this year will be used.
        Parameters:
        year - A string representing a year.
      • isBuiltDateAccepted

        public boolean isBuiltDateAccepted​(java.lang.String date)
        Determine if train will service rolling stock by built date.
        Parameters:
        date - A string representing the built date for a car or engine.
        Returns:
        true is built date is in the acceptable range.
      • isServiceable

        public boolean isServiceable​(Car car)
        Determines if this train will service this car. Note this code doesn't check the location or tracks that needs to be done separately. See Router.java.
        Parameters:
        car - The car to be tested.
        Returns:
        true if this train can service the car.
      • isServiceable

        public boolean isServiceable​(java.io.PrintWriter buildReport,
                                     Car car)
        Note that this code was written after TrainBuilder. It does pretty much the same as TrainBuilder but with much fewer build report messages.
        Parameters:
        buildReport - PrintWriter
        car - the car to be tested
        Returns:
        true if this train can service the car.
      • setServiceStatus

        protected void setServiceStatus​(java.lang.String status)
      • getServiceStatus

        public java.lang.String getServiceStatus()
        Returns the statusCode of the "isServiceable(Car)" routine. There are two statusCodes that need special consideration when the train is being built, the moves in a train's route and the maximum train length. NOTE: The code using getServiceStatus() currently assumes that if there's a service status that the issue is either route moves or maximum train length.
        Returns:
        The statusCode.
      • getNumberCarsWorked

        public int getNumberCarsWorked()
        Returns:
        The number of cars worked by this train
      • setDate

        public void setDate​(java.util.Date date)
      • getDate

        public java.lang.String getDate()
      • getNumberCarsInTrain

        public int getNumberCarsInTrain()
        Gets the number of cars in the train at the current location in the train's route.
        Returns:
        The number of cars currently in the train
      • getNumberCarsInTrain

        public int getNumberCarsInTrain​(RouteLocation routeLocation)
        Gets the number of cars in the train when train departs the route location.
        Parameters:
        routeLocation - The RouteLocation.
        Returns:
        The number of cars in the train departing the route location.
      • getNumberEmptyCarsInTrain

        public int getNumberEmptyCarsInTrain​(RouteLocation routeLocation)
        Gets the number of empty cars in the train when train departs the route location.
        Parameters:
        routeLocation - The RouteLocation.
        Returns:
        The number of empty cars in the train departing the route location.
      • getNumberCarsPickedUp

        public int getNumberCarsPickedUp​(RouteLocation routeLocation)
        Gets the number of cars pulled from a location
        Parameters:
        routeLocation - the location
        Returns:
        number of pick ups
      • getNumberCarsSetout

        public int getNumberCarsSetout​(RouteLocation routeLocation)
        Gets the number of cars delivered to a location
        Parameters:
        routeLocation - the location
        Returns:
        number of set outs
      • getTrainLength

        public int getTrainLength()
        Gets the train's length at the current location in the train's route.
        Returns:
        The train length at the train's current location
      • getTrainLength

        public int getTrainLength​(RouteLocation routeLocation)
        Gets the train's length at the route location specified
        Parameters:
        routeLocation - The route location
        Returns:
        The train length at the route location
      • getTrainWeight

        public int getTrainWeight()
        Get the train's weight at the current location.
        Returns:
        Train's weight in tons.
      • getTrainHorsePower

        public int getTrainHorsePower​(RouteLocation routeLocation)
        Gets the train's locomotive horsepower at the route location specified
        Parameters:
        routeLocation - The route location
        Returns:
        The train's locomotive horsepower at the route location
      • getCabooseRoadAndNumber

        public java.lang.String getCabooseRoadAndNumber()
        Gets the current caboose road and number if there's one assigned to the train.
        Returns:
        Road and number of caboose.
      • setDescription

        public void setDescription​(java.lang.String description)
      • getDescription

        public java.lang.String getDescription()
        Returns a formated string providing the train's description. {0} = lead engine number, {1} = train's departure direction {2} = lead engine road {3} = DCC address of lead engine.
        Returns:
        The train's description.
      • getNumberEngines

        public java.lang.String getNumberEngines()
        Get the number of engines that this train requires.
        Returns:
        The number of engines that this train requires.
      • getSecondLegNumberEngines

        public java.lang.String getSecondLegNumberEngines()
        Get the number of engines needed for the second set.
        Returns:
        The number of engines needed in route
      • getThirdLegNumberEngines

        public java.lang.String getThirdLegNumberEngines()
        Get the number of engines needed for the third set.
        Returns:
        The number of engines needed in route
      • setEngineRoad

        public void setEngineRoad​(java.lang.String road)
        Set the road name of engines servicing this train.
        Parameters:
        road - The road name of engines servicing this train.
      • getEngineRoad

        public java.lang.String getEngineRoad()
        Get the road name of engines servicing this train.
        Returns:
        The road name of engines servicing this train.
      • setSecondLegEngineRoad

        public void setSecondLegEngineRoad​(java.lang.String road)
        Set the road name of engines servicing this train 2nd leg.
        Parameters:
        road - The road name of engines servicing this train.
      • getSecondLegEngineRoad

        public java.lang.String getSecondLegEngineRoad()
        Get the road name of engines servicing this train 2nd leg.
        Returns:
        The road name of engines servicing this train.
      • setThirdLegEngineRoad

        public void setThirdLegEngineRoad​(java.lang.String road)
        Set the road name of engines servicing this train 3rd leg.
        Parameters:
        road - The road name of engines servicing this train.
      • getThirdLegEngineRoad

        public java.lang.String getThirdLegEngineRoad()
        Get the road name of engines servicing this train 3rd leg.
        Returns:
        The road name of engines servicing this train.
      • setEngineModel

        public void setEngineModel​(java.lang.String model)
        Set the model name of engines servicing this train.
        Parameters:
        model - The model name of engines servicing this train.
      • setSecondLegEngineModel

        public void setSecondLegEngineModel​(java.lang.String model)
        Set the model name of engines servicing this train's 2nd leg.
        Parameters:
        model - The model name of engines servicing this train.
      • setThirdLegEngineModel

        public void setThirdLegEngineModel​(java.lang.String model)
        Set the model name of engines servicing this train's 3rd leg.
        Parameters:
        model - The model name of engines servicing this train.
      • replaceModel

        protected void replaceModel​(java.lang.String oldModel,
                                    java.lang.String newModel)
      • setCabooseRoad

        public void setCabooseRoad​(java.lang.String road)
        Set the road name of the caboose servicing this train.
        Parameters:
        road - The road name of the caboose servicing this train.
      • setSecondLegCabooseRoad

        public void setSecondLegCabooseRoad​(java.lang.String road)
        Set the road name of the second leg caboose servicing this train.
        Parameters:
        road - The road name of the caboose servicing this train's 2nd leg.
      • setThirdLegCabooseRoad

        public void setThirdLegCabooseRoad​(java.lang.String road)
        Set the road name of the third leg caboose servicing this train.
        Parameters:
        road - The road name of the caboose servicing this train's 3rd leg.
      • setSecondLegOptions

        public void setSecondLegOptions​(int options)
        Optional changes to train while en route.
        Parameters:
        options - NO_CABOOSE_OR_FRED, CHANGE_ENGINES, ADD_CABOOSE, HELPER_ENGINES, REMOVE_CABOOSE
      • setThirdLegOptions

        public void setThirdLegOptions​(int options)
        Optional changes to train while en route.
        Parameters:
        options - NO_CABOOSE_OR_FRED, CHANGE_ENGINES, ADD_CABOOSE, HELPER_ENGINES, REMOVE_CABOOSE
      • setComment

        public void setComment​(java.lang.String comment)
      • getComment

        public java.lang.String getComment()
      • addBuildScript

        public void addBuildScript​(java.lang.String pathname)
        Add a script to run before a train is built
        Parameters:
        pathname - The script's pathname
      • getBuildScripts

        public java.util.List<java.lang.String> getBuildScripts()
        Gets a list of pathnames (scripts) to run before this train is built
        Returns:
        A list of pathnames to run before this train is built
      • addAfterBuildScript

        public void addAfterBuildScript​(java.lang.String pathname)
        Add a script to run after a train is built
        Parameters:
        pathname - The script's pathname
      • getAfterBuildScripts

        public java.util.List<java.lang.String> getAfterBuildScripts()
        Gets a list of pathnames (scripts) to run after this train is built
        Returns:
        A list of pathnames to run after this train is built
      • addMoveScript

        public void addMoveScript​(java.lang.String pathname)
        Add a script to run when train is moved
        Parameters:
        pathname - The script's pathname
      • deleteMoveScript

        public void deleteMoveScript​(java.lang.String pathname)
      • getMoveScripts

        public java.util.List<java.lang.String> getMoveScripts()
        Gets a list of pathnames (scripts) to run when this train moved
        Returns:
        A list of pathnames to run when this train moved
      • addTerminationScript

        public void addTerminationScript​(java.lang.String pathname)
        Add a script to run when train is terminated
        Parameters:
        pathname - The script's pathname
      • getTerminationScripts

        public java.util.List<java.lang.String> getTerminationScripts()
        Gets a list of pathnames (scripts) to run when this train terminates
        Returns:
        A list of pathnames to run when this train terminates
      • getRailroadName

        public java.lang.String getRailroadName()
        Gets the optional railroad name for this train.
        Returns:
        Train's railroad name.
      • setRailroadName

        public void setRailroadName​(java.lang.String name)
        Overrides the default railroad name for this train.
        Parameters:
        name - The railroad name for this train.
      • setManifestLogoPathName

        public void setManifestLogoPathName​(java.lang.String pathName)
        Overrides the default logo for this train.
        Parameters:
        pathName - file location for the logo.
      • isAllowLocalMovesEnabled

        public boolean isAllowLocalMovesEnabled()
        Allow local moves if car has a custom load or Final Destination
        Returns:
        true if local move is allowed
      • isAllowReturnToStagingEnabled

        public boolean isAllowReturnToStagingEnabled()
        When true allow a turn to return cars to staging. A turn is a train that departs and terminates at the same location.
        Returns:
        true if cars can return to staging
      • setBuilt

        protected void setBuilt​(boolean built)
      • isBuilt

        public boolean isBuilt()
        Used to determine if this train has been built.
        Returns:
        true if the train was successfully built.
      • setModified

        public void setModified​(boolean modified)
        Set true whenever the train's manifest has been modified. For example adding or removing a car from a train, or changing the manifest format. Once the manifest has been regenerated (modified == false), the old status for the train is restored.
        Parameters:
        modified - True if train's manifest has been modified.
      • setBuildEnabled

        public void setBuildEnabled​(boolean build)
        Control flag used to decide if this train is to be built.
        Parameters:
        build - When true, build this train.
      • isBuildEnabled

        public boolean isBuildEnabled()
        Used to determine if train is to be built.
        Returns:
        true if train is to be built.
      • buildIfSelected

        public boolean buildIfSelected()
        Build this train if the build control flag is true.
        Returns:
        True only if train is successfully built.
      • build

        public boolean build()
        Build this train. Creates a train manifest.
        Returns:
        True if build successful.
      • isBuildFailed

        public boolean isBuildFailed()
        Returns true if the train build failed. Note that returning false doesn't mean the build was successful.
        Returns:
        true if train build failed.
      • printManifestIfBuilt

        public boolean printManifestIfBuilt()
        Print manifest for train if already built.
        Returns:
        true if print successful.
      • printManifest

        public boolean printManifest​(boolean isPreview)
                              throws BuildFailedException
        Print manifest for train.
        Parameters:
        isPreview - True if preview.
        Returns:
        true if print successful, false if train print file not found.
        Throws:
        BuildFailedException - if unable to create new Manifests
      • runFile

        public boolean runFile()
      • setPrinted

        public void setPrinted​(boolean printed)
      • isPrinted

        public boolean isPrinted()
        Used to determine if train manifest was printed.
        Returns:
        true if the train manifest was printed.
      • setTrainIconCoordinates

        public boolean setTrainIconCoordinates()
        Sets the panel position for the train icon for the current route location.
        Returns:
        true if train coordinates can be set
      • terminate

        public void terminate()
        Terminate train.
      • move

        public void move()
        Move train to next location in the route. Will move engines, cars, and train icon. Will also terminate a train after it arrives at its final destination.
      • move

        public boolean move​(java.lang.String locationName)
        Move train to a location in the train's route. Code checks to see if the location requested is part of the train's route and if the train hasn't already visited the location. This command can only move the train forward in its route. Note that you can not terminate the train using this command. See move() or terminate().
        Parameters:
        locationName - The name of the location to move this train.
        Returns:
        true if train was able to move to the named location.
      • move

        public boolean move​(RouteLocation rl)
        Moves the train to the specified route location
        Parameters:
        rl - route location
        Returns:
        true if successful
      • moveToNextLocation

        public boolean moveToNextLocation​(java.lang.String locationName)
        Move train to the next location in the train's route. The location name provided must be equal to the next location name in the train's route.
        Parameters:
        locationName - The next location name in the train's route.
        Returns:
        true if successful.
      • getLeadEngine

        public Engine getLeadEngine()
        Gets the lead engine, will create it if the program has been restarted
        Returns:
        lead engine for this train
      • getLeadEngine

        public Engine getLeadEngine​(RouteLocation routeLocation)
        Returns the lead engine in a train's route. There can be up to two changes in the lead engine for a train.
        Parameters:
        routeLocation - where in the train's route to find the lead engine.
        Returns:
        lead engine
      • setSwitchListStatus

        public void setSwitchListStatus​(java.lang.String status)
        Sets the print status for switch lists
        Parameters:
        status - UNKNOWN PRINTED
      • reset

        public boolean reset()
        Resets the train, removes engines and cars from this train.
        Returns:
        true if reset successful
      • store

        public org.jdom2.Element store()
        Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-trains.dtd.
        Returns:
        Contents in a JDOM Element
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • setDirtyAndFirePropertyChange

        protected void setDirtyAndFirePropertyChange​(java.lang.String p,
                                                     java.lang.Object old,
                                                     java.lang.Object n)