Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2013-12-03 14:22:48 -0500
committerPatrick Tasse2013-12-03 17:20:22 -0500
commitcab8ee19031ce8a6e36eae1cd7680c389d4a433d (patch)
tree5b4a885c3327e5c0744790ce916374a96fd6ecd1
parent97d561cdc947ee8a7ff325fb7b99fb2f0ee5d061 (diff)
downloadorg.eclipse.linuxtools-cab8ee19031ce8a6e36eae1cd7680c389d4a433d.tar.gz
org.eclipse.linuxtools-cab8ee19031ce8a6e36eae1cd7680c389d4a433d.tar.xz
org.eclipse.linuxtools-cab8ee19031ce8a6e36eae1cd7680c389d4a433d.zip
tmf: Fix Linux drawing weirdness in Histogram
- Set anti-aliasing to off when drawing histogram bars because it's on by default in Linux - Change order of drawing histogram bars and draw one pixel too far because Linux doesn't draw last pixel of a line - Clamp rounded rectangle arc size to rectangle width because Linux doesn't Change-Id: I574c80ecf15cda8655b3fbb8b34b80fd0f5a6d0c Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/19263 Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java30
1 files changed, 19 insertions, 11 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
index 9d3a29cb60..823789c4fa 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
@@ -685,6 +685,10 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
final int width = image.getBounds().width;
final int height = image.getBounds().height;
+ // Turn off anti-aliasing
+ int aliasing = imageGC.getAntialias();
+ imageGC.setAntialias(SWT.OFF);
+
// Clear the drawing area
imageGC.setBackground(fBackgroundColor);
imageGC.fillRectangle(0, 0, image.getBounds().width + 1, image.getBounds().height + 1);
@@ -693,24 +697,24 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
final int limit = width < scaledData.fWidth ? width : scaledData.fWidth;
double factor = HistogramScaledData.hideLostEvents ? scaledData.fScalingFactor : scaledData.fScalingFactorCombined;
for (int i = 0; i < limit; i++) {
- imageGC.setForeground(fHistoBarColor);
final int value = (int) Math.ceil(scaledData.fData[i] * factor);
int x = i + fOffset;
- imageGC.drawLine(x, height - value, x, height);
+ // in Linux, the last pixel in a line is not drawn,
+ // so draw lost events first, one pixel too far
if (!HistogramScaledData.hideLostEvents) {
imageGC.setForeground(fLostEventColor);
final int lostEventValue = (int) Math.ceil(scaledData.fLostEventsData[i] * factor);
if (lostEventValue != 0) {
- if (lostEventValue == 1) {
- // in linux, a line from x to x is not drawn, in windows it is.
- imageGC.drawPoint(x, height - value - 1);
- } else {
- // drawing a line is inclusive, so we need to remove 1 from the destination to have the correct length
- imageGC.drawLine(x, height - value - lostEventValue, x, height - value - 1);
- }
+ // drawing a line is inclusive, so we should remove 1 from y2
+ // but we don't because Linux
+ imageGC.drawLine(x, height - value - lostEventValue, x, height - value);
}
}
+
+ // then draw normal events second, to overwrite that extra pixel
+ imageGC.setForeground(fHistoBarColor);
+ imageGC.drawLine(x, height - value, x, height);
}
// Draw the selection bars
@@ -743,6 +747,9 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
imageGC.setBackground(fFillColor);
imageGC.fillRectangle(delimiterIndex + 1, 0, width - (delimiterIndex + 1), height);
+ // Restore anti-aliasing
+ imageGC.setAntialias(aliasing);
+
} catch (final Exception e) {
// Do nothing
}
@@ -780,17 +787,18 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
int right = left + rangeWidth;
int center = (left + right) / 2;
int height = fCanvas.getSize().y;
+ int arc = Math.min(15, rangeWidth);
// Draw the selection window
imageGC.setForeground(fTimeRangeColor);
imageGC.setLineWidth(1);
imageGC.setLineStyle(SWT.LINE_SOLID);
- imageGC.drawRoundRectangle(left, 0, rangeWidth, height - 1, 15, 15);
+ imageGC.drawRoundRectangle(left, 0, rangeWidth, height - 1, arc, arc);
// Fill the selection window
imageGC.setBackground(fTimeRangeColor);
imageGC.setAlpha(35);
- imageGC.fillRoundRectangle(left + 1, 1, rangeWidth - 1, height - 2, 15, 15);
+ imageGC.fillRoundRectangle(left + 1, 1, rangeWidth - 1, height - 2, arc, arc);
imageGC.setAlpha(255);
// Draw the cross hair

Back to the top