Search in sources :

Example 61 with SignalHead

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());
    }
}
Also used : SignalHead(jmri.SignalHead)

Example 62 with SignalHead

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());
    }
}
Also used : SignalHead(jmri.SignalHead)

Example 63 with SignalHead

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());
    }
}
Also used : SignalHead(jmri.SignalHead)

Example 64 with SignalHead

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;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Entry(java.util.Map.Entry) HashMap(java.util.HashMap) SignalHead(jmri.SignalHead)

Example 65 with SignalHead

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;
}
Also used : Element(org.jdom2.Element) SignalHead(jmri.SignalHead) TripleOutputSignalHead(jmri.implementation.TripleOutputSignalHead) TripleOutputSignalHead(jmri.implementation.TripleOutputSignalHead) Turnout(jmri.Turnout)

Aggregations

SignalHead (jmri.SignalHead)73 Turnout (jmri.Turnout)20 Element (org.jdom2.Element)13 SignalMast (jmri.SignalMast)12 Sensor (jmri.Sensor)11 JsonException (jmri.server.json.JsonException)8 Test (org.junit.Test)7 NamedBean (jmri.NamedBean)6 DoubleTurnoutSignalHead (jmri.implementation.DoubleTurnoutSignalHead)6 QuadOutputSignalHead (jmri.implementation.QuadOutputSignalHead)6 SingleTurnoutSignalHead (jmri.implementation.SingleTurnoutSignalHead)6 TripleOutputSignalHead (jmri.implementation.TripleOutputSignalHead)6 TripleTurnoutSignalHead (jmri.implementation.TripleTurnoutSignalHead)6 SignalHeadManager (jmri.SignalHeadManager)5 DccSignalHead (jmri.implementation.DccSignalHead)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 JmriException (jmri.JmriException)4 Light (jmri.Light)4 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 ActionEvent (java.awt.event.ActionEvent)3