Search in sources :

Example 11 with ColorMapEntry

use of org.geotools.styling.ColorMapEntry in project sldeditor by robward-scisys.

the class MultipleColourMapEntryTest method testParseList.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.MultipleColourMapEntry#parseList(java.util.List)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.MultipleColourMapEntry#getColourMapEntry()}.
 */
@Test
public void testParseList() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    MultipleColourMapEntry testObj = new MultipleColourMapEntry();
    assertNotNull(testObj.getColourMapEntry());
    ColorMapEntry c1 = new ColorMapEntryImpl();
    String expectedLabel = "abc";
    String expectedColour = "#123456";
    double expectedOpacity = 0.5;
    int expectedQuantity = 42;
    c1.setLabel(expectedLabel);
    c1.setColor(ff.literal(expectedColour));
    c1.setOpacity(ff.literal(expectedOpacity));
    c1.setQuantity(ff.literal(expectedQuantity));
    List<ColorMapEntry> expectedList = new ArrayList<ColorMapEntry>();
    expectedList.add(c1);
    ColorMapEntry c2 = new ColorMapEntryImpl();
    c2.setLabel(expectedLabel);
    c2.setColor(ff.literal(expectedColour));
    c2.setOpacity(ff.literal(expectedOpacity));
    c2.setQuantity(ff.literal(expectedQuantity));
    expectedList.add(c2);
    ColorMapEntry c3 = new ColorMapEntryImpl();
    c3.setLabel(expectedLabel);
    c3.setColor(ff.literal(expectedColour));
    c3.setOpacity(ff.literal(expectedOpacity));
    c3.setQuantity(ff.literal(expectedQuantity));
    expectedList.add(c3);
    testObj.parseList(expectedList);
    ColorMapEntry actual = testObj.getColourMapEntry();
    // All the same
    assertNotNull(testObj.getColourMapEntry());
    assertEquals(actual.getLabel(), expectedLabel);
    assertEquals(actual.getColor().toString(), expectedColour);
    assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
    assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
    // Change label
    c2.setLabel("different");
    testObj.parseList(expectedList);
    actual = testObj.getColourMapEntry();
    assertNotNull(testObj.getColourMapEntry());
    assertNull(actual.getLabel());
    assertEquals(actual.getColor().toString(), expectedColour);
    assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
    assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
    // Change colour
    c1.setColor(ff.literal("#987654"));
    testObj.parseList(expectedList);
    actual = testObj.getColourMapEntry();
    assertNotNull(testObj.getColourMapEntry());
    assertNull(actual.getLabel());
    assertNull(actual.getColor());
    assertEquals(actual.getOpacity().toString(), String.valueOf(expectedOpacity));
    assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
    // Change opacity
    c3.setOpacity(ff.literal(1.0));
    testObj.parseList(expectedList);
    actual = testObj.getColourMapEntry();
    assertNotNull(testObj.getColourMapEntry());
    assertNull(actual.getLabel());
    assertNull(actual.getColor());
    assertNull(actual.getOpacity());
    assertEquals(actual.getQuantity().toString(), String.valueOf(expectedQuantity));
    // Change quantity
    c2.setQuantity(ff.literal(39.0));
    testObj.parseList(expectedList);
    actual = testObj.getColourMapEntry();
    assertNotNull(testObj.getColourMapEntry());
    assertNull(actual.getLabel());
    assertNull(actual.getColor());
    assertNull(actual.getOpacity());
    assertNull(actual.getQuantity());
}
Also used : ColorMapEntryImpl(org.geotools.styling.ColorMapEntryImpl) MultipleColourMapEntry(com.sldeditor.ui.detail.config.colourmap.MultipleColourMapEntry) ArrayList(java.util.ArrayList) ColorMapEntry(org.geotools.styling.ColorMapEntry) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Aggregations

ColorMapEntry (org.geotools.styling.ColorMapEntry)11 ColorMapEntryImpl (org.geotools.styling.ColorMapEntryImpl)5 ArrayList (java.util.ArrayList)3 ColorMapImpl (org.geotools.styling.ColorMapImpl)3 ColorMap (org.geotools.styling.ColorMap)2 Test (org.junit.Test)2 ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)1 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)1 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 FieldConfigColourMap (com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap)1 MultipleColourMapEntry (com.sldeditor.ui.detail.config.colourmap.MultipleColourMapEntry)1 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 IOException (java.io.IOException)1