Search in sources :

Example 1 with RingChart

use of org.cytoscape.ding.internal.charts.ring.RingChart in project cytoscape-impl by cytoscape.

the class RingChartTest method testChartProperties.

@Test
public void testChartProperties() {
    final RingChart chart = new RingChart(props1, serviceRegistrar);
    // The chart properties has to return exactly the same values,
    // except column names, which are converted to CyColumIdentifier when set as String
    Map<String, Object> props2 = chart.getProperties();
    assertEquals(props1.get(DATA_COLUMNS), props2.get(DATA_COLUMNS));
    assertEquals(props1.get(COLOR_SCHEME), props2.get(COLOR_SCHEME));
    assertEquals(props1.get(COLORS), props2.get(COLORS));
    assertEquals(props1.get(BORDER_COLOR), props2.get(BORDER_COLOR));
    assertEquals(props1.get(BORDER_WIDTH), props2.get(BORDER_WIDTH));
    assertEquals("labels1", ((CyColumnIdentifier) props2.get(ITEM_LABELS_COLUMN)).getColumnName());
    assertEquals(props1.get(ITEM_LABELS), props2.get(ITEM_LABELS));
    assertEquals(props1.get(SHOW_ITEM_LABELS), props2.get(SHOW_ITEM_LABELS));
    assertEquals(props1.get(START_ANGLE), props2.get(START_ANGLE));
    assertEquals(props1.get(HOLE_SIZE), props2.get(HOLE_SIZE));
    assertNull(props2.get(VALUES));
    // When calling the internal get methods, some property values are converted to internal types,
    // which are not exposed to the API client code
    assertEquals(props2.get(DATA_COLUMNS), chart.getList(DATA_COLUMNS, CyColumnIdentifier.class));
    assertEquals(ColorScheme.CUSTOM, chart.get(COLOR_SCHEME, ColorScheme.class));
    assertEquals(props1.get(COLORS), chart.getList(COLORS, Color.class));
    assertEquals(Color.WHITE, chart.get(BORDER_COLOR, Color.class));
    assertEquals(new Float(2.5f), chart.get(BORDER_WIDTH, Float.class));
    assertEquals("labels1", chart.get(ITEM_LABELS_COLUMN, CyColumnIdentifier.class).getColumnName());
    assertEquals(props1.get(ITEM_LABELS), chart.getList(ITEM_LABELS, String.class));
    assertEquals(Boolean.TRUE, chart.get(SHOW_ITEM_LABELS, Boolean.class));
    assertEquals(new Double(-45), chart.get(START_ANGLE, Double.class));
    assertEquals(new Double(-2.5), chart.get(HOLE_SIZE, Double.class));
    // Must never be null!
    assertTrue(chart.getList(VALUES, Double.class).isEmpty());
}
Also used : RingChart(org.cytoscape.ding.internal.charts.ring.RingChart) Color(java.awt.Color) ColorScheme(org.cytoscape.ding.customgraphics.ColorScheme) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) AbstractCustomGraphics2Test(org.cytoscape.ding.customgraphics.AbstractCustomGraphics2Test) Test(org.junit.Test)

Aggregations

Color (java.awt.Color)1 AbstractCustomGraphics2Test (org.cytoscape.ding.customgraphics.AbstractCustomGraphics2Test)1 ColorScheme (org.cytoscape.ding.customgraphics.ColorScheme)1 RingChart (org.cytoscape.ding.internal.charts.ring.RingChart)1 CyColumnIdentifier (org.cytoscape.view.presentation.property.values.CyColumnIdentifier)1 Test (org.junit.Test)1