Package jmri.implementation
Class DefaultSignalHead
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractSignalHead
-
- jmri.implementation.DefaultSignalHead
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,NamedBean
,Signal
,SignalHead
- Direct Known Subclasses:
AcelaSignalHead
,DoubleTurnoutSignalHead
,LsDecSignalHead
,MergSD2SignalHead
,SE8cSignalHead
,SE8cSignalHead
,SerialSignalHead
,SingleTurnoutSignalHead
,VirtualSignalHead
public abstract class DefaultSignalHead extends AbstractSignalHead
Default implementation of the basic logic of the SignalHead interface. This class only claims support for the Red, Yellow and Green appearances, and their corresponding flashing forms. Support for Lunar is deferred to DefaultLunarSignalHead or an extended class.
-
-
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 int
delay
On or off time of flashing signal.static int
masterDelay
protected boolean
mFlashOn
Should a flashing signal be on (lit) now?(package private) javax.swing.Timer
timer
-
Fields inherited from class jmri.implementation.AbstractSignalHead
mAppearance, mHeld, mLit
-
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 DefaultSignalHead(java.lang.String systemName)
DefaultSignalHead(java.lang.String systemName, java.lang.String userName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
appearanceSetsFlashTimer(int newAppearance)
Call to set timer when updating the appearance.java.util.List<NamedBeanUsageReport>
getUsageReport(NamedBean bean)
Get a list of references for the specified bean.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
isTurnoutUsed(Turnout t)
Check if a given turnout is used on this head.void
setAppearance(int newAppearance)
Set the Signal Head Appearance.void
setHeld(boolean newHeld)
Set the held parameter.void
setLit(boolean newLit)
protected void
startFlash()
Start the timer that controls flashing.protected void
stopFlash()
protected abstract void
updateOutput()
Type-specific routine to handle output to the layout hardware.-
Methods inherited from class jmri.implementation.AbstractSignalHead
getAppearance, getAppearanceKey, getAppearanceKey, getAppearanceName, getAppearanceName, getBeanType, getDefaultStateName, getDefaultValidStateNames, getDefaultValidStates, getHeld, getLit, getState, isAtStop, isCleared, isShowingRestricting, setState, vetoableChange
-
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, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
mFlashOn
protected boolean mFlashOn
Should a flashing signal be on (lit) now?
-
timer
javax.swing.Timer timer
-
delay
public int delay
On or off time of flashing signal. Public so that it can be overridden by scripting (before first use)
-
masterDelay
public static int masterDelay
-
-
Constructor Detail
-
DefaultSignalHead
public DefaultSignalHead(java.lang.String systemName, java.lang.String userName)
-
DefaultSignalHead
public DefaultSignalHead(java.lang.String systemName)
-
-
Method Detail
-
setAppearance
public void setAppearance(int newAppearance)
Description copied from interface:SignalHead
Set the Signal Head Appearance.- Parameters:
newAppearance
- integer representing a valid Appearance for this head
-
appearanceSetsFlashTimer
protected void appearanceSetsFlashTimer(int newAppearance)
Call to set timer when updating the appearance.- Parameters:
newAppearance
- the new appearance
-
setLit
public void setLit(boolean newLit)
Description copied from interface:SignalHead
-
setHeld
public void setHeld(boolean newHeld)
Set the held parameter.Note that this does not directly effect the output on the layout; the held parameter is a local variable which effects the aspect only via higher-level logic.
- Parameters:
newHeld
- new Held state, true if Held, to be compared with current Held state
-
updateOutput
protected abstract void updateOutput()
Type-specific routine to handle output to the layout hardware.Does not notify listeners of changes; that's done elsewhere. Should use the following variables to determine what to send:
- mAppearance
- mLit
- mFlashOn
-
startFlash
protected void startFlash()
Start the timer that controls flashing.
-
stopFlash
protected void stopFlash()
-
getValidStates
public int[] getValidStates()
Get an array of appearance indexes valid for the mast type.- Specified by:
getValidStates
in interfaceSignalHead
- Overrides:
getValidStates
in classAbstractSignalHead
- 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
- Overrides:
getValidStateKeys
in classAbstractSignalHead
- 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
- Overrides:
getValidStateNames
in classAbstractSignalHead
- Returns:
- array of translated appearance names
-
isTurnoutUsed
public boolean isTurnoutUsed(Turnout t)
Description copied from class:AbstractSignalHead
Check if a given turnout is used on this head.- Specified by:
isTurnoutUsed
in classAbstractSignalHead
- Parameters:
t
- Turnout object to check- Returns:
- true if turnout is configured as output or driver of head
-
getUsageReport
public java.util.List<NamedBeanUsageReport> getUsageReport(NamedBean bean)
Description copied from interface:NamedBean
Get a list of references for the specified bean.- Parameters:
bean
- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-
-