Class TrainManager

    • Method Detail

      • getNumEntries

        public int getNumEntries()
        Get the number of items in the roster
        Returns:
        Number of trains in the roster
      • isBuildMessagesEnabled

        public boolean isBuildMessagesEnabled()
        Returns:
        true if build messages are enabled
      • isBuildReportEnabled

        public boolean isBuildReportEnabled()
        Returns:
        true if build reports are enabled
      • isOpenFileEnabled

        public boolean isOpenFileEnabled()
        Returns:
        true if open file is enabled
      • isRunFileEnabled

        public boolean isRunFileEnabled()
        Returns:
        true if open file is enabled
      • isPrintPreviewEnabled

        public boolean isPrintPreviewEnabled()
        Returns:
        true if print preview is enabled
      • isShowLocationHyphenNameEnabled

        public boolean isShowLocationHyphenNameEnabled()
        When true show entire location name including hyphen
        Returns:
        true when showing entire location name
      • addStartUpScript

        public void addStartUpScript​(java.lang.String pathname)
        Add a script to run after trains have been loaded
        Parameters:
        pathname - The script's pathname
      • getStartUpScripts

        public java.util.List<java.lang.String> getStartUpScripts()
        Gets a list of pathnames to run after trains have been loaded
        Returns:
        A list of pathnames to run after trains have been loaded
      • addShutDownScript

        public void addShutDownScript​(java.lang.String pathname)
        Add a script to run at shutdown
        Parameters:
        pathname - The script's pathname
      • getShutDownScripts

        public java.util.List<java.lang.String> getShutDownScripts()
        Gets a list of pathnames to run at shutdown
        Returns:
        A list of pathnames to run at shutdown
      • isBuiltRestricted

        public boolean isBuiltRestricted()
        Used to determine if a train has any restrictions with regard to car built dates.
        Returns:
        true if there's a restriction
      • isLoadRestricted

        public boolean isLoadRestricted()
        Used to determine if a train has any restrictions with regard to car loads.
        Returns:
        true if there's a restriction
      • isCarRoadRestricted

        public boolean isCarRoadRestricted()
        Used to determine if a train has any restrictions with regard to car roads.
        Returns:
        true if there's a restriction
      • isCabooseRoadRestricted

        public boolean isCabooseRoadRestricted()
        Used to determine if a train has any restrictions with regard to caboose roads.
        Returns:
        true if there's a restriction
      • isLocoRoadRestricted

        public boolean isLocoRoadRestricted()
        Used to determine if a train has any restrictions with regard to Locomotive roads.
        Returns:
        true if there's a restriction
      • isOwnerRestricted

        public boolean isOwnerRestricted()
        Used to determine if a train has any restrictions with regard to car owners.
        Returns:
        true if there's a restriction
      • getTrainByName

        public Train getTrainByName​(java.lang.String name)
        Parameters:
        name - The train's name.
        Returns:
        requested Train object or null if none exists
      • newTrain

        public Train newTrain​(java.lang.String name)
        Finds an existing train or creates a new train if needed. Requires train's name and creates a unique id for a new train
        Parameters:
        name - The train's name.
        Returns:
        new train or existing train
      • register

        public void register​(Train train)
        Remember a NamedBean Object created outside the manager.
        Parameters:
        train - The Train to be added.
      • deregister

        public void deregister​(Train train)
        Forget a NamedBean Object created outside the manager.
        Parameters:
        train - The Train to delete.
      • replaceLoad

        public void replaceLoad​(java.lang.String type,
                                java.lang.String oldLoadName,
                                java.lang.String newLoadName)
      • isAnyTrainBuilt

        public boolean isAnyTrainBuilt()
        Returns:
        true if there's a built train
      • isAnyTrainBuilding

        public boolean isAnyTrainBuilding()
        Returns:
        true if there's a train being built
      • getTrainForCar

        public Train getTrainForCar​(Car car,
                                    java.io.PrintWriter buildReport)
        Parameters:
        car - The car looking for a train.
        buildReport - The optional build report for logging.
        Returns:
        Train that can service car from its current location to the its destination.
      • getTrainForCar

        public Train getTrainForCar​(Car car,
                                    java.util.List<Train> excludeTrains,
                                    java.io.PrintWriter buildReport)
        Parameters:
        car - The car looking for a train.
        excludeTrains - The trains not to try.
        buildReport - The optional build report for logging.
        Returns:
        Train that can service car from its current location to the its destination.
      • getTrainsByNameList

        public java.util.List<TraingetTrainsByNameList()
        Sort by train name
        Returns:
        list of trains ordered by name
      • getTrainsByTimeList

        public java.util.List<TraingetTrainsByTimeList()
        Sort by train departure time
        Returns:
        list of trains ordered by departure time
      • getTrainsByDepartureList

        public java.util.List<TraingetTrainsByDepartureList()
        Sort by train departure location name
        Returns:
        list of trains ordered by departure name
      • getTrainsByTerminatesList

        public java.util.List<TraingetTrainsByTerminatesList()
        Sort by train termination location name
        Returns:
        list of trains ordered by termination name
      • getTrainsByRouteList

        public java.util.List<TraingetTrainsByRouteList()
        Sort by train route name
        Returns:
        list of trains ordered by route name
      • getTrainsByStatusList

        public java.util.List<TraingetTrainsByStatusList()
        Sort by train status
        Returns:
        list of trains ordered by status
      • getTrainsByDescriptionList

        public java.util.List<TraingetTrainsByDescriptionList()
        Sort by train description
        Returns:
        list of trains ordered by train description
      • getTrainsByIdList

        public java.util.List<TraingetTrainsByIdList()
        Sort by train id
        Returns:
        list of trains ordered by id
      • updateTrainComboBox

        public void updateTrainComboBox​(javax.swing.JComboBox<Train> box,
                                        Car car)
        Update combo box with trains that will service this car
        Parameters:
        box - the combo box to update
        car - the car to be serviced
      • getRowColorComboBox

        public javax.swing.JComboBox<java.lang.String> getRowColorComboBox()
        JColorChooser is not a replacement for getRowColorComboBox as it doesn't support no color as a selection.
        Returns:
        the available colors used highlighting table rows including no color.
      • copyTrain

        public Train copyTrain​(Train train,
                               java.lang.String trainName)
        Makes a copy of an existing train.
        Parameters:
        train - the train to copy
        trainName - the name of the new train
        Returns:
        a copy of train
      • getTrainsArrivingThisLocationList

        public java.util.List<TraingetTrainsArrivingThisLocationList​(Location location)
        Provides a list of trains ordered by arrival time to a location
        Parameters:
        location - The location
        Returns:
        A list of trains ordered by arrival time.
      • loadTrainIcons

        public void loadTrainIcons()
        Loads train icons if needed
      • setTrainsSwitchListStatus

        public void setTrainsSwitchListStatus​(java.lang.String status)
        Sets the switch list status for all built trains. Used for switch lists in consolidated mode.
        Parameters:
        status - Train.PRINTED, Train.UNKNOWN
      • setTrainsModified

        public void setTrainsModified()
        Sets all built trains manifests to modified. This causes the train's manifest to be recreated.
      • load

        public void load​(org.jdom2.Element root)
      • store

        public void store​(org.jdom2.Element root)
        Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-trains.dtd.
        Parameters:
        root - common Element for operations-trains.dtd.
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Not currently used.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener