use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.
the class CallStackPresentationProvider method getStateTable.
@Override
public StateItem[] getStateTable() {
if (STATE_TABLE[1] == null) {
int i = 1;
for (RGBAColor color : fPalette.get()) {
STATE_TABLE[i] = new StateItem(RGBAUtil.fromRGBAColor(color).rgb, color.toString());
i++;
}
}
return STATE_TABLE;
}
use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.
the class CustomAnnotationProvider method getSubMarkerList.
private void getSubMarkerList(SplitMarker splitMarker, Annotation markerEvent, Map<String, Collection<@NonNull Annotation>> annotationMap, long startTime, long endTime, long minDuration, Long[] times) {
if (markerEvent.getTime() > endTime || markerEvent.getTime() + markerEvent.getDuration() < startTime) {
return;
}
long lower = splitMarker.getRange().lowerEndpoint();
long upper = splitMarker.getRange().upperEndpoint();
long segments = upper - lower + 1;
long start = markerEvent.getTime();
List<@NonNull Annotation> annotationList = new ArrayList<>();
for (int i = 0; i < segments; i++) {
long end = markerEvent.getTime() + Math.round((double) (i + 1) / segments * markerEvent.getDuration());
long duration = end - start;
long labelIndex = lower + i;
if (end >= startTime && duration > minDuration && splitMarker.getIndexRange().contains(labelIndex)) {
RGBAColor color = (labelIndex & 1) == 0 ? getColor(splitMarker) : getOddColor(getColor(splitMarker));
OutputElementStyle outputStyle = getOutputStyle(color);
Annotation subAnnotation = new Annotation(start, end - start, -1, String.format(splitMarker.getLabel(), labelIndex), outputStyle);
for (SubMarker subMarker : splitMarker.getSubMarkers()) {
getSubMarkerList(Objects.requireNonNull(subMarker), subAnnotation, annotationMap, startTime, endTime, minDuration, times);
}
annotationList.add(subAnnotation);
}
if (start >= endTime) {
break;
}
start = end;
}
populateMap(annotationMap, annotationList, Objects.requireNonNull(splitMarker.getName()));
}
use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.
the class CustomAnnotationProvider method configure.
private CustomPeriodicAnnotationProvider configure(Marker marker) {
if (marker instanceof PeriodicMarker) {
PeriodicMarker periodicMarker = (PeriodicMarker) marker;
long rollover = periodicMarker.getRange().hasUpperBound() ? (periodicMarker.getRange().upperEndpoint() - periodicMarker.getRange().lowerEndpoint() + 1) : 0;
RGBAColor evenColor = getColor(marker);
RGBAColor oddColor = getOddColor(evenColor);
ITmfTrace trace = fTrace;
double period = IMarkerConstants.convertToNanos(periodicMarker.getPeriod(), periodicMarker.getUnit(), trace);
String referenceId = periodicMarker.getReferenceId();
ITimeReference baseReference = null;
if (trace instanceof IAdaptable && !referenceId.isEmpty()) {
ITimeReferenceProvider adapter = ((IAdaptable) trace).getAdapter(ITimeReferenceProvider.class);
if (adapter != null) {
baseReference = adapter.apply(referenceId);
}
}
if (baseReference == null) {
baseReference = ITimeReference.ZERO;
}
ITimeReference reference = new TimeReference(baseReference.getTime() + Math.round(IMarkerConstants.convertToNanos(periodicMarker.getOffset(), periodicMarker.getUnit(), trace)), baseReference.getIndex());
return new CustomPeriodicAnnotationProvider(periodicMarker, reference, period, rollover, evenColor, oddColor);
}
// $NON-NLS-1$
throw new IllegalArgumentException("Marker must be of type PeriodicMarker or SubMarker");
}
use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.
the class StylePropertiesUtils method updateEventStyleProperties.
/**
* Transforms deprecated {@link ITimeEventStyleStrings} methods to the
* proper styles. It will create the new properties out of the deprecated
* ones only if such properties do not exist yet.
*
* @param styleMap
* The original style map.
* @return A new map of style. This map is not immutable.
*/
@SuppressWarnings("deprecation")
@NonNull
public static Map<@NonNull String, @NonNull Object> updateEventStyleProperties(@Nullable Map<String, Object> styleMap) {
if (styleMap == null) {
return new HashMap<>();
}
@NonNull Map<@NonNull String, @NonNull Object> updatedStyles = new HashMap<>(styleMap);
Object object = styleMap.get(ITimeEventStyleStrings.label());
if (object != null && !styleMap.containsKey(StyleProperties.STYLE_NAME)) {
updatedStyles.put(StyleProperties.STYLE_NAME, object);
}
object = styleMap.get(ITimeEventStyleStrings.heightFactor());
if (object != null && !styleMap.containsKey(StyleProperties.HEIGHT)) {
updatedStyles.put(StyleProperties.HEIGHT, object);
}
object = styleMap.get(ITimeEventStyleStrings.fillStyle());
if (object != null && !styleMap.containsKey(StyleProperties.LINEAR_GRADIENT)) {
if (object.equals(ITimeEventStyleStrings.gradientColorFillStyle())) {
updatedStyles.put(StyleProperties.LINEAR_GRADIENT, true);
} else {
updatedStyles.put(StyleProperties.LINEAR_GRADIENT, false);
}
}
object = styleMap.get(ITimeEventStyleStrings.fillColor());
if (object != null && (object instanceof Integer)) {
RGBAColor rgba = new RGBAColor((int) object);
String hexColor = ColorUtils.toHexColor(rgba.getRed(), rgba.getGreen(), rgba.getBlue());
float opacity = (float) rgba.getAlpha() / 255;
if (!styleMap.containsKey(StyleProperties.BACKGROUND_COLOR)) {
updatedStyles.put(StyleProperties.BACKGROUND_COLOR, hexColor);
}
if (!styleMap.containsKey(StyleProperties.COLOR)) {
updatedStyles.put(StyleProperties.COLOR, hexColor);
}
if (!styleMap.containsKey(StyleProperties.OPACITY)) {
updatedStyles.put(StyleProperties.OPACITY, opacity);
}
}
object = styleMap.get(ITimeEventStyleStrings.fillColorEnd());
if (object != null && !styleMap.containsKey(StyleProperties.LINEAR_GRADIENT_COLOR_END)) {
if (object instanceof Integer) {
RGBAColor rgba = new RGBAColor((int) object);
updatedStyles.put(StyleProperties.LINEAR_GRADIENT_COLOR_END, ColorUtils.toHexColor(rgba.getRed(), rgba.getGreen(), rgba.getBlue()));
}
}
object = styleMap.get(ITimeEventStyleStrings.borderEnable());
if (object != null && !styleMap.containsKey(StyleProperties.BORDER_STYLE)) {
if (object instanceof Boolean && (Boolean) object) {
updatedStyles.put(StyleProperties.BORDER_STYLE, BorderStyle.SOLID);
} else {
updatedStyles.put(StyleProperties.BORDER_STYLE, BorderStyle.NONE);
}
}
object = styleMap.get(ITimeEventStyleStrings.borderColor());
if (object != null && !styleMap.containsKey(StyleProperties.BORDER_COLOR)) {
if (object instanceof Integer) {
RGBAColor rgba = new RGBAColor((int) object);
updatedStyles.put(StyleProperties.BORDER_COLOR, ColorUtils.toHexColor(rgba.getRed(), rgba.getGreen(), rgba.getBlue()));
}
}
object = styleMap.get(ITimeEventStyleStrings.borderThickness());
if (object != null && !styleMap.containsKey(StyleProperties.BORDER_WIDTH)) {
updatedStyles.put(StyleProperties.BORDER_WIDTH, object);
}
object = styleMap.get(ITimeEventStyleStrings.symbolStyle());
if (object != null && !styleMap.containsKey(StyleProperties.SYMBOL_TYPE)) {
String symbolType = ITimeEventStyleStrings.SYMBOL_TYPES.get(object);
if (symbolType != null) {
updatedStyles.put(StyleProperties.SYMBOL_TYPE, symbolType);
}
}
return updatedStyles;
}
use of org.eclipse.tracecompass.tmf.core.presentation.RGBAColor in project tracecompass by tracecompass.
the class TimeGraphStyleUtil method loadValue.
/**
* Load default values into the state item from a preference store
*
* @param presentationProvider
* the presentation provider
* @param stateItem
* the state item
*/
public static void loadValue(ITimeGraphPresentationProvider presentationProvider, StateItem stateItem) {
IPreferenceStore store = getStore();
String oldFillColorKey = getPreferenceName(presentationProvider, stateItem, ITimeEventStyleStrings.fillColor());
String oldHeightFactorKey = getPreferenceName(presentationProvider, stateItem, ITimeEventStyleStrings.heightFactor());
String bgColorKey = getPreferenceName(presentationProvider, stateItem, StyleProperties.BACKGROUND_COLOR);
String colorKey = getPreferenceName(presentationProvider, stateItem, StyleProperties.COLOR);
String heightFactorKey = getPreferenceName(presentationProvider, stateItem, StyleProperties.HEIGHT);
String widthKey = getPreferenceName(presentationProvider, stateItem, StyleProperties.WIDTH);
Map<String, Object> styleMap = stateItem.getStyleMap();
String prefBgColor = store.getString(bgColorKey);
if (!prefBgColor.isEmpty()) {
styleMap.put(StyleProperties.BACKGROUND_COLOR, prefBgColor);
} else {
// Update the new value with the old
String oldPrefRgbColor = store.getString(oldFillColorKey);
if (!oldPrefRgbColor.isEmpty()) {
RGBAColor prefRgba = RGBAColor.fromString(oldPrefRgbColor);
if (prefRgba != null) {
String hexColor = ColorUtils.toHexColor(prefRgba.getRed(), prefRgba.getGreen(), prefRgba.getBlue());
styleMap.put(StyleProperties.BACKGROUND_COLOR, hexColor);
store.setValue(bgColorKey, hexColor);
}
}
}
String prefColor = store.getString(colorKey);
if (!prefColor.isEmpty()) {
styleMap.put(StyleProperties.COLOR, prefColor);
}
store.setDefault(heightFactorKey, -1.0f);
store.setDefault(oldHeightFactorKey, -1.0f);
float prefHeightFactor = store.getFloat(heightFactorKey);
if (prefHeightFactor != -1.0f) {
styleMap.put(StyleProperties.HEIGHT, prefHeightFactor);
} else {
// Update the new value with the old
prefHeightFactor = store.getFloat(oldHeightFactorKey);
if (prefHeightFactor != -1.0f) {
styleMap.put(StyleProperties.HEIGHT, prefHeightFactor);
store.setValue(heightFactorKey, prefHeightFactor);
}
}
store.setDefault(widthKey, -1);
int prefWidth = store.getInt(widthKey);
if (prefWidth != -1) {
styleMap.put(StyleProperties.WIDTH, prefWidth);
}
}
Aggregations