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);
}
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");
}
}
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());
}
}
}
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;
}
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;
}
Aggregations