Search in sources :

Example 1 with IndicatorItemPanel

use of jmri.jmrit.display.palette.IndicatorItemPanel 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 IndicatorItemPanel

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

Aggregations

ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 IndicatorItemPanel (jmri.jmrit.display.palette.IndicatorItemPanel)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 IndicatorTOItemPanel (jmri.jmrit.display.palette.IndicatorTOItemPanel)1