use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class MultiIconEditor method setIcon.
public void setIcon(int iconNum, String label, String name) {
iconList[iconNum] = new NamedIcon(name, name);
// make a button to change that icon
JButton j = new IconButton(iconNum, iconList[iconNum]);
j.setToolTipText(iconList[iconNum].getName());
buttonList[iconNum] = j;
// and add it to this panel
JPanel p = new JPanel();
p.add(new JLabel(label));
p.add(j);
this.add(p);
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class MultiSensorIcon method updateSensor.
void updateSensor() {
MultiSensorIconAdder iconEditor = (MultiSensorIconAdder) _iconEditor;
setInactiveIcon(iconEditor.getIcon("SensorStateInactive"));
setInconsistentIcon(iconEditor.getIcon("BeanStateInconsistent"));
setUnknownIcon(iconEditor.getIcon("BeanStateUnknown"));
for (int i = 0; i < entries.size(); i++) {
entries.get(i).namedSensor.getBean().removePropertyChangeListener(this);
}
int numPositions = iconEditor.getNumIcons();
entries = new ArrayList<>(numPositions);
for (int i = 3; i < numPositions; i++) {
NamedIcon icon = iconEditor.getIcon(i);
NamedBeanHandle<Sensor> namedSensor = iconEditor.getSensor(i);
addEntry(namedSensor, icon);
}
setUpDown(iconEditor.getUpDown());
_iconEditorFrame.dispose();
_iconEditorFrame = null;
_iconEditor = null;
invalidate();
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class MultiSensorIcon method editItem.
protected void editItem() {
makePaletteFrame(Bundle.getMessage("EditItem", Bundle.getMessage("MultiSensor")));
_itemPanel = new MultiSensorItemPanel(_paletteFrame, "MultiSensor", _iconFamily, PickListModel.multiSensorPickModelInstance(), _editor);
ActionListener updateAction = (ActionEvent a) -> {
updateItem();
};
// duplicate _iconMap map with unscaled and unrotated icons
HashMap<String, NamedIcon> map = new HashMap<>();
map.put("SensorStateInactive", inactive);
map.put("BeanStateInconsistent", inconsistent);
map.put("BeanStateUnknown", unknown);
for (int i = 0; i < entries.size(); i++) {
map.put(MultiSensorItemPanel.getPositionName(i), entries.get(i).icon);
}
_itemPanel.init(updateAction, map);
for (int i = 0; i < entries.size(); i++) {
_itemPanel.setSelection(entries.get(i).namedSensor.getBean());
}
_itemPanel.setUpDown(getUpDown());
_paletteFrame.add(_itemPanel);
_paletteFrame.pack();
_paletteFrame.setVisible(true);
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class PositionableLabel method rotate.
@Override
public void rotate(int deg) {
if (log.isDebugEnabled()) {
log.debug("rotate({}) with _rotateText {}, _text {}, _icon {}", deg, _rotateText, _text, _icon);
}
_degrees = deg;
if (_rotateText || deg == 0) {
if (deg == 0) {
// restore unrotated whatever
_rotateText = false;
if (_text) {
if (log.isDebugEnabled()) {
log.debug(" super.setText(\"{}\");", _unRotatedText);
}
super.setText(_unRotatedText);
if (_popupUtil != null) {
setOpaque(_popupUtil.hasBackground());
_popupUtil.setBorder(true);
}
if (_namedIcon != null) {
String url = _namedIcon.getURL();
_namedIcon = new NamedIcon(url, url);
}
super.setIcon(_namedIcon);
} else {
if (_namedIcon != null) {
_namedIcon.rotate(deg, this);
}
super.setIcon(_namedIcon);
}
} else {
if (_text & _icon) {
// update text over icon
_namedIcon = makeTextOverlaidIcon(_unRotatedText, _namedIcon);
} else if (_text) {
// update text only icon image
_namedIcon = makeTextIcon(_unRotatedText);
}
_namedIcon.rotate(deg, this);
super.setIcon(_namedIcon);
// rotations cannot be opaque
setOpaque(false);
}
} else {
// first time text or icon is rotated from horizontal
if (_text && _icon) {
// text overlays icon e.g. LocoIcon
_namedIcon = makeTextOverlaidIcon(_unRotatedText, _namedIcon);
super.setText(null);
_rotateText = true;
setOpaque(false);
} else if (_text) {
_namedIcon = makeTextIcon(_unRotatedText);
super.setText(null);
_rotateText = true;
setOpaque(false);
}
if (_popupUtil != null) {
_popupUtil.setBorder(false);
}
_namedIcon.rotate(deg, this);
super.setIcon(_namedIcon);
}
updateSize();
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class MultiSensorIcon method setScale.
@Override
public void setScale(double s) {
for (int i = 0; i < entries.size(); i++) {
NamedIcon icon = entries.get(i).icon;
icon.scale(s, this);
}
inactive.scale(s, this);
unknown.scale(s, this);
inconsistent.scale(s, this);
displayState();
}
Aggregations