use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent in project tracecompass by tracecompass.
the class ITimeGraphPresentationProvider method getEventStyle.
/**
* Get the style map of a given ITimeEvent
*
* @param event
* the time event
* @return the style map, as detailed in {@link ITimeEventStyleStrings}
* @since 3.0
*/
default Map<String, Object> getEventStyle(ITimeEvent event) {
if (event instanceof TimeEvent) {
TimeEvent timeEvent = (TimeEvent) event;
OutputElementStyle style = timeEvent.getModel().getStyle();
if (style != null) {
Map<@NonNull String, @NonNull Object> styleValues = style.getStyleValues();
if (!styleValues.isEmpty()) {
return styleValues;
}
}
}
StateItem stateItem = null;
int index = getStateTableIndex(event);
StateItem[] stateTable = getStateTable();
if (index >= 0 && index < stateTable.length) {
stateItem = stateTable[index];
}
Map<String, Object> styleMap = stateItem == null ? Collections.emptyMap() : stateItem.getStyleMap();
Map<String, Object> specificEventStyles = getSpecificEventStyle(event);
if (specificEventStyles.isEmpty()) {
return styleMap;
}
if (styleMap.isEmpty()) {
return specificEventStyles;
}
styleMap = new HashMap<>(styleMap);
styleMap.putAll(specificEventStyles);
return styleMap;
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent in project tracecompass by tracecompass.
the class StateSystemPresentationProvider method getStateTableIndex.
@Override
public int getStateTableIndex(ITimeEvent event) {
if (event instanceof TimeEvent) {
TimeEvent timeEvent = (TimeEvent) event;
Object value = timeEvent.getLabel();
if (value != null) {
return Math.floorMod(value.hashCode(), NUM_COLORS);
}
ITimeGraphEntry entry = event.getEntry();
if (entry != null) {
ITmfTreeDataModel model = ((TimeGraphEntry) entry).getEntryModel();
if (model instanceof StateSystemEntryModel || model instanceof ModuleEntryModel) {
// tooltip
return INVISIBLE;
}
}
// grey
return NUM_COLORS;
}
return INVISIBLE;
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent in project tracecompass by tracecompass.
the class AbstractTimeGraphView method fillWithNullEvents.
/**
* Fill the gaps between non-excluded events with null time events
*
* @param entry
* The entry
* @param eventList
* The entry event list
*/
private void fillWithNullEvents(TimeGraphEntry entry, List<ITimeEvent> eventList) {
List<ITimeEvent> filtered = new ArrayList<>();
ViewFilterDialog viewFilterDialog = getViewFilterDialog();
if (!eventList.isEmpty() && viewFilterDialog != null && viewFilterDialog.hasActiveSavedFilters()) {
eventList.forEach(te -> {
// Keep only the events that do not have the 'exclude' property activated
if (!te.isPropertyActive(CoreFilterProperty.EXCLUDE)) {
filtered.add(te);
}
});
long prevTime = eventList.get(0).getTime();
long endTime = eventList.get(eventList.size() - 1).getTime() + eventList.get(eventList.size() - 1).getDuration();
eventList.clear();
// Replace unused events with null time events to fill gaps
for (ITimeEvent event : filtered) {
if (prevTime < event.getTime()) {
NullTimeEvent nullTimeEvent = new NullTimeEvent(entry, prevTime, event.getTime() - prevTime);
nullTimeEvent.setProperty(CoreFilterProperty.DIMMED, true);
nullTimeEvent.setProperty(CoreFilterProperty.EXCLUDE, true);
eventList.add(nullTimeEvent);
}
eventList.add(event);
prevTime = event.getTime() + event.getDuration();
}
if (prevTime < endTime) {
NullTimeEvent nullTimeEvent = new NullTimeEvent(entry, prevTime, endTime - prevTime);
nullTimeEvent.setProperty(CoreFilterProperty.DIMMED, true);
nullTimeEvent.setProperty(CoreFilterProperty.EXCLUDE, true);
eventList.add(nullTimeEvent);
}
}
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent 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.ITimeEvent in project tracecompass by tracecompass.
the class ResourcesPresentationProvider method getEventHoverToolTipInfo.
@Override
public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event, long hoverTime) {
ITimeGraphEntry entry = event.getEntry();
if (event instanceof TimeEvent && ((TimeEvent) event).hasValue() && entry instanceof TimeGraphEntry) {
ITmfTreeDataModel model = ((TimeGraphEntry) entry).getEntryModel();
TimeEvent tcEvent = (TimeEvent) event;
if (tcEvent.hasValue() && model instanceof ResourcesEntryModel) {
ResourcesEntryModel resourcesModel = (ResourcesEntryModel) model;
if (resourcesModel.getType().equals(Type.IRQ) || resourcesModel.getType().equals(Type.SOFT_IRQ) || resourcesModel.getType().equals(Type.CPU) || resourcesModel.getType().equals(Type.CURRENT_THREAD) || resourcesModel.getType().equals(Type.FREQUENCY)) {
ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = BaseDataProviderTimeGraphView.getProvider((TimeGraphEntry) entry);
if (provider != null) {
return getTooltip(provider, model.getId(), hoverTime);
}
}
}
}
return Collections.emptyMap();
}
Aggregations