Class DefaultSignalAppearanceMap
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.DefaultSignalAppearanceMap
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,PropertyChangeProvider
,NamedBean
,SignalAppearanceMap
public class DefaultSignalAppearanceMap extends AbstractNamedBean implements SignalAppearanceMap
Default implementation of a basic signal mast aspect - appearance mapping.The default contents are taken from the NamedBeanBundle properties file. This makes creation a little more heavy-weight, but speeds operation.
-
-
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 java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>>
aspectAttributeMap
protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>>
aspectImageMap
protected java.util.Hashtable<java.lang.String,java.lang.String[]>
aspectRelationshipMap
(package private) static java.util.HashMap<java.lang.String,DefaultSignalAppearanceMap>
maps
protected java.util.Hashtable<java.lang.Integer,java.lang.String>
specificMaps
protected SignalSystem
systemDefn
protected java.util.HashMap<java.lang.String,int[]>
table
-
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.SignalAppearanceMap
DANGER, DARK, HELD, PERMISSIVE
-
-
Constructor Summary
Constructors Constructor Description DefaultSignalAppearanceMap(java.lang.String systemName)
DefaultSignalAppearanceMap(java.lang.String systemName, java.lang.String userName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAspect(java.lang.String aspect, int[] appearances)
boolean
checkAspect(java.lang.String aspect)
Check if an aspect can be displayed.static DefaultSignalAppearanceMap
findMap(java.lang.String systemName)
java.util.Enumeration<java.lang.String>
getAspects()
Provide the Aspect elements to GUI and store methods.int[]
getAspectSettings(java.lang.String aspect)
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.java.lang.String
getImageLink(java.lang.String aspect, java.lang.String type)
Get an Image Link associated with a specific aspect and typejava.util.Vector<java.lang.String>
getImageTypes(java.lang.String aspect)
Get a list of valid icon sets.static DefaultSignalAppearanceMap
getMap(java.lang.String signalSystemName, java.lang.String aspectMapName)
java.lang.String
getProperty(java.lang.String aspect, java.lang.String key)
Get a property associated with a specific aspect.SignalSystem
getSignalSystem()
Get the associated signal system and the common information it contains.java.lang.String
getSpecificAppearance(int appearance)
Return the aspect for a specific appearance.int
getState()
Provide generic access to internal state.java.lang.String[]
getValidAspectsForAdvancedAspect(java.lang.String advancedAspect)
Get a list of potential aspects that we could set the SignalMast to, given the state of the advanced signal mast.(package private) static void
loadAspectRelationMap(java.lang.String signalSystemName, java.lang.String aspectMapName, DefaultSignalAppearanceMap SMmap, org.jdom2.Element root)
void
loadDefaults()
(package private) static void
loadImageMaps(java.util.List<org.jdom2.Element> img, java.lang.String name, DefaultSignalAppearanceMap map)
(package private) static DefaultSignalAppearanceMap
loadMap(java.lang.String signalSystemName, java.lang.String aspectMapName)
(package private) static void
loadSpecificAspect(java.lang.String signalSystemName, java.lang.String aspectMapName, int aspectType, DefaultSignalAppearanceMap SMmap, org.jdom2.Element root)
(package private) static void
loadSpecificMap(java.lang.String signalSystemName, java.lang.String aspectMapName, DefaultSignalAppearanceMap SMmap, org.jdom2.Element root)
protected void
registerMap()
void
setSignalSystem(SignalSystem t)
void
setState(int s)
Provide generic access to internal state.java.lang.String
summary()
Provide a multi-line summary of the signal system content, typically for printing.-
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, vetoableChange
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.NamedBean
compareTo, getRecommendedToolTip, getUsageReport
-
-
-
-
Field Detail
-
aspectAttributeMap
protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> aspectAttributeMap
-
aspectImageMap
protected java.util.Hashtable<java.lang.String,java.util.Hashtable<java.lang.String,java.lang.String>> aspectImageMap
-
maps
static java.util.HashMap<java.lang.String,DefaultSignalAppearanceMap> maps
-
specificMaps
protected java.util.Hashtable<java.lang.Integer,java.lang.String> specificMaps
-
aspectRelationshipMap
protected java.util.Hashtable<java.lang.String,java.lang.String[]> aspectRelationshipMap
-
systemDefn
protected SignalSystem systemDefn
-
table
protected java.util.HashMap<java.lang.String,int[]> table
-
-
Constructor Detail
-
DefaultSignalAppearanceMap
public DefaultSignalAppearanceMap(java.lang.String systemName, java.lang.String userName)
-
DefaultSignalAppearanceMap
public DefaultSignalAppearanceMap(java.lang.String systemName)
-
-
Method Detail
-
getBeanType
public java.lang.String 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
-
getMap
public static DefaultSignalAppearanceMap getMap(java.lang.String signalSystemName, java.lang.String aspectMapName)
-
registerMap
protected void registerMap()
-
findMap
public static DefaultSignalAppearanceMap findMap(java.lang.String systemName)
-
loadMap
static DefaultSignalAppearanceMap loadMap(java.lang.String signalSystemName, java.lang.String aspectMapName)
-
loadImageMaps
static void loadImageMaps(java.util.List<org.jdom2.Element> img, java.lang.String name, DefaultSignalAppearanceMap map)
-
loadSpecificMap
static void loadSpecificMap(java.lang.String signalSystemName, java.lang.String aspectMapName, DefaultSignalAppearanceMap SMmap, org.jdom2.Element root)
-
loadSpecificAspect
static void loadSpecificAspect(java.lang.String signalSystemName, java.lang.String aspectMapName, int aspectType, DefaultSignalAppearanceMap SMmap, org.jdom2.Element root)
-
loadAspectRelationMap
static void loadAspectRelationMap(java.lang.String signalSystemName, java.lang.String aspectMapName, DefaultSignalAppearanceMap SMmap, org.jdom2.Element root)
-
getProperty
public java.lang.String getProperty(java.lang.String aspect, java.lang.String key)
Get a property associated with a specific aspect.- Specified by:
getProperty
in interfaceSignalAppearanceMap
- Parameters:
aspect
- the aspect containing the propertykey
- the property key- Returns:
- the property value or null if none is defined for key
-
getImageLink
public java.lang.String getImageLink(java.lang.String aspect, java.lang.String type)
Description copied from interface:SignalAppearanceMap
Get an Image Link associated with a specific aspect and type- Specified by:
getImageLink
in interfaceSignalAppearanceMap
- Parameters:
aspect
- the aspecttype
- the image link key- Returns:
- the image link or an empty String if none is defined
-
getImageTypes
public java.util.Vector<java.lang.String> getImageTypes(java.lang.String aspect)
Description copied from interface:SignalAppearanceMap
Get a list of valid icon sets.- Specified by:
getImageTypes
in interfaceSignalAppearanceMap
- Parameters:
aspect
- the aspect to get icon sets for- Returns:
- a list of sets or an empty list if none are defined
-
loadDefaults
public void loadDefaults()
-
checkAspect
public boolean checkAspect(java.lang.String aspect)
Description copied from interface:SignalAppearanceMap
Check if an aspect can be displayed.- Specified by:
checkAspect
in interfaceSignalAppearanceMap
- Parameters:
aspect
- the aspect to check- Returns:
- true if the aspect can be displayed; false otherwise
-
addAspect
public void addAspect(java.lang.String aspect, int[] appearances)
-
getAspects
public java.util.Enumeration<java.lang.String> getAspects()
Provide the Aspect elements to GUI and store methods.- Specified by:
getAspects
in interfaceSignalAppearanceMap
- Returns:
- all aspects in this signal mast appearance map, in the order defined in xml definition
-
getSpecificAppearance
public java.lang.String getSpecificAppearance(int appearance)
Description copied from interface:SignalAppearanceMap
Return the aspect for a specific appearance.- Specified by:
getSpecificAppearance
in interfaceSignalAppearanceMap
- Parameters:
appearance
- the appearance- Returns:
- the aspect
-
getValidAspectsForAdvancedAspect
public java.lang.String[] getValidAspectsForAdvancedAspect(java.lang.String advancedAspect)
Get a list of potential aspects that we could set the SignalMast to, given the state of the advanced signal mast.- Specified by:
getValidAspectsForAdvancedAspect
in interfaceSignalAppearanceMap
- Parameters:
advancedAspect
- the aspect- Returns:
- a string array of potential aspects or null if none defined
-
getSignalSystem
public SignalSystem getSignalSystem()
Description copied from interface:SignalAppearanceMap
Get the associated signal system and the common information it contains.- Specified by:
getSignalSystem
in interfaceSignalAppearanceMap
- Returns:
- the signal system
-
setSignalSystem
public void setSignalSystem(SignalSystem t)
-
getState
public int getState()
Provide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read. This method returns a constant result on the DefaultSignalAppearanceMap.
- Specified by:
getState
in interfaceNamedBean
- Returns:
NamedBean.INCONSISTENT
-
setState
public void setState(int s)
Provide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read. This method has no effect on the DefaultSignalAppearanceMap.
-
getAspectSettings
public int[] getAspectSettings(java.lang.String aspect)
-
summary
public java.lang.String summary()
Description copied from interface:SignalAppearanceMap
Provide a multi-line summary of the signal system content, typically for printing.Not intended for further parsing, i.e. for persistence, as format likely to differ from type to type, and to change often.
- Specified by:
summary
in interfaceSignalAppearanceMap
- Returns:
- summary string.
-
-