Search in sources :

Example 11 with Color

use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.

the class TableDisplayTest method shouldSendCommMsgWhenAddValueHighlighterForColumnChange.

@Test
public void shouldSendCommMsgWhenAddValueHighlighterForColumnChange() throws Exception {
    // given;
    ValueHighlighter highlighter = new ValueHighlighter(COL_1, Arrays.asList(new Color(247, 106, 106)));
    // when
    tableDisplay.addCellHighlighter(highlighter);
    // then
    assertThat(tableDisplay.getCellHighlighters().get(0)).isEqualTo(highlighter);
    LinkedHashMap model = getModelUpdate();
    assertThat(model.size()).isEqualTo(1);
    List actual = getValueAsList(model, CELL_HIGHLIGHTERS);
    Map column = (Map) actual.get(0);
    assertThat(column.get(ValueHighlighterSerializer.TYPE)).isEqualTo(ValueHighlighter.class.getSimpleName());
    assertThat(column.get(ValueHighlighterSerializer.COL_NAME)).isEqualTo(COL_1);
    assertThat(column.get(ValueHighlighterSerializer.COLORS)).isNotNull();
}
Also used : Color(com.twosigma.beakerx.chart.Color) List(java.util.List) ArrayList(java.util.ArrayList) ValueHighlighter(com.twosigma.beakerx.table.highlight.ValueHighlighter) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 12 with Color

use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.

the class TableDisplayTest method shouldSendCommMsgWhenAddThreeColorHighlighterForColumnChange.

@Test
public void shouldSendCommMsgWhenAddThreeColorHighlighterForColumnChange() throws Exception {
    // given;
    ThreeColorHeatmapHighlighter highlighter = new ThreeColorHeatmapHighlighter(COL_1, TableDisplayCellHighlighter.SINGLE_COLUMN, 4, 6, 8, new Color(247, 106, 106), new Color(239, 218, 82), new Color(100, 189, 122));
    // when
    tableDisplay.addCellHighlighter(highlighter);
    // then
    assertThat(tableDisplay.getCellHighlighters().get(0)).isEqualTo(highlighter);
    LinkedHashMap model = getModelUpdate();
    assertThat(model.size()).isEqualTo(1);
    List actual = getValueAsList(model, CELL_HIGHLIGHTERS);
    Map column = (Map) actual.get(0);
    assertThat(column.get(ThreeColorHeatmapHighlighterSerializer.TYPE)).isEqualTo(ThreeColorHeatmapHighlighter.class.getSimpleName());
    assertThat(column.get(ThreeColorHeatmapHighlighterSerializer.STYLE)).isEqualTo(TableDisplayCellHighlighter.SINGLE_COLUMN.toString());
    assertThat(column.get(ThreeColorHeatmapHighlighterSerializer.MID_VAL)).isEqualTo(6);
    assertThat(column.get(ThreeColorHeatmapHighlighterSerializer.MID_COLOR)).isNotNull();
}
Also used : ThreeColorHeatmapHighlighter(com.twosigma.beakerx.table.highlight.ThreeColorHeatmapHighlighter) Color(com.twosigma.beakerx.chart.Color) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 13 with Color

use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.

the class TableDisplayClosureTest method addCellHighlighterClosure_shouldFormatCellColors.

@Test
public void addCellHighlighterClosure_shouldFormatCellColors() throws Exception {
    // when
    tableDisplay.addCellHighlighter(new ClosureTest() {

        @Override
        public Color call(Object row, Object col, Object tbl) {
            return ((int) row % 2 == 0) ? Color.GREEN : Color.BLUE;
        }

        @Override
        public int getMaximumNumberOfParameters() {
            return 3;
        }
    });
    // then
    ValueHighlighter highlighter = (ValueHighlighter) tableDisplay.getCellHighlighters().get(0);
    Assertions.assertThat(highlighter.getColors().get(0)).isEqualTo(Color.GREEN);
    Assertions.assertThat(highlighter.getColors().get(1)).isEqualTo(Color.BLUE);
}
Also used : Color(com.twosigma.beakerx.chart.Color) ValueHighlighter(com.twosigma.beakerx.table.highlight.ValueHighlighter) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 14 with Color

use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.

the class ColorUtilsTest method callInterpolateColorWithGreenBlueColorsAndFractionIsZero_returnBeakerColorWithGreenValue.

@Test
public void callInterpolateColorWithGreenBlueColorsAndFractionIsZero_returnBeakerColorWithGreenValue() {
    // when
    Color color = ColorUtils.interpolateColor(java.awt.Color.GREEN, java.awt.Color.BLUE, 0f);
    // then
    Assertions.assertThat(color).isEqualTo(Color.GREEN);
}
Also used : Color(com.twosigma.beakerx.chart.Color) Test(org.junit.Test)

Example 15 with Color

use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.

the class HistogramTest method setColorWithAwtColorParam_colorHasBeakerColorType.

@Test
public void setColorWithAwtColorParam_colorHasBeakerColorType() {
    // given
    histogram = createWidget();
    // when
    histogram.setColor(java.awt.Color.GREEN);
    // then
    assertThat(histogram.getColor() instanceof Color).isTrue();
    LinkedHashMap model = getModelUpdate();
    assertThat(model.size()).isEqualTo(1);
    assertThat(model.get(COLOR)).isNotNull();
}
Also used : Color(com.twosigma.beakerx.chart.Color) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) AbstractChartTest(com.twosigma.beakerx.chart.AbstractChartTest)

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