Search in sources :

Example 16 with NamedIcon

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

the class IconItemPanel method addNewIcon.

/**
     * Action item for initButtonPanel
     */
protected void addNewIcon() {
    if (log.isDebugEnabled()) {
        log.debug("addNewIcon Action: iconMap.size()= " + _iconMap.size());
    }
    //        String name = Bundle.getMessage("RedX");
    String name = JOptionPane.showInputDialog(this, Bundle.getMessage("NoIconName"), null);
    if (name == null || name.trim().length() == 0) {
        return;
    }
    if (_iconMap.get(name) != null) {
        JOptionPane.showMessageDialog(this, Bundle.getMessage("DuplicateIconName", name), Bundle.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);
        name = setIconName(name);
        if (name == null || _iconMap.get(name) != null) {
            return;
        }
    }
    String fileName = "resources/icons/misc/X-red.gif";
    NamedIcon icon = new jmri.jmrit.catalog.NamedIcon(fileName, fileName);
    putIcon(name, icon);
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon)

Example 17 with NamedIcon

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

the class IndicatorTOItemPanel method initIconFamiliesPanel.

/**
     * CENTER Panel
     */
@Override
protected void initIconFamiliesPanel() {
    _iconFamilyPanel = new JPanel();
    _iconFamilyPanel.setLayout(new BoxLayout(_iconFamilyPanel, BoxLayout.Y_AXIS));
    HashMap<String, HashMap<String, HashMap<String, NamedIcon>>> families = ItemPalette.getLevel4FamilyMaps(_itemType);
    if (families != null && families.size() > 0) {
        JPanel familyPanel = makeFamilyButtons(families.keySet().iterator(), (_iconGroupsMap == null));
        if (_iconGroupsMap == null) {
            _iconGroupsMap = families.get(_family);
        }
        // make _iconPanel & _dragIconPanel before calls to add icons
        addFamilyPanels(familyPanel);
        if (_iconGroupsMap == null) {
            log.error("_iconGroupsMap is null in initIconFamiliesPanel");
            _family = null;
        } else {
            // need to have family iconMap identified before calling
            addIcons2Panel(_iconGroupsMap);
            makeDndIconPanel(_iconGroupsMap.get("ClearTrack"), "TurnoutStateClosed");
        }
    } else {
        familiesMissing();
    //createNewFamily();
    }
    if (log.isDebugEnabled()) {
        log.debug("initIconFamiliesPanel done");
    }
}
Also used : JPanel(javax.swing.JPanel) NamedIcon(jmri.jmrit.catalog.NamedIcon) HashMap(java.util.HashMap) BoxLayout(javax.swing.BoxLayout)

Example 18 with NamedIcon

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

the class ItemPalette method storeIcons.

/**
     * Store palette icons in preferences file catalogTrees.xml
     */
public static void storeIcons() {
    if (_iconMaps == null) {
        // never loaded
        return;
    }
    if (!jmri.util.ThreadingUtil.isGUIThread())
        log.error("Not on GUI thread", new Exception("traceback"));
    CatalogTreeManager manager = InstanceManager.getDefault(jmri.CatalogTreeManager.class);
    // unfiltered, xml-stored, item palate icon tree
    CatalogTree tree = manager.getBySystemName("NXPI");
    // discard old version
    if (tree != null) {
        manager.deregister(tree);
    }
    tree = manager.newCatalogTree("NXPI", "Item Palette");
    CatalogTreeNode root = tree.getRoot();
    Iterator<Entry<String, HashMap<String, HashMap<String, NamedIcon>>>> it = _iconMaps.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, HashMap<String, HashMap<String, NamedIcon>>> entry = it.next();
        root.add(store3levelMap(entry.getKey(), entry.getValue()));
        if (log.isDebugEnabled()) {
            log.debug("Add type node " + entry.getKey());
        }
    }
    Iterator<Entry<String, HashMap<String, HashMap<String, HashMap<String, NamedIcon>>>>> its = _indicatorTOMaps.entrySet().iterator();
    while (its.hasNext()) {
        Entry<String, HashMap<String, HashMap<String, HashMap<String, NamedIcon>>>> entry = its.next();
        CatalogTreeNode typeNode = new CatalogTreeNode(entry.getKey());
        Iterator<Entry<String, HashMap<String, HashMap<String, NamedIcon>>>> iter = entry.getValue().entrySet().iterator();
        while (iter.hasNext()) {
            Entry<String, HashMap<String, HashMap<String, NamedIcon>>> ent = iter.next();
            typeNode.add(store3levelMap(ent.getKey(), ent.getValue()));
            if (log.isDebugEnabled()) {
                log.debug("Add IndicatorTO node " + ent.getKey());
            }
        }
        root.add(typeNode);
        if (log.isDebugEnabled()) {
            log.debug("Add IndicatorTO node " + entry.getKey());
        }
    }
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) HashMap(java.util.HashMap) CatalogTreeManager(jmri.CatalogTreeManager) CatalogTreeNode(jmri.jmrit.catalog.CatalogTreeNode) Entry(java.util.Map.Entry) CatalogTree(jmri.CatalogTree)

Example 19 with NamedIcon

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

the class IconDialog method clone.

protected HashMap<String, NamedIcon> clone(HashMap<String, NamedIcon> map) {
    HashMap<String, NamedIcon> clone = null;
    if (map != null) {
        clone = new HashMap<String, NamedIcon>();
        Iterator<Entry<String, NamedIcon>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            Entry<String, NamedIcon> entry = it.next();
            clone.put(entry.getKey(), new NamedIcon(entry.getValue()));
        }
    }
    return clone;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Entry(java.util.Map.Entry)

Example 20 with NamedIcon

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

the class ItemPalette method cloneMap.

/**
     * ***********************************************************************
     */
protected static HashMap<String, NamedIcon> cloneMap(HashMap<String, NamedIcon> map) {
    HashMap<String, NamedIcon> clone = new HashMap<String, NamedIcon>();
    if (map != null) {
        Iterator<Entry<String, NamedIcon>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            Entry<String, NamedIcon> entry = it.next();
            String name = entry.getKey();
            NamedIcon icon = new NamedIcon(entry.getValue());
            clone.put(name, icon);
        }
    }
    return clone;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Entry(java.util.Map.Entry) HashMap(java.util.HashMap)

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