Search in sources :

Example 1 with TableItemPanel

use of jmri.jmrit.display.palette.TableItemPanel in project JMRI by JMRI.

the class TurnoutIcon method editItem.

protected void editItem() {
    makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("BeanNameTurnout")));
    _itemPanel = new TableItemPanel(_paletteFrame, "Turnout", _iconFamily, PickListModel.turnoutPickModelInstance(), // NOI18N
    _editor);
    ActionListener updateAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            updateItem();
        }
    };
    // duplicate icon map with state names rather than int states and unscaled and unrotated
    HashMap<String, NamedIcon> strMap = new HashMap<String, NamedIcon>();
    Iterator<Entry<Integer, NamedIcon>> it = _iconStateMap.entrySet().iterator();
    while (it.hasNext()) {
        Entry<Integer, 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);
        strMap.put(_state2nameMap.get(entry.getKey()), newIcon);
    }
    _itemPanel.init(updateAction, strMap);
    _itemPanel.setSelection(getTurnout());
    _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)

Example 2 with TableItemPanel

use of jmri.jmrit.display.palette.TableItemPanel 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

ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 NamedIcon (jmri.jmrit.catalog.NamedIcon)2 TableItemPanel (jmri.jmrit.display.palette.TableItemPanel)2