Class BasicCalendarRenderingHandler

java.lang.Object
org.jdesktop.swingx.plaf.basic.BasicCalendarRenderingHandler
All Implemented Interfaces:
CalendarRenderingHandler
Direct Known Subclasses:
BasicMonthViewUI.RenderingHandler

class BasicCalendarRenderingHandler extends 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 Details

    • cellContext

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

      private Map<CalendarState,ComponentProvider<?>> providers
      The providers to use per DayState.
    • textCross

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

      private Color unselectableDayForeground
      The foreground color for unselectable date highlight.
    • calendarAdapter

      private CalendarAdapter calendarAdapter
    • highlighter

      private CompoundHighlighter highlighter
  • Constructor Details

    • BasicCalendarRenderingHandler

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

    • install

      private void install()
    • installProviders

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

      protected StringValue createMonthHeaderStringValue(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(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(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(Locale locale)
      Updates internal state to the given Locale.
      Specified by:
      setLocale in interface CalendarRenderingHandler
      Parameters:
      locale - the new Locale.
    • prepareRenderingComponent

      public JComponent prepareRenderingComponent(JXMonthView monthView, 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 JComponent highlight(JComponent comp, JXMonthView monthView, 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, Calendar calendar, CalendarState dayState)
      Parameters:
      monthView -
      calendar -
      dayState -
      Returns:
    • getDerivedFont

      private Font getDerivedFont(Font font)
      Parameters:
      font -
      Returns:
    • isFocused

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

      private boolean isSelected(JXMonthView monthView, 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: