001package jmri.jmrit.throttle;
002
003import java.awt.event.*;
004
005import jmri.DccThrottle;
006
007
008/**
009 *
010 * @author Lionel Jeanson
011 * 
012 * This class implements mouse wheel action on a throttle frame
013 * 
014 */
015public class ThrottleWindowInputsListener extends ThrottleWindowActions implements MouseWheelListener {
016
017    public ThrottleWindowInputsListener(ThrottleWindow tw) {
018        super(tw);
019    }
020
021    @Override
022    public void mouseWheelMoved(MouseWheelEvent e) {
023        // Throttle commands
024        DccThrottle throttle = tw.getCurrentThrottleFrame().getAddressPanel().getThrottle();
025        if (throttle != null) {
026            float multiplier;
027            if (e.getWheelRotation() > 0) {
028                multiplier = -1f;
029                if ( e.isControlDown() ) {
030                    multiplier = - tpwkc.getMoreSpeedMultiplier();
031                }
032            } else {
033                multiplier = 1f;
034                if ( e.isControlDown() ) {
035                    multiplier = tpwkc.getMoreSpeedMultiplier();
036                }
037            }
038            incrementSpeed(throttle, throttle.getSpeedIncrement() * multiplier);
039        }        
040    }
041}