Search in sources :

Example 1 with StateItem

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem in project tracecompass by tracecompass.

the class StateSystemPresentationProvider method getStateTable.

@Override
public StateItem[] getStateTable() {
    if (STATE_TABLE[0] == null) {
        List<@NonNull RGBAColor> colors = fPalette.get();
        for (int i = 0; i < colors.size(); i++) {
            RGBAColor rgbaColor = colors.get(i);
            STATE_TABLE[i] = new StateItem(RGBAUtil.fromInt(rgbaColor.toInt()).rgb, rgbaColor.toString());
        }
    }
    return STATE_TABLE;
}
Also used : RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) StateItem(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem)

Example 2 with StateItem

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem in project tracecompass by tracecompass.

the class TimeChartAnalysisProvider method getEventStyle.

@Override
public Map<String, Object> getEventStyle(ITimeEvent event) {
    StateItem stateItem = null;
    int index = getStateTableIndex(event);
    if (index == ColorSettingsManager.PRIORITY_NONE) {
        return DEFAULT_STATE.getStyleMap();
    }
    StateItem[] stateTable = getStateTable();
    if (index >= 0 && index < stateTable.length) {
        stateItem = stateTable[index];
    }
    return stateItem == null ? Collections.emptyMap() : stateItem.getStyleMap();
}
Also used : StateItem(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem)

Example 3 with StateItem

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem in project tracecompass by tracecompass.

the class TimeChartAnalysisProvider method colorSettingsChanged.

@Override
public void colorSettingsChanged(ColorSetting[] settings) {
    StateItem[] stateItems = new StateItem[settings.length];
    for (int i = 0; i < settings.length; i++) {
        stateItems[i] = new StateItem(settings[i].getTickColorRGB(), StateItem.UNDEFINED_STATE_NAME);
    }
    fStateTable = stateItems;
}
Also used : StateItem(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem)

Example 4 with StateItem

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem in project tracecompass by tracecompass.

the class FlameGraphPresentationProvider method getStateTable.

@Override
public StateItem[] getStateTable() {
    if (fStateTable[1] == null) {
        Map<@NonNull String, @NonNull OutputElementStyle> styles = FlameDefaultPalette.getStyles();
        if (styles.isEmpty()) {
            for (int i = 0; i < NUM_COLORS; i++) {
                fStateTable[i + 1] = new StateItem(Collections.emptyMap());
            }
            return fStateTable;
        }
        int tableIndex = 1;
        for (Entry<@NonNull String, @NonNull OutputElementStyle> styleEntry : styles.entrySet()) {
            String styleKey = styleEntry.getKey();
            fKeyToIndex.put(styleKey, tableIndex);
            OutputElementStyle elementStyle = styleEntry.getValue();
            Map<String, Object> styleMap = new HashMap<>();
            RGBAColor bgColor = getColorStyle(elementStyle, StyleProperties.BACKGROUND_COLOR);
            if (bgColor != null) {
                RGB rgb = new RGB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue());
                styleMap.put(StyleProperties.BACKGROUND_COLOR, ColorUtils.toHexColor(rgb));
            }
            RGBAColor color = getColorStyle(elementStyle, StyleProperties.COLOR);
            if (color != null) {
                RGB rgb = new RGB(color.getRed(), color.getGreen(), color.getBlue());
                styleMap.put(StyleProperties.COLOR, ColorUtils.toHexColor(rgb));
            }
            Object styleName = getStyle(elementStyle, StyleProperties.STYLE_NAME);
            if (styleName instanceof String) {
                styleMap.put(StyleProperties.STYLE_NAME, styleName);
            } else {
                styleMap.put(StyleProperties.STYLE_NAME, styleEntry.getKey());
            }
            Float height = getFloatStyle(elementStyle, StyleProperties.HEIGHT);
            if (height != null) {
                styleMap.put(StyleProperties.HEIGHT, height);
            }
            Float width = getFloatStyle(elementStyle, StyleProperties.WIDTH);
            if (width != null) {
                styleMap.put(StyleProperties.WIDTH, width.intValue());
            }
            Object symbolType = getStyle(elementStyle, StyleProperties.SYMBOL_TYPE);
            if (symbolType instanceof String) {
                styleMap.put(StyleProperties.SYMBOL_TYPE, symbolType);
            }
            Object styleGroup = getStyle(elementStyle, StyleProperties.STYLE_GROUP);
            if (styleGroup != null) {
                styleMap.put(StyleProperties.STYLE_GROUP, styleGroup);
            }
            fStateTable[tableIndex] = new StateItem(styleMap);
            tableIndex++;
        }
    }
    return fStateTable;
}
Also used : OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) HashMap(java.util.HashMap) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) RGB(org.eclipse.swt.graphics.RGB) StateItem(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem)

Example 5 with StateItem

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem in project tracecompass by tracecompass.

the class XmlPresentationProvider method addOrUpdateState.

private synchronized void addOrUpdateState(int value, String name, String color) {
    // FIXME Allow this case
    if (value < 0) {
        return;
    }
    final RGB colorRGB = (color.startsWith(TmfXmlStrings.COLOR_PREFIX)) ? parseColor(color) : calcColor(name);
    StateItem item = new StateItem(colorRGB, name);
    Integer index = stateIndex.get(value);
    if (index == null) {
        /* Add the new state value */
        stateIndex.put(value, stateValues.size());
        stateValues.add(item);
    } else {
        /* Override a previous state value */
        stateValues.set(index, item);
    }
    stateTable = stateValues.toArray(new StateItem[stateValues.size()]);
}
Also used : RGB(org.eclipse.swt.graphics.RGB) StateItem(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem)

Aggregations

StateItem (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.StateItem)12 RGB (org.eclipse.swt.graphics.RGB)5 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)5 HashMap (java.util.HashMap)3 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)3 ArrayList (java.util.ArrayList)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Group (org.eclipse.swt.widgets.Group)2 Collections2 (com.google.common.collect.Collections2)1 LinkedHashMultimap (com.google.common.collect.LinkedHashMultimap)1 Multimap (com.google.common.collect.Multimap)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 TitleAreaDialog (org.eclipse.jface.dialogs.TitleAreaDialog)1