Search in sources :

Example 1 with ITimeEvent

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;
}
Also used : OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)

Example 2 with ITimeEvent

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;
}
Also used : ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) ModuleEntryModel(org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) StateSystemEntryModel(org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.StateSystemEntryModel) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)

Example 3 with ITimeEvent

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);
        }
    }
}
Also used : ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) ViewFilterDialog(org.eclipse.tracecompass.internal.provisional.tmf.ui.widgets.ViewFilterDialog) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList)

Example 4 with ITimeEvent

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;
}
Also used : OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ITimeGraphEntryModelWeighted(org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph.ITimeGraphEntryModelWeighted) MarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)

Example 5 with ITimeEvent

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();
}
Also used : ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) ResourcesEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)

Aggregations

ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)43 TimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)22 NullTimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent)21 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)18 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)18 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)4 NonNull (org.eclipse.jdt.annotation.NonNull)4 Point (org.eclipse.swt.graphics.Point)4 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)4 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)4 LongPoint (org.eclipse.tracecompass.internal.tmf.ui.widgets.timegraph.TimeGraphRender.LongPoint)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ViewFilterDialog (org.eclipse.tracecompass.internal.provisional.tmf.ui.widgets.ViewFilterDialog)2