use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class IconAdder method makeIconMap.
void makeIconMap(NamedBean bean) {
if (bean != null && _type != null && _type.equals("SignalHead")) {
_order = new ArrayList<>();
_iconMap = new HashMap<>(12);
int k = 0;
ArrayList<CatalogTreeLeaf> list = _defaultIcons.getLeaves();
String[] states = ((SignalHead) bean).getValidStateNames();
for (int i = 0; i < list.size(); i++) {
CatalogTreeLeaf leaf = list.get(i);
String name = leaf.getName();
try {
name = Bundle.getMessage(leaf.getName());
} catch (java.util.MissingResourceException mre) {
}
if (log.isDebugEnabled()) {
log.debug("makeIconMap: leafName= " + leaf.getName() + ", name= " + name);
}
for (String state : states) {
if (name.equals(state) || leaf.getName().equals(Bundle.getMessage("SignalHeadStateDark")) || leaf.getName().equals(Bundle.getMessage("SignalHeadStateHeld"))) {
String path = leaf.getPath();
this.setIcon(k++, leaf.getName(), new NamedIcon(path, path));
break;
}
}
}
} else {
makeIcons(_defaultIcons);
}
if (log.isDebugEnabled()) {
log.debug("makeIconMap: _iconMap.size()= " + _iconMap.size());
}
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class Editor method putMemory.
protected MemoryIcon putMemory() {
MemoryIcon l = new MemoryIcon(new NamedIcon("resources/icons/misc/X-red.gif", "resources/icons/misc/X-red.gif"), this);
IconAdder memoryIconEditor = getIconEditor("Memory");
l.setMemory(memoryIconEditor.getTableSelection().getDisplayName());
l.setSize(l.getPreferredSize().width, l.getPreferredSize().height);
l.setDisplayLevel(MEMORIES);
setNextLocation(l);
putItem(l);
return l;
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class IndicatorTrackIcon method setOccSensorHandle.
@Override
public void setOccSensorHandle(NamedBeanHandle<Sensor> senHandle) {
if (namedOccSensor != null) {
getOccSensor().removePropertyChangeListener(this);
}
namedOccSensor = senHandle;
if (namedOccSensor != null) {
if (_iconMap == null) {
_iconMap = new HashMap<String, NamedIcon>();
}
Sensor sensor = getOccSensor();
sensor.addPropertyChangeListener(this, namedOccSensor.getName(), "Indicator Track");
_status = _pathUtil.getStatus(sensor.getKnownState());
displayState(_status);
}
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class Editor method addMultiSensor.
public MultiSensorIcon addMultiSensor() {
MultiSensorIcon m = new MultiSensorIcon(this);
MultiSensorIconAdder editor = (MultiSensorIconAdder) getIconEditor("MultiSensor");
m.setUnknownIcon(editor.getIcon("BeanStateUnknown"));
m.setInconsistentIcon(editor.getIcon("BeanStateInconsistent"));
m.setInactiveIcon(editor.getIcon("SensorStateInactive"));
int numPositions = editor.getNumIcons();
for (int i = 3; i < numPositions; i++) {
NamedIcon icon = editor.getIcon(i);
String sensor = editor.getSensor(i).getName();
m.addEntry(sensor, icon);
}
m.setUpDown(editor.getUpDown());
m.setDisplayLevel(SENSORS);
setNextLocation(m);
putItem(m);
return m;
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class SensorIcon method editItem.
protected void editItem() {
makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("BeanNameSensor")));
_itemPanel = new TableItemPanel(_paletteFrame, "Sensor", _iconFamily, PickListModel.sensorPickModelInstance(), // NOI18N
_editor);
ActionListener updateAction = (ActionEvent a) -> {
updateItem();
};
// duplicate _iconMap map with unscaled and unrotated icons
HashMap<String, NamedIcon> map = new HashMap<>();
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(getSensor());
_paletteFrame.add(_itemPanel);
_paletteFrame.pack();
_paletteFrame.setVisible(true);
}
Aggregations