Search in sources :

Example 6 with TreeMapNode

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();
}
Also used : TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) Test(org.junit.Test) ChartTest(com.twosigma.beakerx.chart.ChartTest)

Example 7 with TreeMapNode

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));
}
Also used : DefaultValue(net.sf.jtreemap.swing.DefaultValue) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) Before(org.junit.Before)

Example 8 with TreeMapNode

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);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode)

Example 9 with TreeMapNode

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();
}
Also used : TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 10 with TreeMapNode

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");
}
Also used : DefaultValue(net.sf.jtreemap.swing.DefaultValue) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) TreeMapNode(net.sf.jtreemap.swing.TreeMapNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

TreeMapNode (net.sf.jtreemap.swing.TreeMapNode)18 Test (org.junit.Test)11 DefaultValue (net.sf.jtreemap.swing.DefaultValue)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)8 KernelTest (com.twosigma.beakerx.KernelTest)3 TreeMap (com.twosigma.beakerx.chart.treemap.TreeMap)3 Before (org.junit.Before)3 ChartTest (com.twosigma.beakerx.chart.ChartTest)2 IToolTipBuilder (com.twosigma.beakerx.chart.treemap.util.IToolTipBuilder)2 Color (com.twosigma.beakerx.chart.Color)1 StringWriter (java.io.StringWriter)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1