tmf: Scale tree images in time graph
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 13 Jan 2017 21:37:17 +0000 (16:37 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Mon, 16 Jan 2017 16:20:36 +0000 (11:20 -0500)
If the item height is smaller than the image height, scale the image.

Change-Id: I9393a7d0d7eebf28c30c4a51e271d7c6ea8e2216
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/88688
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java

index 0969b587a77a6224797eb54e64f95125b64c5c13..9eeb3b372588a099dd5788319dc9ba663d43bcde 100644 (file)
@@ -2330,9 +2330,11 @@ public class TimeGraphControl extends TimeGraphBaseControl
                     // draw icon
                     int imgHeight = img.getImageData().height;
                     int imgWidth = img.getImageData().width;
                     // 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 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 {
                     width += imgWidth + MARGIN;
                 }
             } else {
This page took 0.041208 seconds and 5 git commands to generate.