use of jmri.jmrit.catalog.CatalogTreeLeaf in project JMRI by JMRI.
the class IconAdder method makeIcons.
/**
* Build iconMap and orderArray from user's choice of defaults.
*
* @param n the root in a catalog from which icons are made
*/
protected void makeIcons(CatalogTreeNode n) {
if (log.isDebugEnabled()) {
log.debug("makeIcons from node= {}, numChildren= {}, NumLeaves= {}", n.toString(), n.getChildCount(), n.getNumLeaves());
}
_iconMap = new HashMap<>(10);
_order = new ArrayList<>();
ArrayList<CatalogTreeLeaf> list = n.getLeaves();
// adjust order of icons
int k = list.size() - 1;
for (int i = list.size() - 1; i >= 0; i--) {
CatalogTreeLeaf leaf = list.get(i);
String name = leaf.getName();
String path = leaf.getPath();
switch(name) {
case "BeanStateInconsistent":
this.setIcon(0, name, new NamedIcon(path, path));
break;
case "BeanStateUnknown":
this.setIcon(1, name, new NamedIcon(path, path));
break;
default:
this.setIcon(k, name, new NamedIcon(path, path));
k--;
break;
}
}
}
use of jmri.jmrit.catalog.CatalogTreeLeaf in project JMRI by JMRI.
the class IconAdder method getDefaultIconNodeFromMap.
private CatalogTreeNode getDefaultIconNodeFromMap() {
if (log.isDebugEnabled()) {
log.debug("getDefaultIconNodeFromMap for node= " + _type + ", _order.size()= " + _order.size());
}
_defaultIcons = new CatalogTreeNode(_type);
Iterator<Entry<String, JToggleButton>> it = _iconMap.entrySet().iterator();
while (it.hasNext()) {
Entry<String, JToggleButton> e = it.next();
NamedIcon icon = (NamedIcon) e.getValue().getIcon();
_defaultIcons.addLeaf(new CatalogTreeLeaf(e.getKey(), icon.getURL(), _order.indexOf(e.getKey())));
}
return _defaultIcons;
}
use of jmri.jmrit.catalog.CatalogTreeLeaf in project JMRI by JMRI.
the class MultiSensorIconAdder method makeIcons.
/**
* Build iconMap and orderArray from user's choice of defaults (override)
*/
@Override
protected void makeIcons(CatalogTreeNode n) {
if (log.isDebugEnabled()) {
log.debug("makeIcons from node= " + n.toString() + ", numChildren= " + n.getChildCount() + ", NumLeaves= " + n.getNumLeaves());
}
_iconMap = new HashMap<>(10);
_order = new ArrayList<>();
ArrayList<CatalogTreeLeaf> list = n.getLeaves();
// adjust order of icons
for (int i = list.size() - 1; i >= 0; i--) {
CatalogTreeLeaf leaf = list.get(i);
String name = leaf.getName();
String path = leaf.getPath();
if ("BeanStateInconsistent".equals(name)) {
setIcon(0, name, new NamedIcon(path, path));
} else if ("BeanStateUnknown".equals(name)) {
setIcon(1, name, new NamedIcon(path, path));
} else if ("SensorStateInactive".equals(name)) {
setIcon(2, name, new NamedIcon(path, path));
} else {
int k = Character.digit(name.charAt(name.length() - 1), 10);
setIcon(k + 3, name, new NamedIcon(path, path));
}
}
}
Aggregations