Search in sources :

Example 1 with ColourMapData

use of com.sldeditor.ui.detail.config.colourmap.ColourMapData in project sldeditor by robward-scisys.

the class ColourMapDataTest method testColourMapData.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.ColourMapData#ColourMapData()}.
 */
@Test
public void testColourMapData() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ColourMapData actual = new ColourMapData();
    String expectedLabel = "abc";
    String expectedColour = "#123456";
    double expectedOpacity = 0.5;
    int expectedQuantity = 42;
    actual.setLabel(expectedLabel);
    actual.setColour(ff.literal(expectedColour));
    actual.setOpacity(ff.literal(expectedOpacity));
    actual.setQuantity(ff.literal(expectedQuantity));
    assertEquals(actual.getLabel(), expectedLabel);
    assertEquals(ColourUtils.fromColour(actual.getColour()), expectedColour);
    assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
    assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
    // Test getNextQuantity with a value
    Expression nextQuantity = actual.getNextQuantity();
    int iValue = Double.valueOf(nextQuantity.toString()).intValue();
    assertTrue(iValue == (expectedQuantity + 1));
    // Test getNextQuantity with a function expression set
    Divide divide = ff.divide(ff.literal(10.0), ff.literal(2.0));
    actual.setQuantity(divide);
    nextQuantity = actual.getNextQuantity();
    assertEquals(nextQuantity.toString(), actual.getQuantity().toString());
    actual.update(null);
    // Label
    ColourMapData update = new ColourMapData();
    String updatedLabel = "new label";
    update.setLabel(updatedLabel);
    actual.update(update);
    assertEquals(actual.getLabel(), updatedLabel);
    // Colour
    ColourMapData updateColour = new ColourMapData();
    String updatedColour = "#234567";
    updateColour.setColour(ff.literal(updatedColour));
    actual.update(updateColour);
    assertEquals(actual.getColourString(), updatedColour);
    // Opacity
    ColourMapData updateOpacity = new ColourMapData();
    double updatedOpacity = 0.25;
    updateOpacity.setOpacity(ff.literal(updatedOpacity));
    actual.update(updateOpacity);
    assertEquals(actual.getOpacity().toString(), String.valueOf(updatedOpacity));
    // Quantity
    ColourMapData updateQuantity = new ColourMapData();
    int updatedQuantity = 78;
    updateQuantity.setQuantity(ff.literal(updatedQuantity));
    actual.update(updateQuantity);
    assertEquals(actual.getQuantity().toString(), String.valueOf(updatedQuantity));
}
Also used : Divide(org.opengis.filter.expression.Divide) Expression(org.opengis.filter.expression.Expression) ColourMapData(com.sldeditor.ui.detail.config.colourmap.ColourMapData) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Aggregations

ColourMapData (com.sldeditor.ui.detail.config.colourmap.ColourMapData)1 Test (org.junit.Test)1 FilterFactory (org.opengis.filter.FilterFactory)1 Divide (org.opengis.filter.expression.Divide)1 Expression (org.opengis.filter.expression.Expression)1