Skip to content

Commit 9a76828

Browse files
tmf.ui: Instrument Histogram
Add two flow scope logs and one scope log. Change-Id: I1b59629da5f7f417880d8f35694fb296eaaddc62 Signed-off-by: Matthew Khouzam <[email protected]> Signed-off-by: Arnaud Fiorini <[email protected]>
1 parent 01fa360 commit 9a76828

File tree

1 file changed

+32
-16
lines changed
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram

1 file changed

+32
-16
lines changed

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
package org.eclipse.tracecompass.tmf.ui.views.histogram;
2020

21+
import java.util.logging.Level;
22+
import java.util.logging.Logger;
23+
2124
import org.eclipse.jdt.annotation.NonNull;
2225
import org.eclipse.jface.action.IStatusLineManager;
2326
import org.eclipse.jface.layout.GridDataFactory;
@@ -48,6 +51,7 @@
4851
import org.eclipse.swt.widgets.Control;
4952
import org.eclipse.swt.widgets.Display;
5053
import org.eclipse.swt.widgets.Label;
54+
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
5155
import org.eclipse.tracecompass.internal.tmf.ui.views.histogram.HistogramTimeAdapter;
5256
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
5357
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
@@ -67,6 +71,8 @@
6771
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;
6872
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;
6973
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphScale;
74+
import org.eclipse.tracecompass.traceeventlogger.LogUtils;
75+
import org.eclipse.tracecompass.traceeventlogger.LogUtils.ScopeLog;
7076

7177
/**
7278
* Re-usable histogram widget.
@@ -110,6 +116,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
110116
// ------------------------------------------------------------------------
111117

112118
private static final int TIME_SCALE_HEIGHT = 27;
119+
private static final Logger LOGGER = TraceCompassLog.getLogger(Histogram.class);
113120

114121
// Histogram colors
115122

@@ -250,7 +257,6 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
250257
*/
251258
static boolean showTraces = true;
252259

253-
254260
private boolean fSendTimeAlignSignals = false;
255261

256262
private IStatusLineManager fStatusLineManager;
@@ -655,17 +661,27 @@ protected void moveCursor(final int keyCode) {
655661
*/
656662
@Override
657663
public void modelUpdated() {
658-
if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) {
659-
fCanvas.getDisplay().asyncExec(() -> {
660-
if (!fCanvas.isDisposed()) {
661-
// Retrieve and normalize the data
662-
final int canvasWidth = fCanvas.getBounds().width;
663-
final int canvasHeight = fCanvas.getBounds().height;
664-
if (canvasWidth <= 0 || canvasHeight <= 0) {
665-
return;
664+
try (LogUtils.FlowScopeLog fs = new LogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:ModelUpdated").setCategory("Histogram").build()) { //$NON-NLS-1$ //$NON-NLS-2$
665+
if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) {
666+
fCanvas.getDisplay().asyncExec(() -> {
667+
int canvasWidth = -1;
668+
int canvasHeight = -1;
669+
try (LogUtils.FlowScopeLog fs1 = new LogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:getBounds").setParentScope(fs).build()) { //$NON-NLS-1$
670+
if (!fCanvas.isDisposed()) {
671+
// Retrieve and normalize the data
672+
canvasWidth = fCanvas.getBounds().width;
673+
canvasHeight = fCanvas.getBounds().height;
666674
}
675+
}
676+
677+
if (canvasHeight <= 0 || canvasWidth <= 0) {
678+
return;
679+
}
680+
try (LogUtils.FlowScopeLog fs1 = new LogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:scaleData").setParentScope(fs).build()) { //$NON-NLS-1$
667681
fDataModel.setSelection(fSelectionBegin, fSelectionEnd);
668682
fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1);
683+
}
684+
try (LogUtils.FlowScopeLog fs1 = new LogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:redraw").setParentScope(fs).build()) { //$NON-NLS-1$
669685
synchronized (fDataModel) {
670686
if (fScaledData != null) {
671687
fCanvas.redraw();
@@ -679,16 +695,16 @@ public void modelUpdated() {
679695
GridData gd = (GridData) fMaxNbEventsLabel.getLayoutData();
680696
gd.widthHint = Math.max(gd.widthHint, fMaxNbEventsLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
681697
fMaxNbEventsLabel.getParent().layout();
682-
if (old.length() < fMaxNbEventsLabel.getText().length()) {
683-
if ((fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) {
684-
TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true));
685-
}
698+
if (old.length() < fMaxNbEventsLabel.getText().length() && (fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) {
699+
TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true));
686700
}
701+
687702
}
688703
fTimeLineScale.redraw();
689704
}
690-
}
691-
});
705+
}
706+
});
707+
}
692708
}
693709
}
694710

@@ -786,7 +802,7 @@ private void formatImage(final GC imageGC, final Image image) {
786802

787803
final HistogramScaledData scaledData = new HistogramScaledData(fScaledData);
788804

789-
try {
805+
try (ScopeLog sl = new ScopeLog(LOGGER, Level.FINER, "Histogram:FmtImg")) { //$NON-NLS-1$
790806
final int height = image.getBounds().height;
791807

792808
// Clear the drawing area

0 commit comments

Comments
 (0)