Search in sources :

Example 26 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class IconAdder method makeIconMap.

void makeIconMap(NamedBean bean) {
    if (bean != null && _type != null && _type.equals("SignalHead")) {
        _order = new ArrayList<>();
        _iconMap = new HashMap<>(12);
        int k = 0;
        ArrayList<CatalogTreeLeaf> list = _defaultIcons.getLeaves();
        String[] states = ((SignalHead) bean).getValidStateNames();
        for (int i = 0; i < list.size(); i++) {
            CatalogTreeLeaf leaf = list.get(i);
            String name = leaf.getName();
            try {
                name = Bundle.getMessage(leaf.getName());
            } catch (java.util.MissingResourceException mre) {
            }
            if (log.isDebugEnabled()) {
                log.debug("makeIconMap: leafName= " + leaf.getName() + ", name= " + name);
            }
            for (String state : states) {
                if (name.equals(state) || leaf.getName().equals(Bundle.getMessage("SignalHeadStateDark")) || leaf.getName().equals(Bundle.getMessage("SignalHeadStateHeld"))) {
                    String path = leaf.getPath();
                    this.setIcon(k++, leaf.getName(), new NamedIcon(path, path));
                    break;
                }
            }
        }
    } else {
        makeIcons(_defaultIcons);
    }
    if (log.isDebugEnabled()) {
        log.debug("makeIconMap: _iconMap.size()= " + _iconMap.size());
    }
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) CatalogTreeLeaf(jmri.jmrit.catalog.CatalogTreeLeaf) SignalHead(jmri.SignalHead)

Example 27 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class Editor method putMemory.

protected MemoryIcon putMemory() {
    MemoryIcon l = new MemoryIcon(new NamedIcon("resources/icons/misc/X-red.gif", "resources/icons/misc/X-red.gif"), this);
    IconAdder memoryIconEditor = getIconEditor("Memory");
    l.setMemory(memoryIconEditor.getTableSelection().getDisplayName());
    l.setSize(l.getPreferredSize().width, l.getPreferredSize().height);
    l.setDisplayLevel(MEMORIES);
    setNextLocation(l);
    putItem(l);
    return l;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon)

Example 28 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class IndicatorTrackIcon method setOccSensorHandle.

@Override
public void setOccSensorHandle(NamedBeanHandle<Sensor> senHandle) {
    if (namedOccSensor != null) {
        getOccSensor().removePropertyChangeListener(this);
    }
    namedOccSensor = senHandle;
    if (namedOccSensor != null) {
        if (_iconMap == null) {
            _iconMap = new HashMap<String, NamedIcon>();
        }
        Sensor sensor = getOccSensor();
        sensor.addPropertyChangeListener(this, namedOccSensor.getName(), "Indicator Track");
        _status = _pathUtil.getStatus(sensor.getKnownState());
        displayState(_status);
    }
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Sensor(jmri.Sensor)

Example 29 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class Editor method addMultiSensor.

public MultiSensorIcon addMultiSensor() {
    MultiSensorIcon m = new MultiSensorIcon(this);
    MultiSensorIconAdder editor = (MultiSensorIconAdder) getIconEditor("MultiSensor");
    m.setUnknownIcon(editor.getIcon("BeanStateUnknown"));
    m.setInconsistentIcon(editor.getIcon("BeanStateInconsistent"));
    m.setInactiveIcon(editor.getIcon("SensorStateInactive"));
    int numPositions = editor.getNumIcons();
    for (int i = 3; i < numPositions; i++) {
        NamedIcon icon = editor.getIcon(i);
        String sensor = editor.getSensor(i).getName();
        m.addEntry(sensor, icon);
    }
    m.setUpDown(editor.getUpDown());
    m.setDisplayLevel(SENSORS);
    setNextLocation(m);
    putItem(m);
    return m;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Point(java.awt.Point)

Example 30 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class SensorIcon method editItem.

protected void editItem() {
    makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("BeanNameSensor")));
    _itemPanel = new TableItemPanel(_paletteFrame, "Sensor", _iconFamily, PickListModel.sensorPickModelInstance(), // NOI18N
    _editor);
    ActionListener updateAction = (ActionEvent a) -> {
        updateItem();
    };
    // duplicate _iconMap map with unscaled and unrotated icons
    HashMap<String, NamedIcon> map = new HashMap<>();
    Iterator<Entry<String, NamedIcon>> it = _iconMap.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, NamedIcon> entry = it.next();
        NamedIcon oldIcon = entry.getValue();
        NamedIcon newIcon = cloneIcon(oldIcon, this);
        newIcon.rotate(0, this);
        newIcon.scale(1.0, this);
        newIcon.setRotation(4, this);
        map.put(entry.getKey(), newIcon);
    }
    _itemPanel.init(updateAction, map);
    _itemPanel.setSelection(getSensor());
    _paletteFrame.add(_itemPanel);
    _paletteFrame.pack();
    _paletteFrame.setVisible(true);
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Entry(java.util.Map.Entry) ActionListener(java.awt.event.ActionListener) HashMap(java.util.HashMap) ActionEvent(java.awt.event.ActionEvent) TableItemPanel(jmri.jmrit.display.palette.TableItemPanel)

Aggregations

NamedIcon (jmri.jmrit.catalog.NamedIcon)128 Entry (java.util.Map.Entry)28 Element (org.jdom2.Element)27 HashMap (java.util.HashMap)23 JPanel (javax.swing.JPanel)13 Editor (jmri.jmrit.display.Editor)13 Attribute (org.jdom2.Attribute)13 ActionEvent (java.awt.event.ActionEvent)12 ActionListener (java.awt.event.ActionListener)12 JLabel (javax.swing.JLabel)11 JButton (javax.swing.JButton)10 DataFlavor (java.awt.datatransfer.DataFlavor)6 CatalogTreeNode (jmri.jmrit.catalog.CatalogTreeNode)6 DragJLabel (jmri.jmrit.catalog.DragJLabel)6 Sensor (jmri.Sensor)5 CatalogTreeLeaf (jmri.jmrit.catalog.CatalogTreeLeaf)5 RosterEntry (jmri.jmrit.roster.RosterEntry)5 Point (java.awt.Point)4 JComponent (javax.swing.JComponent)4 JDialog (javax.swing.JDialog)4