use of com.sldeditor.common.xml.ui.XMLColourMapEntry in project sldeditor by robward-scisys.
the class EncodeColourMapTest method testEncodeColorMap.
/**
* Test method for {@link com.sldeditor.ui.detail.config.colourmap.EncodeColourMap#encode(org.geotools.styling.ColorMap)}.
* Test method for {@link com.sldeditor.ui.detail.config.colourmap.EncodeColourMap#encode(java.util.List)}.
*/
@Test
public void testEncodeColorMap() {
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
ColorMapEntryImpl entry1 = new ColorMapEntryImpl();
entry1.setColor(ff.literal(COLOUR_1));
entry1.setOpacity(ff.literal(OPACITY_1));
entry1.setQuantity(ff.literal(QUANTITY_1));
ColorMap expectedValue = new ColorMapImpl();
expectedValue.addColorMapEntry(entry1);
ColorMapEntryImpl entry2 = new ColorMapEntryImpl();
entry2.setColor(ff.literal(COLOUR_2));
entry2.setLabel(LABEL_2);
entry2.setOpacity(ff.literal(OPACITY_2));
entry2.setQuantity(ff.literal(QUANTITY_2));
expectedValue.addColorMapEntry(entry2);
XMLColourMapEntry xml1 = new XMLColourMapEntry();
xml1.setColour(COLOUR_1);
xml1.setOpacity(OPACITY_1);
xml1.setQuantity(42);
List<XMLColourMapEntry> xmlList = new ArrayList<XMLColourMapEntry>();
xmlList.add(xml1);
XMLColourMapEntry xml2 = new XMLColourMapEntry();
xml2.setColour(COLOUR_2);
xml2.setLabel(LABEL_2);
xml2.setOpacity(OPACITY_2);
xml2.setQuantity(QUANTITY_2);
xmlList.add(xml2);
String actualValue1 = EncodeColourMap.encode(expectedValue);
String actualValue2 = EncodeColourMap.encode(xmlList);
assertTrue(actualValue1.compareTo(actualValue2) == 0);
}
use of com.sldeditor.common.xml.ui.XMLColourMapEntry in project sldeditor by robward-scisys.
the class EncodeColourMap method encode.
/**
* Encode test colour map entries into a string.
*
* @param colourMap the colour map
* @return the string
*/
public static String encode(List<XMLColourMapEntry> colourMap) {
StringBuilder sb = new StringBuilder();
for (XMLColourMapEntry entry : colourMap) {
sb.append((entry.getLabel() == null) ? "" : entry.getLabel());
sb.append(SEPARATOR);
sb.append(entry.getColour());
sb.append(SEPARATOR);
sb.append(entry.getOpacity());
sb.append(SEPARATOR);
sb.append(entry.getQuantity());
sb.append(ENTRY_SEPARATOR);
}
return sb.toString();
}
Aggregations