use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class MemoryIcon method updateIconFromRosterVal.
protected Object updateIconFromRosterVal(RosterEntry roster) {
re = roster;
javax.swing.ImageIcon icon = jmri.InstanceManager.rosterIconFactoryInstance().getIcon(roster);
if (icon == null || icon.getIconWidth() == -1 || icon.getIconHeight() == -1) {
//the IconPath is still at default so no icon set
return roster.titleString();
} else {
NamedIcon rosterIcon = new NamedIcon(roster.getIconPath(), roster.getIconPath());
_text = false;
_icon = true;
updateIcon(rosterIcon);
if (flipRosterIcon) {
flipIcon(NamedIcon.HORIZONTALFLIP);
}
jmri.InstanceManager.throttleManagerInstance().attachListener(re.getDccLocoAddress(), this);
Object isForward = jmri.InstanceManager.throttleManagerInstance().getThrottleInfo(re.getDccLocoAddress(), "IsForward");
if (isForward != null) {
if (!(Boolean) isForward) {
flipIcon(NamedIcon.HORIZONTALFLIP);
}
}
return null;
}
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class IndicatorTurnoutIcon method editItem.
@Override
protected void editItem() {
makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("IndicatorTO")));
_TOPanel = new IndicatorTOItemPanel(_paletteFrame, "IndicatorTO", _iconFamily, PickListModel.turnoutPickModelInstance(), _editor);
ActionListener updateAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
updateItem();
}
};
// Convert _iconMaps state (ints) to Palette's bean names
HashMap<String, HashMap<String, NamedIcon>> iconMaps = new HashMap<String, HashMap<String, NamedIcon>>();
iconMaps.put("ClearTrack", new HashMap<String, NamedIcon>());
iconMaps.put("OccupiedTrack", new HashMap<String, NamedIcon>());
iconMaps.put("PositionTrack", new HashMap<String, NamedIcon>());
iconMaps.put("AllocatedTrack", new HashMap<String, NamedIcon>());
iconMaps.put("DontUseTrack", new HashMap<String, NamedIcon>());
iconMaps.put("ErrorTrack", new HashMap<String, NamedIcon>());
Iterator<Entry<String, HashMap<Integer, NamedIcon>>> it = _iconMaps.entrySet().iterator();
while (it.hasNext()) {
Entry<String, HashMap<Integer, NamedIcon>> entry = it.next();
HashMap<String, NamedIcon> clone = iconMaps.get(entry.getKey());
Iterator<Entry<Integer, NamedIcon>> iter = entry.getValue().entrySet().iterator();
while (iter.hasNext()) {
Entry<Integer, NamedIcon> ent = iter.next();
NamedIcon oldIcon = ent.getValue();
NamedIcon newIcon = cloneIcon(oldIcon, this);
newIcon.rotate(0, this);
newIcon.scale(1.0, this);
newIcon.setRotation(4, this);
clone.put(_state2nameMap.get(ent.getKey()), newIcon);
}
}
_TOPanel.initUpdate(updateAction, iconMaps);
_TOPanel.setSelection(getTurnout());
if (namedOccSensor != null) {
_TOPanel.setOccDetector(namedOccSensor.getBean().getDisplayName());
}
if (namedOccBlock != null) {
_TOPanel.setOccDetector(namedOccBlock.getBean().getDisplayName());
}
_TOPanel.setShowTrainName(_pathUtil.showTrain());
_TOPanel.setPaths(_pathUtil.getPaths());
_paletteFrame.add(_TOPanel);
_paletteFrame.pack();
_paletteFrame.setVisible(true);
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class IndicatorTurnoutIcon method displayState.
/**
* Drive the current state of the display from the state of the turnout and
* status of track.
*/
@Override
public void displayState(int state) {
if (getNamedTurnout() == null) {
log.debug("Display state " + state + ", disconnected");
} else {
if (_status != null && _iconMaps != null) {
NamedIcon icon = getIcon(_status, state);
if (icon != null) {
super.setIcon(icon);
}
}
}
super.displayState(state);
updateSize();
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class IndicatorTurnoutIcon method rotateOrthogonal.
/**
* ****** popup AbstractAction.actionPerformed method overrides ********
*/
@Override
protected void rotateOrthogonal() {
if (_iconMaps != null) {
Iterator<HashMap<Integer, NamedIcon>> it = _iconMaps.values().iterator();
while (it.hasNext()) {
Iterator<NamedIcon> iter = it.next().values().iterator();
while (iter.hasNext()) {
NamedIcon icon = iter.next();
icon.setRotation(icon.getRotation() + 1, this);
}
}
}
displayState(turnoutState());
}
use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.
the class IndicatorTrackIcon method editItem.
protected void editItem() {
makePaletteFrame(java.text.MessageFormat.format(Bundle.getMessage("EditItem"), Bundle.getMessage("IndicatorTrack")));
_trackPanel = new IndicatorItemPanel(_paletteFrame, "IndicatorTrack", _iconFamily, _editor);
ActionListener updateAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
updateItem();
}
};
// 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);
}
_trackPanel.init(updateAction, map);
if (namedOccSensor != null) {
_trackPanel.setOccDetector(namedOccSensor.getBean().getDisplayName());
}
if (namedOccBlock != null) {
_trackPanel.setOccDetector(namedOccBlock.getBean().getDisplayName());
}
_trackPanel.setShowTrainName(_pathUtil.showTrain());
_trackPanel.setPaths(_pathUtil.getPaths());
_paletteFrame.add(_trackPanel);
_paletteFrame.setLocationRelativeTo(this);
_paletteFrame.toFront();
_paletteFrame.pack();
_paletteFrame.setVisible(true);
}
Aggregations