Java Code Examples for org.geotools.styling.ColorMapEntry#setLabel()

The following examples show how to use org.geotools.styling.ColorMapEntry#setLabel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleColourMapEntry.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the colour map entry.
 *
 * @return the colour map entry
 */
public ColorMapEntry getColourMapEntry() {
    ColorMapEntry entry = new ColorMapEntryImpl();

    if (firstEntry != null) {
        entry.setLabel(labelMultipleValue ? firstEntry.getLabel() : null);
        entry.setOpacity(opacityMultipleValue ? firstEntry.getOpacity() : null);
        entry.setQuantity(quantityMultipleValue ? firstEntry.getQuantity() : null);
        entry.setColor(colourMultipleValue ? firstEntry.getColor() : null);
    }

    return entry;
}
 
Example 2
Source File: ColourMapModel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the colour map entry.
 *
 * @param data the data
 * @return the color map entry
 */
private ColorMapEntry createColourMapEntry(ColourMapData data) {
    ColorMapEntry entry = new ColorMapEntryImpl();
    entry.setColor(data.getColourExpression());
    entry.setOpacity(data.getOpacity());
    entry.setQuantity(data.getQuantity());
    entry.setLabel(data.getLabel());
    return entry;
}
 
Example 3
Source File: MultipleColourMapEntryTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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());
}