Search in sources :

Example 6 with AxisRange

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange in project tracecompass by tracecompass.

the class AbstractSegmentStoreDensityViewer method updateWithRange.

/**
 * Update the display range
 *
 * @param timeRange
 *            the range
 * @since 1.2
 */
@VisibleForTesting
public void updateWithRange(final TmfTimeRange timeRange) {
    fCurrentTimeRange = timeRange;
    final AxisRange durationRange = getDefaultRange();
    fCurrentDurationRange = durationRange;
    computeDataAsync(timeRange, durationRange).thenAccept(data -> {
        synchronized (fListeners) {
            if (fCurrentTimeRange.equals(timeRange) && fCurrentDurationRange.equals(durationRange)) {
                applyData(data);
            }
        }
    });
}
Also used : AxisRange(org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with AxisRange

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange in project tracecompass by tracecompass.

the class AbstractSegmentStoreDensityViewer method computeData.

@Nullable
private Map<String, SegmentStoreWithRange<ISegment>> computeData(final TmfTimeRange timeRange, final AxisRange durationRange) {
    Map<String, SegmentStoreWithRange<ISegment>> retVal = new HashMap<>();
    for (Entry<String, ISegmentStoreProvider> entry : fSegmentStoreProviders.entrySet()) {
        final ISegmentStoreProvider segmentProvider = Objects.requireNonNull(entry.getValue());
        final ISegmentStore<ISegment> segStore = segmentProvider.getSegmentStore();
        if (segStore == null) {
            continue;
        }
        // Filter on the segment duration if necessary
        if (durationRange.getLower() > Double.MIN_VALUE || durationRange.getUpper() < Double.MAX_VALUE) {
            Predicate<ISegment> predicate = segment -> segment.getLength() >= durationRange.getLower() && segment.getLength() <= durationRange.getUpper();
            retVal.put(entry.getKey(), new SegmentStoreWithRange<>(segStore, timeRange, predicate));
        } else {
            retVal.put(entry.getKey(), new SegmentStoreWithRange<>(segStore, timeRange));
        }
    }
    return retVal;
}
Also used : TmfViewer(org.eclipse.tracecompass.tmf.ui.viewers.TmfViewer) PlotSymbolType(org.eclipse.swtchart.ILineSeries.PlotSymbolType) SimpleTooltipProvider(org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density2.SimpleTooltipProvider) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) Arrays(java.util.Arrays) ILineSeries(org.eclipse.swtchart.ILineSeries) Format(java.text.Format) Type(org.eclipse.tracecompass.tmf.core.presentation.IYAppearance.Type) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) Nullable(org.eclipse.jdt.annotation.Nullable) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) ISeriesSet(org.eclipse.swtchart.ISeriesSet) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) MouseSelectionProvider(org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density2.MouseSelectionProvider) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) ISegmentStore(org.eclipse.tracecompass.segmentstore.core.ISegmentStore) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Predicate(java.util.function.Predicate) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) Set(java.util.Set) Display(org.eclipse.swt.widgets.Display) Objects(java.util.Objects) SubSecondTimeWithUnitFormat(org.eclipse.tracecompass.common.core.format.SubSecondTimeWithUnitFormat) List(java.util.List) Range(org.eclipse.swtchart.Range) SWT(org.eclipse.swt.SWT) Entry(java.util.Map.Entry) IYAppearance(org.eclipse.tracecompass.tmf.core.presentation.IYAppearance) Optional(java.util.Optional) SeriesType(org.eclipse.swtchart.ISeries.SeriesType) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) NonNull(org.eclipse.jdt.annotation.NonNull) LineStyle(org.eclipse.swtchart.LineStyle) SegmentComparators(org.eclipse.tracecompass.segmentstore.core.SegmentComparators) SegmentStoreWithRange(org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider.SegmentStoreWithRange) Chart(org.eclipse.swtchart.Chart) MouseDragZoomProvider(org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density2.MouseDragZoomProvider) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) NonNullUtils(org.eclipse.tracecompass.common.core.NonNullUtils) HashSet(java.util.HashSet) ISegmentStoreProvider(org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider) IAxis(org.eclipse.swtchart.IAxis) ILegend(org.eclipse.swtchart.ILegend) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) RotatingPaletteProvider(org.eclipse.tracecompass.tmf.core.presentation.RotatingPaletteProvider) RGB(org.eclipse.swt.graphics.RGB) StreamSupport(java.util.stream.StreamSupport) TimeGraphColorScheme(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme) IAnalysisProgressListener(org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener) IBarSeries(org.eclipse.swtchart.IBarSeries) ISeries(org.eclipse.swtchart.ISeries) AxisRange(org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange) IImageSave(org.eclipse.tracecompass.tmf.ui.viewers.IImageSave) DoubleArraySeriesModel(org.eclipse.swtchart.model.DoubleArraySeriesModel) Color(org.eclipse.swt.graphics.Color) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) RGBAUtil(org.eclipse.tracecompass.tmf.ui.colors.RGBAUtil) HashMap(java.util.HashMap) ISegmentStoreProvider(org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) SegmentStoreWithRange(org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider.SegmentStoreWithRange) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 8 with AxisRange

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange in project tracecompass by tracecompass.

the class MouseDragZoomProvider method mouseUp.

@Override
public void mouseUp(@Nullable MouseEvent e) {
    if ((fIsUpdate) && (fStartCoordinate != fEndCoordinate)) {
        if (fStartCoordinate > fEndCoordinate) {
            double tmp = fStartCoordinate;
            fStartCoordinate = fEndCoordinate;
            fEndCoordinate = tmp;
        }
        AxisRange range = new AxisRange(fStartCoordinate, fEndCoordinate);
        getDensityViewer().zoom(range);
    }
    if (fIsUpdate) {
        redraw();
    }
    fIsUpdate = false;
}
Also used : AxisRange(org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange)

Example 9 with AxisRange

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange in project tracecompass by tracecompass.

the class TmfXyUiUtils method horizontalScroll.

/**
 * Perform horizontal scrolling for a given viewer.
 *
 * @param viewer
 *            the chart time provider to use for scrolling
 * @param xAxis
 *            the x axis reference to use the scrolling
 * @param left
 *            true to scroll left else scroll right
 */
public static void horizontalScroll(ITmfChartTimeProvider viewer, IAxis xAxis, boolean left) {
    if (xAxis == null) {
        return;
    }
    long windowStartTime = viewer.getWindowStartTime();
    long windowsEndTime = viewer.getWindowEndTime();
    long startTime = viewer.getStartTime();
    long endTime = viewer.getEndTime();
    long range = windowsEndTime - windowStartTime;
    if (range <= 0) {
        return;
    }
    long increment = Math.max(1, range / 2);
    if (left) {
        windowStartTime = Math.max(windowStartTime - increment, startTime);
        windowsEndTime = windowStartTime + range;
    } else {
        windowsEndTime = Math.min(windowsEndTime + increment, endTime);
        windowStartTime = windowsEndTime - range;
    }
    viewer.updateWindow(windowStartTime, windowsEndTime);
    xAxis.setRange(new AxisRange(windowStartTime - viewer.getTimeOffset(), windowsEndTime - viewer.getTimeOffset()));
}
Also used : AxisRange(org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange)

Example 10 with AxisRange

use of org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange in project tracecompass by tracecompass.

the class TmfXyUiUtils method zoomIn.

// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
private static void zoomIn(ITmfChartTimeProvider viewer, IAxis chart) {
    IAxis xAxis = chart;
    if (xAxis == null) {
        return;
    }
    long prevTime0 = viewer.getWindowStartTime();
    long prevTime1 = viewer.getWindowEndTime();
    long prevRange = prevTime1 - prevTime0;
    if (prevRange == 0) {
        return;
    }
    long selTime = (viewer.getSelectionEndTime() + viewer.getSelectionBeginTime()) / 2;
    if (selTime < prevTime0 || selTime > prevTime1) {
        selTime = (prevTime0 + prevTime1) / 2;
    }
    long time0 = selTime - (long) ((selTime - prevTime0) / ZOOM_FACTOR_SELECTION_CENTERED);
    long time1 = selTime + (long) ((prevTime1 - selTime) / ZOOM_FACTOR_SELECTION_CENTERED);
    if ((time1 - time0) < MIN_WINDOW_SIZE) {
        time0 = selTime - (selTime - prevTime0) * MIN_WINDOW_SIZE / prevRange;
        time1 = time0 + MIN_WINDOW_SIZE;
    }
    time0 = validateWindowStartTime(viewer, time0);
    time1 = validateWindowEndTime(viewer, time0, time1);
    viewer.updateWindow(time0, time1);
    xAxis.setRange(new AxisRange(time0 - viewer.getTimeOffset(), time1 - viewer.getTimeOffset()));
}
Also used : AxisRange(org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange) IAxis(org.eclipse.tracecompass.tmf.ui.viewers.xychart.IAxis)

Aggregations

AxisRange (org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange)10 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IAxis (org.eclipse.swtchart.IAxis)2 ILegend (org.eclipse.swtchart.ILegend)2 Range (org.eclipse.swtchart.Range)2 DoubleArraySeriesModel (org.eclipse.swtchart.model.DoubleArraySeriesModel)2 Format (java.text.Format)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Predicate (java.util.function.Predicate)1 StreamSupport (java.util.stream.StreamSupport)1