tmf.ui: make TimeGraphControl use styles from markers
Check if there's a style before defaulting to MarkerEvent#getColor()
Change-Id: I68a42f741c11237c1ff9f1423d4cf744fa5746b6
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/181115
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/MarkerEvent.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/MarkerEvent.java
index 5d63069..fb0efb9 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/MarkerEvent.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/MarkerEvent.java
@@ -18,6 +18,10 @@
import org.eclipse.swt.graphics.RGBA;
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IAnnotation;
+import org.eclipse.tracecompass.tmf.core.model.OutputElementStyle;
+import org.eclipse.tracecompass.tmf.core.model.StyleProperties;
+import org.eclipse.tracecompass.tmf.core.presentation.RGBAColor;
+import org.eclipse.tracecompass.tmf.ui.model.StyleManager;
/**
* TimeEvent implementation for marker events
@@ -26,6 +30,7 @@
*/
public class MarkerEvent extends TimeEvent implements IMarkerEvent {
+ private static final RGBAColor BLACK = new RGBAColor(0,0,0);
private final String fCategory;
private final RGBA fColor;
private final String fLabel;
@@ -102,7 +107,16 @@
super(entry, annotation);
fCategory = category;
fLabel = annotation.getLabel();
- fColor = new RGBA(0, 0, 0, 255);
+ OutputElementStyle style = annotation.getStyle();
+ RGBAColor color = null;
+ if (style != null) {
+ StyleManager styleManager = StyleManager.empty();
+ color = styleManager.getColorStyle(style, StyleProperties.COLOR);
+ }
+ if (color == null) {
+ color = BLACK;
+ }
+ fColor = new RGBA(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
fForeground = foreground;
}
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
index c570059..cdafe62 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
@@ -2299,13 +2299,14 @@
return;
}
}
- oldDrawMarker(marker, gc, rect);
+ oldDrawMarker(marker, gc, rect, rgba);
}
- private void oldDrawMarker(IMarkerEvent marker, GC gc, Rectangle rect) {
- Color color = getColorScheme().getColor(marker.getColor());
+ private void oldDrawMarker(IMarkerEvent marker, GC gc, Rectangle rect, @Nullable RGBAColor rgba) {
+ int colorInt = (rgba != null) ? rgba.toInt() : RGBAUtil.fromRGBA(marker.getColor());
+ Color color = TimeGraphRender.getColor(colorInt);
gc.setBackground(color);
- gc.setAlpha(color.getAlpha());
+ gc.setAlpha(rgba != null ? rgba.getAlpha() : color.getAlpha());
gc.fillRectangle(rect);
gc.setAlpha(OPAQUE);
String label = marker.getLabel();