use of jmri.jmrit.display.palette.IndicatorTOItemPanel in project JMRI by JMRI.
the class CircuitBuilder method convertIcon.
/**
* Converts icon to IndicatorTrack
*/
private void convertIcon(Positionable pos) {
_oldIcon = (PositionableLabel) pos;
_editor.highlight(_oldIcon);
_editor.toFront();
_editor.repaint();
if (pos instanceof TurnoutIcon) {
makePaletteFrame("IndicatorTO");
_trackTOPanel = new IndicatorTOItemPanel(_convertFrame, "IndicatorTO", null, null, _editor);
ActionListener updateAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
convertTO();
}
};
_trackTOPanel.init(updateAction);
_convertDialog.add(_trackTOPanel);
} else {
makePaletteFrame("IndicatorTrack");
_trackPanel = new IndicatorItemPanel(_convertFrame, "IndicatorTrack", null, _editor);
ActionListener updateAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent a) {
convertSeg();
}
};
_trackPanel.init(updateAction);
_convertDialog.add(_trackPanel);
}
_convertDialog.pack();
_convertDialog.setVisible(true);
_editor.repaint();
}
use of jmri.jmrit.display.palette.IndicatorTOItemPanel 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);
}
Aggregations