This repository has been archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timegraph: Implement "event owner" navigation mode
Continue using an Eclipse Job for this action, it is important to report progress in this case. Refs #8. Signed-off-by: Alexandre Montplaisir <[email protected]>
- Loading branch information
Alexandre Montplaisir
committed
Mar 31, 2017
1 parent
1d3920a
commit f55ca7f
Showing
9 changed files
with
201 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...mf2.views.ui/src/org/lttng/scope/tmf2/views/ui/timegraph/swtjfx/toolbar/nav/NavUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <[email protected]> | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v1.0 which | ||
* accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.lttng.scope.tmf2.views.ui.timegraph.swtjfx.toolbar.nav; | ||
|
||
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; | ||
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; | ||
import org.lttng.scope.tmf2.views.core.TimeRange; | ||
import org.lttng.scope.tmf2.views.ui.timegraph.swtjfx.SwtJfxTimeGraphViewer; | ||
|
||
/** | ||
* Common utilities for navigation actions. | ||
* | ||
* @author Alexandre Montplaisir | ||
*/ | ||
final class NavUtils { | ||
|
||
private NavUtils() {} | ||
|
||
/** | ||
* Move the selection to the target timestamp. Also update the visible range | ||
* to be centered on that timestamp, but only if it is outside of the | ||
* current visible range. | ||
* | ||
* This should only be called when reaching the new timestamp is caused by a | ||
* user action (ie, not simply because another view sent a signal). | ||
* | ||
* @param viewer | ||
* The viewer on which to work | ||
* @param timestamp | ||
* The timestamp to select, and potentially move to | ||
*/ | ||
public static void selectNewTimestamp(SwtJfxTimeGraphViewer viewer, long timestamp) { | ||
/* Update the selection to the new timestamp. */ | ||
viewer.getControl().updateTimeRangeSelection(TimeRange.of(timestamp, timestamp)); | ||
|
||
TimeRange fullTimeGraphRange = viewer.getControl().getFullTimeGraphRange(); | ||
TmfTimeRange windowRange = TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange(); | ||
long windowStart = windowRange.getStartTime().toNanos(); | ||
long windowEnd = windowRange.getEndTime().toNanos(); | ||
if (windowStart <= timestamp && timestamp <= windowEnd) { | ||
/* Timestamp is still in the visible range, don't touch anything. */ | ||
return; | ||
} | ||
/* Update the visible range to the requested timestamp. */ | ||
/* The "span" of the window (aka zoom level) will remain constant. */ | ||
long windowSpan = windowEnd - windowStart; | ||
if (windowSpan > fullTimeGraphRange.getDuration()) { | ||
/* Should never happen, but just to be mathematically safe. */ | ||
windowSpan = fullTimeGraphRange.getDuration(); | ||
} | ||
|
||
long newStart = timestamp - (windowSpan / 2); | ||
long newEnd = newStart + windowSpan; | ||
|
||
/* Clamp the range to the borders of the pane/trace. */ | ||
if (newStart < fullTimeGraphRange.getStart()) { | ||
newStart = fullTimeGraphRange.getStart(); | ||
newEnd = newStart + windowSpan; | ||
} else if (newEnd > fullTimeGraphRange.getEnd()) { | ||
newEnd = fullTimeGraphRange.getEnd(); | ||
newStart = newEnd - windowSpan; | ||
} | ||
|
||
viewer.getControl().updateVisibleTimeRange(TimeRange.of(newStart, newEnd), true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters