Commit 5f59bd64 authored by Simon Barner's avatar Simon Barner
Browse files

Suppress rendering of labels in case the height of the Gantt chart bars is too small.

refs 3371
parent 3753344c
AbstractObjectToDraw.java a1bbb2390af2b4485ec1dc7ad2fd316d305dbe5c GREEN
LabelToDraw.java 999a987f051ecf08965832c43c6164b20cb0431a GREEN
LineToDraw.java 96fb75373891873a51b557fece736f1c337069fc GREEN
ScheduleModelElementToDraw.java 8d3da6f399fb33bfc243a5519345ee9d36953304 YELLOW
ScheduleModelElementToDraw.java 5a647092cd53e0120a13b013f4ccda067889cb60 YELLOW
ScheduleView.java 3c0165545106c338f3a00449b09b4e219bf94a29 GREEN
ScheduleViewCanvas.java 00f5ab7cac8bf9c14756fe6ebd15c5a7b3bdee18 YELLOW
ScheduleViewColors.java a5544e371ea55d1d6cec99cd119bdddfef3d1239 GREEN
......
......@@ -28,6 +28,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.fortiss.af3.schedule.model.ResourceAllocation;
import org.fortiss.af3.schedule.model.ResourceAllocationFragment;
......@@ -97,7 +98,13 @@ public class ScheduleModelElementToDraw extends AbstractObjectToDraw {
}
period = ScheduleUtils.getPeriod(ra);
if(period != null) {
drawInfoLabel(gc, "p=" + period, rectangle);
String periodLabel = "p=" + period;
final Point periodLabelExtend = gc.stringExtent(periodLabel);
// Suppress rendering of period label unless the is enough space in the first text row
// of the Gantt chart bar, where the task/message name label is rendered in the center.
if(3 * periodLabelExtend.y < height) {
drawInfoLabel(gc, periodLabel, rectangle);
}
}
}
......
ScheduleUIUtils.java af8dfbb4763296603fa8a0595829f7b460b39cd7 GREEN
ScheduleViewUtils.java 3fa24fc22cff4e5344e35a01db0314d103358180 GREEN
ScheduleViewUtils.java 7981ad3b6b7a50e4666f362602ef086afd3ff384 YELLOW
......@@ -61,8 +61,10 @@ public class ScheduleViewUtils {
* with the respective fonts on a graphics context. The text is horizontally
* and vertically centered within the given <i>bounds</i>.
* <p>
* If the caption and subscript-text do not fit within the bounds, the caption is truncated
* 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 "..".
* <p>
* If the caption and subscript-text do not fit the available height, rendering is suppressed.
*
* @see #drawSubscriptedCaptionCentered(String, String, Rectangle, GC, Font, Font, float)
*/
......@@ -72,6 +74,10 @@ 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)) + "..";
......
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