Search in sources :

Example 16 with Color

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;
}
Also used : Color(com.twosigma.beakerx.chart.Color)

Example 17 with Color

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);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Color(com.twosigma.beakerx.chart.Color) TableDisplayToJson.serializeFontColor(com.twosigma.beakerx.table.TableDisplayToJson.serializeFontColor) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ValueHighlighter(com.twosigma.beakerx.table.highlight.ValueHighlighter)

Aggregations

Color (com.twosigma.beakerx.chart.Color)17 Test (org.junit.Test)11 LinkedHashMap (java.util.LinkedHashMap)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 KernelTest (com.twosigma.beakerx.KernelTest)6 HashMap (java.util.HashMap)6 ValueHighlighter (com.twosigma.beakerx.table.highlight.ValueHighlighter)5 Map (java.util.Map)4 TableDisplayToJson.serializeFontColor (com.twosigma.beakerx.table.TableDisplayToJson.serializeFontColor)2 ThreeColorHeatmapHighlighter (com.twosigma.beakerx.table.highlight.ThreeColorHeatmapHighlighter)2 Arrays.asList (java.util.Arrays.asList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 TreeMap (com.twosigma.beakerx.chart.treemap.TreeMap)1 IToolTipBuilder (com.twosigma.beakerx.chart.treemap.util.IToolTipBuilder)1 Line (com.twosigma.beakerx.chart.xychart.plotitem.Line)1 Points (com.twosigma.beakerx.chart.xychart.plotitem.Points)1 XYGraphics (com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics)1