Package jmri.jmrit.display.palette
Class FamilyItemPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- jmri.jmrit.display.palette.ItemPanel
-
- jmri.jmrit.display.palette.FamilyItemPanel
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
IndicatorItemPanel
,PortalItemPanel
,RPSItemPanel
,TableItemPanel
public abstract class FamilyItemPanel extends ItemPanel
ItemPanel general implementation for placement of CPE items having sets of icons (families). The "family" is the set of icons that represent the various states and/or status of the item.- See Also:
palette class diagram
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_cntlDown
protected IconDialog
_dialog
protected ImagePanel
_dragIconPanel
protected java.lang.String
_family
protected javax.swing.ButtonGroup
_familyButtonGroup
protected javax.swing.JPanel
_familyButtonPanel
protected boolean
_isUnstoredMap
protected javax.swing.JButton
_showIconsButton
protected java.util.HashMap<java.lang.String,NamedIcon>
_unstoredMap
protected javax.swing.JButton
_updateButton
(package private) javax.swing.Action
pressed
(package private) javax.swing.Action
released
-
Fields inherited from class jmri.jmrit.display.palette.ItemPanel
_askOnce, _bottomPanel, _currentIconMap, _doneAction, _frame, _iconFamilyPanel, _iconPanel, _initialized, _instructions, _itemType, _linkName, _previewPanel, _suppressDragging, _update, _wasEmpty, INDICATOR_TRACK, LIGHT, MULTISENSOR, NAME_MAP, PORTAL, RPSREPORTER, SENSOR, SIGNALHEAD, STATE_MAP, TURNOUT
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description FamilyItemPanel(DisplayFrame parentFrame, java.lang.String type, java.lang.String family)
Constructor types with multiple families and multiple icon families.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addCreateDeleteFamilyButtons(javax.swing.JPanel panel)
protected void
addFamilyPanels(boolean hasMaps)
void
closeDialogs()
protected void
deleteFamilySet()
Action item for deletion of an icon family.protected void
dialogDoneAction(java.lang.String family, java.util.HashMap<java.lang.String,NamedIcon> iconMap)
IconDialog calls this method to make any changes 'permanent'.void
dispose()
protected java.lang.String
findFamilyOfMap(java.lang.String exemptFamily, java.util.HashMap<java.lang.String,NamedIcon> newMap, java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,NamedIcon>> families)
Find the family name of the map in a families HashMap.javax.swing.JPanel
getBottomPanel()
Needed by CPE ConvertDialog.javaprotected abstract java.lang.String
getDisplayKey()
Get the key to display the icon to be used for dragging to the panelprotected javax.swing.JLabel
getDragger(java.awt.datatransfer.DataFlavor flavor, java.util.HashMap<java.lang.String,NamedIcon> map, NamedIcon icon)
java.lang.String
getFamilyName()
java.util.HashMap<java.lang.String,NamedIcon>
getIconMap()
Create icon set to panel icon display class.javax.swing.JButton
getUpdateButton()
protected java.lang.String
getValidFamilyName(java.lang.String family, java.util.HashMap<java.lang.String,NamedIcon> iconMap)
Check that family name proposed by user for an icon family 1. name is not a duplicate key 2. icon family is already stored.protected void
hideIcons()
void
init()
Initialize panel for selecting a new Control Panel item or for updating an existing item.void
init(java.awt.event.ActionListener doneAction, java.util.HashMap<java.lang.String,NamedIcon> iconMap)
Init for update of existing palette item type.void
init(javax.swing.JPanel bottomPanel)
Initialization for conversion of plain track to indicator track by CircuitBuilder.protected javax.swing.JPanel
instructions()
protected boolean
isUpdate()
protected void
makeDndIcon(java.util.HashMap<java.lang.String,NamedIcon> iconMap)
protected void
makeDragIconPanel()
Position initial Preview component on _iconFamilyPanel.protected void
makeFamiliesPanel()
Part of the initialization and reseting of an ItemPanel.protected void
makeFamilyButtons(java.util.Set<java.lang.String> keySet)
Make the _familyButtonPanel panel of buttons to select a family.protected javax.swing.JPanel
makeIconDisplayPanel(java.lang.String key, java.util.HashMap<java.lang.String,NamedIcon> iconMap, boolean dropIcon)
Utility for above method.protected javax.swing.JPanel
makeItemButtonPanel()
Make a button panel to populate editing an ItemPanelprotected javax.swing.JButton
makeShowIconsButton()
protected javax.swing.JPanel
makeSpecialBottomPanel(boolean update)
Replacement panel for _bottomPanel when no icon families exist for _itemType.protected javax.swing.JButton
makeUpdateButton(java.awt.event.ActionListener doneAction)
Add [Update] button to _bottomPanel.protected boolean
namesStoredMap(java.lang.String family)
protected void
openDialog(java.lang.String type, java.lang.String family)
protected void
previewColorChange()
protected void
setControlDown(boolean b)
protected void
setFamily()
Recover from cancelled Add Family dialogprotected void
setFamily(java.lang.String family)
Action of family radio button.protected void
setFamilyButton()
protected void
setFamilyMaps()
protected void
showIcons()
protected void
updateFamiliesPanel()
-
Methods inherited from class jmri.jmrit.display.palette.ItemPanel
addIconsToPanel, checkIconMap, initIconFamiliesPanel, itemGridBagConstraint, loadDefaultType, makeBottomPanel, makeNewIconMap, makePreviewPanel, mapsAreEqual, reSizeDisplay, shellDimension, wrapIconImage
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
_family
protected java.lang.String _family
-
_dragIconPanel
protected ImagePanel _dragIconPanel
-
_familyButtonPanel
protected javax.swing.JPanel _familyButtonPanel
-
_showIconsButton
protected javax.swing.JButton _showIconsButton
-
_updateButton
protected javax.swing.JButton _updateButton
-
_unstoredMap
protected java.util.HashMap<java.lang.String,NamedIcon> _unstoredMap
-
_dialog
protected IconDialog _dialog
-
_familyButtonGroup
protected javax.swing.ButtonGroup _familyButtonGroup
-
_isUnstoredMap
protected boolean _isUnstoredMap
-
_cntlDown
protected boolean _cntlDown
-
pressed
javax.swing.Action pressed
-
released
javax.swing.Action released
-
-
Constructor Detail
-
FamilyItemPanel
public FamilyItemPanel(DisplayFrame parentFrame, java.lang.String type, java.lang.String family)
Constructor types with multiple families and multiple icon families.- Parameters:
parentFrame
- enclosing parentFrametype
- bean typefamily
- icon family
-
-
Method Detail
-
init
public void init()
Description copied from class:ItemPanel
Initialize panel for selecting a new Control Panel item or for updating an existing item. Adds table if item is a bean. i.e. customizes for the item type. Called by enclosing TabbedPanel on change of displayed tab Pane.
-
init
public void init(java.awt.event.ActionListener doneAction, java.util.HashMap<java.lang.String,NamedIcon> iconMap)
Init for update of existing palette item type.- Parameters:
doneAction
- doneActioniconMap
- iconMap
-
init
public void init(javax.swing.JPanel bottomPanel)
Initialization for conversion of plain track to indicator track by CircuitBuilder.- Parameters:
bottomPanel
- button panel
-
getBottomPanel
public javax.swing.JPanel getBottomPanel()
Needed by CPE ConvertDialog.java- Returns:
- JPanel
-
getUpdateButton
public javax.swing.JButton getUpdateButton()
-
makeUpdateButton
protected javax.swing.JButton makeUpdateButton(java.awt.event.ActionListener doneAction)
Add [Update] button to _bottomPanel.- Overrides:
makeUpdateButton
in classItemPanel
- Parameters:
doneAction
- Action for button- Returns:
- button with doneAction Action
-
makeItemButtonPanel
protected javax.swing.JPanel makeItemButtonPanel()
Description copied from class:ItemPanel
Make a button panel to populate editing an ItemPanel- Specified by:
makeItemButtonPanel
in classItemPanel
- Returns:
- the panel
-
makeShowIconsButton
protected javax.swing.JButton makeShowIconsButton()
-
makeSpecialBottomPanel
protected javax.swing.JPanel makeSpecialBottomPanel(boolean update)
Replacement panel for _bottomPanel when no icon families exist for _itemType.- Specified by:
makeSpecialBottomPanel
in classItemPanel
- Parameters:
update
- edit icons on a panel- Returns:
- the panel
-
addCreateDeleteFamilyButtons
protected void addCreateDeleteFamilyButtons(javax.swing.JPanel panel)
-
getValidFamilyName
protected java.lang.String getValidFamilyName(java.lang.String family, java.util.HashMap<java.lang.String,NamedIcon> iconMap)
Check that family name proposed by user for an icon family 1. name is not a duplicate key 2. icon family is already stored. (Sets "_isUnstoredMap" flag.)- Parameters:
family
- name for icon seticonMap
- map the family name refers to.- Returns:
- valid family name or null if user declines to provide a valid name.
-
findFamilyOfMap
protected java.lang.String findFamilyOfMap(java.lang.String exemptFamily, java.util.HashMap<java.lang.String,NamedIcon> newMap, java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,NamedIcon>> families)
Find the family name of the map in a families HashMap.- Parameters:
exemptFamily
- exclude from matchingnewMap
- iconMapfamilies
- families of itemType- Returns:
- null if map is not in the family
-
namesStoredMap
protected boolean namesStoredMap(java.lang.String family)
-
makeFamiliesPanel
protected void makeFamiliesPanel()
Description copied from class:ItemPanel
Part of the initialization and reseting of an ItemPanel. Allows divergence for different panel needs.- Specified by:
makeFamiliesPanel
in classItemPanel
-
instructions
protected javax.swing.JPanel instructions()
- Specified by:
instructions
in classItemPanel
-
addFamilyPanels
protected void addFamilyPanels(boolean hasMaps)
-
updateFamiliesPanel
protected void updateFamiliesPanel()
-
makeFamilyButtons
protected void makeFamilyButtons(java.util.Set<java.lang.String> keySet)
Make the _familyButtonPanel panel of buttons to select a family. Create and set actions of radioButtons to change family on pane.- Parameters:
keySet
- of icon family names
-
makeDragIconPanel
protected void makeDragIconPanel()
Position initial Preview component on _iconFamilyPanel. If already present, keep and clear it.
-
makeIconDisplayPanel
protected javax.swing.JPanel makeIconDisplayPanel(java.lang.String key, java.util.HashMap<java.lang.String,NamedIcon> iconMap, boolean dropIcon)
Description copied from class:ItemPanel
Utility for above method. Implementation returns a JPanel extension containing a bordered JLabel extension of icon and labels- Specified by:
makeIconDisplayPanel
in classItemPanel
- Parameters:
key
- name of iconiconMap
- containing icon for possible replacementdropIcon
- JLabel extension may be replaceable or dragable.- Returns:
- the JPanel
-
getDragger
protected javax.swing.JLabel getDragger(java.awt.datatransfer.DataFlavor flavor, java.util.HashMap<java.lang.String,NamedIcon> map, NamedIcon icon)
-
makeDndIcon
protected void makeDndIcon(java.util.HashMap<java.lang.String,NamedIcon> iconMap)
-
getDisplayKey
protected abstract java.lang.String getDisplayKey()
Get the key to display the icon to be used for dragging to the panel- Returns:
- key for desired icon
-
showIcons
protected void showIcons()
-
deleteFamilySet
protected void deleteFamilySet()
Action item for deletion of an icon family.
-
setControlDown
protected void setControlDown(boolean b)
-
openDialog
protected void openDialog(java.lang.String type, java.lang.String family)
-
dialogDoneAction
protected void dialogDoneAction(java.lang.String family, java.util.HashMap<java.lang.String,NamedIcon> iconMap)
IconDialog calls this method to make any changes 'permanent'. It is responsible for testing that the changes are valid.- Parameters:
family
- family name, possibly changediconMap
- family map, possibly changed
-
isUpdate
protected boolean isUpdate()
-
closeDialogs
public void closeDialogs()
- Overrides:
closeDialogs
in classItemPanel
-
dispose
public void dispose()
-
setFamily
protected void setFamily()
Recover from cancelled Add Family dialog
-
setFamily
protected void setFamily(java.lang.String family)
Action of family radio button. MultiSensorItemPanel and IndicatorTOItemPanel must override.- Parameters:
family
- icon family name
-
setFamilyMaps
protected void setFamilyMaps()
-
setFamilyButton
protected void setFamilyButton()
-
previewColorChange
protected void previewColorChange()
- Overrides:
previewColorChange
in classItemPanel
-
getIconMap
public java.util.HashMap<java.lang.String,NamedIcon> getIconMap()
Create icon set to panel icon display class.- Returns:
- updated icon map
-
getFamilyName
public java.lang.String getFamilyName()
-
-