Class 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.
    See Also:
    for class diagram for the palette package., 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
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • 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
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • 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 ItemPanel
      protected 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 ItemPanel
      protected 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ItemPanel

        public ItemPanel​(DisplayFrame parentFrame,
                         @Nonnull
                         java.lang.String type)
        Constructor for all item types.
        Parameters:
        parentFrame - ItemPalette instance
        type - 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.
      • checkIconMap

        protected static void checkIconMap​(java.lang.String type,
                                           java.util.HashMap<java.lang.String,​NamedIcon> map)
      • 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
      • 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 maps
        iconPanel - panel to fill with icons
        dropIcon - 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 icon
        iconMap - containing icon for possible replacement
        dropIcon - 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 JLabel
        image - background image for panel
        panel - holds image and JLable
        key - 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 HashMap
        mapTwo - another icon HashMap
        Returns:
        true if all of signal head entries have matching entries in the family map.
      • 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 frame
        oldDim - old panel size
        frameDim - old frame size