Commit 6551d9f8 authored by Simon Barner's avatar Simon Barner
Browse files

Suppress rendering in case label does not fit width of Gantt chart bar.

refs 3371
parent 5f59bd64
ScheduleUIUtils.java af8dfbb4763296603fa8a0595829f7b460b39cd7 GREEN
ScheduleViewUtils.java 7981ad3b6b7a50e4666f362602ef086afd3ff384 YELLOW
ScheduleViewUtils.java bc21f86a2edfcfae0169ee06550cb0e965f466f3 YELLOW
......@@ -62,7 +62,8 @@ public class ScheduleViewUtils {
* and vertically centered within the given <i>bounds</i>.
* <p>
* If the caption and subscript-text do not fit the available width, the caption is truncated
* according to {@link #truncateStringToWidth(String, int, GC)} and appended with "..".
* according to {@link #truncateStringToWidth(String, int, GC)}. If space permits, the truncated
* text is appended with "{@code ..}".
* <p>
* If the caption and subscript-text do not fit the available height, rendering is suppressed.
*
......@@ -74,16 +75,17 @@ public class ScheduleViewUtils {
gc.setFont(subscriptFont);
final Point subscriptExtent = gc.stringExtent(subscript);
gc.setFont(captionFont);
final Point captionExtend = gc.stringExtent(caption);
if(captionExtend.y + (!subscript.isEmpty() ? subscriptExtent.y : 0) > bounds.height + 4) {
return;
}
String actualName = truncateStringToWidth(caption, bounds.width - subscriptExtent.x, gc);
if(actualName.length() < caption.length()) {
actualName = actualName.substring(0, Math.max(0, actualName.length() - 1)) + "..";
}
final Point nameExtent = gc.stringExtent(actualName);
final int totalWidth = nameExtent.x + subscriptExtent.x;
final int totalHeight = nameExtent.y + (!subscript.isEmpty() ? subscriptExtent.y : 0);
if((totalWidth > bounds.width) || (totalHeight > bounds.height + 4)) {
return;
}
gc.drawString(actualName, bounds.x + (bounds.width - totalWidth) / 2, bounds.y +
(bounds.height - nameExtent.y) / 2, true);
gc.setFont(subscriptFont);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment