package org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
int value = tcEvent.getValue();
if (entry.getType() == EntryDisplayType.DISPLAY) {
- Integer index = checkNotNull(stateIndex.get(value));
- String rgb = stateValues.get(index.intValue()).getStateString();
- return rgb;
+ Integer index = stateIndex.get(value);
+ if (index != null) {
+ String rgb = stateValues.get(index.intValue()).getStateString();
+ return rgb;
+ }
}
return null;
}
return;
}
- RGB colorRGB = new RGB(255, 0, 0);
- if (color.startsWith(TmfXmlStrings.COLOR_PREFIX)) {
- Integer hex = Integer.parseInt(color.substring(1), 16);
- int hex1 = hex.intValue() % 256;
- int hex2 = (hex.intValue() / 256) % 256;
- int hex3 = (hex.intValue() / (256 * 256)) % 256;
- colorRGB = new RGB(hex3, hex2, hex1);
- } else {
- colorRGB = calcColor(value);
- }
+ final RGB colorRGB = (color.startsWith(TmfXmlStrings.COLOR_PREFIX)) ? parseColor(color) : calcColor(value);
StateItem item = new StateItem(colorRGB, name);
});
}
+ private static RGB parseColor(String color) {
+ RGB colorRGB;
+ Integer hex = Integer.parseInt(color.substring(1), 16);
+ int hex1 = hex.intValue() % 256;
+ int hex2 = (hex.intValue() / 256) % 256;
+ int hex3 = (hex.intValue() / (256 * 256)) % 256;
+ colorRGB = new RGB(hex3, hex2, hex1);
+ return colorRGB;
+ }
+
private static RGB calcColor(int value) {
int x = (value * 97) % 1530;
int r = 0, g = 0, b = 0;