Package jmri.implementation
Class AbstractSignalHead
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractSignalHead
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,NamedBean
,Signal
,SignalHead
- Direct Known Subclasses:
DccSignalHead
,DefaultSignalHead
public abstract class AbstractSignalHead extends AbstractNamedBean implements SignalHead, java.beans.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(java.lang.String systemName)
AbstractSignalHead(java.lang.String systemName, java.lang.String userName)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
getAppearance()
Get the Signal Head Appearance.java.lang.String
getAppearanceKey()
Get the current Signal Head Appearance Key.java.lang.String
getAppearanceKey(int appearance)
Get the Appearance Key for a particular Appearance.java.lang.String
getAppearanceName()
Get the current appearance name.java.lang.String
getAppearanceName(int appearance)
Get the Appearance Name for a particular Appearance.java.lang.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 java.lang.String
getDefaultStateName(int appearance)
Get a localized text describing appearance from the corresponding state index.static java.lang.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.java.lang.String[]
getValidStateKeys()
Get an array of non-localized appearance keys valid for the mast type.java.lang.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.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(java.beans.PropertyChangeEvent evt)
-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, 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, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.SignalHead
setAppearance, setHeld, setLit
-
-
-
-
Field Detail
-
mAppearance
protected int mAppearance
-
mLit
protected boolean mLit
By default, signals are lit.
-
mHeld
protected boolean mHeld
By default, signals are not held.
-
-
Constructor Detail
-
AbstractSignalHead
public AbstractSignalHead(java.lang.String systemName, java.lang.String userName)
-
AbstractSignalHead
public AbstractSignalHead(java.lang.String systemName)
-
-
Method Detail
-
getAppearanceName
@Nonnull public java.lang.String getAppearanceName(int appearance)
Get the Appearance Name for a particular Appearance.- Specified by:
getAppearanceName
in interfaceSignalHead
- Parameters:
appearance
- id for the Name.- Returns:
- the Appearance Name, or empty String if unknown.
-
getAppearanceName
@Nonnull public java.lang.String getAppearanceName()
Get the current appearance name.- Specified by:
getAppearanceName
in interfaceSignalHead
- Returns:
- Name of the Appearance, e.g. "Dark" or "Flashing Red"
-
getAppearanceKey
@Nonnull public java.lang.String getAppearanceKey(int appearance)
Get the Appearance Key for a particular Appearance.- Specified by:
getAppearanceKey
in interfaceSignalHead
- Parameters:
appearance
- id for the key, e.g. SignalHead.GREEN- Returns:
- the Appearance Key, e.g. "Green" or empty String if unknown. The key can be used as a Bundle String, e.g. Bundle.getMessage(getAppearanceKey(SignalHead.RED))
-
getAppearanceKey
@Nonnull public java.lang.String getAppearanceKey()
Get the current Signal Head Appearance Key.- Specified by:
getAppearanceKey
in interfaceSignalHead
- Returns:
- Key, or empty String if no valid appearance set.
-
getAppearance
public int getAppearance()
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, e.g. SignalHead.YELLOW
-
isCleared
public boolean 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
public boolean 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
public boolean 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
public boolean getLit()
Default behavior for "lit" parameter is to track value and return it. Get whether the signal is lit or dark. Changes to this value can be listened to using the Lit property.- Specified by:
getLit
in interfaceSignal
- Specified by:
getLit
in interfaceSignalHead
- Returns:
- is lit
-
getHeld
public boolean getHeld()
"Held" parameter is just tracked and notified. Get whether the signal is held. Changes to this value can be listened to using the Held property. It controls what mechanisms can control the signal's appearance. The actual semantics are defined by those external mechanisms.- Specified by:
getHeld
in interfaceSignal
- Specified by:
getHeld
in interfaceSignalHead
- Returns:
- is held
-
setState
public void setState(int s)
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
public int 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
public static int[] getDefaultValidStates()
-
getDefaultValidStateNames
public static java.lang.String[] getDefaultValidStateNames()
-
getDefaultStateName
@Nonnull public static java.lang.String getDefaultStateName(int appearance)
Get a localized text describing appearance from the corresponding state index.- Parameters:
appearance
- the index of the appearance- Returns:
- translated name for appearance
-
getValidStates
public int[] 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
public java.lang.String[] 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
public java.lang.String[] 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
public abstract boolean isTurnoutUsed(Turnout t)
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
public void vetoableChange(java.beans.PropertyChangeEvent evt) throws java.beans.PropertyVetoException
- Specified by:
vetoableChange
in interfaceNamedBean
- Specified by:
vetoableChange
in interfacejava.beans.VetoableChangeListener
- Overrides:
vetoableChange
in classAbstractNamedBean
- Throws:
java.beans.PropertyVetoException
-
getBeanType
@Nonnull public java.lang.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.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
-