Search in sources :

Example 1 with CGArc

use of org.eclipse.linuxtools.internal.gprof.view.histogram.CGArc in project linuxtools by eclipse.

the class GmonView method getBackground.

/*
     * I do not know where to put this static method. It is used by all ProfFields
     */
public static Color getBackground(Object element) {
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    // FIXME: Not sure if color1-color4 are ever used...picked colors found in JFacesResources ColorRegistry
    // not tied to any particular language (e.g. didn't choose CDT or Java colors)
    // Color5 seems to work ok as bg in the one dark theme I tried (Nissl-Adwaita-dark-4) and as well
    // in default light adwaita, but it is much simpler to just return null and let the table color default
    // appropriately.
    // $NON-NLS-1$
    Color color1 = colorRegistry.get("org.eclipse.ui.editors.currentLineColor");
    // $NON-NLS-1$
    Color color2 = colorRegistry.get("org.eclipse.ui.workbench.INACTIVE_TAB_BG_START");
    // $NON-NLS-1$
    Color color3 = colorRegistry.get("org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END");
    // $NON-NLS-1$
    Color color4 = colorRegistry.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END");
    if (element instanceof CGCategory) {
        CGCategory cat = (CGCategory) element;
        if (CGCategory.CHILDREN.equals(cat.category)) {
            return color1 == null ? BLUE1 : color1;
        } else {
            return color2 == null ? GREEN1 : color2;
        }
    } else if (element instanceof CGArc) {
        CGArc arc = (CGArc) element;
        CGCategory cat = (CGCategory) arc.getParent();
        if (CGCategory.CHILDREN.equals(cat.category)) {
            return color3 == null ? BLUE2 : color3;
        } else {
            return color4 == null ? GREEN2 : color4;
        }
    }
    // default background
    return null;
// return color5 == null ? DEFAULT_BG : color5;
}
Also used : CGCategory(org.eclipse.linuxtools.internal.gprof.view.histogram.CGCategory) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) Color(org.eclipse.swt.graphics.Color) CGArc(org.eclipse.linuxtools.internal.gprof.view.histogram.CGArc)

Aggregations

ColorRegistry (org.eclipse.jface.resource.ColorRegistry)1 CGArc (org.eclipse.linuxtools.internal.gprof.view.histogram.CGArc)1 CGCategory (org.eclipse.linuxtools.internal.gprof.view.histogram.CGCategory)1 Color (org.eclipse.swt.graphics.Color)1