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
_comment
protected java.lang.String
_id
protected int
_IdNumber
protected java.lang.String
_name
protected java.util.Hashtable<java.lang.String,RouteLocation>
_routeHashTable
protected int
_sequenceNum
static java.lang.String
DISPOSE
static int
EAST
static java.lang.String
ERROR
static java.lang.String
LISTCHANGE_CHANGED_PROPERTY
static java.lang.String
NONE
static int
NORTH
static java.lang.String
OKAY
static java.lang.String
ORPHAN
static java.lang.String
ROUTE_BLOCKING_CHANGED_PROPERTY
static java.lang.String
ROUTE_NAME_CHANGED_PROPERTY
static java.lang.String
ROUTE_STATUS_CHANGED_PROPERTY
static int
SOUTH
static int
START
static java.lang.String
TRAIN_BUILT
static int
WEST
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RouteLocation
addLocation(Location location)
Adds a location to the end of this routeRouteLocation
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.STARTvoid
deleteLocation(RouteLocation rl)
Delete a RouteLocationvoid
dispose()
java.util.List<RouteLocation>
getBlockingOrder()
javax.swing.JComboBox<RouteLocation>
getComboBox()
java.lang.String
getComment()
RouteLocation
getDepartsRouteLocation()
Get the first location in a routejava.lang.String
getDepartureDirection()
java.lang.String
getId()
RouteLocation
getLastLocationByName(java.lang.String name)
Get location by name (gets last route location with name)RouteLocation
getLocationById(java.lang.String id)
Get a RouteLocation by idjava.util.List<RouteLocation>
getLocationsBySequenceList()
Get a list of RouteLocations sorted by route orderjava.lang.String
getName()
RouteLocation
getNextRouteLocation(RouteLocation rl)
Gets the next route location in a routeRouteLocation
getRouteLocationBySequenceNumber(int sequence)
1st RouteLocation in a route starts at 1.int
getRouteMaximumTrainLength()
Gets the longest train length specified in the route.int
getRouteMinimumTrainLength()
Gets the shortest train length specified in the route.java.lang.String
getStatus()
Gets the status of the route: OKAY ORPHAN ERROR TRAIN_BUILTRouteLocation
getTerminatesRouteLocation()
Get the last location in a routeboolean
isLocationNameInRoute(java.lang.String name)
Used to determine if a "similar" location name is in the route.void
moveLocationDown(RouteLocation rl)
Moves a RouteLocation later in the route.void
moveLocationUp(RouteLocation rl)
Places a RouteLocation earlier in the route.void
propertyChange(java.beans.PropertyChangeEvent e)
void
register(RouteLocation rl)
Remember a NamedBean Object created outside the manager.void
resetBlockingOrder()
void
setBlockingOrderDown(RouteLocation rl)
void
setBlockingOrderUp(RouteLocation rl)
void
setComment(java.lang.String comment)
protected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setName(java.lang.String name)
int
size()
org.jdom2.Element
store()
Create an XML element to represent this Entry.java.lang.String
toString()
void
updateComboBox(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:
toString
in 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
-
getLocationById
public RouteLocation getLocationById(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()
-
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:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
setDirtyAndFirePropertyChange
protected void setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
-
-