Search in sources :

Example 6 with NamedIcon

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

the class PositionableLabel method deepClone.

@Override
public Positionable deepClone() {
    PositionableLabel pos;
    if (_icon) {
        NamedIcon icon = new NamedIcon((NamedIcon) getIcon());
        pos = new PositionableLabel(icon, _editor);
    } else {
        pos = new PositionableLabel(getText(), _editor);
    }
    return finishClone(pos);
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon)

Example 7 with NamedIcon

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

the class SignalHeadIcon method editItem.

protected void editItem() {
    makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("BeanNameSignalHead")));
    _itemPanel = new SignalHeadItemPanel(_paletteFrame, "SignalHead", getFamily(), PickListModel.signalHeadPickModelInstance(), //NOI18N
    _editor);
    ActionListener updateAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            updateItem();
        }
    };
    // _iconMap keys with local names - Let SignalHeadItemPanel figure this out
    // duplicate _iconMap map with unscaled and unrotated icons
    HashMap<String, NamedIcon> map = new HashMap<String, NamedIcon>();
    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(getSignalHead());
    _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) SignalHeadItemPanel(jmri.jmrit.display.palette.SignalHeadItemPanel) HashMap(java.util.HashMap) ActionEvent(java.awt.event.ActionEvent)

Example 8 with NamedIcon

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

the class SignalMastIcon method loadIcons.

private boolean loadIcons(String aspect) {
    String s = getSignalMast().getAppearanceMap().getImageLink(aspect, useIconSet);
    if (s.equals("")) {
        if (aspect.startsWith("$")) {
            log.debug("No icon found for specific appearance " + aspect);
        } else {
            log.error("No icon found for appearance " + aspect);
        }
        return true;
    } else {
        if (!s.contains("preference:")) {
            s = s.substring(s.indexOf("resources"));
        }
        NamedIcon n;
        try {
            n = new NamedIcon(s, s);
        } catch (java.lang.NullPointerException e) {
            JOptionPane.showMessageDialog(null, Bundle.getMessage("SignalMastIconLoadError2", new Object[] { aspect, s, getNameString() }), Bundle.getMessage("SignalMastIconLoadErrorTitle"), JOptionPane.ERROR_MESSAGE);
            log.error(Bundle.getMessage("SignalMastIconLoadError2", aspect, s, getNameString()));
            return true;
        }
        _iconMap.put(s, n);
        if (_rotate != 0) {
            n.rotate(_rotate, this);
        }
        if (_scale != 1.0) {
            n.scale(_scale, this);
        }
    }
    return false;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon)

Example 9 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon 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 10 with NamedIcon

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

the class TurnoutIcon method updateTurnout.

void updateTurnout() {
    HashMap<Integer, NamedIcon> oldMap = cloneMap(_iconStateMap, this);
    setTurnout(_iconEditor.getTableSelection().getDisplayName());
    Hashtable<String, NamedIcon> iconMap = _iconEditor.getIconMap();
    Iterator<Entry<String, NamedIcon>> it = iconMap.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, NamedIcon> entry = it.next();
        if (log.isDebugEnabled()) {
            log.debug("key= " + entry.getKey());
        }
        NamedIcon newIcon = entry.getValue();
        NamedIcon oldIcon = oldMap.get(_name2stateMap.get(entry.getKey()));
        newIcon.setLoad(oldIcon.getDegrees(), oldIcon.getScale(), this);
        newIcon.setRotation(oldIcon.getRotation(), this);
        setIcon(entry.getKey(), newIcon);
    }
    _iconEditorFrame.dispose();
    _iconEditorFrame = null;
    _iconEditor = null;
    invalidate();
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Entry(java.util.Map.Entry)

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