jmri.jmrit.throttle
Class ControlPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JInternalFrame
                  extended by jmri.jmrit.throttle.ControlPanel
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, AddressListener

public class ControlPanel
extends JInternalFrame
implements PropertyChangeListener, ActionListener, AddressListener

A JInternalFrame that contains a JSlider to control loco speed, and buttons for forward, reverse and STOP.

TODO: fix speed increments (14, 28)

See Also:
Serialized Form

Nested Class Summary
(package private)  class ControlPanel.ControlPadKeyListener
          A KeyAdapter that listens for the keys that work the control pad buttons
(package private) static class ControlPanel.PopupListener
          A PopupListener to handle mouse clicks and releases.
 
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIcon
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 int accelerateKey
           
 int accelerateKey1
           
 int accelerateKey2
           
static int BUTTON_SIZE
           
 int decelerateKey
           
 int decelerateKey1
           
 int decelerateKey2
           
 int forwardKey
           
 int idleKey
           
(package private) static org.slf4j.Logger log
           
 int reverseKey
           
static int SLIDERDISPLAY
           
static int SLIDERDISPLAYCONTINUOUS
           
static int STEPDISPLAY
           
 int stopKey
           
 
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ControlPanel()
          Constructor.
 
Method Summary
 void accelerate1()
           
 void accelerate10()
           
 void actionPerformed(ActionEvent e)
          Handle the selection from the popup menu.
 void decelerate1()
           
 void decelerate10()
           
 void destroy()
           
 int getDisplaySlider()
          Get the value indicating what speed input we're displaying
 boolean getIsForward()
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 JSlider getSpeedSlider()
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 String getSwitchSliderFunction()
           
 boolean getTrackSlider()
          Get status of real-time speed slider tracking
 org.jdom.Element getXml()
          Collect the prefs of this object into XML Element Window prefs
 boolean isSpeedControllerAvailable(int displaySlider)
          Is this Speed Control selection method possible?
 void notifyAddressChosen(LocoAddress l)
          Receive notification that a new address has been selected.
 void notifyAddressReleased(LocoAddress la)
          Receive notification that an address has been released/dispatched
 void notifyAddressThrottleFound(DccThrottle t)
          Receive notification that a throttle has been found
 void notifyConsistAddressChosen(int newAddress, boolean isLong)
          Receive notification that a new Consist address has been selected.
 void notifyConsistAddressReleased(int address, boolean isLong)
          Receive notification that a consist address has been released/dispatched
 void notifyConsistAddressThrottleFound(DccThrottle throttle)
          Receive notification that a throttle has been found
 void propertyChange(PropertyChangeEvent e)
           
 void saveToRoster(RosterEntry re)
           
 void setAddressPanel(AddressPanel addressPanel)
           
 void setEnabled(boolean isEnabled)
          Enable/Disable all buttons and slider.
 void setForwardDirection(boolean isForward)
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 void setIsForward(boolean isForward)
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 void setSpeedController(int displaySlider)
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 void setSpeedStepsMode(int speedStepMode)
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 void setSpeedValues(float speedIncrement, float speed)
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 void setSwitchSliderFunction(String fn)
           
 void setTrackSlider(boolean track)
          Set real-time tracking of speed slider, or not
 void setXml(org.jdom.Element e)
          Set the preferences based on the XML Element.
 void stop()
          Deprecated. You should not directly manipulate the UI. Use a throttle object instead.
 
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SLIDERDISPLAY

public static final int SLIDERDISPLAY
See Also:
Constant Field Values

STEPDISPLAY

public static final int STEPDISPLAY
See Also:
Constant Field Values

SLIDERDISPLAYCONTINUOUS

public static final int SLIDERDISPLAYCONTINUOUS
See Also:
Constant Field Values

BUTTON_SIZE

public static final int BUTTON_SIZE
See Also:
Constant Field Values

accelerateKey

public int accelerateKey

decelerateKey

public int decelerateKey

accelerateKey1

public int accelerateKey1

decelerateKey1

public int decelerateKey1

accelerateKey2

public int accelerateKey2

decelerateKey2

public int decelerateKey2

reverseKey

public int reverseKey

forwardKey

public int forwardKey

stopKey

public int stopKey

idleKey

public int idleKey

log

static org.slf4j.Logger log
Constructor Detail

ControlPanel

public ControlPanel()
Constructor.

Method Detail

setAddressPanel

public void setAddressPanel(AddressPanel addressPanel)

destroy

public void destroy()

setEnabled

public void setEnabled(boolean isEnabled)
Enable/Disable all buttons and slider.

Overrides:
setEnabled in class JComponent
Parameters:
isEnabled - True if the buttons/slider should be enabled, false otherwise.

setIsForward

public void setIsForward(boolean isForward)
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Set the GUI to match that the loco is set to forward. TODO: move to private

Parameters:
isForward - True if the loco is set to forward, false otherwise.

getIsForward

public boolean getIsForward()
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Get the GUI direction. TODO: move to private

Returns:
True if the loco is set to forward, false otherwise.

setForwardDirection

public void setForwardDirection(boolean isForward)
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Set forward/reverse direction in both the GUI and on the layout TODO: move to private


setSpeedStepsMode

public void setSpeedStepsMode(int speedStepMode)
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Set the GUI to match the speed steps of the current address. Initialises the speed slider and spinner - including setting their maximums based on the speed step setting and the max speed for the particular loco TODO: move to private

Parameters:
speedStepMode - Desired speed step mode. One of: DccThrottle.SpeedStepMode128, DccThrottle.SpeedStepMode28, DccThrottle.SpeedStepMode27, DccThrottle.SpeedStepMode14 step mode

isSpeedControllerAvailable

public boolean isSpeedControllerAvailable(int displaySlider)
Is this Speed Control selection method possible?

Parameters:
displaySlider - integer value. possible values: SLIDERDISPLAY = use speed slider display STEPDISPLAY = use speed step display

setSpeedController

public void setSpeedController(int displaySlider)
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Set the Speed Control selection method TODO: move to private

Parameters:
displaySlider - integer value. possible values: SLIDERDISPLAY = use speed slider display STEPDISPLAY = use speed step display

getDisplaySlider

public int getDisplaySlider()
Get the value indicating what speed input we're displaying


setTrackSlider

public void setTrackSlider(boolean track)
Set real-time tracking of speed slider, or not

Parameters:
track - boolean value, true to track, false to set speed on unclick

getTrackSlider

public boolean getTrackSlider()
Get status of real-time speed slider tracking


setSpeedValues

public void setSpeedValues(float speedIncrement,
                           float speed)
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Set the GUI to match that the loco speed. TODO: move to private

Parameters:
speedIncrement - The throttle back end's speed increment value - % increase for each speed step.
speed - The speed value of the loco.

getSpeedSlider

public JSlider getSpeedSlider()
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Get the speed slider. TODO: move to private


stop

public void stop()
Deprecated. You should not directly manipulate the UI. Use a throttle object instead.

Perform an emergency stop. TODO: move to private


accelerate1

public void accelerate1()

accelerate10

public void accelerate10()

decelerate1

public void decelerate1()

decelerate10

public void decelerate10()

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

actionPerformed

public void actionPerformed(ActionEvent e)
Handle the selection from the popup menu.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - The ActionEvent causing the action.

getXml

public org.jdom.Element getXml()
Collect the prefs of this object into XML Element

Returns:
the XML of this object.

setXml

public void setXml(org.jdom.Element e)
Set the preferences based on the XML Element.

Parameters:
e - The Element for this object.

notifyAddressChosen

public void notifyAddressChosen(LocoAddress l)
Description copied from interface: AddressListener
Receive notification that a new address has been selected.

Specified by:
notifyAddressChosen in interface AddressListener
Parameters:
l - The address that is now selected.

notifyAddressReleased

public void notifyAddressReleased(LocoAddress la)
Description copied from interface: AddressListener
Receive notification that an address has been released/dispatched

Specified by:
notifyAddressReleased in interface AddressListener
Parameters:
la - The address released/dispatched

notifyAddressThrottleFound

public void notifyAddressThrottleFound(DccThrottle t)
Description copied from interface: AddressListener
Receive notification that a throttle has been found

Specified by:
notifyAddressThrottleFound in interface AddressListener
Parameters:
t - The throttle

notifyConsistAddressChosen

public void notifyConsistAddressChosen(int newAddress,
                                       boolean isLong)
Description copied from interface: AddressListener
Receive notification that a new Consist address has been selected.

Specified by:
notifyConsistAddressChosen in interface AddressListener
Parameters:
newAddress - The address that is now selected.

notifyConsistAddressReleased

public void notifyConsistAddressReleased(int address,
                                         boolean isLong)
Description copied from interface: AddressListener
Receive notification that a consist address has been released/dispatched

Specified by:
notifyConsistAddressReleased in interface AddressListener
Parameters:
address - The address released/dispatched

notifyConsistAddressThrottleFound

public void notifyConsistAddressThrottleFound(DccThrottle throttle)
Description copied from interface: AddressListener
Receive notification that a throttle has been found

Specified by:
notifyConsistAddressThrottleFound in interface AddressListener
Parameters:
throttle - The throttle

setSwitchSliderFunction

public void setSwitchSliderFunction(String fn)

getSwitchSliderFunction

public String getSwitchSliderFunction()

saveToRoster

public void saveToRoster(RosterEntry re)


Copyright © 1997-2013 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads