Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 410302

Summary: Calendar field [Swing]: Short Appointments are painted outside calendarItem
Product: z_Archived Reporter: Judith Gull <judith.gull>
Component: ScoutAssignee: Project Inbox <scout.core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: bertinrid
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
shortAppointmentsMinus2Correction
none
shortAppointmentsMinus4Correction
none
shortAppointmentsNoCorrection none

Description Judith Gull CLA 2013-06-10 04:13:00 EDT
Comments in bug 388722 by Bertin Kiekebosch:

In Swing, the text of very small items is painted outside the calendarItem. Although technically the code is correct, the effect of using FontMetrics.getAscent is that there appears some whitespace above the text. This is perfect when there is enough space and there are some characters in some fonts that might use this space.

Possible fix: If the calendarItem has a small height, then working with an ofset of -4 gives better results. There are some characters that are not totally visible then, for example Ä, Ü are drawn without a umlaut but in most cases it is perfectly readable and the text starts on the item and not below. Without the correction, if there are more small items below each other, the text appears to be on the wrong item.

See the shortAppointmentsNoCorrection.PNG, shortAppointmentsMinus2Correction.PNG and shortAppointmentsMinus4Correction.PNG for how it looks in out screen.

Can be fixed by using an ofset of -4 (in class LargeCalendarCell). When made dynamically this negative ofset is only usen when neccessary

if (cc.isLabeled()) {
g.setColor(getForeground());
String s = m_dateChooser.getModel().getLabel(cc.getItem(), getRepresentedDate());
int centery = Math.max(0, (r.height – fm.getAscent()) / 2);
g.setClip(r.x, r.y + centery, r.width, fm.getHeight());
if (s != null) {
int yCorrection = 0;
if (fm.getAscent() > r.height) {
yCorrection = 4;
}
g.drawString(s, r.x + 3, r.y + centery + fm.getAscent() - yCorrection);
}
}

This change is not in the patch because I like to discuss it first.
Comment 1 Judith Gull CLA 2013-06-10 04:15:09 EDT
Created attachment 232153 [details]
shortAppointmentsMinus2Correction
Comment 2 Judith Gull CLA 2013-06-10 04:15:29 EDT
Created attachment 232154 [details]
shortAppointmentsMinus4Correction
Comment 3 Judith Gull CLA 2013-06-10 04:15:54 EDT
Created attachment 232155 [details]
shortAppointmentsNoCorrection
Comment 4 Matthias Zimmermann CLA 2017-06-06 05:38:19 EDT
Swing support for Scout is no longer maintained in the open source domain. In case you need a bug to be fixed please consider our commercial options.