use of jmri.SignalHead in project JMRI by JMRI.
the class LayoutTurnout method setSignalC2Name.
public void setSignalC2Name(String signalHead) {
if (signalHead == null || signalHead.equals("")) {
signalC2HeadNamed = null;
return;
}
SignalHead head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(signalHead);
if (head != null) {
signalC2HeadNamed = InstanceManager.getDefault(jmri.NamedBeanHandleManager.class).getNamedBeanHandle(signalHead, head);
} else {
signalC2HeadNamed = null;
log.error("Signal Head " + signalHead + " Not found for turnout " + getTurnoutName());
}
}
use of jmri.SignalHead in project JMRI by JMRI.
the class LayoutTurnout method setSignalA2Name.
public void setSignalA2Name(String signalHead) {
if (signalHead == null || signalHead.equals("")) {
signalA2HeadNamed = null;
return;
}
SignalHead head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(signalHead);
if (head != null) {
signalA2HeadNamed = InstanceManager.getDefault(jmri.NamedBeanHandleManager.class).getNamedBeanHandle(signalHead, head);
} else {
signalA2HeadNamed = null;
log.error("Signal Head " + signalHead + " Not found for turnout " + getTurnoutName());
}
}
use of jmri.SignalHead in project JMRI by JMRI.
the class LayoutTurnout method setSignalC1Name.
public void setSignalC1Name(String signalHead) {
if (signalHead == null || signalHead.equals("")) {
signalC1HeadNamed = null;
return;
}
SignalHead head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(signalHead);
if (head != null) {
signalC1HeadNamed = InstanceManager.getDefault(jmri.NamedBeanHandleManager.class).getNamedBeanHandle(signalHead, head);
} else {
signalC1HeadNamed = null;
log.error("Signal Head " + signalHead + " Not found for turnout " + getTurnoutName());
}
}
use of jmri.SignalHead in project JMRI by JMRI.
the class SignalHeadItemPanel method getFilteredIconMap.
protected HashMap<String, NamedIcon> getFilteredIconMap(HashMap<String, NamedIcon> allIconsMap) {
if (allIconsMap == null) {
JOptionPane.showMessageDialog(_paletteFrame, Bundle.getMessage("FamilyNotFound", _itemType, _family), Bundle.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);
return null;
}
if (_table == null || _table.getSelectedRow() < 0) {
return allIconsMap;
}
SignalHead sh = (SignalHead) getDeviceNamedBean();
if (sh != null) {
String[] states = sh.getValidStateNames();
if (states.length == 0) {
return allIconsMap;
}
HashMap<String, NamedIcon> iconMap = new HashMap<String, NamedIcon>();
Iterator<Entry<String, NamedIcon>> it = allIconsMap.entrySet().iterator();
while (it.hasNext()) {
Entry<String, NamedIcon> entry = it.next();
String name = entry.getKey();
String borderName = ItemPalette.convertText(name);
for (int j = 0; j < states.length; j++) {
if (borderName.equals(states[j]) || name.equals("SignalHeadStateDark") || name.equals("SignalHeadStateHeld")) {
iconMap.put(name, entry.getValue());
break;
}
}
}
if (log.isDebugEnabled()) {
log.debug("filteredMap size= " + iconMap.size());
}
return iconMap;
}
if (log.isDebugEnabled()) {
log.debug("Map NOT filtered, size= " + allIconsMap.size());
}
return allIconsMap;
}
use of jmri.SignalHead in project JMRI by JMRI.
the class TripleOutputSignalHeadXml method load.
@Override
public boolean load(Element shared, Element perNode) {
List<Element> l = shared.getChildren("turnoutname");
if (l.size() == 0) {
l = shared.getChildren("turnout");
}
NamedBeanHandle<Turnout> green = loadTurnout(l.get(0));
NamedBeanHandle<Turnout> blue = loadTurnout(l.get(1));
NamedBeanHandle<Turnout> red = loadTurnout(l.get(2));
// put it together
String sys = getSystemName(shared);
String uname = getUserName(shared);
SignalHead h;
if (uname == null) {
h = new TripleOutputSignalHead(sys, green, blue, red);
} else {
h = new TripleOutputSignalHead(sys, uname, green, blue, red);
}
loadCommon(h, shared);
InstanceManager.getDefault(jmri.SignalHeadManager.class).register(h);
return true;
}
Aggregations