jmri.jmrit.operations.rollingstock.cars
Class CarManager

java.lang.Object
  extended by jmri.jmrit.operations.rollingstock.RollingStockManager
      extended by jmri.jmrit.operations.rollingstock.cars.CarManager

public class CarManager
extends RollingStockManager

Manages the cars.

Author:
Daniel Boudreau Copyright (C) 2008

Field Summary
protected  Hashtable<String,Kernel> _kernelHashTable
           
static String KERNELLISTLENGTH_CHANGED_PROPERTY
           
 
Fields inherited from class jmri.jmrit.operations.rollingstock.RollingStockManager
_hashTable, BY_BUILT, BY_COLOR, BY_DESTINATION, BY_LOCATION, BY_MOVES, BY_NUMBER, BY_OWNER, BY_RFID, BY_ROAD, BY_TRAIN, BY_TYPE, BY_VALUE, LISTLENGTH_CHANGED_PROPERTY
 
Constructor Summary
CarManager()
           
 
Method Summary
 void deleteKernel(String name)
          Delete a Kernel by name
 List<String> getByFinalDestinationList()
           
 Car getById(String id)
          Get rolling stock by id
 List<String> getByKernelList()
          Sort by car kernel names
 List<String> getByLoadList()
          Sort by car loads
 List<String> getByLocationList()
          Sort by rolling stock location
 Car getByRoadAndNumber(String road, String number)
          Get Car by road and number
 List<String> getByRweList()
          Sort by car return when empty location and track
 List<String> getByTrainDestinationList(Train train)
          Get a list of Cars assigned to a train sorted by destination.
 Car getByTypeAndRoad(String type, String road)
          Get a Car by type and road.
 List<String> getCabooseRoadNames()
          Get a list of car road names where the car was flagged as a caboose.
 int[] getCarsFrameTableColumnWidths()
           
 List<String> getCarsLocationUnknown()
           
 List<String> getFredRoadNames()
          Get a list of car road names where the car was flagged with FRED
 Kernel getKernelByName(String name)
          Get a Kernel by name
 JComboBox getKernelComboBox()
          Get a comboBox loaded with current Kernel names
 List<String> getKernelNameList()
          Get a list of kernel names
protected  Object getRsAttribute(RollingStock rs, int attribute)
           
static CarManager instance()
           
 Car newCar(String road, String number)
          Finds an existing Car or creates a new Car if needed requires car's road and number
 Kernel newKernel(String name)
          Create a new Kernel
 void options(Element values)
           
 void replaceLoad(String type, String oldLoadName, String newLoadName)
          Replace car loads
 void setCarsFrameTableColumnWidths(int[] tableColumnWidths)
           
 Element store()
          Create an XML element to represent this Entry.
 void updateKernelComboBox(JComboBox box)
          Update an existing comboBox with the current kernel names
 
Methods inherited from class jmri.jmrit.operations.rollingstock.RollingStockManager
addPropertyChangeListener, deleteAll, deregister, dispose, firePropertyChange, getAvailableTrainList, getByBuiltList, getByColorList, getByDestinationList, getByIdList, getByList, getByMovesList, getByNumberList, getByOwnerList, getByRfid, getByRfidList, getByRoadNameList, getByTrainList, getByTrainList, getByTypeList, getByTypeList, getByValueList, getNumEntries, register, removePropertyChangeListener, sortList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_kernelHashTable

protected Hashtable<String,Kernel> _kernelHashTable

KERNELLISTLENGTH_CHANGED_PROPERTY

public static final String KERNELLISTLENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values
Constructor Detail

CarManager

public CarManager()
Method Detail

instance

public static CarManager instance()

newCar

public Car newCar(String road,
                  String number)
Finds an existing Car or creates a new Car if needed requires car's road and number

Parameters:
road - car road
number - car number
Returns:
new car or existing Car

getById

public Car getById(String id)
Description copied from class: RollingStockManager
Get rolling stock by id

Overrides:
getById in class RollingStockManager
Returns:
requested Car object or null if none exists

getByRoadAndNumber

public Car getByRoadAndNumber(String road,
                              String number)
Get Car by road and number

Overrides:
getByRoadAndNumber in class RollingStockManager
Parameters:
road - Car road
number - Car number
Returns:
requested Car object or null if none exists

getByTypeAndRoad

public Car getByTypeAndRoad(String type,
                            String road)
Get a Car by type and road. Used to test that a car with a specific type and road exists.

Overrides:
getByTypeAndRoad in class RollingStockManager
Parameters:
type - car type.
road - car road.
Returns:
the first car found with the specified type and road.

newKernel

public Kernel newKernel(String name)
Create a new Kernel

Parameters:
name -
Returns:
Kernel

deleteKernel

public void deleteKernel(String name)
Delete a Kernel by name

Parameters:
name -

getKernelByName

public Kernel getKernelByName(String name)
Get a Kernel by name

Parameters:
name -
Returns:
named Kernel

getKernelComboBox

public JComboBox getKernelComboBox()
Get a comboBox loaded with current Kernel names

Returns:
comboBox with Kernel names.

updateKernelComboBox

public void updateKernelComboBox(JComboBox box)
Update an existing comboBox with the current kernel names

Parameters:
box - comboBox requesting update

getKernelNameList

public List<String> getKernelNameList()
Get a list of kernel names

Returns:
ordered list of kernel names

getByLocationList

public List<String> getByLocationList()
Sort by rolling stock location

Overrides:
getByLocationList in class RollingStockManager
Returns:
list of RollingStock ids ordered by RollingStock location

getByKernelList

public List<String> getByKernelList()
Sort by car kernel names

Returns:
list of car ids ordered by car kernel

getByLoadList

public List<String> getByLoadList()
Sort by car loads

Returns:
list of car ids ordered by car loads

getByRweList

public List<String> getByRweList()
Sort by car return when empty location and track

Returns:
list of RollingStock ids ordered by car return when empty

getByFinalDestinationList

public List<String> getByFinalDestinationList()

getRsAttribute

protected Object getRsAttribute(RollingStock rs,
                                int attribute)
Overrides:
getRsAttribute in class RollingStockManager

getByTrainDestinationList

public List<String> getByTrainDestinationList(Train train)
Get a list of Cars assigned to a train sorted by destination. Passenger cars will be placed at the end of the list. Caboose or car with FRED will be the last car(s) in the list

Parameters:
train -
Returns:
Ordered list of Car ids assigned to the train

getCabooseRoadNames

public List<String> getCabooseRoadNames()
Get a list of car road names where the car was flagged as a caboose.

Returns:
List of caboose road names.

getFredRoadNames

public List<String> getFredRoadNames()
Get a list of car road names where the car was flagged with FRED

Returns:
List of road names of cars with FREDs

replaceLoad

public void replaceLoad(String type,
                        String oldLoadName,
                        String newLoadName)
Replace car loads

Parameters:
type - type of car
oldLoadName - old load name
newLoadName - new load name

getCarsLocationUnknown

public List<String> getCarsLocationUnknown()

getCarsFrameTableColumnWidths

public int[] getCarsFrameTableColumnWidths()
Returns:
get an array of table column widths for the trains frame

setCarsFrameTableColumnWidths

public void setCarsFrameTableColumnWidths(int[] tableColumnWidths)

options

public void options(Element values)

store

public Element store()
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-locations.dtd.

Returns:
Contents in a JDOM Element


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads