Package jmri.jmrit.operations.trains
Class Train
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.trains.Train
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,Identifiable
,PropertyChangeFirer
,PropertyChangeProvider
public class Train extends PropertyChangeSupport implements Identifiable, java.beans.PropertyChangeListener
Represents a train on the layout
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>
_afterBuildScripts
protected boolean
_allowCarsReturnStaging
protected boolean
_allowLocalMoves
protected boolean
_allowThroughCars
protected boolean
_build
protected boolean
_buildConsist
protected boolean
_buildFailed
protected java.lang.String
_buildFailedMessage
protected boolean
_buildNormal
protected java.util.List<java.lang.String>
_buildScripts
protected boolean
_built
protected java.lang.String
_builtEndYear
protected java.lang.String
_builtStartYear
protected java.lang.String
_cabooseRoad
protected java.util.List<java.lang.String>
_cabooseRoadList
protected java.lang.String
_cabooseRoadOption
protected java.util.List<java.lang.String>
_carRoadList
protected java.lang.String
_carRoadOption
protected java.lang.String
_comment
protected RouteLocation
_current
protected java.util.Date
_date
protected java.lang.String
_departureTime
protected Track
_departureTrack
protected java.lang.String
_description
protected RouteLocation
_end2Leg
protected java.lang.String
_engineModel
protected java.lang.String
_engineRoad
protected java.lang.String
_id
protected Engine
_leadEngine
protected java.lang.String
_leadEngineId
protected java.lang.String
_leg2CabooseRoad
protected java.lang.String
_leg2Engines
protected java.lang.String
_leg2Model
protected int
_leg2Options
protected java.lang.String
_leg2Road
protected RouteLocation
_leg2Start
protected java.lang.String
_leg3CabooseRoad
protected RouteLocation
_leg3End
protected java.lang.String
_leg3Engines
protected java.lang.String
_leg3Model
protected int
_leg3Options
protected java.lang.String
_leg3Road
protected RouteLocation
_leg3Start
(package private) java.util.List<java.lang.String>
_loadList
protected java.lang.String
_loadOption
protected java.util.List<java.lang.String>
_locoRoadList
protected java.lang.String
_locoRoadOption
protected java.lang.String
_logoPathName
protected boolean
_modified
protected java.util.List<java.lang.String>
_moveScripts
protected java.lang.String
_name
protected java.lang.String
_numberEngines
protected int
_oldStatusCode
(package private) java.util.List<java.lang.String>
_ownerList
protected java.lang.String
_ownerOption
protected boolean
_printed
protected java.lang.String
_railroadName
protected int
_requires
protected Route
_route
protected boolean
_sendCarsWithCustomLoadsToStaging
protected boolean
_sendToTerminal
protected boolean
_serviceAllCarsWithFinalDestinations
protected java.lang.String
_serviceStatus
protected boolean
_showTimes
(package private) java.util.List<java.lang.String>
_skipLocationsList
protected int
_statusCarsRequested
protected int
_statusCode
protected java.lang.String
_switchListStatus
(package private) TrainIconAnimation
_ta
protected java.lang.String
_tableRowColorName
protected java.lang.String
_tableRowColorResetName
protected java.util.List<java.lang.String>
_terminationScripts
protected Track
_terminationTrack
protected TrainIcon
_trainIcon
(package private) java.util.List<java.lang.String>
_typeList
static int
ADD_CABOOSE
static int
ADD_ENGINES
static java.lang.String
ALL_LOADS
static java.lang.String
ALL_OWNERS
static java.lang.String
ALL_ROADS
static java.lang.String
ALREADY_SERVICED
static java.lang.String
AUTO
static java.lang.String
AUTO_HPT
static java.lang.String
BUILD_CHANGED_PROPERTY
static java.lang.String
BUILD_FAILED
static java.lang.String
BUILDING
static java.lang.String
BUILT
static java.lang.String
BUILT_CHANGED_PROPERTY
static java.lang.String
BUILT_YEAR_CHANGED_PROPERTY
static int
CABOOSE
static int
CHANGE_ENGINES
static int
CODE_BUILD_FAILED
static int
CODE_BUILDING
static int
CODE_BUILT
static int
CODE_MANIFEST_MODIFIED
static int
CODE_PARTIAL_BUILT
static int
CODE_RUN_SCRIPTS
static int
CODE_TERMINATED
static int
CODE_TRAIN_EN_ROUTE
static int
CODE_TRAIN_RESET
static int
CODE_UNKNOWN
static java.lang.String
DEPARTURETIME_CHANGED_PROPERTY
static java.lang.String
DESCRIPTION_CHANGED_PROPERTY
static java.lang.String
DISPOSE_CHANGED_PROPERTY
static java.lang.String
EXCLUDE_LOADS
static java.lang.String
EXCLUDE_OWNERS
static java.lang.String
EXCLUDE_ROADS
static int
FRED
static int
HELPER_ENGINES
static java.lang.String
INCLUDE_LOADS
static java.lang.String
INCLUDE_OWNERS
static java.lang.String
INCLUDE_ROADS
static java.lang.String
LOADS_CHANGED_PROPERTY
static java.lang.String
MANIFEST_MODIFIED
static java.lang.String
NAME_CHANGED_PROPERTY
static int
NO_CABOOSE_OR_FRED
static java.lang.String
NONE
static java.lang.String
OWNERS_CHANGED_PROPERTY
static java.lang.String
PARTIAL_BUILT
static java.lang.String
PRINTED
static int
REMOVE_CABOOSE
static int
REMOVE_ENGINES
static java.lang.String
ROADS_CHANGED_PROPERTY
static java.lang.String
RUN_SCRIPTS
protected static java.lang.String
SEVEN
static java.lang.String
STATUS_CHANGED_PROPERTY
static java.lang.String
STOPS_CHANGED_PROPERTY
static java.lang.String
TERMINATED
static java.lang.String
TRAIN_EN_ROUTE
static java.lang.String
TRAIN_LOCATION_CHANGED_PROPERTY
static java.lang.String
TRAIN_MODIFIED_CHANGED_PROPERTY
static java.lang.String
TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY
static java.lang.String
TRAIN_REQUIREMENTS_CHANGED_PROPERTY
static java.lang.String
TRAIN_RESET
static java.lang.String
TRAIN_ROUTE_CHANGED_PROPERTY
static java.lang.String
TRAIN_ROW_COLOR_CHANGED_PROPERTY
static java.lang.String
TRAIN_ROW_COLOR_RESET_CHANGED_PROPERTY
static java.lang.String
TYPES_CHANGED_PROPERTY
static java.lang.String
UNKNOWN
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAfterBuildScript(java.lang.String pathname)
Add a script to run after a train is builtvoid
addBuildScript(java.lang.String pathname)
Add a script to run before a train is builtboolean
addCabooseRoadName(java.lang.String road)
Add a caboose road name that the train will either service or exclude.boolean
addCarRoadName(java.lang.String road)
Add a car road name that the train will either service or exclude.boolean
addLoadName(java.lang.String load)
Add a load that the train will either service or exclude.boolean
addLocoRoadName(java.lang.String road)
Add a engine road name that the train will either service or exclude.void
addMoveScript(java.lang.String pathname)
Add a script to run when train is movedboolean
addOwnerName(java.lang.String owner)
Add a owner name that the train will either service or exclude.void
addTerminationScript(java.lang.String pathname)
Add a script to run when train is terminatedvoid
addTrainSkipsLocation(java.lang.String routelocationId)
Train will skip the RouteLocationvoid
addTypeName(java.lang.String type)
Add a car or engine type name that this train will service.boolean
build()
Build this train.boolean
buildIfSelected()
Build this train if the build control flag is true.java.io.File
createCsvManifestFile()
void
createTrainIcon(RouteLocation rl)
void
deleteAfterBuildScript(java.lang.String pathname)
void
deleteBuildScript(java.lang.String pathname)
boolean
deleteCabooseRoadName(java.lang.String road)
Delete a caboose road name that the train will either service or exclude.boolean
deleteCarRoadName(java.lang.String road)
Delete a car road name that the train will either service or exclude.boolean
deleteLoadName(java.lang.String load)
Delete a load name that the train will either service or exclude.boolean
deleteLocoRoadName(java.lang.String road)
Delete a engine road name that the train will either service or exclude.void
deleteMoveScript(java.lang.String pathname)
boolean
deleteOwnerName(java.lang.String owner)
Delete a owner name that the train will either service or exclude.void
deleteTerminationScript(java.lang.String pathname)
void
deleteTrainSkipsLocation(java.lang.String locationId)
void
deleteTypeName(java.lang.String type)
void
dispose()
java.util.List<java.lang.String>
getAfterBuildScripts()
Gets a list of pathnames (scripts) to run after this train is builtprotected java.lang.String
getBuildFailedMessage()
java.util.List<java.lang.String>
getBuildScripts()
Gets a list of pathnames (scripts) to run before this train is builtjava.lang.String
getBuiltEndYear()
java.lang.String
getBuiltStartYear()
java.lang.String
getCabooseRoad()
java.lang.String
getCabooseRoadAndNumber()
Gets the current caboose road and number if there's one assigned to the train.java.lang.String[]
getCabooseRoadNames()
Provides a list of caboose road names that the train will either service or exclude.java.lang.String
getCabooseRoadOption()
Get how this train deals with caboose road names.java.lang.String[]
getCarRoadNames()
Provides a list of car road names that the train will either service or exclude.java.lang.String
getCarRoadOption()
Get how this train deals with car road names.java.lang.String[]
getCarTypeNames()
java.lang.String
getComment()
java.lang.String
getCommentWithColor()
java.lang.String
getCurrentLocationName()
Get train's current location nameRouteLocation
getCurrentRouteLocation()
Get train's current route locationjava.lang.String
getDate()
int
getDepartTimeMinutes()
Get train's departure time in minutes from midnight for sortingjava.lang.String
getDepartureTime()
Get's train's departure timejava.lang.String
getDepartureTimeHour()
java.lang.String
getDepartureTimeMinute()
Track
getDepartureTrack()
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.java.lang.String
getEngineModel()
java.lang.String
getEngineRoad()
Get the road name of engines servicing this train.java.lang.String
getExpectedArrivalTime(RouteLocation routeLocation)
Gets the expected time when this train will arrive at the location rl.java.lang.String
getExpectedDepartureTime(RouteLocation routeLocation)
int
getExpectedTravelTimeInMinutes(RouteLocation routeLocation)
java.lang.String
getFormatedDepartureTime()
Get's train's departure time in 12hr or 24hr formatjava.lang.String
getIconName()
java.lang.String
getId()
Get the identity of the object.Engine
getLeadEngine()
Gets the lead engine, will create it if the program has been restartedEngine
getLeadEngine(RouteLocation routeLocation)
Returns the lead engine in a train's route.java.lang.String
getLeadEngineDccAddress()
java.lang.String
getLeadEngineNumber()
java.lang.String
getLeadEngineRoadAndNumber()
java.lang.String
getLeadEngineRoadName()
java.lang.String[]
getLoadNames()
Provides a list of loads that the train will either service or exclude.java.lang.String
getLoadOption()
Gets the car load option for this train.java.lang.String[]
getLocoRoadNames()
Provides a list of engine road names that the train will either service or exclude.java.lang.String
getLocoRoadOption()
Get how this train deals with locomotive road names.java.lang.String[]
getLocoTypeNames()
java.lang.String
getManifestLogoPathName()
java.util.List<java.lang.String>
getMoveScripts()
Gets a list of pathnames (scripts) to run when this train movedjava.lang.String
getMRStatus()
java.lang.String
getName()
Get's a train's namejava.lang.String
getNextLocationName()
Get the train's next location namejava.lang.String
getNextLocationName(int number)
Get a location name in a train's route from the current train's location.RouteLocation
getNextRouteLocation(RouteLocation currentRouteLocation)
int
getNumberCarsInTrain()
Gets the number of cars in the train at the current location in the train's route.int
getNumberCarsInTrain(RouteLocation routeLocation)
Gets the number of cars in the train when train departs the route location.int
getNumberCarsPickedUp(RouteLocation routeLocation)
Gets the number of cars pulled from a locationint
getNumberCarsRequested()
int
getNumberCarsSetout(RouteLocation routeLocation)
Gets the number of cars delivered to a locationint
getNumberCarsWorked()
int
getNumberEmptyCarsInTrain(RouteLocation routeLocation)
Gets the number of empty cars in the train when train departs the route location.java.lang.String
getNumberEngines()
Get the number of engines that this train requires.int
getNumberLoadedCarsInTrain(RouteLocation routeLocation)
protected int
getOldStatusCode()
java.lang.String[]
getOwnerNames()
Provides a list of owner names that the train will either service or exclude.java.lang.String
getOwnerOption()
java.lang.String
getRailroadName()
Gets the optional railroad name for this train.java.lang.String
getRawDescription()
int
getRequirements()
Get a train's requirements with regards to the last car in the train.Route
getRoute()
Gets the train's routejava.lang.String
getSecondLegCabooseRoad()
java.lang.String
getSecondLegEndLocationName()
RouteLocation
getSecondLegEndRouteLocation()
java.lang.String
getSecondLegEngineModel()
java.lang.String
getSecondLegEngineRoad()
Get the road name of engines servicing this train 2nd leg.java.lang.String
getSecondLegNumberEngines()
Get the number of engines needed for the second set.int
getSecondLegOptions()
java.lang.String
getSecondLegStartLocationName()
RouteLocation
getSecondLegStartRouteLocation()
java.lang.String
getServiceStatus()
Returns the statusCode of the "isServiceable(Car)" routine.java.lang.String
getSortDate()
java.lang.String
getStatus()
Get train's status in the default locale.java.lang.String
getStatus(java.util.Locale locale)
Get train's status in the specified locale.java.lang.String
getStatus(java.util.Locale locale, int code)
Get the human-readable status for the requested status code.int
getStatusCode()
java.lang.String
getSwitchListStatus()
java.awt.Color
getTableRowColor()
java.lang.String
getTableRowColorName()
java.lang.String
getTableRowColorNameReset()
java.util.List<java.lang.String>
getTerminationScripts()
Gets a list of pathnames (scripts) to run when this train terminatesTrack
getTerminationTrack()
java.lang.String
getThirdLegCabooseRoad()
java.lang.String
getThirdLegEndLocationName()
RouteLocation
getThirdLegEndRouteLocation()
java.lang.String
getThirdLegEngineModel()
java.lang.String
getThirdLegEngineRoad()
Get the road name of engines servicing this train 3rd leg.java.lang.String
getThirdLegNumberEngines()
Get the number of engines needed for the third set.int
getThirdLegOptions()
java.lang.String
getThirdLegStartLocationName()
RouteLocation
getThirdLegStartRouteLocation()
java.util.List<RouteLocation>
getTrainBlockingOrder()
Returns the order the train should be blocked.java.lang.String
getTrainDepartsDirection()
java.lang.String
getTrainDepartsName()
Get the train's departure location's nameRouteLocation
getTrainDepartsRouteLocation()
int
getTrainHorsePower(RouteLocation routeLocation)
Gets the train's locomotive horsepower at the route location specifiedTrainIcon
getTrainIcon()
int
getTrainLength()
Gets the train's length at the current location in the train's route.int
getTrainLength(RouteLocation routeLocation)
Gets the train's length at the route location specifiedjava.lang.String
getTrainRouteName()
Get's the train's route name.protected java.lang.String[]
getTrainSkipsLocations()
java.lang.String
getTrainTerminatesName()
Get train's final location's nameRouteLocation
getTrainTerminatesRouteLocation()
int
getTrainWeight()
Get the train's weight at the current location.int
getTrainWeight(RouteLocation routeLocation)
protected java.lang.String[]
getTypeNames()
Get's the type names of rolling stock this train will serviceint
getWorkTimeAtLocation(RouteLocation routeLocation)
boolean
isAllowLocalMovesEnabled()
Allow local moves if car has a custom load or Final Destinationboolean
isAllowReturnToStagingEnabled()
When true allow a turn to return cars to staging.boolean
isAllowThroughCarsEnabled()
boolean
isBuildConsistEnabled()
boolean
isBuildEnabled()
Used to determine if train is to be built.boolean
isBuildFailed()
Returns true if the train build failed.boolean
isBuildTrainNormalEnabled()
boolean
isBuilt()
Used to determine if this train has been built.boolean
isBuiltDateAccepted(java.lang.String date)
Determine if train will service rolling stock by built date.boolean
isCabooseNeeded()
boolean
isCabooseRoadNameAccepted(java.lang.String road)
Determine if train will service a specific road name for a caboose.boolean
isCarRoadNameAccepted(java.lang.String road)
Determine if train will service a specific road name for a car.boolean
isDepartingStaging()
boolean
isFredNeeded()
boolean
isLoadNameAccepted(java.lang.String load)
Determine if train will service a specific load name.boolean
isLoadNameAccepted(java.lang.String load, java.lang.String type)
Determine if train will service a specific load and car type.boolean
isLocalSwitcher()
Used to determine if train is a local switcher serving one location.boolean
isLocationSkipped(java.lang.String locationId)
Determines if this train skips a location (doesn't service the location).boolean
isLocoRoadNameAccepted(java.lang.String road)
Determine if train will service a specific road name for an engine.boolean
isModified()
boolean
isOnlyPassengerCars()
Used to determine if train is carrying only passenger cars.boolean
isOwnerNameAccepted(java.lang.String owner)
Determine if train will service a specific owner name.boolean
isPrinted()
Used to determine if train manifest was printed.boolean
isSendCarsToTerminalEnabled()
boolean
isSendCarsWithCustomLoadsToStagingEnabled()
boolean
isServiceable(java.io.PrintWriter buildReport, Car car)
Note that this code was written after TrainBuilder.boolean
isServiceable(Car car)
Determines if this train will service this car.boolean
isServiceAllCarsWithFinalDestinationsEnabled()
boolean
isShowArrivalAndDepartureTimesEnabled()
boolean
isTrainEnRoute()
Used to determine if train has departed the first location in the train's routeboolean
isTurn()
boolean
isTypeNameAccepted(java.lang.String type)
Returns true if this train will service the type of car or engine.void
loadTrainIcon()
void
move()
Move train to next location in the route.boolean
move(java.lang.String locationName)
Move train to a location in the train's route.boolean
move(RouteLocation rl)
Moves the train to the specified route locationboolean
moveToNextLocation(java.lang.String locationName)
Move train to the next location in the train's route.protected void
moveTrainIcon(RouteLocation rl)
boolean
openFile()
boolean
printBuildReport()
boolean
printBuildReport(boolean isPreview)
boolean
printManifest(boolean isPreview)
Print manifest for train.boolean
printManifestIfBuilt()
Print manifest for train if already built.void
propertyChange(java.beans.PropertyChangeEvent e)
protected void
replaceModel(java.lang.String oldModel, java.lang.String newModel)
protected void
replaceOwner(java.lang.String oldName, java.lang.String newName)
protected void
replaceRoad(java.lang.String oldRoad, java.lang.String newRoad)
protected void
replaceType(java.lang.String oldType, java.lang.String newType)
boolean
reset()
Resets the train, removes engines and cars from this train.boolean
runFile()
void
setAllowLocalMovesEnabled(boolean enable)
void
setAllowReturnToStagingEnabled(boolean enable)
void
setAllowThroughCarsEnabled(boolean enable)
void
setBuildConsistEnabled(boolean enable)
void
setBuildEnabled(boolean build)
Control flag used to decide if this train is to be built.protected void
setBuildFailed(boolean status)
protected void
setBuildFailedMessage(java.lang.String message)
void
setBuildTrainNormalEnabled(boolean enable)
protected void
setBuilt(boolean built)
void
setBuiltEndYear(java.lang.String year)
Only rolling stock built in or before this year will be used.void
setBuiltStartYear(java.lang.String year)
Only rolling stock built in or after this year will be used.void
setCabooseRoad(java.lang.String road)
Set the road name of the caboose servicing this train.protected void
setCabooseRoadNames(java.lang.String[] roads)
void
setCabooseRoadOption(java.lang.String option)
Set how this train deals with caboose road names.protected void
setCarRoadNames(java.lang.String[] roads)
void
setCarRoadOption(java.lang.String option)
Set how this train deals with car road names.void
setComment(java.lang.String comment)
protected void
setCurrentLocation(RouteLocation location)
Set train's current route locationvoid
setDate(java.util.Date date)
void
setDepartureTime(java.lang.String hour, java.lang.String minute)
void
setDepartureTrack(Track track)
void
setDescription(java.lang.String description)
protected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setEngineModel(java.lang.String model)
Set the model name of engines servicing this train.void
setEngineRoad(java.lang.String road)
Set the road name of engines servicing this train.void
setLeadEngine(Engine engine)
protected void
setLoadNames(java.lang.String[] loads)
void
setLoadOption(java.lang.String option)
Set how this train deals with car loadsprotected void
setLocoRoadNames(java.lang.String[] roads)
void
setLocoRoadOption(java.lang.String option)
Set how this train deals with locomotive road names.void
setManifestLogoPathName(java.lang.String pathName)
Overrides the default logo for this train.void
setModified(boolean modified)
Set true whenever the train's manifest has been modified.void
setName(java.lang.String name)
Sets the name of this train, normally a short name that can fit within the train icon.void
setNumberCarsRequested(int number)
void
setNumberEngines(java.lang.String number)
protected void
setOldStatusCode(int code)
protected void
setOwnerNames(java.lang.String[] owners)
void
setOwnerOption(java.lang.String option)
Set how this train deals with car owner namesvoid
setPrinted(boolean printed)
void
setRailroadName(java.lang.String name)
Overrides the default railroad name for this train.void
setRequirements(int requires)
Set train requirements.void
setRoute(Route route)
void
setSecondLegCabooseRoad(java.lang.String road)
Set the road name of the second leg caboose servicing this train.void
setSecondLegEndRouteLocation(RouteLocation rl)
void
setSecondLegEngineModel(java.lang.String model)
Set the model name of engines servicing this train's 2nd leg.void
setSecondLegEngineRoad(java.lang.String road)
Set the road name of engines servicing this train 2nd leg.void
setSecondLegNumberEngines(java.lang.String number)
void
setSecondLegOptions(int options)
Optional changes to train while en route.void
setSecondLegStartRouteLocation(RouteLocation rl)
void
setSendCarsToTerminalEnabled(boolean enable)
void
setSendCarsWithCustomLoadsToStagingEnabled(boolean enable)
void
setServiceAllCarsWithFinalDestinationsEnabled(boolean enable)
protected void
setServiceStatus(java.lang.String status)
void
setShowArrivalAndDepartureTimes(boolean enable)
void
setStatusCode(int code)
Set the train's machine readable status.void
setSwitchListStatus(java.lang.String status)
Sets the print status for switch listsvoid
setTableRowColorName(java.lang.String colorName)
void
setTableRowColorNameReset(java.lang.String colorName)
void
setTerminationTrack(Track track)
void
setThirdLegCabooseRoad(java.lang.String road)
Set the road name of the third leg caboose servicing this train.void
setThirdLegEndRouteLocation(RouteLocation rl)
void
setThirdLegEngineModel(java.lang.String model)
Set the model name of engines servicing this train's 3rd leg.void
setThirdLegEngineRoad(java.lang.String road)
Set the road name of engines servicing this train 3rd leg.void
setThirdLegNumberEngines(java.lang.String number)
void
setThirdLegOptions(int options)
Optional changes to train while en route.void
setThirdLegStartRouteLocation(RouteLocation rl)
boolean
setTrainIconCoordinates()
Sets the panel position for the train icon for the current route location.protected void
setTrainSkipsLocations(java.lang.String[] locationIds)
protected void
setTypeNames(java.lang.String[] types)
Set the type of cars or engines this train will service, see types in Cars and Engines.org.jdom2.Element
store()
Create an XML element to represent this Entry.void
terminate()
Terminate train.java.lang.String
toString()
Get's a train's namevoid
updateTrainTableRowColor()
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
NONE
public static final java.lang.String NONE
- See Also:
- Constant Field Values
-
_id
protected java.lang.String _id
-
_name
protected java.lang.String _name
-
_description
protected java.lang.String _description
-
_current
protected RouteLocation _current
-
_buildFailedMessage
protected java.lang.String _buildFailedMessage
-
_built
protected boolean _built
-
_modified
protected boolean _modified
-
_build
protected boolean _build
-
_buildFailed
protected boolean _buildFailed
-
_printed
protected boolean _printed
-
_sendToTerminal
protected boolean _sendToTerminal
-
_allowLocalMoves
protected boolean _allowLocalMoves
-
_allowThroughCars
protected boolean _allowThroughCars
-
_buildNormal
protected boolean _buildNormal
-
_allowCarsReturnStaging
protected boolean _allowCarsReturnStaging
-
_serviceAllCarsWithFinalDestinations
protected boolean _serviceAllCarsWithFinalDestinations
-
_buildConsist
protected boolean _buildConsist
-
_sendCarsWithCustomLoadsToStaging
protected boolean _sendCarsWithCustomLoadsToStaging
-
_departureTrack
protected Track _departureTrack
-
_terminationTrack
protected Track _terminationTrack
-
_carRoadOption
protected java.lang.String _carRoadOption
-
_carRoadList
protected java.util.List<java.lang.String> _carRoadList
-
_cabooseRoadOption
protected java.lang.String _cabooseRoadOption
-
_cabooseRoadList
protected java.util.List<java.lang.String> _cabooseRoadList
-
_locoRoadOption
protected java.lang.String _locoRoadOption
-
_locoRoadList
protected java.util.List<java.lang.String> _locoRoadList
-
_requires
protected int _requires
-
_numberEngines
protected java.lang.String _numberEngines
-
_engineRoad
protected java.lang.String _engineRoad
-
_engineModel
protected java.lang.String _engineModel
-
_cabooseRoad
protected java.lang.String _cabooseRoad
-
_departureTime
protected java.lang.String _departureTime
-
_leadEngineId
protected java.lang.String _leadEngineId
-
_builtStartYear
protected java.lang.String _builtStartYear
-
_builtEndYear
protected java.lang.String _builtEndYear
-
_loadOption
protected java.lang.String _loadOption
-
_ownerOption
protected java.lang.String _ownerOption
-
_buildScripts
protected java.util.List<java.lang.String> _buildScripts
-
_afterBuildScripts
protected java.util.List<java.lang.String> _afterBuildScripts
-
_moveScripts
protected java.util.List<java.lang.String> _moveScripts
-
_terminationScripts
protected java.util.List<java.lang.String> _terminationScripts
-
_railroadName
protected java.lang.String _railroadName
-
_logoPathName
protected java.lang.String _logoPathName
-
_showTimes
protected boolean _showTimes
-
_leadEngine
protected Engine _leadEngine
-
_switchListStatus
protected java.lang.String _switchListStatus
-
_comment
protected java.lang.String _comment
-
_serviceStatus
protected java.lang.String _serviceStatus
-
_statusCode
protected int _statusCode
-
_oldStatusCode
protected int _oldStatusCode
-
_date
protected java.util.Date _date
-
_statusCarsRequested
protected int _statusCarsRequested
-
_tableRowColorName
protected java.lang.String _tableRowColorName
-
_tableRowColorResetName
protected java.lang.String _tableRowColorResetName
-
_leg2Options
protected int _leg2Options
-
_leg2Start
protected RouteLocation _leg2Start
-
_end2Leg
protected RouteLocation _end2Leg
-
_leg2Engines
protected java.lang.String _leg2Engines
-
_leg2Road
protected java.lang.String _leg2Road
-
_leg2Model
protected java.lang.String _leg2Model
-
_leg2CabooseRoad
protected java.lang.String _leg2CabooseRoad
-
_leg3Options
protected int _leg3Options
-
_leg3Start
protected RouteLocation _leg3Start
-
_leg3End
protected RouteLocation _leg3End
-
_leg3Engines
protected java.lang.String _leg3Engines
-
_leg3Road
protected java.lang.String _leg3Road
-
_leg3Model
protected java.lang.String _leg3Model
-
_leg3CabooseRoad
protected java.lang.String _leg3CabooseRoad
-
CHANGE_ENGINES
public static final int CHANGE_ENGINES
- See Also:
- Constant Field Values
-
HELPER_ENGINES
public static final int HELPER_ENGINES
- See Also:
- Constant Field Values
-
ADD_CABOOSE
public static final int ADD_CABOOSE
- See Also:
- Constant Field Values
-
REMOVE_CABOOSE
public static final int REMOVE_CABOOSE
- See Also:
- Constant Field Values
-
ADD_ENGINES
public static final int ADD_ENGINES
- See Also:
- Constant Field Values
-
REMOVE_ENGINES
public static final int REMOVE_ENGINES
- See Also:
- Constant Field Values
-
DISPOSE_CHANGED_PROPERTY
public static final java.lang.String DISPOSE_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
STOPS_CHANGED_PROPERTY
public static final java.lang.String STOPS_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TYPES_CHANGED_PROPERTY
public static final java.lang.String TYPES_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
BUILT_CHANGED_PROPERTY
public static final java.lang.String BUILT_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
BUILT_YEAR_CHANGED_PROPERTY
public static final java.lang.String BUILT_YEAR_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
BUILD_CHANGED_PROPERTY
public static final java.lang.String BUILD_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
ROADS_CHANGED_PROPERTY
public static final java.lang.String ROADS_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
LOADS_CHANGED_PROPERTY
public static final java.lang.String LOADS_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
OWNERS_CHANGED_PROPERTY
public static final java.lang.String OWNERS_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
NAME_CHANGED_PROPERTY
public static final java.lang.String NAME_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
DESCRIPTION_CHANGED_PROPERTY
public static final java.lang.String DESCRIPTION_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
STATUS_CHANGED_PROPERTY
public static final java.lang.String STATUS_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
DEPARTURETIME_CHANGED_PROPERTY
public static final java.lang.String DEPARTURETIME_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_LOCATION_CHANGED_PROPERTY
public static final java.lang.String TRAIN_LOCATION_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_ROUTE_CHANGED_PROPERTY
public static final java.lang.String TRAIN_ROUTE_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_REQUIREMENTS_CHANGED_PROPERTY
public static final java.lang.String TRAIN_REQUIREMENTS_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY
public static final java.lang.String TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_ROW_COLOR_CHANGED_PROPERTY
public static final java.lang.String TRAIN_ROW_COLOR_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_ROW_COLOR_RESET_CHANGED_PROPERTY
public static final java.lang.String TRAIN_ROW_COLOR_RESET_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_MODIFIED_CHANGED_PROPERTY
public static final java.lang.String TRAIN_MODIFIED_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
TRAIN_RESET
public static final java.lang.String TRAIN_RESET
-
RUN_SCRIPTS
public static final java.lang.String RUN_SCRIPTS
-
BUILDING
public static final java.lang.String BUILDING
-
BUILD_FAILED
public static final java.lang.String BUILD_FAILED
-
BUILT
public static final java.lang.String BUILT
-
PARTIAL_BUILT
public static final java.lang.String PARTIAL_BUILT
-
TRAIN_EN_ROUTE
public static final java.lang.String TRAIN_EN_ROUTE
-
TERMINATED
public static final java.lang.String TERMINATED
-
MANIFEST_MODIFIED
public static final java.lang.String MANIFEST_MODIFIED
-
CODE_TRAIN_RESET
public static final int CODE_TRAIN_RESET
- See Also:
- Constant Field Values
-
CODE_RUN_SCRIPTS
public static final int CODE_RUN_SCRIPTS
- See Also:
- Constant Field Values
-
CODE_BUILDING
public static final int CODE_BUILDING
- See Also:
- Constant Field Values
-
CODE_BUILD_FAILED
public static final int CODE_BUILD_FAILED
- See Also:
- Constant Field Values
-
CODE_BUILT
public static final int CODE_BUILT
- See Also:
- Constant Field Values
-
CODE_PARTIAL_BUILT
public static final int CODE_PARTIAL_BUILT
- See Also:
- Constant Field Values
-
CODE_TRAIN_EN_ROUTE
public static final int CODE_TRAIN_EN_ROUTE
- See Also:
- Constant Field Values
-
CODE_TERMINATED
public static final int CODE_TERMINATED
- See Also:
- Constant Field Values
-
CODE_MANIFEST_MODIFIED
public static final int CODE_MANIFEST_MODIFIED
- See Also:
- Constant Field Values
-
CODE_UNKNOWN
public static final int CODE_UNKNOWN
- See Also:
- Constant Field Values
-
NO_CABOOSE_OR_FRED
public static final int NO_CABOOSE_OR_FRED
- See Also:
- Constant Field Values
-
CABOOSE
public static final int CABOOSE
- See Also:
- Constant Field Values
-
FRED
public static final int FRED
- See Also:
- Constant Field Values
-
ALL_ROADS
public static final java.lang.String ALL_ROADS
-
INCLUDE_ROADS
public static final java.lang.String INCLUDE_ROADS
-
EXCLUDE_ROADS
public static final java.lang.String EXCLUDE_ROADS
-
ALL_OWNERS
public static final java.lang.String ALL_OWNERS
-
INCLUDE_OWNERS
public static final java.lang.String INCLUDE_OWNERS
-
EXCLUDE_OWNERS
public static final java.lang.String EXCLUDE_OWNERS
-
ALL_LOADS
public static final java.lang.String ALL_LOADS
-
INCLUDE_LOADS
public static final java.lang.String INCLUDE_LOADS
-
EXCLUDE_LOADS
public static final java.lang.String EXCLUDE_LOADS
-
UNKNOWN
public static final java.lang.String UNKNOWN
- See Also:
- Constant Field Values
-
PRINTED
public static final java.lang.String PRINTED
-
AUTO
public static final java.lang.String AUTO
-
AUTO_HPT
public static final java.lang.String AUTO_HPT
-
ALREADY_SERVICED
public static final java.lang.String ALREADY_SERVICED
- See Also:
- Constant Field Values
-
_skipLocationsList
java.util.List<java.lang.String> _skipLocationsList
-
_typeList
java.util.List<java.lang.String> _typeList
-
_loadList
java.util.List<java.lang.String> _loadList
-
_ownerList
java.util.List<java.lang.String> _ownerList
-
SEVEN
protected static final java.lang.String SEVEN
- See Also:
- Constant Field Values
-
_trainIcon
protected TrainIcon _trainIcon
-
-
Method Detail
-
getId
public java.lang.String getId()
Description copied from interface:Identifiable
Get the identity of the object.- Specified by:
getId
in interfaceIdentifiable
- 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 classjava.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
-
setTableRowColorName
public void setTableRowColorName(java.lang.String colorName)
-
getTableRowColorNameReset
public java.lang.String getTableRowColorNameReset()
- Returns:
- The name of the train row color when the train is reset
-
setTableRowColorNameReset
public void setTableRowColorNameReset(java.lang.String colorName)
-
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)
-
getDepartureTimeHour
public java.lang.String getDepartureTimeHour()
-
getDepartureTimeMinute
public java.lang.String getDepartureTimeMinute()
-
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)
-
getExpectedDepartureTime
public java.lang.String getExpectedDepartureTime(RouteLocation routeLocation)
-
getWorkTimeAtLocation
public int getWorkTimeAtLocation(RouteLocation routeLocation)
-
getExpectedTravelTimeInMinutes
public int getExpectedTravelTimeInMinutes(RouteLocation routeLocation)
-
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
-
isCabooseNeeded
public boolean isCabooseNeeded()
-
isFredNeeded
public boolean isFredNeeded()
-
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
-
getTrainDepartsRouteLocation
public RouteLocation getTrainDepartsRouteLocation()
-
getTrainDepartsDirection
public java.lang.String getTrainDepartsDirection()
-
getTrainTerminatesName
public java.lang.String getTrainTerminatesName()
Get train's final location's name- Returns:
- train's final location's name
-
getTrainTerminatesRouteLocation
public RouteLocation getTrainTerminatesRouteLocation()
-
getTrainBlockingOrder
public java.util.List<RouteLocation> getTrainBlockingOrder()
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
-
getCurrentRouteLocation
public RouteLocation getCurrentRouteLocation()
Get train's current route location- Returns:
- Train's current route location
-
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.
-
getNextRouteLocation
public RouteLocation getNextRouteLocation(RouteLocation currentRouteLocation)
-
setDepartureTrack
public void setDepartureTrack(Track track)
-
getDepartureTrack
public Track getDepartureTrack()
-
isDepartingStaging
public boolean isDepartingStaging()
-
setTerminationTrack
public void setTerminationTrack(Track track)
-
getTerminationTrack
public Track getTerminationTrack()
-
setStatusCode
public void setStatusCode(int code)
Set the train's machine readable status. Calls update train table row color.- Parameters:
code
- machine readable
-
updateTrainTableRowColor
public void updateTrainTableRowColor()
-
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
-
getMRStatus
public java.lang.String getMRStatus()
-
getStatusCode
public int getStatusCode()
-
setOldStatusCode
protected void setOldStatusCode(int code)
-
getOldStatusCode
protected int getOldStatusCode()
-
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.
-
getTrainSkipsLocations
protected java.lang.String[] getTrainSkipsLocations()
-
setTrainSkipsLocations
protected void setTrainSkipsLocations(java.lang.String[] locationIds)
-
addTrainSkipsLocation
public void addTrainSkipsLocation(java.lang.String routelocationId)
Train will skip the RouteLocation- Parameters:
routelocationId
- RouteLocation Id
-
deleteTrainSkipsLocation
public void deleteTrainSkipsLocation(java.lang.String locationId)
-
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
-
getCarTypeNames
public java.lang.String[] getCarTypeNames()
-
getLocoTypeNames
public java.lang.String[] getLocoTypeNames()
-
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
-
setCabooseRoadNames
protected void setCabooseRoadNames(java.lang.String[] 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.
-
getOwnerOption
public java.lang.String getOwnerOption()
-
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.
-
getBuiltStartYear
public java.lang.String getBuiltStartYear()
-
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.
-
getBuiltEndYear
public java.lang.String getBuiltEndYear()
-
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
- PrintWritercar
- 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
-
setNumberCarsRequested
public void setNumberCarsRequested(int number)
-
getNumberCarsRequested
public int getNumberCarsRequested()
-
setDate
public void setDate(java.util.Date date)
-
getSortDate
public java.lang.String getSortDate()
-
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.
-
getNumberLoadedCarsInTrain
public int getNumberLoadedCarsInTrain(RouteLocation routeLocation)
-
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.
-
getTrainWeight
public int getTrainWeight(RouteLocation routeLocation)
-
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)
-
getRawDescription
public java.lang.String getRawDescription()
-
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.
-
setNumberEngines
public void setNumberEngines(java.lang.String number)
-
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
-
setSecondLegNumberEngines
public void setSecondLegNumberEngines(java.lang.String number)
-
getThirdLegNumberEngines
public java.lang.String getThirdLegNumberEngines()
Get the number of engines needed for the third set.- Returns:
- The number of engines needed in route
-
setThirdLegNumberEngines
public void setThirdLegNumberEngines(java.lang.String number)
-
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.
-
getEngineModel
public java.lang.String getEngineModel()
-
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.
-
getSecondLegEngineModel
public java.lang.String getSecondLegEngineModel()
-
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.
-
getThirdLegEngineModel
public java.lang.String getThirdLegEngineModel()
-
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.
-
getCabooseRoad
public java.lang.String getCabooseRoad()
-
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.
-
getSecondLegCabooseRoad
public java.lang.String getSecondLegCabooseRoad()
-
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.
-
getThirdLegCabooseRoad
public java.lang.String getThirdLegCabooseRoad()
-
setSecondLegStartRouteLocation
public void setSecondLegStartRouteLocation(RouteLocation rl)
-
getSecondLegStartRouteLocation
public RouteLocation getSecondLegStartRouteLocation()
-
getSecondLegStartLocationName
public java.lang.String getSecondLegStartLocationName()
-
setThirdLegStartRouteLocation
public void setThirdLegStartRouteLocation(RouteLocation rl)
-
getThirdLegStartRouteLocation
public RouteLocation getThirdLegStartRouteLocation()
-
getThirdLegStartLocationName
public java.lang.String getThirdLegStartLocationName()
-
setSecondLegEndRouteLocation
public void setSecondLegEndRouteLocation(RouteLocation rl)
-
getSecondLegEndLocationName
public java.lang.String getSecondLegEndLocationName()
-
getSecondLegEndRouteLocation
public RouteLocation getSecondLegEndRouteLocation()
-
setThirdLegEndRouteLocation
public void setThirdLegEndRouteLocation(RouteLocation rl)
-
getThirdLegEndRouteLocation
public RouteLocation getThirdLegEndRouteLocation()
-
getThirdLegEndLocationName
public java.lang.String getThirdLegEndLocationName()
-
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
-
getSecondLegOptions
public int getSecondLegOptions()
-
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
-
getThirdLegOptions
public int getThirdLegOptions()
-
setComment
public void setComment(java.lang.String comment)
-
getComment
public java.lang.String getComment()
-
getCommentWithColor
public java.lang.String getCommentWithColor()
-
addBuildScript
public void addBuildScript(java.lang.String pathname)
Add a script to run before a train is built- Parameters:
pathname
- The script's pathname
-
deleteBuildScript
public void deleteBuildScript(java.lang.String 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
-
deleteAfterBuildScript
public void deleteAfterBuildScript(java.lang.String 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
-
deleteTerminationScript
public void deleteTerminationScript(java.lang.String 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.
-
getManifestLogoPathName
public java.lang.String getManifestLogoPathName()
-
setManifestLogoPathName
public void setManifestLogoPathName(java.lang.String pathName)
Overrides the default logo for this train.- Parameters:
pathName
- file location for the logo.
-
isShowArrivalAndDepartureTimesEnabled
public boolean isShowArrivalAndDepartureTimesEnabled()
-
setShowArrivalAndDepartureTimes
public void setShowArrivalAndDepartureTimes(boolean enable)
-
isSendCarsToTerminalEnabled
public boolean isSendCarsToTerminalEnabled()
-
setSendCarsToTerminalEnabled
public void setSendCarsToTerminalEnabled(boolean enable)
-
isAllowLocalMovesEnabled
public boolean isAllowLocalMovesEnabled()
Allow local moves if car has a custom load or Final Destination- Returns:
- true if local move is allowed
-
setAllowLocalMovesEnabled
public void setAllowLocalMovesEnabled(boolean enable)
-
isAllowThroughCarsEnabled
public boolean isAllowThroughCarsEnabled()
-
setAllowThroughCarsEnabled
public void setAllowThroughCarsEnabled(boolean enable)
-
isBuildTrainNormalEnabled
public boolean isBuildTrainNormalEnabled()
-
setBuildTrainNormalEnabled
public void setBuildTrainNormalEnabled(boolean enable)
-
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
-
setAllowReturnToStagingEnabled
public void setAllowReturnToStagingEnabled(boolean enable)
-
isServiceAllCarsWithFinalDestinationsEnabled
public boolean isServiceAllCarsWithFinalDestinationsEnabled()
-
setServiceAllCarsWithFinalDestinationsEnabled
public void setServiceAllCarsWithFinalDestinationsEnabled(boolean enable)
-
isBuildConsistEnabled
public boolean isBuildConsistEnabled()
-
setBuildConsistEnabled
public void setBuildConsistEnabled(boolean enable)
-
isSendCarsWithCustomLoadsToStagingEnabled
public boolean isSendCarsWithCustomLoadsToStagingEnabled()
-
setSendCarsWithCustomLoadsToStagingEnabled
public void setSendCarsWithCustomLoadsToStagingEnabled(boolean enable)
-
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.
-
isModified
public boolean isModified()
-
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.
-
printBuildReport
public boolean printBuildReport()
-
printBuildReport
public boolean printBuildReport(boolean isPreview)
-
setBuildFailed
protected void setBuildFailed(boolean status)
-
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.
-
setBuildFailedMessage
protected void setBuildFailedMessage(java.lang.String message)
-
getBuildFailedMessage
protected java.lang.String getBuildFailedMessage()
-
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
-
openFile
public boolean openFile()
-
runFile
public boolean runFile()
-
createCsvManifestFile
public java.io.File createCsvManifestFile()
-
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.
-
loadTrainIcon
public void loadTrainIcon()
-
moveTrainIcon
protected void moveTrainIcon(RouteLocation rl)
-
getIconName
public java.lang.String getIconName()
-
getLeadEngineNumber
public java.lang.String getLeadEngineNumber()
-
getLeadEngineRoadName
public java.lang.String getLeadEngineRoadName()
-
getLeadEngineRoadAndNumber
public java.lang.String getLeadEngineRoadAndNumber()
-
getLeadEngineDccAddress
public java.lang.String getLeadEngineDccAddress()
-
getLeadEngine
public Engine getLeadEngine()
Gets the lead engine, will create it if the program has been restarted- Returns:
- lead engine for this train
-
setLeadEngine
public void setLeadEngine(Engine engine)
-
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
-
getTrainIcon
public TrainIcon getTrainIcon()
-
createTrainIcon
public void createTrainIcon(RouteLocation rl)
-
setSwitchListStatus
public void setSwitchListStatus(java.lang.String status)
Sets the print status for switch lists- Parameters:
status
- UNKNOWN PRINTED
-
getSwitchListStatus
public java.lang.String getSwitchListStatus()
-
reset
public boolean reset()
Resets the train, removes engines and cars from this train.- Returns:
- true if reset successful
-
dispose
public void dispose()
-
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 interfacejava.beans.PropertyChangeListener
-
setDirtyAndFirePropertyChange
protected void setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
-
-