jmri.jmrit.operations.locations
Class Location

java.lang.Object
  extended by jmri.jmrit.operations.locations.Location
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class Location
extends Object
implements PropertyChangeListener

Represents a location on the layout

Author:
Daniel Boudreau Copyright (C) 2008

Field Summary
protected  String _comment
           
protected  String _defaultPrinter
           
protected  int _dropRS
           
protected  String _id
           
protected  int _IdNumber
           
protected  int _idPoolNumber
           
protected  int _length
           
protected  int _locationOps
           
protected  String _name
           
protected  int _numberRS
           
protected  int _pickupRS
           
protected  Hashtable<String,Pool> _poolHashTable
           
protected  String _status
           
protected  boolean _switchList
           
protected  Hashtable<String,Track> _trackHashTable
           
protected  int _trainDir
           
protected  Point _trainIconEast
           
protected  Point _trainIconNorth
           
protected  Point _trainIconSouth
           
protected  Point _trainIconWest
           
protected  int _usedLength
           
static String CSV_GENERATED
           
static String DISPOSE_CHANGED_PROPERTY
           
static int EAST
           
static String LENGTH_CHANGED_PROPERTY
           
static String MODIFIED
           
static String NAME_CHANGED_PROPERTY
           
static int NORMAL
           
static int NORTH
           
static String POOL_LENGTH_CHANGED_PROPERTY
           
static String PRINTED
           
static int SOUTH
           
static int STAGING
           
static String STATUS_CHANGED_PROPERTY
           
static String SWITCHLIST_CHANGED_PROPERTY
           
static String TRACK_LISTLENGTH_CHANGED_PROPERTY
           
static String TRAINDIRECTION_CHANGED_PROPERTY
           
static String TYPES_CHANGED_PROPERTY
           
static String UNKNOWN
           
static String USEDLENGTH_CHANGED_PROPERTY
           
static int WEST
           
 
Constructor Summary
Location(Element e)
          Construct this Entry from XML.
Location(String id, String name)
           
 
Method Summary
 boolean acceptsTypeName(String type)
           
 void addDropRS()
          Increments the number of cars and or engines that will be dropped off by trains at this location.
 void addPickupRS()
          Increments the number of cars and or engines that will be picked up by a train at this location.
 Pool addPool(String name)
           
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void addRS(RollingStock rs)
          Adds rolling stock to a specific location.
 Track addTrack(String name, String type)
          Adds a track to this location.
 void addTypeName(String type)
          Adds the specific type of rolling stock to the will service list
 void deleteDropRS()
          Decrements the number of cars and or engines that will be dropped off by trains at this location.
 void deletePickupRS()
          Decrements the number of cars and or engines that will be picked up by a train at this location.
 void deleteRS(RollingStock rs)
           
 void deleteTrack(Track track)
           
 void deleteTypeName(String type)
           
 void dispose()
           
protected  void firePropertyChange(String p, Object old, Object n)
           
 String getComment()
           
 String getDefaultPrinterName()
           
 int getDropRS()
           
 String getId()
           
 int getLength()
           
 int getLocationOps()
           
 String getName()
           
 int getNumberRS()
          Gets the number of cars and engines at this location
 int getPickupRS()
           
 Pool getPoolByName(String name)
           
 List<Pool> getPoolsByNameList()
           
 String getStatus()
           
 boolean getSwitchList()
          Used to determine if switch list is needed for this location
 Track getTrackById(String id)
           
 Track getTrackByName(String name, String type)
          Get track location by name and type
 List<String> getTracksByMovesList(String type)
          Sort ids by track moves.
 List<String> getTracksByNameList(String type)
          Sort ids by track location name.
 int getTrainDirections()
           
 Point getTrainIconEast()
           
 Point getTrainIconNorth()
           
 Point getTrainIconSouth()
           
 Point getTrainIconWest()
           
 int getUsedLength()
           
 boolean hasPools()
           
 boolean isTrackAtLocation(Track track)
           
 void propertyChange(PropertyChangeEvent e)
           
 void register(Pool pool)
           
 void register(Track track)
          Remember a NamedBean Object created outside the manager.
 void removePool(Pool pool)
           
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void resetMoves()
          Reset the move count for all tracks at this location
 void setComment(String comment)
           
 void setDefaultPrinterName(String name)
           
 void setLength(int length)
          Set total length of all tracks for this location
 void setLocationOps(int ops)
          Set the operations mode for this location
 void setName(String name)
           
 void setNumberRS(int number)
          Sets the number of cars and or engines on for this location
 void setStatus()
          Automatically sets the print status for this location's switch list
 void setStatus(String status)
          Sets the print status for this location's switch list
 void setSwitchList(boolean switchList)
          When true, a switchlist is desired for this location.
 void setTrainDirections(int direction)
           
 void setTrainIconEast(Point point)
           
 void setTrainIconNorth(Point point)
           
 void setTrainIconSouth(Point point)
           
 void setTrainIconWest(Point point)
           
 void setUsedLength(int length)
           
 Element store()
          Create an XML element to represent this Entry.
 String toString()
           
 void updateComboBox(JComboBox box)
          Updates a JComboBox with all of the track locations for this location.
 void updateComboBox(JComboBox box, RollingStock rs, boolean filter, boolean destination)
          Updates a JComboBox with tracks that can service the rolling stock.
 void updatePoolComboBox(JComboBox box)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_id

protected String _id

_name

protected String _name

_IdNumber

protected int _IdNumber

_numberRS

protected int _numberRS

_pickupRS

protected int _pickupRS

_dropRS

protected int _dropRS

_locationOps

protected int _locationOps

_trainDir

protected int _trainDir

_length

protected int _length

_usedLength

protected int _usedLength

_comment

protected String _comment

_switchList

protected boolean _switchList

_defaultPrinter

protected String _defaultPrinter

_status

protected String _status

_trainIconEast

protected Point _trainIconEast

_trainIconWest

protected Point _trainIconWest

_trainIconNorth

protected Point _trainIconNorth

_trainIconSouth

protected Point _trainIconSouth

_trackHashTable

protected Hashtable<String,Track> _trackHashTable

_idPoolNumber

protected int _idPoolNumber

_poolHashTable

protected Hashtable<String,Pool> _poolHashTable

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

STAGING

public static final int STAGING
See Also:
Constant Field Values

EAST

public static final int EAST
See Also:
Constant Field Values

WEST

public static final int WEST
See Also:
Constant Field Values

NORTH

public static final int NORTH
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
See Also:
Constant Field Values

UNKNOWN

public static final String UNKNOWN
See Also:
Constant Field Values

PRINTED

public static final String PRINTED

CSV_GENERATED

public static final String CSV_GENERATED

MODIFIED

public static final String MODIFIED

TRACK_LISTLENGTH_CHANGED_PROPERTY

public static final String TRACK_LISTLENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

TYPES_CHANGED_PROPERTY

public static final String TYPES_CHANGED_PROPERTY
See Also:
Constant Field Values

TRAINDIRECTION_CHANGED_PROPERTY

public static final String TRAINDIRECTION_CHANGED_PROPERTY
See Also:
Constant Field Values

LENGTH_CHANGED_PROPERTY

public static final String LENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

USEDLENGTH_CHANGED_PROPERTY

public static final String USEDLENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

NAME_CHANGED_PROPERTY

public static final String NAME_CHANGED_PROPERTY
See Also:
Constant Field Values

SWITCHLIST_CHANGED_PROPERTY

public static final String SWITCHLIST_CHANGED_PROPERTY
See Also:
Constant Field Values

DISPOSE_CHANGED_PROPERTY

public static final String DISPOSE_CHANGED_PROPERTY
See Also:
Constant Field Values

STATUS_CHANGED_PROPERTY

public static final String STATUS_CHANGED_PROPERTY
See Also:
Constant Field Values

POOL_LENGTH_CHANGED_PROPERTY

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

Location

public Location(String id,
                String name)

Location

public Location(Element e)
Construct this Entry from XML. This member has to remain synchronized with the detailed DTD in operations-locations.dtd

Parameters:
e - Consist XML element
Method Detail

getId

public String getId()

setName

public void setName(String name)

toString

public String toString()
Overrides:
toString in class Object

getName

public String getName()

setLength

public void setLength(int length)
Set total length of all tracks for this location

Parameters:
length -

getLength

public int getLength()
Returns:
total length of all tracks for this location

setUsedLength

public void setUsedLength(int length)

getUsedLength

public int getUsedLength()
Returns:
The length of the track that is occupied by cars and engines

setLocationOps

public void setLocationOps(int ops)
Set the operations mode for this location

Parameters:
ops - NORMAL STAGING

getLocationOps

public int getLocationOps()

setTrainDirections

public void setTrainDirections(int direction)

getTrainDirections

public int getTrainDirections()

setNumberRS

public void setNumberRS(int number)
Sets the number of cars and or engines on for this location

Parameters:
number -

getNumberRS

public int getNumberRS()
Gets the number of cars and engines at this location

Returns:
number of cars at this location

setSwitchList

public void setSwitchList(boolean switchList)
When true, a switchlist is desired for this location. Used for preview and printing a manifest for a single location

Parameters:
switchList -

getSwitchList

public boolean getSwitchList()
Used to determine if switch list is needed for this location

Returns:
true if switch list needed

setDefaultPrinterName

public void setDefaultPrinterName(String name)

getDefaultPrinterName

public String getDefaultPrinterName()

setStatus

public void setStatus()
Automatically sets the print status for this location's switch list


setStatus

public void setStatus(String status)
Sets the print status for this location's switch list

Parameters:
status - UNKNOWN PRINTED MODIFIED

getStatus

public String getStatus()

setTrainIconEast

public void setTrainIconEast(Point point)

getTrainIconEast

public Point getTrainIconEast()

setTrainIconWest

public void setTrainIconWest(Point point)

getTrainIconWest

public Point getTrainIconWest()

setTrainIconNorth

public void setTrainIconNorth(Point point)

getTrainIconNorth

public Point getTrainIconNorth()

setTrainIconSouth

public void setTrainIconSouth(Point point)

getTrainIconSouth

public Point getTrainIconSouth()

addRS

public void addRS(RollingStock rs)
Adds rolling stock to a specific location.

Parameters:
rs -

deleteRS

public void deleteRS(RollingStock rs)

addPickupRS

public void addPickupRS()
Increments the number of cars and or engines that will be picked up by a train at this location.


deletePickupRS

public void deletePickupRS()
Decrements the number of cars and or engines that will be picked up by a train at this location.


addDropRS

public void addDropRS()
Increments the number of cars and or engines that will be dropped off by trains at this location.


deleteDropRS

public void deleteDropRS()
Decrements the number of cars and or engines that will be dropped off by trains at this location.


getPickupRS

public int getPickupRS()
Returns:
the number of cars and engines that are scheduled for pick up at this location.

getDropRS

public int getDropRS()
Returns:
the number of cars and engines that are scheduled for drop at this location.

setComment

public void setComment(String comment)

getComment

public String getComment()

addTypeName

public void addTypeName(String type)
Adds the specific type of rolling stock to the will service list

Parameters:
type - of rolling stock that location will service

deleteTypeName

public void deleteTypeName(String type)

acceptsTypeName

public boolean acceptsTypeName(String type)

addTrack

public Track addTrack(String name,
                      String type)
Adds a track to this location. Valid tracks are spurs, yards, staging and interchange tracks.

Parameters:
name - of track
type - of track
Returns:
Track

register

public void register(Track track)
Remember a NamedBean Object created outside the manager.


deleteTrack

public void deleteTrack(Track track)

getTrackByName

public Track getTrackByName(String name,
                            String type)
Get track location by name and type

Parameters:
name - track's name
type - track type
Returns:
track location

getTrackById

public Track getTrackById(String id)

getTracksByNameList

public List<String> getTracksByNameList(String type)
Sort ids by track location name. Returns a list of a given location type if type is not null, otherwise all track locations are returned.

Parameters:
type - track type: Track.YARD, Track.SIDING, Track.INTERCHANGE, Track.STAGING
Returns:
list of track location ids ordered by name

getTracksByMovesList

public List<String> getTracksByMovesList(String type)
Sort ids by track moves. Returns a list of a given track type if type is not null, otherwise all track locations are returned.

Parameters:
type - track type: Track.YARD, Track.SIDING, Track.INTERCHANGE, Track.STAGING
Returns:
list of track location ids ordered by moves

isTrackAtLocation

public boolean isTrackAtLocation(Track track)

resetMoves

public void resetMoves()
Reset the move count for all tracks at this location


updateComboBox

public void updateComboBox(JComboBox box)
Updates a JComboBox with all of the track locations for this location.

Parameters:
box - JComboBox to be updated.

updateComboBox

public void updateComboBox(JComboBox box,
                           RollingStock rs,
                           boolean filter,
                           boolean destination)
Updates a JComboBox with tracks that can service the rolling stock.

Parameters:
box - JComboBox to be updated.
rs - Rolling Stock to be serviced
filter - When true, remove tracks not able to service rs.
destination - When true, the tracks are destinations for the rs.

addPool

public Pool addPool(String name)

removePool

public void removePool(Pool pool)

getPoolByName

public Pool getPoolByName(String name)

register

public void register(Pool pool)

updatePoolComboBox

public void updatePoolComboBox(JComboBox box)

getPoolsByNameList

public List<Pool> getPoolsByNameList()

hasPools

public boolean hasPools()

dispose

public void dispose()

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

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)


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