Package jmri.implementation
Class AbstractSignalHead
java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.implementation.AbstractSignalHead
- All Implemented Interfaces:
VetoableChangeListener
,Comparable<NamedBean>
,EventListener
,PropertyChangeProvider
,NamedBean
,Signal
,SignalHead
- Direct Known Subclasses:
DccSignalHead
,DefaultSignalHead
public abstract class AbstractSignalHead extends AbstractNamedBean implements SignalHead, VetoableChangeListener
Abstract class providing the basic logic of the SignalHead interface.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
Field Summary
Fields Modifier and Type Field Description protected int
mAppearance
protected boolean
mHeld
By default, signals are not held.protected boolean
mLit
By default, signals are lit.Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
Fields inherited from interface jmri.SignalHead
DARK, FLASHGREEN, FLASHLUNAR, FLASHRED, FLASHYELLOW, GREEN, HELD, LUNAR, RED, YELLOW
-
Constructor Summary
Constructors Constructor Description AbstractSignalHead(String systemName)
AbstractSignalHead(String systemName, String userName)
-
Method Summary
Modifier and Type Method Description int
getAppearance()
Get the Signal Head Appearance.String
getAppearanceKey()
String
getAppearanceKey(int appearance)
String
getAppearanceName()
String
getAppearanceName(int appearance)
String
getBeanType()
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.static String
getDefaultStateName(int appearance)
Get a localized text describing appearance from the corresponding state index.static String[]
getDefaultValidStateNames()
static int[]
getDefaultValidStates()
boolean
getHeld()
"Held" parameter is just tracked and notified.boolean
getLit()
Default behavior for "lit" parameter is to track value and return it.int
getState()
Implement a shorter name for getAppearance.String[]
getValidStateKeys()
Get an array of non-localized appearance keys valid for the mast type.String[]
getValidStateNames()
Get an array of localized appearance descriptions valid for the mast type.int[]
getValidStates()
Get an array of appearance indexes valid for the mast type.boolean
isAtStop()
Determine whether this signal shows an aspect or appearance that forbid travel past it.boolean
isCleared()
Determine whether this signal shows an aspect or appearance that allows travel past it, e.g. it's "been cleared".boolean
isShowingRestricting()
Determine whether this signal shows an aspect or appearance that allows travel past it only at restricted speed.(package private) abstract boolean
isTurnoutUsed(Turnout t)
Check if a given turnout is used on this head.void
setState(int s)
Implement a shorter name for setAppearance.void
vetoableChange(PropertyChangeEvent evt)
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
mAppearance
-
mLit
By default, signals are lit. -
mHeld
By default, signals are not held.
-
-
Constructor Details
-
Method Details
-
getAppearanceName
- Specified by:
getAppearanceName
in interfaceSignalHead
-
getAppearanceName
- Specified by:
getAppearanceName
in interfaceSignalHead
-
getAppearanceKey
- Specified by:
getAppearanceKey
in interfaceSignalHead
-
getAppearanceKey
- Specified by:
getAppearanceKey
in interfaceSignalHead
-
getAppearance
Description copied from interface:SignalHead
Get the Signal Head Appearance. Changes in this value can be listened to using the Appearance property.- Specified by:
getAppearance
in interfaceSignalHead
- Returns:
- the appearance
-
isCleared
Determine whether this signal shows an aspect or appearance that allows travel past it, e.g. it's "been cleared". This might be a yellow or green appearance, or an Approach or Clear aspect -
isShowingRestricting
Determine whether this signal shows an aspect or appearance that allows travel past it only at restricted speed. This might be a flashing red appearance, or a Restricting aspect.- Specified by:
isShowingRestricting
in interfaceSignal
- Returns:
- true if the signal is showing a restricting indication; false otherwise
-
isAtStop
Determine whether this signal shows an aspect or appearance that forbid travel past it. This might be a red appearance, or a Stop aspect. Stop-and-Proceed or Restricting would return false here. -
getLit
Default behavior for "lit" parameter is to track value and return it.- Specified by:
getLit
in interfaceSignal
- Specified by:
getLit
in interfaceSignalHead
- Returns:
- is lit
-
getHeld
"Held" parameter is just tracked and notified.- Specified by:
getHeld
in interfaceSignal
- Specified by:
getHeld
in interfaceSignalHead
- Returns:
- is held
-
setState
Implement a shorter name for setAppearance.This generally shouldn't be used by Java code; use setAppearance instead. The is provided to make Jython script access easier to read.
-
getState
Implement a shorter name for getAppearance.This generally shouldn't be used by Java code; use getAppearance instead. The is provided to make Jython script access easier to read.
-
getDefaultValidStates
-
getDefaultValidStateNames
-
getDefaultStateName
Get a localized text describing appearance from the corresponding state index.- Parameters:
appearance
- the index of the appearance- Returns:
- translated name for appearance
-
getValidStates
Get an array of appearance indexes valid for the mast type.- Specified by:
getValidStates
in interfaceSignalHead
- Returns:
- array of appearance state values available on this mast type
-
getValidStateKeys
Get an array of non-localized appearance keys valid for the mast type. For GUI application consider using (capitalized)SignalHead.getValidStateNames()
- Specified by:
getValidStateKeys
in interfaceSignalHead
- Returns:
- array of translated appearance names available on this mast type
-
getValidStateNames
Get an array of localized appearance descriptions valid for the mast type. For persistance and comparison consider usingSignalHead.getValidStateKeys()
- Specified by:
getValidStateNames
in interfaceSignalHead
- Returns:
- array of translated appearance names
-
isTurnoutUsed
Check if a given turnout is used on this head.- Parameters:
t
- Turnout object to check- Returns:
- true if turnout is configured as output or driver of head
-
vetoableChange
- Specified by:
vetoableChange
in interfaceNamedBean
- Specified by:
vetoableChange
in interfaceVetoableChangeListener
- Overrides:
vetoableChange
in classAbstractNamedBean
- Throws:
PropertyVetoException
-
getBeanType
Description copied from interface:NamedBean
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-