use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class Editor method putIcon.
/**
* Add an icon to the target.
*
* @return The icon that was added to the target.
*/
protected Positionable putIcon() {
IconAdder iconEditor = getIconEditor("Icon");
String url = iconEditor.getIcon("plainIcon").getURL();
NamedIcon icon = NamedIcon.getIconByName(url);
if (log.isDebugEnabled()) {
log.debug("putIcon: {} url= {}", (icon == null ? "null" : "icon"), url);
}
PositionableLabel l = new PositionableLabel(icon, this);
// l.setPopupUtility(null); // no text
l.setDisplayLevel(ICONS);
setNextLocation(l);
putItem(l);
l.updateSize();
return l;
}
use of jmri.jmrit.catalog.NamedIcon 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.NamedIcon 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.NamedIcon in project JMRI by JMRI.
the class IndicatorTrackIcon method displayState.
/*
* Drive the current state of the display from the status.
*/
public void displayState(String status) {
if (log.isDebugEnabled()) {
log.debug(getNameString() + " displayStatus " + _status);
}
NamedIcon icon = getIcon(status);
if (icon != null) {
super.setIcon(icon);
}
updateSize();
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class IndicatorTurnoutIcon method updateItem.
@Override
void updateItem() {
if (log.isDebugEnabled()) {
log.debug("updateItem: " + getNameString() + " family= " + _TOPanel.getFamilyName());
}
setTurnout(_TOPanel.getTableSelection().getSystemName());
setOccSensor(_TOPanel.getOccSensor());
setOccBlock(_TOPanel.getOccBlock());
_pathUtil.setShowTrain(_TOPanel.getShowTrainName());
_iconFamily = _TOPanel.getFamilyName();
_pathUtil.setPaths(_TOPanel.getPaths());
HashMap<String, HashMap<String, NamedIcon>> iconMap = _TOPanel.getIconMaps();
if (iconMap != null) {
Iterator<Entry<String, HashMap<String, NamedIcon>>> it = iconMap.entrySet().iterator();
while (it.hasNext()) {
Entry<String, HashMap<String, NamedIcon>> entry = it.next();
String status = entry.getKey();
HashMap<Integer, NamedIcon> oldMap = _iconMaps.get(entry.getKey());
Iterator<Entry<String, NamedIcon>> iter = entry.getValue().entrySet().iterator();
while (iter.hasNext()) {
Entry<String, NamedIcon> ent = iter.next();
if (log.isDebugEnabled()) {
log.debug("key= " + ent.getKey());
}
NamedIcon newIcon = cloneIcon(ent.getValue(), this);
NamedIcon oldIcon = oldMap.get(_name2stateMap.get(ent.getKey()));
newIcon.setLoad(oldIcon.getDegrees(), oldIcon.getScale(), this);
newIcon.setRotation(oldIcon.getRotation(), this);
setIcon(status, ent.getKey(), newIcon);
}
}
}
// otherwise retain current map
// jmri.jmrit.catalog.ImageIndexEditor.checkImageIndex();
_paletteFrame.dispose();
_paletteFrame = null;
_TOPanel.dispose();
_TOPanel = null;
displayState(turnoutState());
}
Aggregations