Search in sources :

Example 1 with IndicatorTOItemPanel

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();
}
Also used : IndicatorTOItemPanel(jmri.jmrit.display.palette.IndicatorTOItemPanel) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IndicatorTurnoutIcon(jmri.jmrit.display.IndicatorTurnoutIcon) TurnoutIcon(jmri.jmrit.display.TurnoutIcon) IndicatorItemPanel(jmri.jmrit.display.palette.IndicatorItemPanel)

Example 2 with IndicatorTOItemPanel

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);
}
Also used : IndicatorTOItemPanel(jmri.jmrit.display.palette.IndicatorTOItemPanel) NamedIcon(jmri.jmrit.catalog.NamedIcon) HashMap(java.util.HashMap) ActionEvent(java.awt.event.ActionEvent) Entry(java.util.Map.Entry) ActionListener(java.awt.event.ActionListener)

Aggregations

ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 IndicatorTOItemPanel (jmri.jmrit.display.palette.IndicatorTOItemPanel)2 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 NamedIcon (jmri.jmrit.catalog.NamedIcon)1 IndicatorTurnoutIcon (jmri.jmrit.display.IndicatorTurnoutIcon)1 TurnoutIcon (jmri.jmrit.display.TurnoutIcon)1 IndicatorItemPanel (jmri.jmrit.display.palette.IndicatorItemPanel)1