use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.
the class ColorDeserializer method deserialize.
@Override
public Object deserialize(JsonNode n, ObjectMapper mapper) {
Object o = null;
try {
long i = Long.parseLong(n.asText().substring(1), 16);
o = new Color((int) ((i >> 16) & 0xFF), (int) ((i >> 8) & 0xFF), (int) (i & 0xFF), (int) ((i >> 24) & 0xFF));
} catch (Exception e) {
logger.error("exception deserializing Color {}", e.getMessage());
}
return o;
}
use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.
the class TableDisplay method addCellHighlighter.
public void addCellHighlighter(Object closure) {
Map<String, List<Color>> colors = new HashMap<>();
try {
int rowSize = this.values.get(0).size();
for (int colInd = 0; colInd < rowSize; colInd++) {
boolean hasHighlightedValues = false;
List<Color> columnColors = new ArrayList<>();
for (int rowInd = 0; rowInd < this.values.size(); rowInd++) {
Object[] params = new Object[] { rowInd, colInd, this };
Color color = (Color) runClosure(closure, params);
if (color != null) {
hasHighlightedValues = true;
}
columnColors.add(color);
}
if (hasHighlightedValues) {
addCellHighlighter(new ValueHighlighter(this.columns.get(colInd), columnColors));
}
}
} catch (Throwable e) {
throw new IllegalArgumentException("Can not set cell highlighter using closure.", e);
}
}
Aggregations