jmri.jmrit.display
Class SlipTurnoutIcon

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by jmri.jmrit.display.PositionableLabel
                      extended by jmri.jmrit.display.SlipTurnoutIcon
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, Cloneable, EventListener, Accessible, SwingConstants, Positionable

public class SlipTurnoutIcon
extends PositionableLabel
implements PropertyChangeListener

An icon to display a status of a Slip, either Single or Double.

This responds to only KnownState, leaving CommandedState to some other graphic representation later.

A click on the icon will command a state change. Specifically, it will set the CommandedState to the opposite (THROWN vs CLOSED) of the current KnownState.

Note: lower west to lower east icon is used for storing the slip icon, in a single slip, even if the slip is set for upper west to upper east.

With a 3-Way point we use the following translations

Based upon the TurnoutIcon by Bob Jacobsen

Author:
Kevin Dickerson Copyright (c) 2010
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
 
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
static int DOUBLESLIP
          Constant used to refer to a Double Slip Configuration.
static int EAST
          Constant used to referred to the Turnout address configured to operate the east (or second for a three way) of the Turnout.
static int LOWEREAST
          Constant used for a scissor crossing using 4 turnout address, and refers to the turnout located at the lower east.
static int LOWERWEST
          Constant used for a scissor crossing using 4 turnout address, and refers to the turnout located at the lower west.
static int SCISSOR
          Constant used to refer to a Scissor (Double Crossover) Configuration.
static int SINGLESLIP
          Constant used to refer to a Single Slip Configuration.
static int THREEWAY
          Constant used to refer to a Three Way Turnout Configuration.
static int WEST
          Constant used to referred to the Turnout address configured to operate the west (or first for a three way) of the Turnout.
 
Fields inherited from class jmri.jmrit.display.PositionableLabel
_control, _controlling, _displayLevel, _editable, _editor, _hidden, _icon, _namedIcon, _positionable, _showTooltip, _text, _tooltip, _viewCoordinates, rb, rbean
 
Fields inherited from class javax.swing.JLabel
labelFor
 
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.SwingConstants
BOTTOM, CENTER, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SlipTurnoutIcon(Editor editor)
           
 
Method Summary
 void dispose()
          Clean up when this object is no longer needed.
 void doMouseClicked(MouseEvent e)
          Throw the turnout when the icon is clicked
protected  void edit()
           
 NamedIcon getInconsistentIcon()
           
 NamedIcon getLowerWestToLowerEastIcon()
           
 NamedIcon getLowerWestToUpperEastIcon()
           
 String getLWLEText()
          Get the text used in the pop-up for setting the route from Lower West to Lower East.
 String getLWUEText()
          Get the text used in the pop-up for setting the route from Lower West to Upper East For a scissor crossing this the Left-hand crossing.
 NamedBeanHandle<Turnout> getNamedTurnout(int turn)
           
 String getNameString()
          Methods to add popup menu items return true if a popup item is set
 boolean getSingleSlipRoute()
          Single Slip Route, determines if the slip route is from upper west to upper east (true) or lower west to lower east (false) This also doubles up for the three way and determines if the first turnout routes to the upper (true) or lower (false) exit point.
 boolean getTristate()
           
 Turnout getTurnout(int turn)
          Returns the turnout located at the position specified.
protected  HashMap<Turnout,Integer> getTurnoutSettings()
           
 int getTurnoutType()
           
 NamedIcon getUnknownIcon()
           
 NamedIcon getUpperWestToLowerEastIcon()
           
 NamedIcon getUpperWestToUpperEastIcon()
           
 String getUWLEText()
          Get the text used in the pop-up for setting the route from Upper West to Lower East.
 String getUWUEText()
          Get the text used in the pop-up for setting the route from Upper West to Upper East.
protected  boolean isSlipBusy()
          Method to query if Slip is busy (returns true if commands are being issued to Slips turnouts)
 int maxHeight()
           
 int maxWidth()
           
 void propertyChange(PropertyChangeEvent e)
           
protected  void reset()
           
 void rotate(int deg)
           
protected  void rotateOrthogonal()
          popup AbstractAction.actionPerformed method overrides
 void setInconsistentIcon(NamedIcon i)
           
 void setLowerWestToLowerEastIcon(NamedIcon i)
           
 void setLowerWestToUpperEastIcon(NamedIcon i)
           
 void setLWLEText(String txt)
           
 void setLWUEText(String txt)
           
 void setScale(double s)
           
 void setSingleSlipRoute(boolean route)
           
protected  void setSlipBusy()
          Method to set Slip busy when commands are being issued to Slip turnouts
protected  void setSlipNotBusy()
          Method to set Slip not busy when all commands have been issued to Slip turnouts
 boolean setTextEditMenu(JPopupMenu popup)
           
 void setTristate(boolean set)
           
 void setTurnout(NamedBeanHandle<Turnout> to, int turn)
          Attached a namedBean Handle turnout to this display item
 void setTurnout(String pName, int turn)
          Attached a named turnout to this display item
 void setTurnoutType(int slip)
          Sets the type of turnout configuration which is being used
 void setUnknownIcon(NamedIcon i)
           
 void setUpperWestToLowerEastIcon(NamedIcon i)
           
 void setUpperWestToUpperEastIcon(NamedIcon i)
           
 void setUWLEText(String txt)
           
 void setUWUEText(String txt)
           
 boolean showPopUp(JPopupMenu popup)
          Displays a popup menu to select a given state, rather than cycling through each state
 void slipTurnoutTextEdit(String name)
           
 
Methods inherited from class jmri.jmrit.display.PositionableLabel
cloneIcon, deepClone, doMouseDragged, doMouseEntered, doMouseExited, doMouseMoved, doMousePressed, doMouseReleased, doViemMenu, editIcon, finishClone, getDegrees, getDisplayLevel, getEditor, getPopupUtility, getScale, getTooltip, getViewCoordinates, isActive, isBackground, isControl, isControlling, isEditable, isHidden, isIcon, isPositionable, isText, makeIconEditorFrame, makePalettteFrame, remove, setControlling, setDisableControlMenu, setDisplayLevel, setEditable, setEditIconMenu, setEditItemMenu, setEditor, setHidden, setLevel, setPopupUtility, setPositionable, setRotateMenu, setRotateOrthogonalMenu, setScaleMenu, setShowTooltip, setTooltip, setViewCoordinates, showHidden, showTooltip, storeItem, updateIcon, updateSize
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, 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, getRootPane, 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, paintComponent, 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, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, 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, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, getFocusCycleRootAncestor, 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, hide, 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, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmri.jmrit.display.Positionable
contains, getBackground, getBounds, getFont, getForeground, getHeight, getLocation, getParent, getPreferredSize, getWidth, getX, getY, invalidate, isOpaque, repaint, setBackground, setBorder, setForeground, setLocation, setLocation, setOpaque, setSize, setVisible
 

Field Detail

WEST

public static final int WEST
Constant used to referred to the Turnout address configured to operate the west (or first for a three way) of the Turnout.

See Also:
Constant Field Values

EAST

public static final int EAST
Constant used to referred to the Turnout address configured to operate the east (or second for a three way) of the Turnout.

See Also:
Constant Field Values

LOWERWEST

public static final int LOWERWEST
Constant used for a scissor crossing using 4 turnout address, and refers to the turnout located at the lower west.

See Also:
Constant Field Values

LOWEREAST

public static final int LOWEREAST
Constant used for a scissor crossing using 4 turnout address, and refers to the turnout located at the lower east.

See Also:
Constant Field Values

DOUBLESLIP

public static final int DOUBLESLIP
Constant used to refer to a Double Slip Configuration.

See Also:
Constant Field Values

SINGLESLIP

public static final int SINGLESLIP
Constant used to refer to a Single Slip Configuration.

See Also:
Constant Field Values

THREEWAY

public static final int THREEWAY
Constant used to refer to a Three Way Turnout Configuration.

See Also:
Constant Field Values

SCISSOR

public static final int SCISSOR
Constant used to refer to a Scissor (Double Crossover) Configuration.

See Also:
Constant Field Values
Constructor Detail

SlipTurnoutIcon

public SlipTurnoutIcon(Editor editor)
Method Detail

setTurnout

public void setTurnout(String pName,
                       int turn)
Attached a named turnout to this display item

Parameters:
pName - Used as a system/user name to lookup the turnout object
turn - is used to determine which turnout position this is for. 0x01 - West 0x02 - East 0x04 - Lower West 0x06 - Upper East

setTurnout

public void setTurnout(NamedBeanHandle<Turnout> to,
                       int turn)
Attached a namedBean Handle turnout to this display item

Parameters:
to - Used as the NamedBeanHandle to lookup the turnout object
turn - is used to determine which turnout position this is for.
  • 0x01 - West
  • 0x02 - East
  • 0x04 - Lower West
  • 0x06 - Upper East

setTurnoutType

public void setTurnoutType(int slip)
Sets the type of turnout configuration which is being used

Parameters:
slip - - valid values are
  • 0x00 - Double Slip
  • 0x02 - Single Slip
  • 0x04 - Three Way Turnout
  • 0x08 - Scissor Crossing

getTurnoutType

public int getTurnoutType()

getSingleSlipRoute

public boolean getSingleSlipRoute()
Single Slip Route, determines if the slip route is from upper west to upper east (true) or lower west to lower east (false) This also doubles up for the three way and determines if the first turnout routes to the upper (true) or lower (false) exit point. returns

In a Scissor crossing this returns true if only two turnout address are required to set the crossing or false if four turnout address are required


setSingleSlipRoute

public void setSingleSlipRoute(boolean route)

getTurnout

public Turnout getTurnout(int turn)
Returns the turnout located at the position specified.

Parameters:
turn - See constants for EAST, WEST, LOWEREAST, LOWERWEST

getNamedTurnout

public NamedBeanHandle<Turnout> getNamedTurnout(int turn)

getLowerWestToUpperEastIcon

public NamedIcon getLowerWestToUpperEastIcon()

setLowerWestToUpperEastIcon

public void setLowerWestToUpperEastIcon(NamedIcon i)

getUpperWestToLowerEastIcon

public NamedIcon getUpperWestToLowerEastIcon()

setUpperWestToLowerEastIcon

public void setUpperWestToLowerEastIcon(NamedIcon i)

getLowerWestToLowerEastIcon

public NamedIcon getLowerWestToLowerEastIcon()

setLowerWestToLowerEastIcon

public void setLowerWestToLowerEastIcon(NamedIcon i)

getUpperWestToUpperEastIcon

public NamedIcon getUpperWestToUpperEastIcon()

setUpperWestToUpperEastIcon

public void setUpperWestToUpperEastIcon(NamedIcon i)

getInconsistentIcon

public NamedIcon getInconsistentIcon()

setInconsistentIcon

public void setInconsistentIcon(NamedIcon i)

getUnknownIcon

public NamedIcon getUnknownIcon()

setUnknownIcon

public void setUnknownIcon(NamedIcon i)

maxHeight

public int maxHeight()
Specified by:
maxHeight in interface Positionable
Overrides:
maxHeight in class PositionableLabel

maxWidth

public int maxWidth()
Specified by:
maxWidth in interface Positionable
Overrides:
maxWidth in class PositionableLabel

propertyChange

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

getNameString

public String getNameString()
Description copied from interface: Positionable
Methods to add popup menu items return true if a popup item is set

Specified by:
getNameString in interface Positionable
Overrides:
getNameString in class PositionableLabel

setTristate

public void setTristate(boolean set)

getTristate

public boolean getTristate()

rotateOrthogonal

protected void rotateOrthogonal()
popup AbstractAction.actionPerformed method overrides

Overrides:
rotateOrthogonal in class PositionableLabel

setScale

public void setScale(double s)
Specified by:
setScale in interface Positionable
Overrides:
setScale in class PositionableLabel

rotate

public void rotate(int deg)
Specified by:
rotate in interface Positionable
Overrides:
rotate in class PositionableLabel

getLWUEText

public String getLWUEText()
Get the text used in the pop-up for setting the route from Lower West to Upper East For a scissor crossing this the Left-hand crossing. For a 3 Way turnout this is the Upper Exit.


getUWLEText

public String getUWLEText()
Get the text used in the pop-up for setting the route from Upper West to Lower East. For a scissor crossing this the Right-hand crossing. For a 3 Way turnout this is the Middle Exit.


getLWLEText

public String getLWLEText()
Get the text used in the pop-up for setting the route from Lower West to Lower East. For a scissor crossing this the Straight (Normal) Route. For a 3 Way turnout this is the Lower Exit.


getUWUEText

public String getUWUEText()
Get the text used in the pop-up for setting the route from Upper West to Upper East. For a scissor crossing this is not used. For a 3 Way turnout this is not used.


setLWUEText

public void setLWUEText(String txt)

setUWLEText

public void setUWLEText(String txt)

setLWLEText

public void setLWLEText(String txt)

setUWUEText

public void setUWUEText(String txt)

edit

protected void edit()
Overrides:
edit in class PositionableLabel

doMouseClicked

public void doMouseClicked(MouseEvent e)
Throw the turnout when the icon is clicked

Specified by:
doMouseClicked in interface Positionable
Overrides:
doMouseClicked in class PositionableLabel
Parameters:
e -

getTurnoutSettings

protected HashMap<Turnout,Integer> getTurnoutSettings()

reset

protected void reset()

showPopUp

public boolean showPopUp(JPopupMenu popup)
Displays a popup menu to select a given state, rather than cycling through each state

Specified by:
showPopUp in interface Positionable
Overrides:
showPopUp in class PositionableLabel
Parameters:
popup -

setTextEditMenu

public boolean setTextEditMenu(JPopupMenu popup)
Specified by:
setTextEditMenu in interface Positionable
Overrides:
setTextEditMenu in class PositionableLabel

slipTurnoutTextEdit

public void slipTurnoutTextEdit(String name)

dispose

public void dispose()
Description copied from class: PositionableLabel
Clean up when this object is no longer needed. Should not be called while the object is still displayed; see remove()

Overrides:
dispose in class PositionableLabel

setSlipBusy

protected void setSlipBusy()
Method to set Slip busy when commands are being issued to Slip turnouts


setSlipNotBusy

protected void setSlipNotBusy()
Method to set Slip not busy when all commands have been issued to Slip turnouts


isSlipBusy

protected boolean isSlipBusy()
Method to query if Slip is busy (returns true if commands are being issued to Slips turnouts)



Copyright © 1997 - 2011 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