001package jmri.jmrit.logix;
002
003import jmri.SpeedStepMode;
004import jmri.Throttle;
005
006/**
007 * A JInternalFrame that contains a JSlider to control loco speed, and buttons
008 * for forward, reverse and STOP.
009 *
010 * @author Pete Cressman Copyright 2020
011 */
012public class LearnControlPanel extends jmri.jmrit.throttle.ControlPanel {
013
014    private final LearnThrottleFrame _throttleFrame;
015
016    LearnControlPanel(LearnThrottleFrame ltf) {
017        super();
018        _throttleFrame = ltf;
019        
020    }
021
022    // update the state of this panel if any of the properties change
023    @Override
024    public void propertyChange(java.beans.PropertyChangeEvent e) {
025        if (log.isDebugEnabled()) {
026            log.debug("propertyChange: {}, newValue= {}", e.getPropertyName(), e.getNewValue());
027        }
028        switch (e.getPropertyName()) {
029            case Throttle.SPEEDSETTING:
030                float speed = ((Float) e.getNewValue());
031                _throttleFrame.setSpeedSetting(speed);
032                break;
033            case Throttle.SPEEDSTEPS:
034                SpeedStepMode steps = (SpeedStepMode)e.getNewValue();
035                _throttleFrame.setSpeedStepMode(steps);
036                break;
037            case Throttle.ISFORWARD:
038                boolean forward = ((Boolean) e.getNewValue());
039                _throttleFrame.setButtonForward(forward);
040                break;
041            default:
042                break;
043        }
044        super.propertyChange(e);
045    }
046
047    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LearnControlPanel.class);
048
049}