Search in sources :

Example 1 with ITimeGraphEntryModelWeighted

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph.ITimeGraphEntryModelWeighted 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)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ITimeGraphEntryModelWeighted (org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph.ITimeGraphEntryModelWeighted)1 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)1 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)1 ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)1 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)1 MarkerEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent)1 NullTimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent)1 TimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)1 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)1