use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent in project tracecompass by tracecompass.
the class TimeGraphViewer method getToggleBookmarkAction.
/**
* Get the toggle bookmark action.
*
* @return The Action object
* @since 2.0
*/
public Action getToggleBookmarkAction() {
if (fToggleBookmarkAction == null) {
fToggleBookmarkAction = new Action() {
@Override
public void runWithEvent(Event event) {
IMarkerEvent selectedBookmark = getBookmarkAtSelection();
if (selectedBookmark == null) {
final long time = Math.min(fSelectionBegin, fSelectionEnd);
final long duration = Math.max(fSelectionBegin, fSelectionEnd) - time;
final AddBookmarkDialog dialog = new AddBookmarkDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), null);
if (dialog.open() == Window.OK) {
final String label = dialog.getValue();
final RGBA rgba = dialog.getColorValue();
IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARKS, rgba, label, true);
fBookmarks.add(bookmark);
updateMarkerList();
updateMarkerActions();
getControl().redraw();
fireBookmarkAdded(bookmark);
}
} else {
fBookmarks.remove(selectedBookmark);
updateMarkerList();
updateMarkerActions();
getControl().redraw();
fireBookmarkRemoved(selectedBookmark);
}
}
};
fToggleBookmarkAction.setText(Messages.TmfTimeGraphViewer_BookmarkActionAddText);
fToggleBookmarkAction.setToolTipText(Messages.TmfTimeGraphViewer_BookmarkActionAddText);
fToggleBookmarkAction.setImageDescriptor(ADD_BOOKMARK);
}
return fToggleBookmarkAction;
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent in project tracecompass by tracecompass.
the class ResourcesPresentationProvider method getSpecificEventStyle.
@Override
public Map<String, Object> getSpecificEventStyle(ITimeEvent event) {
Map<String, Object> map = new HashMap<>(super.getSpecificEventStyle(event));
if (isType(event.getEntry(), Type.CURRENT_THREAD) && event instanceof TimeEvent) {
if (event instanceof MarkerEvent) {
TimeEvent timeEvent = (TimeEvent) event;
OutputElementStyle style = timeEvent.getModel().getStyle();
if (style != null) {
return style.getStyleValues();
}
} else {
int threadEventValue = ((TimeEvent) event).getValue();
RGBAColor color = PALETTE.get(Math.floorMod(threadEventValue + COLOR_DIFFERENCIATION_FACTOR, NUM_COLORS));
map.put(StyleProperties.BACKGROUND_COLOR, ColorUtils.toHexColor(color.getRed(), color.getGreen(), color.getBlue()));
map.put(StyleProperties.STYLE_NAME, String.valueOf(threadEventValue));
}
} else if (event.getEntry() instanceof TimeGraphEntry && ((TimeGraphEntry) event.getEntry()).getEntryModel() instanceof ITimeGraphEntryModelWeighted) {
ITimeGraphEntryModelWeighted model = (ITimeGraphEntryModelWeighted) ((TimeGraphEntry) event.getEntry()).getEntryModel();
int eventValue = ((TimeEvent) event).getValue();
map.put(StyleProperties.HEIGHT, (float) model.getWeight(eventValue));
}
return map;
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent in project tracecompass by tracecompass.
the class TimeGraphViewStub method getViewMarkerList.
@Override
@NonNull
protected List<IMarkerEvent> getViewMarkerList(Iterable<@NonNull TimeGraphEntry> entries, long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) {
ITmfTrace trace = getTrace();
if (trace == null) {
return Collections.emptyList();
}
long start = trace.getStartTime().toNanos();
return Arrays.<IMarkerEvent>asList((IMarkerEvent) new MarkerEvent(fHead1, 120 + start, 50, MARKER_GROUP, new RGBA(33, 33, 33, 33), "Wind", true), (IMarkerEvent) new MarkerEvent(fRow4, 20 + start, 60, MARKER_GROUP, new RGBA(22, 33, 44, 22), "Speed", false), (IMarkerEvent) new MarkerEvent(fRow2, 20 + start, 0, MARKER_GROUP, new RGBA(160, 170, 200, 80), "", true, 0), (IMarkerEvent) new MarkerEvent(fRow2, 26 + start, 0, MARKER_GROUP, new RGBA(160, 170, 200, 80), "", false, 1), (IMarkerEvent) new MarkerEvent(fRow2, 32 + start, 0, MARKER_GROUP, new RGBA(160, 170, 200, 80), "", true, 2), (IMarkerEvent) new MarkerEvent(fRow2, 38 + start, 0, MARKER_GROUP, new RGBA(160, 170, 200, 80), "", false, 3), (IMarkerEvent) new MarkerEvent(fRow2, 44 + start, 0, MARKER_GROUP, new RGBA(160, 170, 200, 80), "", true, 4), (IMarkerEvent) new MarkerEvent(fRow2, 50 + start, 0, MARKER_GROUP, new RGBA(160, 170, 200, 80), "", false, 5), (IMarkerEvent) new MarkerEvent(fRow2, 56 + start, 0, MARKER_GROUP, new RGBA(160, 170, 200, 80), "", true, 6));
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent in project tracecompass by tracecompass.
the class TimeGraphViewWithTooManyMarkersStub method getViewMarkerList.
@Override
@NonNull
protected List<IMarkerEvent> getViewMarkerList(Iterable<@NonNull TimeGraphEntry> entries, long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) {
ITmfTrace trace = getTrace();
if (trace == null) {
return Collections.emptyList();
}
RGBA fromInt = new RGBA(0, 0, 0, 255);
long start = trace.getStartTime().toNanos();
List<IMarkerEvent> markers = new ArrayList<>();
for (TimeGraphEntry row : entries) {
int rowId = fEntries.indexOf(row);
int offset = (int) (MARKER_STEP / 2 * Math.sin(rowId * Math.PI / MARKER_STEP)) + MARKER_STEP / 2;
for (long i = 0; i < NB_MARKERS; i += MARKER_STEP) {
long time = start + i + offset;
if (time >= startTime && time <= endTime) {
markers.add(new MarkerEvent(row, time, 0L, "", fromInt, "", true, (rowId / MARKER_STEP) % 7));
}
}
}
return markers;
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent in project tracecompass by tracecompass.
the class PeriodicMarkerEventSourceTest method testRollover.
/**
* Test a marker event source with roll-over.
*/
@Test
public void testRollover() {
IMarkerEventSource source = new PeriodicMarkerEventSource(CATEGORY, Reference.ZERO, 100L, 4, COLOR, false);
List<IMarkerEvent> expected = Arrays.asList(new MarkerEvent(null, -100L, 0L, CATEGORY, COLOR, "3", false), new MarkerEvent(null, 0L, 0L, CATEGORY, COLOR, "0", false), new MarkerEvent(null, 100L, 0L, CATEGORY, COLOR, "1", false), new MarkerEvent(null, 200L, 0L, CATEGORY, COLOR, "2", false), new MarkerEvent(null, 300L, 0L, CATEGORY, COLOR, "3", false), new MarkerEvent(null, 400L, 0L, CATEGORY, COLOR, "0", false));
assertMarkerListEquals(expected, source.getMarkerList(CATEGORY, 0L, 300L, 1, new NullProgressMonitor()));
}
Aggregations