Class BasicCalendarRenderingHandler

  • All Implemented Interfaces:
    CalendarRenderingHandler
    Direct Known Subclasses:
    BasicMonthViewUI.RenderingHandler

    class BasicCalendarRenderingHandler
    extends java.lang.Object
    implements CalendarRenderingHandler
    The RenderingHandler responsible for text rendering. It provides and configures a rendering component for the given cell of a JXMonthView.

    Note: exposing the createXXStringValue methods is an emergency workaround for Issue #1062-swingx (core doesn't use arabic digits where appropriate) to allow subclasses to do better than core. So beware of future changes!

    • Field Detail

      • cellContext

        private CalendarCellContext cellContext
        The CellContext for content and default visual config.
      • textCross

        private TextCrossingPainter<?> textCross
        The Painter used for highlighting unselectable dates.
      • unselectableDayForeground

        private java.awt.Color unselectableDayForeground
        The foreground color for unselectable date highlight.
    • Constructor Detail

      • BasicCalendarRenderingHandler

        public BasicCalendarRenderingHandler()
        Instantiates a RenderingHandler and installs default state.
    • Method Detail

      • install

        private void install()
      • installProviders

        private void installProviders()
        Creates and stores ComponentProviders for all DayStates.
      • createMonthHeaderStringValue

        protected StringValue createMonthHeaderStringValue​(java.util.Locale locale)
        Creates and returns a StringValue used for rendering the title of a month box. The input they are assumed to handle is a Calendar configured to a day of the month to render.
        Parameters:
        locale - the Locale to use, might be null to indicate usage of the default Locale
        Returns:
        a StringValue appropriate for rendering month title.
      • createWeekOfYearStringValue

        protected StringValue createWeekOfYearStringValue​(java.util.Locale locale)
        Creates and returns a StringValue used for rendering the week of year. The input they are assumed to handle is a Calendar configured to a day of the week to render.
        Parameters:
        locale - the Locale to use, might be null to indicate usage of the default Locale
        Returns:
        a StringValue appropriate for rendering week of year.
      • createDayStringValue

        protected StringValue createDayStringValue​(java.util.Locale locale)
        Creates and returns a StringValue used for rendering days in a month. The input they are assumed to handle is a Calendar configured to the day.
        Parameters:
        locale - the Locale to use, might be null to indicate usage of the default Locale
        Returns:
        a StringValue appropriate for rendering days in a month
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Updates internal state to the given Locale.
        Specified by:
        setLocale in interface CalendarRenderingHandler
        Parameters:
        locale - the new Locale.
      • prepareRenderingComponent

        public javax.swing.JComponent prepareRenderingComponent​(JXMonthView monthView,
                                                                java.util.Calendar calendar,
                                                                CalendarState dayState)
        Configures and returns a component for rendering of the given monthView cell.
        Specified by:
        prepareRenderingComponent in interface CalendarRenderingHandler
        Parameters:
        monthView - the JXMonthView to render onto
        calendar - the cell value
        dayState - the DayState of the cell
        Returns:
        a component configured for rendering the given cell
      • highlight

        private javax.swing.JComponent highlight​(javax.swing.JComponent comp,
                                                 JXMonthView monthView,
                                                 java.util.Calendar calendar,
                                                 CalendarState dayState)
        NOTE: it's the responsibility of the CalendarCellContext to detangle all "default" (that is: which could be queried from the comp and/or UIManager) foreground/background colors based on the given state! Moved out off here.

        PENDING JW: replace hard-coded logic by giving over to highlighters.

        Parameters:
        monthView - the JXMonthView to render onto
        calendar - the cell value
        dayState - the DayState of the cell
        dayState -
      • getHighlighter

        private Highlighter getHighlighter()
        Returns:
      • installHighlighters

        private void installHighlighters()
      • getCalendarAdapter

        private CalendarAdapter getCalendarAdapter​(JXMonthView monthView,
                                                   java.util.Calendar calendar,
                                                   CalendarState dayState)
        Parameters:
        monthView -
        calendar -
        dayState -
        Returns:
      • getDerivedFont

        private java.awt.Font getDerivedFont​(java.awt.Font font)
        Parameters:
        font -
        Returns:
      • isFocused

        private boolean isFocused​(JXMonthView monthView,
                                  java.util.Calendar calendar,
                                  CalendarState dayState)
        Parameters:
        monthView -
        calendar -
        dayState -
        Returns:
      • isSelected

        private boolean isSelected​(JXMonthView monthView,
                                   java.util.Calendar calendar,
                                   CalendarState dayState)
        Parameters:
        monthView - the JXMonthView to render onto
        calendar - the cell value
        dayState - the DayState of the cell
        Returns:
      • isSelectable

        private boolean isSelectable​(CalendarState dayState)
        Parameters:
        dayState -
        Returns: