import org.eclipse.linuxtools.tmf.core.signal.TmfTimestampFormatUpdateSignal;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampDelta;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
composite.setLayoutData(gridData);
// Y-axis max event
gridData.verticalSpan = 2;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
+ gridData.heightHint = 0;
+ gridData.widthHint = 0;
gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
canvasComposite.setLayoutData(gridData);
canvasComposite.setLayout(new FillLayout());
fCanvas = new Canvas(canvasComposite, SWT.DOUBLE_BUFFERED);
long maxNbEvents = HistogramScaledData.hideLostEvents ? fScaledData.fMaxValue : fScaledData.fMaxCombinedValue;
fMaxNbEventsText.setText(Long.toString(maxNbEvents));
// The Y-axis area might need to be re-sized
+ GridData gd = (GridData) fMaxNbEventsText.getLayoutData();
+ gd.widthHint = Math.max(gd.widthHint, fMaxNbEventsText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
fMaxNbEventsText.getParent().layout();
}
}
// ------------------------------------------------------------------------
private void updateSelectionTime() {
+ if (fSelectionBegin > fSelectionEnd) {
+ long end = fSelectionBegin;
+ fSelectionBegin = fSelectionEnd;
+ fSelectionEnd = end;
+ }
((HistogramView) fParentView).updateSelectionTime(fSelectionBegin, fSelectionEnd);
}
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);
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
imageGC.setBackground(fFillColor);
imageGC.fillRectangle(delimiterIndex + 1, 0, width - (delimiterIndex + 1), height);
+ // Restore anti-aliasing
+ imageGC.setAntialias(aliasing);
+
} catch (final Exception e) {
// Do nothing
}
*/
protected void drawTimeRangeWindow(GC imageGC, long rangeStartTime, long rangeDuration) {
+ if (fScaledData == null) {
+ return;
+ }
+
// Map times to histogram coordinates
long bucketSpan = Math.max(fScaledData.fBucketDuration, 1);
long startTime = Math.min(rangeStartTime, rangeStartTime + rangeDuration);
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
@Override
public void mouseDown(final MouseEvent event) {
- if (event.button == 1 && fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
+ if (fScaledData != null && event.button == 1 && fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
fDragState = DRAG_SELECTION;
fDragButton = event.button;
if ((event.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
final int nbEvents = (index >= 0) ? fScaledData.fData[index] : 0;
final String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
final StringBuffer buffer = new StringBuffer();
- buffer.append("Range = ["); //$NON-NLS-1$
- buffer.append(new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE).toString());
- buffer.append(',');
- buffer.append(new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE).toString());
- buffer.append(')');
+ int selectionBeginBucket = Math.min(fScaledData.fSelectionBeginBucket, fScaledData.fSelectionEndBucket);
+ int selectionEndBucket = Math.max(fScaledData.fSelectionBeginBucket, fScaledData.fSelectionEndBucket);
+ if (selectionBeginBucket <= index && index <= selectionEndBucket && fSelectionBegin != fSelectionEnd) {
+ TmfTimestampDelta delta = new TmfTimestampDelta(Math.abs(fSelectionEnd - fSelectionBegin), ITmfTimestamp.NANOSECOND_SCALE);
+ buffer.append(NLS.bind(Messages.Histogram_selectionSpanToolTip, delta.toString()));
+ buffer.append(newLine);
+ }
+ buffer.append(NLS.bind(Messages.Histogram_bucketRangeToolTip,
+ new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE).toString(),
+ new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE).toString()));
buffer.append(newLine);
- buffer.append("Event count = "); //$NON-NLS-1$
- buffer.append(nbEvents);
+ buffer.append(NLS.bind(Messages.Histogram_eventCountToolTip, nbEvents));
if (!HistogramScaledData.hideLostEvents) {
final int nbLostEvents = (index >= 0) ? fScaledData.fLostEventsData[index] : 0;
buffer.append(newLine);
- buffer.append("Lost events count = "); //$NON-NLS-1$
- buffer.append(nbLostEvents);
+ buffer.append(NLS.bind(Messages.Histogram_lostEventCountToolTip, nbLostEvents));
}
return buffer.toString();
}