Class BasicCalendarRenderingHandler
java.lang.Object
org.jdesktop.swingx.plaf.basic.BasicCalendarRenderingHandler
- All Implemented Interfaces:
CalendarRenderingHandler
- Direct Known Subclasses:
BasicMonthViewUI.RenderingHandler
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 Summary
FieldsModifier and TypeFieldDescriptionprivate CalendarAdapterprivate CalendarCellContextThe CellContext for content and default visual config.private CompoundHighlighterprivate Map<CalendarState, ComponentProvider<?>> The providers to use per DayState.private TextCrossingPainter<?> The Painter used for highlighting unselectable dates.private ColorThe foreground color for unselectable date highlight. -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a RenderingHandler and installs default state. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringValuecreateDayStringValue(Locale locale) Creates and returns a StringValue used for rendering days in a month.protected StringValuecreateMonthHeaderStringValue(Locale locale) Creates and returns a StringValue used for rendering the title of a month box.protected StringValuecreateWeekOfYearStringValue(Locale locale) Creates and returns a StringValue used for rendering the week of year.private CalendarAdaptergetCalendarAdapter(JXMonthView monthView, Calendar calendar, CalendarState dayState) private FontgetDerivedFont(Font font) private Highlighterprivate JComponenthighlight(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.private voidinstall()private voidprivate voidCreates and stores ComponentProviders for all DayStates.private booleanisFocused(JXMonthView monthView, Calendar calendar, CalendarState dayState) private booleanisSelectable(CalendarState dayState) private booleanisSelected(JXMonthView monthView, Calendar calendar, CalendarState dayState) prepareRenderingComponent(JXMonthView monthView, Calendar calendar, CalendarState dayState) Configures and returns a component for rendering of the given monthView cell.voidUpdates internal state to the given Locale.
-
Field Details
-
cellContext
The CellContext for content and default visual config. -
providers
The providers to use per DayState. -
textCross
The Painter used for highlighting unselectable dates. -
unselectableDayForeground
The foreground color for unselectable date highlight. -
calendarAdapter
-
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
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
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
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
Updates internal state to the given Locale.- Specified by:
setLocalein interfaceCalendarRenderingHandler- 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:
prepareRenderingComponentin interfaceCalendarRenderingHandler- Parameters:
monthView- the JXMonthView to render ontocalendar- the cell valuedayState- 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 ontocalendar- the cell valuedayState- the DayState of the celldayState-
-
getHighlighter
- Returns:
-
installHighlighters
private void installHighlighters() -
getCalendarAdapter
private CalendarAdapter getCalendarAdapter(JXMonthView monthView, Calendar calendar, CalendarState dayState) - Parameters:
monthView-calendar-dayState-- Returns:
-
getDerivedFont
-
isFocused
- Parameters:
monthView-calendar-dayState-- Returns:
-
isSelected
- Parameters:
monthView- the JXMonthView to render ontocalendar- the cell valuedayState- the DayState of the cell- Returns:
-
isSelectable
- Parameters:
dayState-- Returns:
-