use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.
the class CustomAnnotationProvider method getMarkers.
private Map<@NonNull String, @NonNull Collection<@NonNull Annotation>> getMarkers(Map<@NonNull String, @NonNull Object> fetchParams, @Nullable IProgressMonitor monitor) {
List<@NonNull Long> timeRequested = DataProviderParameterUtils.extractTimeRequested(fetchParams);
if (timeRequested == null || timeRequested.size() < 2) {
return Collections.emptyMap();
}
Long[] times = timeRequested.toArray(new Long[0]);
long starttime = timeRequested.get(0);
long endtime = timeRequested.get(timeRequested.size() - 1);
int resolution = (int) Math.min(Integer.MAX_VALUE, timeRequested.get(1) - timeRequested.get(0));
Map<@NonNull String, @NonNull Collection<@NonNull Annotation>> markerMap = new LinkedHashMap<>();
for (CustomPeriodicAnnotationProvider periodicAnnotationProvider : fAnnotationProviders) {
long minDuration = resolution * MIN_PERIOD;
long maxDuration = (long) periodicAnnotationProvider.getPeriod();
if (maxDuration > minDuration) {
AnnotationModel model = periodicAnnotationProvider.fetchAnnotations(fetchParams, monitor).getModel();
if (model != null) {
Map<@NonNull String, @NonNull Collection<@NonNull Annotation>> annotations = model.getAnnotations();
List<Annotation> markerList = new ArrayList<>();
for (Entry<@NonNull String, @NonNull Collection<@NonNull Annotation>> entryAnnotation : annotations.entrySet()) {
String category = Objects.requireNonNull(entryAnnotation.getKey());
for (Annotation annotation : Objects.requireNonNull(entryAnnotation.getValue())) {
markerList.add(annotation);
for (SubMarker subMarker : periodicAnnotationProvider.getSubMarkers()) {
getSubMarkerList(Objects.requireNonNull(subMarker), annotation, markerMap, starttime, endtime, minDuration, times);
}
}
markerMap.put(category, markerList);
}
}
}
}
@Nullable Set<@NonNull String> categoriesRequested = DataProviderParameterUtils.extractSelectedCategories(fetchParams);
markerMap.keySet().removeIf(cat -> categoriesRequested != null && !categoriesRequested.contains(cat));
return markerMap;
}
use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation in project tracecompass by tracecompass.
the class BaseDataProviderTimeGraphView method getViewMarkerList.
@Override
@NonNull
protected List<IMarkerEvent> getViewMarkerList(Iterable<@NonNull TimeGraphEntry> entries, long startTime, long endTime, long resolution, @NonNull IProgressMonitor monitor) {
List<IMarkerEvent> viewMarkerList = super.getViewMarkerList(startTime, endTime, resolution, monitor);
List<@NonNull TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries == null) {
return viewMarkerList;
}
List<@NonNull Long> times = StateSystemUtils.getTimes(startTime, endTime, resolution);
Multimap<ITimeGraphDataProvider<? extends TimeGraphEntryModel>, Long> providersToModelIds = filterGroupEntries(entries, startTime, endTime);
for (ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider : providersToModelIds.keySet()) {
if (provider instanceof IOutputAnnotationProvider) {
List<String> categories = new ArrayList<>(fMarkerCategories.get(provider));
categories.removeIf(category -> !getTimeGraphViewer().isMarkerCategoryVisible(category));
if (categories.isEmpty()) {
continue;
}
Map<@NonNull String, @NonNull Object> parameters = getFetchAnnotationsParameters(times, providersToModelIds.get(provider));
parameters.put(DataProviderParameterUtils.REQUESTED_MARKER_CATEGORIES_KEY, categories);
TmfModelResponse<@NonNull AnnotationModel> response = ((IOutputAnnotationProvider) provider).fetchAnnotations(parameters, new NullProgressMonitor());
AnnotationModel model = response.getModel();
if (model != null) {
for (Entry<String, Collection<Annotation>> entry : model.getAnnotations().entrySet()) {
String category = entry.getKey();
for (Annotation annotation : entry.getValue()) {
if (annotation.getType() == AnnotationType.CHART) {
// If the annotation entry ID is -1 we want the
// marker to span across all entries
ITimeGraphEntry markerEntry = null;
if (annotation.getEntryId() != -1) {
synchronized (fEntries) {
markerEntry = fEntries.get(provider, annotation.getEntryId());
}
}
MarkerEvent markerEvent = new MarkerEvent(annotation, markerEntry, category, true);
viewMarkerList.add(markerEvent);
}
}
}
}
}
}
return viewMarkerList;
}
Aggregations