Package jmri.jmrit.display.palette
Class ItemPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- jmri.jmrit.display.palette.ItemPanel
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
FamilyItemPanel
,IconItemPanel
,TextItemPanel
public abstract class ItemPanel extends javax.swing.JPanel
JPanels for the various item types that can be added to a Panel - e.g. Sensors, Turnouts, etc. Devices such as these have sets of icons to display their various states. Such sets are called a "family" in the code. These devices then may have sets of families to provide the user with a choice of the icon set to use for a particular device. These sets/families are defined in an xml file stored as xml/defaultPanelIcons.xml including the icon file paths, to be loaded by an iterator. The subclass FamilyItemPanel.java and its subclasses handles these devices. Other devices, e.g. Backgrounds or Memory, may use only one or no icon to display. The subclass IconItemPanel.java and its subclasses handles these devices.
-
-
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
_askOnce
protected javax.swing.JPanel
_bottomPanel
protected java.util.HashMap<java.lang.String,NamedIcon>
_currentIconMap
protected java.awt.event.ActionListener
_doneAction
protected DisplayFrame
_frame
protected javax.swing.JPanel
_iconFamilyPanel
protected ImagePanel
_iconPanel
protected boolean
_initialized
protected javax.swing.JPanel
_instructions
protected java.lang.String
_itemType
protected javax.swing.JTextField
_linkName
protected PreviewPanel
_previewPanel
protected boolean
_suppressDragging
protected boolean
_update
protected boolean
_wasEmpty
(package private) static java.lang.String[]
INDICATOR_TRACK
(package private) static java.lang.String[]
LIGHT
(package private) static java.lang.String[]
MULTISENSOR
protected static java.util.HashMap<java.lang.String,java.lang.String>
NAME_MAP
(package private) static java.lang.String[]
PORTAL
(package private) static java.lang.String[]
RPSREPORTER
(package private) static java.lang.String[]
SENSOR
(package private) static java.lang.String[]
SIGNALHEAD
protected static java.util.HashMap<java.lang.String,java.lang.String[]>
STATE_MAP
(package private) static java.lang.String[]
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 ItemPanel(DisplayFrame parentFrame, java.lang.String type)
Constructor for all item types.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addIconsToPanel(java.util.HashMap<java.lang.String,NamedIcon> iconMap, ImagePanel iconPanel, boolean dropIcon)
Add the current set of icons to a Show Icons pane.protected static void
checkIconMap(java.lang.String type, java.util.HashMap<java.lang.String,NamedIcon> map)
void
closeDialogs()
protected abstract void
hideIcons()
void
init()
Initialize panel for selecting a new Control Panel item or for updating an existing item.protected void
initIconFamiliesPanel()
Initialize or reset an ItemPanel.protected abstract javax.swing.JPanel
instructions()
static java.awt.GridBagConstraints
itemGridBagConstraint()
protected void
loadDefaultType()
protected void
makeBottomPanel(boolean isEmpty)
protected abstract void
makeFamiliesPanel()
Part of the initialization and reseting of an ItemPanel.protected abstract javax.swing.JPanel
makeIconDisplayPanel(java.lang.String key, java.util.HashMap<java.lang.String,NamedIcon> iconMap, boolean dropIcon)
Utility for above method.protected abstract javax.swing.JPanel
makeItemButtonPanel()
Make a button panel to populate editing an ItemPanelprotected java.util.HashMap<java.lang.String,NamedIcon>
makeNewIconMap(java.lang.String type)
protected void
makePreviewPanel(boolean hasMaps, ImagePanel dragIconPanel)
protected abstract javax.swing.JPanel
makeSpecialBottomPanel(boolean update)
Make a button panel that can populate an empty ItemPanelprotected javax.swing.JButton
makeUpdateButton(java.awt.event.ActionListener doneAction)
Add [Update] button to _bottom1Panel.protected boolean
mapsAreEqual(java.util.HashMap<java.lang.String,NamedIcon> mapOne, java.util.HashMap<java.lang.String,NamedIcon> mapTwo)
See if the map is supported by the family map.protected void
previewColorChange()
protected void
reSizeDisplay(boolean isPalette, java.awt.Dimension oldDim, java.awt.Dimension frameDim)
Resize frame to allow display/shrink after Icon map is dieplayed.java.awt.Dimension
shellDimension(ItemPanel panel)
protected void
wrapIconImage(NamedIcon icon, javax.swing.JLabel image, javax.swing.JPanel panel, java.lang.String key)
Utility used by implementations of above 'makeIconDisplayPanel' method to wrap its panel-
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
-
_frame
protected DisplayFrame _frame
-
_itemType
protected java.lang.String _itemType
-
_initialized
protected boolean _initialized
-
_update
protected boolean _update
-
_suppressDragging
protected boolean _suppressDragging
-
_askOnce
protected boolean _askOnce
-
_linkName
protected javax.swing.JTextField _linkName
-
_previewPanel
protected PreviewPanel _previewPanel
-
_currentIconMap
protected java.util.HashMap<java.lang.String,NamedIcon> _currentIconMap
-
_iconPanel
protected ImagePanel _iconPanel
-
_iconFamilyPanel
protected javax.swing.JPanel _iconFamilyPanel
-
_bottomPanel
protected javax.swing.JPanel _bottomPanel
-
_doneAction
protected java.awt.event.ActionListener _doneAction
-
_wasEmpty
protected boolean _wasEmpty
-
_instructions
protected javax.swing.JPanel _instructions
-
TURNOUT
static final java.lang.String[] TURNOUT
-
SENSOR
static final java.lang.String[] SENSOR
-
SIGNALHEAD
static final java.lang.String[] SIGNALHEAD
-
LIGHT
static final java.lang.String[] LIGHT
-
MULTISENSOR
static final java.lang.String[] MULTISENSOR
-
RPSREPORTER
static final java.lang.String[] RPSREPORTER
-
INDICATOR_TRACK
static final java.lang.String[] INDICATOR_TRACK
-
PORTAL
static final java.lang.String[] PORTAL
-
STATE_MAP
protected static java.util.HashMap<java.lang.String,java.lang.String[]> STATE_MAP
-
NAME_MAP
protected static java.util.HashMap<java.lang.String,java.lang.String> NAME_MAP
-
-
Constructor Detail
-
ItemPanel
public ItemPanel(DisplayFrame parentFrame, @Nonnull java.lang.String type)
Constructor for all item types.- Parameters:
parentFrame
- ItemPalette instancetype
- identifier of the ItemPanel type
-
-
Method Detail
-
init
public void init()
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.
-
makeNewIconMap
@Nonnull protected java.util.HashMap<java.lang.String,NamedIcon> makeNewIconMap(java.lang.String type)
-
checkIconMap
protected static void checkIconMap(java.lang.String type, java.util.HashMap<java.lang.String,NamedIcon> map)
-
previewColorChange
protected void previewColorChange()
-
closeDialogs
public void closeDialogs()
-
makeSpecialBottomPanel
protected abstract javax.swing.JPanel makeSpecialBottomPanel(boolean update)
Make a button panel that can populate an empty ItemPanel- Parameters:
update
- edit icons on a panel- Returns:
- the panel
-
makeItemButtonPanel
protected abstract javax.swing.JPanel makeItemButtonPanel()
Make a button panel to populate editing an ItemPanel- Returns:
- the panel
-
makeUpdateButton
protected javax.swing.JButton makeUpdateButton(java.awt.event.ActionListener doneAction)
Add [Update] button to _bottom1Panel.- Parameters:
doneAction
- Action for button- Returns:
- button with doneAction Action
-
makeBottomPanel
protected void makeBottomPanel(boolean isEmpty)
-
initIconFamiliesPanel
protected void initIconFamiliesPanel()
Initialize or reset an ItemPanel.
-
makePreviewPanel
protected void makePreviewPanel(boolean hasMaps, ImagePanel dragIconPanel)
-
addIconsToPanel
protected void addIconsToPanel(java.util.HashMap<java.lang.String,NamedIcon> iconMap, ImagePanel iconPanel, boolean dropIcon)
Add the current set of icons to a Show Icons pane. Used in several ways by different ItemPanels. When dropIcon is true, call may be from an editing dialog and the caller may allow the icon to dropped upon (replaced) or be the source of dragging it - (e.g. IconItemPanel). When_showIconsButton pressed, dropIcon will be false.- Parameters:
iconMap
- family mapsiconPanel
- panel to fill with iconsdropIcon
- true for ability to drop new image on icon to change icon source- See Also:
hideIcons()
-
makeIconDisplayPanel
protected abstract javax.swing.JPanel makeIconDisplayPanel(java.lang.String key, java.util.HashMap<java.lang.String,NamedIcon> iconMap, boolean dropIcon)
Utility for above method. Implementation returns a JPanel extension containing a bordered JLabel extension of icon and labels- Parameters:
key
- name of iconiconMap
- containing icon for possible replacementdropIcon
- JLabel extension may be replaceable or dragable.- Returns:
- the JPanel
-
wrapIconImage
protected void wrapIconImage(NamedIcon icon, javax.swing.JLabel image, javax.swing.JPanel panel, java.lang.String key)
Utility used by implementations of above 'makeIconDisplayPanel' method to wrap its panel- Parameters:
icon
- icon held by a JLabelimage
- background image for panelpanel
- holds image and JLablekey
- key of icon in its set - name for the icon can be extracted from it
-
instructions
protected abstract javax.swing.JPanel instructions()
-
makeFamiliesPanel
protected abstract void makeFamiliesPanel()
Part of the initialization and reseting of an ItemPanel. Allows divergence for different panel needs.
-
hideIcons
protected abstract void hideIcons()
-
mapsAreEqual
protected boolean mapsAreEqual(java.util.HashMap<java.lang.String,NamedIcon> mapOne, java.util.HashMap<java.lang.String,NamedIcon> mapTwo)
See if the map is supported by the family map. "Equals" in this context means that each map is the same size the keys are equal and the urls for the icons are equal. Note that icons with different urls may be or appear to be the same. The item type "SignalHead" allows for unequal sizes but 'mapOne' must contain 'mapTwo' elements.- Parameters:
mapOne
- an icon HashMapmapTwo
- another icon HashMap- Returns:
- true if all of signal head entries have matching entries in the family map.
-
loadDefaultType
protected void loadDefaultType()
-
reSizeDisplay
protected void reSizeDisplay(boolean isPalette, java.awt.Dimension oldDim, java.awt.Dimension frameDim)
Resize frame to allow display/shrink after Icon map is dieplayed.- Parameters:
isPalette
- selector for what to resize, true to resize parent tabbed frameoldDim
- old panel sizeframeDim
- old frame size
-
shellDimension
public java.awt.Dimension shellDimension(ItemPanel panel)
-
itemGridBagConstraint
public static java.awt.GridBagConstraints itemGridBagConstraint()
-
-