Package org.jdesktop.swingx.plaf.basic
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 CalendarAdapter
private CalendarCellContext
The CellContext for content and default visual config.private CompoundHighlighter
private Map
<CalendarState, ComponentProvider<?>> The providers to use per DayState.private TextCrossingPainter
<?> The Painter used for highlighting unselectable dates.private Color
The foreground color for unselectable date highlight. -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a RenderingHandler and installs default state. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringValue
createDayStringValue
(Locale locale) Creates and returns a StringValue used for rendering days in a month.protected StringValue
createMonthHeaderStringValue
(Locale locale) Creates and returns a StringValue used for rendering the title of a month box.protected StringValue
createWeekOfYearStringValue
(Locale locale) Creates and returns a StringValue used for rendering the week of year.private CalendarAdapter
getCalendarAdapter
(JXMonthView monthView, Calendar calendar, CalendarState dayState) private Font
getDerivedFont
(Font font) private Highlighter
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.private void
install()
private void
private void
Creates and stores ComponentProviders for all DayStates.private boolean
isFocused
(JXMonthView monthView, Calendar calendar, CalendarState dayState) private boolean
isSelectable
(CalendarState dayState) private boolean
isSelected
(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.void
Updates 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:
setLocale
in 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:
prepareRenderingComponent
in 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
- Parameters:
font
-- Returns:
-
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:
-