use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class PositionableLabel method deepClone.
@Override
public Positionable deepClone() {
PositionableLabel pos;
if (_icon) {
NamedIcon icon = new NamedIcon((NamedIcon) getIcon());
pos = new PositionableLabel(icon, _editor);
} else {
pos = new PositionableLabel(getText(), _editor);
}
return finishClone(pos);
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class SignalHeadIcon method editItem.
protected void editItem() {
makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("BeanNameSignalHead")));
_itemPanel = new SignalHeadItemPanel(_paletteFrame, "SignalHead", getFamily(), PickListModel.signalHeadPickModelInstance(), //NOI18N
_editor);
ActionListener updateAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
updateItem();
}
};
// _iconMap keys with local names - Let SignalHeadItemPanel figure this out
// duplicate _iconMap map with unscaled and unrotated icons
HashMap<String, NamedIcon> map = new HashMap<String, NamedIcon>();
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(getSignalHead());
_paletteFrame.add(_itemPanel);
_paletteFrame.pack();
_paletteFrame.setVisible(true);
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class SignalMastIcon method loadIcons.
private boolean loadIcons(String aspect) {
String s = getSignalMast().getAppearanceMap().getImageLink(aspect, useIconSet);
if (s.equals("")) {
if (aspect.startsWith("$")) {
log.debug("No icon found for specific appearance " + aspect);
} else {
log.error("No icon found for appearance " + aspect);
}
return true;
} else {
if (!s.contains("preference:")) {
s = s.substring(s.indexOf("resources"));
}
NamedIcon n;
try {
n = new NamedIcon(s, s);
} catch (java.lang.NullPointerException e) {
JOptionPane.showMessageDialog(null, Bundle.getMessage("SignalMastIconLoadError2", new Object[] { aspect, s, getNameString() }), Bundle.getMessage("SignalMastIconLoadErrorTitle"), JOptionPane.ERROR_MESSAGE);
log.error(Bundle.getMessage("SignalMastIconLoadError2", aspect, s, getNameString()));
return true;
}
_iconMap.put(s, n);
if (_rotate != 0) {
n.rotate(_rotate, this);
}
if (_scale != 1.0) {
n.scale(_scale, this);
}
}
return false;
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class TurnoutIcon method editItem.
protected void editItem() {
makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("BeanNameTurnout")));
_itemPanel = new TableItemPanel(_paletteFrame, "Turnout", _iconFamily, PickListModel.turnoutPickModelInstance(), // NOI18N
_editor);
ActionListener updateAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
updateItem();
}
};
// duplicate icon map with state names rather than int states and unscaled and unrotated
HashMap<String, NamedIcon> strMap = new HashMap<String, NamedIcon>();
Iterator<Entry<Integer, NamedIcon>> it = _iconStateMap.entrySet().iterator();
while (it.hasNext()) {
Entry<Integer, 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);
strMap.put(_state2nameMap.get(entry.getKey()), newIcon);
}
_itemPanel.init(updateAction, strMap);
_itemPanel.setSelection(getTurnout());
_paletteFrame.add(_itemPanel);
_paletteFrame.pack();
_paletteFrame.setVisible(true);
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class TurnoutIcon method updateTurnout.
void updateTurnout() {
HashMap<Integer, NamedIcon> oldMap = cloneMap(_iconStateMap, this);
setTurnout(_iconEditor.getTableSelection().getDisplayName());
Hashtable<String, NamedIcon> iconMap = _iconEditor.getIconMap();
Iterator<Entry<String, NamedIcon>> it = iconMap.entrySet().iterator();
while (it.hasNext()) {
Entry<String, NamedIcon> entry = it.next();
if (log.isDebugEnabled()) {
log.debug("key= " + entry.getKey());
}
NamedIcon newIcon = entry.getValue();
NamedIcon oldIcon = oldMap.get(_name2stateMap.get(entry.getKey()));
newIcon.setLoad(oldIcon.getDegrees(), oldIcon.getScale(), this);
newIcon.setRotation(oldIcon.getRotation(), this);
setIcon(entry.getKey(), newIcon);
}
_iconEditorFrame.dispose();
_iconEditorFrame = null;
_iconEditor = null;
invalidate();
}
Aggregations