From c44be4c05a2750b5238109321ffe494a5c5aa002 Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Fri, 13 Jan 2017 16:37:17 -0500 Subject: [PATCH] tmf: Scale tree images in time graph If the item height is smaller than the image height, scale the image. Change-Id: I9393a7d0d7eebf28c30c4a51e271d7c6ea8e2216 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/88688 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- .../tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java index 0969b587a7..9eeb3b3725 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java @@ -2330,9 +2330,11 @@ public class TimeGraphControl extends TimeGraphBaseControl // draw icon int imgHeight = img.getImageData().height; int imgWidth = img.getImageData().width; + int dstHeight = Math.min(bounds.height, imgHeight); + int dstWidth = dstHeight * imgWidth / imgHeight; int x = width; - int y = bounds.y + (bounds.height - imgHeight) / 2; - gc.drawImage(img, x, y); + int y = bounds.y + (bounds.height - dstHeight) / 2; + gc.drawImage(img, 0, 0, imgWidth, imgHeight, x, y, dstWidth, dstHeight); width += imgWidth + MARGIN; } } else { -- 2.34.1