*/
private void installProviders() {
providers = new HashMap<CalendarState, ComponentProvider<?>>();
StringValue sv = createDayStringValue(null);
ComponentProvider<?> provider = new LabelProvider(sv, JLabel.RIGHT);
providers.put(CalendarState.IN_MONTH, provider);
providers.put(CalendarState.TODAY, provider);
providers.put(CalendarState.TRAILING, provider);
providers.put(CalendarState.LEADING, provider);
StringValue wsv = createWeekOfYearStringValue(null);
ComponentProvider<?> weekOfYearProvider = new LabelProvider(wsv,
JLabel.RIGHT);
providers.put(CalendarState.WEEK_OF_YEAR, weekOfYearProvider);
ComponentProvider<?> dayOfWeekProvider = new LabelProvider(JLabel.CENTER) {
@Override
protected String getValueAsString(CellContext context) {
Object value = context.getValue();
// PENDING JW: this is breaking provider's contract in its
// role as StringValue! Don't in the general case.
if (value instanceof Calendar) {
int day = ((Calendar) value).get(Calendar.DAY_OF_WEEK);
return ((JXMonthView) context.getComponent()).getDayOfTheWeek(day);
}
return super.getValueAsString(context);
}
};
providers.put(CalendarState.DAY_OF_WEEK, dayOfWeekProvider);
StringValue tsv = createMonthHeaderStringValue(null);
ComponentProvider<?> titleProvider = new LabelProvider(tsv,
JLabel.CENTER);
providers.put(CalendarState.TITLE, titleProvider);
}