use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.
the class ColorUtilsTest method callInterpolateColorWithGreenBlueColors_returnBeakerColorWithRGB.
@Test
public void callInterpolateColorWithGreenBlueColors_returnBeakerColorWithRGB() {
// when
Color color = ColorUtils.interpolateColor(java.awt.Color.GREEN, java.awt.Color.BLUE, 0.1f);
// then
Assertions.assertThat(color.getRGB()).isNotZero();
}
use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.
the class ColorDeserializerTest method deserialize_resultObjectHasColor.
@Test
public void deserialize_resultObjectHasColor() throws Exception {
// given
ObjectMapper mapper = new ObjectMapper();
JsonNode actualObj = mapper.readTree(json);
ColorDeserializer deserializer = new ColorDeserializer(new BasicObjectSerializer());
// when
Color color = (Color) deserializer.deserialize(actualObj, mapper);
// then
Assertions.assertThat(color).isNotNull();
Assertions.assertThat(color.getRGB()).isEqualTo(Color.GREEN.getRGB());
}
use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.
the class SimpleTimePlot method reinitialize.
private void reinitialize() {
List<XYGraphics> graphics = getGraphics();
filter(graphics, new Predicate<XYGraphics>() {
public boolean test(XYGraphics graphic) {
return !(graphic instanceof Line || graphic instanceof Points);
}
});
List<Object> xs = new ArrayList<>();
List<List<Number>> yss = new ArrayList<>();
Set<String> dataColumnsNames = new HashSet<>();
if (data != null && columns != null) {
for (Map<String, Object> row : data) {
dataColumnsNames.addAll(row.keySet());
xs.add(getNumberForTimeColumn(row.get(timeColumn)));
for (int i = 0; i < columns.size(); i++) {
String column = columns.get(i);
if (i >= yss.size()) {
yss.add(new ArrayList<Number>());
}
yss.get(i).add(getNumberForTimeColumn(row.get(column)));
}
}
final HashSet<String> columnsWithoutData = getColumnsWithoutData(dataColumnsNames);
if (!columnsWithoutData.isEmpty()) {
throw new IllegalArgumentException(String.format("Chart data not found for columns: %s", columnsWithoutData));
}
List<Color> colors = getChartColors();
for (int i = 0; i < yss.size(); i++) {
List<Number> ys = yss.get(i);
if (displayLines) {
Line line = new Line();
line.setX(xs);
line.setY(ys);
if (displayNames != null && i < displayNames.size()) {
line.setDisplayName(displayNames.get(i));
} else {
line.setDisplayName(columns.get(i));
}
if (i < colors.size()) {
line.setColor(colors.get(i));
}
add(line);
}
if (displayPoints) {
Points points = new Points();
points.setX(xs);
points.setY(ys);
if (displayNames != null && i < displayNames.size()) {
points.setDisplayName(displayNames.get(i));
} else {
points.setDisplayName(columns.get(i));
}
if (i < colors.size()) {
points.setColor(colors.get(i));
}
add(points);
}
}
}
}
use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.
the class TableDisplayTest method shouldSendCommMsgWhenAddValueHighlighterClosureForColumnChange.
@Test
public void shouldSendCommMsgWhenAddValueHighlighterClosureForColumnChange() 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
List actual = getValueAsList(getModelUpdate(), CELL_HIGHLIGHTERS);
Map column = (Map) actual.get(0);
assertThat(column.get(ValueHighlighterSerializer.TYPE)).isEqualTo(ValueHighlighter.class.getSimpleName());
}
use of com.twosigma.beakerx.chart.Color in project beakerx by twosigma.
the class TableDisplayTest method shouldSendCommMsgWhenSetFontColorProviderClojureChange.
@Test
public void shouldSendCommMsgWhenSetFontColorProviderClojureChange() throws Exception {
// when
tableDisplay.setFontColorProvider(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
LinkedHashMap model = getModelUpdate();
assertThat(model.size()).isEqualTo(1);
List colors = getValueAsList(model, FONT_COLOR);
List actual = (List) colors.get(0);
assertThat(actual.get(0).toString()).startsWith("#");
}
Aggregations