Class CalendarHeaderHandler

  • Direct Known Subclasses:
    BasicCalendarHeaderHandler, SpinningCalendarHeaderHandler

    public abstract class CalendarHeaderHandler
    extends java.lang.Object
    Provides and wires a component appropriate as a calendar navigation header. The design idea is to support a pluggable header for a zoomable (PENDING JW: naming!) JXMonthView. Then custom implementations can be tailored to exactly fit their needs.

    To install a custom implementation, register the class name of the custom header handler with the key CalendarHeaderHandler.uiControllerID , example:

     
      UIManager.put(CalendarHeaderHandler.uiControllerID, "com.foo.bar.MagicHeaderHandler")
     
     
    Basic navigation action should (will) be defined by the ui delegate itself (PENDING JW: still incomplete in BasicMonthViewUI). This handler can modify/enhance them as appropriate for its context.

    PENDING JW: those icons ... who's responsible? Shouldn't we use any of the default arrows as defined in the laf anyway (are there any?)

    Note: this is work-in-progress, be prepared to change if subclassing for custom requirements!

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void componentOrientationChanged()
      Synchronizes internal state which depends on the month view's componentOrientation.
      protected abstract javax.swing.JComponent createCalendarHeader()
      Creates and returns the component used as header in a zoomable monthView.
      protected java.awt.Font createDerivedFont()
      Create a derived font used to when painting various pieces of the month view component.
      protected void fontChanged()
      Synchronizes internal state which depends on the month view's font.
      private java.awt.Color getAsNotUIResource​(java.awt.Color color)
      Returns a Color based on the param which is not of type UIResource.
      private java.awt.Font getAsNotUIResource​(java.awt.Font font)
      Returns a Font based on the param which is not of type UIResource.
      javax.swing.JComponent getHeaderComponent()
      Returns a component to be used as header in a zoomable month view, guaranteed to be not null.
      private java.beans.PropertyChangeListener getMonthViewPropertyChangeListener()
      Returns the propertyChangelistener for the monthView.
      void install​(JXMonthView monthView)
      Installs this handler to the given month view.
      protected void installListeners()
      Creates and registered listeners on the monthView as appropriate.
      protected void installNavigationActions()
      Installs and configures navigational actions.
      private void installWrapper​(java.lang.String actionKey, java.lang.String newActionKey, javax.swing.Icon icon)
      Creates an life action wrapper around the action registered with actionKey, sets its SMALL_ICON property to the given icon and installs itself with the newActionKey.
      protected void monthStringBackgroundChanged()
      Synchronizes internal state which depends on the month view's monthStringBackground.
      void uninstall​(JXMonthView monthView)
      Uninstalls this handler from the given target month view.
      protected void uninstallListeners()
      Unregisters listeners which had been installed to the monthView.
      private void updateActionIcon​(java.lang.String previousKey, javax.swing.Icon previous)  
      private void updateMonthNavigationIcons​(javax.swing.Icon previous, javax.swing.Icon next)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final java.util.logging.Logger LOG
      • calendarHeader

        private javax.swing.JComponent calendarHeader
      • monthDownImage

        protected javax.swing.Icon monthDownImage
      • monthUpImage

        protected javax.swing.Icon monthUpImage
      • monthViewPropertyChangeListener

        private java.beans.PropertyChangeListener monthViewPropertyChangeListener
    • Constructor Detail

      • CalendarHeaderHandler

        public CalendarHeaderHandler()
    • Method Detail

      • install

        public void install​(JXMonthView monthView)
        Installs this handler to the given month view.
        Parameters:
        monthView - the target month view to install to.
      • uninstall

        public void uninstall​(JXMonthView monthView)
        Uninstalls this handler from the given target month view.
        Parameters:
        monthView - the target month view to install from.
      • getHeaderComponent

        public javax.swing.JComponent getHeaderComponent()
        Returns a component to be used as header in a zoomable month view, guaranteed to be not null.
        Returns:
        a component to be used as header in a zoomable JXMonthView
      • installListeners

        protected void installListeners()
        Creates and registered listeners on the monthView as appropriate. This implementation registers a PropertyChangeListener which synchronizes internal state on changes of componentOrientation, font and monthStringBackground.
      • uninstallListeners

        protected void uninstallListeners()
        Unregisters listeners which had been installed to the monthView.
      • getMonthViewPropertyChangeListener

        private java.beans.PropertyChangeListener getMonthViewPropertyChangeListener()
        Returns the propertyChangelistener for the monthView. Lazily created.
        Returns:
        the propertyChangeListener for the monthView.
      • monthStringBackgroundChanged

        protected void monthStringBackgroundChanged()
        Synchronizes internal state which depends on the month view's monthStringBackground.
      • fontChanged

        protected void fontChanged()
        Synchronizes internal state which depends on the month view's font.
      • componentOrientationChanged

        protected void componentOrientationChanged()
        Synchronizes internal state which depends on the month view's componentOrientation. This implementation updates the month navigation icons and the header component's orientation.
      • updateMonthNavigationIcons

        private void updateMonthNavigationIcons​(javax.swing.Icon previous,
                                                javax.swing.Icon next)
        Parameters:
        previous - the icon to use in the previousMonth action
        next - the icon to use on the nextMonth action
      • updateActionIcon

        private void updateActionIcon​(java.lang.String previousKey,
                                      javax.swing.Icon previous)
        Parameters:
        previousKey -
        previous -
      • createCalendarHeader

        protected abstract javax.swing.JComponent createCalendarHeader()
        Creates and returns the component used as header in a zoomable monthView.
        Returns:
        the component used as header in a zoomable monthView, guaranteed to be not null.
      • installNavigationActions

        protected void installNavigationActions()
        Installs and configures navigational actions.

        This implementation creates and installs wrappers around the scrollToPrevious/-NextMonth actions installed by the ui and configures them with the appropriate next/previous icons.

      • installWrapper

        private void installWrapper​(java.lang.String actionKey,
                                    java.lang.String newActionKey,
                                    javax.swing.Icon icon)
        Creates an life action wrapper around the action registered with actionKey, sets its SMALL_ICON property to the given icon and installs itself with the newActionKey.
        Parameters:
        actionKey - the key of the action to wrap around
        newActionKey - the key of the wrapper action
        icon - the icon to use in the wrapper action
      • getAsNotUIResource

        private java.awt.Font getAsNotUIResource​(java.awt.Font font)
        Returns a Font based on the param which is not of type UIResource.
        Parameters:
        font - the base font
        Returns:
        a font not of type UIResource, may be null.
      • getAsNotUIResource

        private java.awt.Color getAsNotUIResource​(java.awt.Color color)
        Returns a Color based on the param which is not of type UIResource.
        Parameters:
        color - the base color
        Returns:
        a color not of type UIResource, may be null.
      • createDerivedFont

        protected java.awt.Font createDerivedFont()
        Create a derived font used to when painting various pieces of the month view component. This method will be called whenever the font on the component is set so a new derived font can be created.