use of net.sf.jtreemap.swing.TreeMapNode in project beakerx by twosigma.
the class TreeMapTest method createTreeMapWithTreeMapNodeParam_hasColorProviderNotNullShowLegendIsFalseRootInNotNull.
@Test
public void createTreeMapWithTreeMapNodeParam_hasColorProviderNotNullShowLegendIsFalseRootInNotNull() {
// when
TreeMap treeMap = new TreeMap(new TreeMapNode("label"));
// then
assertThat(treeMap.getColorProvider()).isNotNull();
assertThat(treeMap.getShowLegend()).isFalse();
assertThat(treeMap.getRoot()).isNotNull();
}
use of net.sf.jtreemap.swing.TreeMapNode in project beakerx by twosigma.
the class RandomColorProviderTest method initStubData.
@Before
public void initStubData() {
node01 = new TreeMapNode("010", 1, new DefaultValue(1));
node02 = new TreeMapNode("021");
node02.setWeight(2.0);
node02.setValue(new DefaultValue(2));
}
use of net.sf.jtreemap.swing.TreeMapNode in project beakerx by twosigma.
the class ColorProvider method setValues.
protected void setValues(final TreeMapNode root) {
if (root.isLeaf()) {
double value;
if (valueAccessor == ValueAccessor.VALUE) {
if (root.getValue() == null) {
return;
}
value = root.getValue().getValue();
} else {
value = root.getWeight();
}
if (maxValue == null || value >= maxValue) {
maxValue = value;
}
if (minValue == null || value <= minValue) {
minValue = value;
}
} else {
for (final Enumeration e = root.children(); e.hasMoreElements(); ) {
final TreeMapNode node = (TreeMapNode) e.nextElement();
setValues(node);
}
}
}
use of net.sf.jtreemap.swing.TreeMapNode in project beakerx by twosigma.
the class PlotObjectSerializerTest method serializeTreeMapNode_returnTrue.
@Test
public void serializeTreeMapNode_returnTrue() throws Exception {
// when
boolean result = plotObjectSerializer.writeObject(new TreeMapNode("010"), jgen, true);
// then
Assertions.assertThat(result).isTrue();
}
use of net.sf.jtreemap.swing.TreeMapNode in project beakerx by twosigma.
the class TreeMapNodeSerializerTest method serializeLabelValueOfTreeMapNode_resultJsonHasLabelValue.
@Test
public void serializeLabelValueOfTreeMapNode_resultJsonHasLabelValue() throws IOException {
// when
TreeMapNode treeMapNode = new TreeMapNode("010", 1, new DefaultValue(1.5));
treeMapNode.setUserObject(values);
treeMapNodeSerializer.serialize(treeMapNode, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("labelValue")).isTrue();
Assertions.assertThat(actualObj.get("labelValue").asText()).isEqualTo("1.5");
}
Aggregations