Package jmri.jmrit.operations.routes
Class Route
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.routes.Route
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.util.EventListener,PropertyChangeFirer,PropertyChangeProvider
public class Route extends PropertyChangeSupport implements java.beans.PropertyChangeListener
Represents a route on the layout
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String_commentprotected java.lang.String_idprotected int_IdNumberprotected java.lang.String_nameprotected java.util.Hashtable<java.lang.String,RouteLocation>_routeHashTableprotected int_sequenceNumstatic java.lang.StringDISPOSEstatic intEASTstatic java.lang.StringERRORstatic java.lang.StringLISTCHANGE_CHANGED_PROPERTYstatic java.lang.StringNONEstatic intNORTHstatic java.lang.StringOKAYstatic java.lang.StringORPHANstatic java.lang.StringROUTE_BLOCKING_CHANGED_PROPERTYstatic java.lang.StringROUTE_NAME_CHANGED_PROPERTYstatic java.lang.StringROUTE_STATUS_CHANGED_PROPERTYstatic intSOUTHstatic intSTARTstatic java.lang.StringTRAIN_BUILTstatic intWEST-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RouteLocationaddLocation(Location location)Adds a location to the end of this routeRouteLocationaddLocation(Location location, int sequence)Add a location at a specific place (sequence) in the route Allowable sequence numbers are 1 to max size of route. 1 = start of route, or Route.STARTvoiddeleteLocation(RouteLocation rl)Delete a RouteLocationvoiddispose()RouteLocationgetBlockingLocationFrontOfTrain()RouteLocationgetBlockingLocationRearOfTrain()java.util.List<RouteLocation>getBlockingOrder()javax.swing.JComboBox<RouteLocation>getComboBox()java.lang.StringgetComment()RouteLocationgetDepartsRouteLocation()Get the first location in a routejava.lang.StringgetDepartureDirection()java.lang.StringgetId()RouteLocationgetLastLocationByName(java.lang.String name)Get location by name (gets last route location with name)java.util.List<RouteLocation>getLocationsBySequenceList()Get a list of RouteLocations sorted by route orderjava.lang.StringgetName()RouteLocationgetNextRouteLocation(RouteLocation rl)Gets the next route location in a routeRouteLocationgetRouteLocationById(java.lang.String id)Get a RouteLocation by idRouteLocationgetRouteLocationBySequenceNumber(int sequence)1st RouteLocation in a route starts at 1.intgetRouteMaximumTrainLength()Gets the longest train length specified in the route.intgetRouteMinimumTrainLength()Gets the shortest train length specified in the route.java.lang.StringgetStatus()Gets the status of the route: OKAY ORPHAN ERROR TRAIN_BUILTRouteLocationgetTerminatesRouteLocation()Get the last location in a routebooleanisLocationNameInRoute(java.lang.String name)Used to determine if a "similar" location name is in the route.voidmoveLocationDown(RouteLocation rl)Moves a RouteLocation later in the route.voidmoveLocationUp(RouteLocation rl)Places a RouteLocation earlier in the route.voidpropertyChange(java.beans.PropertyChangeEvent e)voidregister(RouteLocation rl)Remember a NamedBean Object created outside the manager.voidresetBlockingOrder()voidsetBlockingOrderDown(RouteLocation rl)voidsetBlockingOrderUp(RouteLocation rl)voidsetComment(java.lang.String comment)protected voidsetDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)voidsetName(java.lang.String name)intsize()org.jdom2.Elementstore()Create an XML element to represent this Entry.java.lang.StringtoString()voidupdateComboBox(javax.swing.JComboBox<RouteLocation> box)-
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
-
_comment
protected java.lang.String _comment
-
_routeHashTable
protected java.util.Hashtable<java.lang.String,RouteLocation> _routeHashTable
-
_IdNumber
protected int _IdNumber
-
_sequenceNum
protected int _sequenceNum
-
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
-
LISTCHANGE_CHANGED_PROPERTY
public static final java.lang.String LISTCHANGE_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
ROUTE_STATUS_CHANGED_PROPERTY
public static final java.lang.String ROUTE_STATUS_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
ROUTE_BLOCKING_CHANGED_PROPERTY
public static final java.lang.String ROUTE_BLOCKING_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
ROUTE_NAME_CHANGED_PROPERTY
public static final java.lang.String ROUTE_NAME_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
DISPOSE
public static final java.lang.String DISPOSE
- See Also:
- Constant Field Values
-
OKAY
public static final java.lang.String OKAY
-
TRAIN_BUILT
public static final java.lang.String TRAIN_BUILT
-
ORPHAN
public static final java.lang.String ORPHAN
-
ERROR
public static final java.lang.String ERROR
-
START
public static final int START
- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
public java.lang.String getId()
-
setName
public void setName(java.lang.String name)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getName
public java.lang.String getName()
-
setComment
public void setComment(java.lang.String comment)
-
getComment
public java.lang.String getComment()
-
dispose
public void dispose()
-
addLocation
public RouteLocation addLocation(Location location)
Adds a location to the end of this route- Parameters:
location- The Location.- Returns:
- RouteLocation created for the location added
-
addLocation
public RouteLocation addLocation(Location location, int sequence)
Add a location at a specific place (sequence) in the route Allowable sequence numbers are 1 to max size of route. 1 = start of route, or Route.START- Parameters:
location- The Location to add.sequence- Where in the route to add the location.- Returns:
- route location
-
register
public void register(RouteLocation rl)
Remember a NamedBean Object created outside the manager.- Parameters:
rl- The RouteLocation to add to this route.
-
deleteLocation
public void deleteLocation(RouteLocation rl)
Delete a RouteLocation- Parameters:
rl- The RouteLocation to remove from the route.
-
size
public int size()
-
getDepartsRouteLocation
public RouteLocation getDepartsRouteLocation()
Get the first location in a route- Returns:
- the first route location
-
getDepartureDirection
public java.lang.String getDepartureDirection()
-
getTerminatesRouteLocation
public RouteLocation getTerminatesRouteLocation()
Get the last location in a route- Returns:
- the last route location
-
getNextRouteLocation
public RouteLocation getNextRouteLocation(RouteLocation rl)
Gets the next route location in a route- Parameters:
rl- the current route location- Returns:
- the next route location, null if rl is the last location in a route.
-
getLastLocationByName
public RouteLocation getLastLocationByName(java.lang.String name)
Get location by name (gets last route location with name)- Parameters:
name- The string location name.- Returns:
- route location
-
isLocationNameInRoute
public boolean isLocationNameInRoute(java.lang.String name)
Used to determine if a "similar" location name is in the route. Note that a similar name might not actually be part of the route.- Parameters:
name- the name of the location- Returns:
- true if a "similar" name was found
-
getRouteLocationById
public RouteLocation getRouteLocationById(java.lang.String id)
Get a RouteLocation by id- Parameters:
id- The string id.- Returns:
- route location
-
getLocationsBySequenceList
public java.util.List<RouteLocation> getLocationsBySequenceList()
Get a list of RouteLocations sorted by route order- Returns:
- list of RouteLocations ordered by sequence
-
getBlockingOrder
public java.util.List<RouteLocation> getBlockingOrder()
-
getBlockingLocationFrontOfTrain
public RouteLocation getBlockingLocationFrontOfTrain()
-
getBlockingLocationRearOfTrain
public RouteLocation getBlockingLocationRearOfTrain()
-
setBlockingOrderUp
public void setBlockingOrderUp(RouteLocation rl)
-
setBlockingOrderDown
public void setBlockingOrderDown(RouteLocation rl)
-
resetBlockingOrder
public void resetBlockingOrder()
-
moveLocationUp
public void moveLocationUp(RouteLocation rl)
Places a RouteLocation earlier in the route.- Parameters:
rl- The RouteLocation to move.
-
moveLocationDown
public void moveLocationDown(RouteLocation rl)
Moves a RouteLocation later in the route.- Parameters:
rl- The RouteLocation to move.
-
getRouteLocationBySequenceNumber
public RouteLocation getRouteLocationBySequenceNumber(int sequence)
1st RouteLocation in a route starts at 1.- Parameters:
sequence- selects which RouteLocation is to be returned- Returns:
- RouteLocation selected
-
getStatus
public java.lang.String getStatus()
Gets the status of the route: OKAY ORPHAN ERROR TRAIN_BUILT- Returns:
- string with status of route.
-
getRouteMinimumTrainLength
public int getRouteMinimumTrainLength()
Gets the shortest train length specified in the route.- Returns:
- the minimum scale train length for this route.
-
getRouteMaximumTrainLength
public int getRouteMaximumTrainLength()
Gets the longest train length specified in the route.- Returns:
- the maximum scale train length for this route.
-
getComboBox
public javax.swing.JComboBox<RouteLocation> getComboBox()
-
updateComboBox
public void updateComboBox(javax.swing.JComboBox<RouteLocation> box)
-
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-config.xml.- Returns:
- Contents in a JDOM Element
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
setDirtyAndFirePropertyChange
protected void setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
-
-