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);
}
}
});
}
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;
}
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;
}
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()));
}
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()));
}
Aggregations