assertEquals("Standard Deviation", osc.getStdDev(), sss.getStdDev(), ERROR);
assertEquals("Min", osc.getMin(), sss.getMin());
assertEquals("Max", osc.getMax(), sss.getMax());
+ assertEquals("Min Segment", osc.getMin(), sss.getMinSegment().getLength());
+ assertEquals("Max Segment", osc.getMax(), sss.getMaxSegment().getLength());
}
/**
assertEquals("Min", 0, sss.getMin());
assertEquals("Max", 99, sss.getMax());
assertEquals("Standard Deviation", 29.0, sss.getStdDev(), 0.02);
+ assertEquals("Min Segment", 0, sss.getMinSegment().getLength());
+ assertEquals("Max Segment", 99, sss.getMaxSegment().getLength());
testOnlineVsOffline(fixture);
}
assertEquals("Min", 0, sss.getMin());
assertEquals("Max", 100, sss.getMax());
assertEquals("Standard Deviation", 29.3, sss.getStdDev(), 0.01);
+ assertEquals("Min Segment", 0, sss.getMinSegment().getLength());
+ assertEquals("Max Segment", 100, sss.getMaxSegment().getLength());
testOnlineVsOffline(fixture);
}
*******************************************************************************/
package org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics;
+import org.eclipse.tracecompass.segmentstore.core.BasicSegment;
import org.eclipse.tracecompass.segmentstore.core.ISegment;
/**
* @author Bernd Hufmann
*/
public class SegmentStoreStatistics {
- private long fMin;
- private long fMax;
+ private ISegment fMin;
+ private ISegment fMax;
private long fNbSegments;
private double fAverage;
private double fVariance;
* Constructor
*/
public SegmentStoreStatistics() {
- fMin = Long.MAX_VALUE;
- fMax = Long.MIN_VALUE;
+ fMin = new BasicSegment(0, Long.MAX_VALUE);
+ fMax = new BasicSegment(Long.MIN_VALUE, 0);
fNbSegments = 0;
fAverage = 0.0;
fVariance = 0.0;
* @return minimum value
*/
public long getMin() {
- return fMin;
+ return fMin.getLength();
}
/**
* @return maximum value
*/
public long getMax() {
+ return fMax.getLength();
+ }
+
+ /**
+ * Get segment with minimum length
+ *
+ * @return segment with minimum length
+ */
+ public ISegment getMinSegment() {
+ return fMin;
+ }
+
+ /**
+ * Get segment with maximum length
+ *
+ * @return segment with maximum length
+ */
+ public ISegment getMaxSegment() {
return fMax;
}
/*
* Min and max are trivial, as well as number of segments
*/
- fMin = Math.min(fMin, value);
- fMax = Math.max(fMax, value);
+ long min = fMin.getLength();
+ long max = fMax.getLength();
+ fMin = min <= value ? fMin : segment;
+ fMax = max >= value ? fMax : segment;
fNbSegments++;
/*
import java.util.List;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator;
import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.ui.viewers.tree.AbstractTmfTreeViewer;
import org.eclipse.tracecompass.tmf.ui.viewers.tree.ITmfTreeColumnDataProvider;
@Nullable
private TmfAbstractAnalysisModule fModule;
+ private MenuManager fTablePopupMenuManager;
private static final String[] COLUMN_NAMES = new String[] {
checkNotNull(Messages.SegmentStoreStatistics_LevelLabel),
public AbstractSegmentStoreStatisticsViewer(Composite parent) {
super(parent, false);
setLabelProvider(new SegmentStoreStatisticsLabelProvider());
+ fTablePopupMenuManager = new MenuManager();
+ fTablePopupMenuManager.setRemoveAllWhenShown(true);
+ fTablePopupMenuManager.addMenuListener(manager -> {
+ TreeViewer viewer = getTreeViewer();
+ ISelection selection = viewer.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection sel = (IStructuredSelection) selection;
+ if (manager != null) {
+ appendToTablePopupMenu(manager, sel);
+ }
+ }
+ });
+ Menu tablePopup = fTablePopupMenuManager.createContextMenu(getTreeViewer().getTree());
+ getTreeViewer().getTree().setMenu(tablePopup);
}
/** Provides label for the Segment Store tree viewer cells */
}
}
+ /**
+ * Method to add commands to the context sensitive menu.
+ * @param manager
+ * the menu manager
+ * @param sel
+ * the current selection
+ */
+ protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
+ Object element = sel.getFirstElement();
+ if ((element instanceof SegmentStoreStatisticsEntry) && !(element instanceof HiddenTreeViewerEntry)) {
+ final SegmentStoreStatisticsEntry segment = (SegmentStoreStatisticsEntry) element;
+ IAction gotoStartTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMinAction) {
+ @Override
+ public void run() {
+ long start = segment.getEntry().getMinSegment().getStart();
+ long end = segment.getEntry().getMinSegment().getEnd();
+ broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end)));
+ }
+ };
+
+ IAction gotoEndTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMaxAction) {
+ @Override
+ public void run() {
+ long start = segment.getEntry().getMaxSegment().getStart();
+ long end = segment.getEntry().getMaxSegment().getEnd();
+ broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end)));
+ }
+ };
+
+ manager.add(gotoStartTime);
+ manager.add(gotoEndTime);
+ }
+ }
+
/**
* Formats a double value string
*