Search in sources :

Example 1 with FieldConfigColourMap

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

the class FieldConfigColourMapTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#internal_setEnabled(boolean)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#isEnabled()}.
 */
@Test
public void testSetEnabled() {
    FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    // Field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 2 with FieldConfigColourMap

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

the class FieldConfigColourMapTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#populateField(org.geotools.styling.ColorMap)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#setTestValue(com.sldeditor.ui.detail.config.FieldId, org.geotools.styling.ColorMap)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#getColourMap()}.
 */
@Test
public void testGenerateExpression() {
    FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    ColorMap testValue = null;
    field.populate(null);
    field.setTestValue(FieldIdEnum.UNKNOWN, testValue);
    field.populateField(testValue);
    field.createUI();
    ColorMap expectedValue1 = new ColorMapImpl();
    field.populateField(expectedValue1);
    assertEquals(expectedValue1, field.getColourMap());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ColorMap expectedValue2 = new ColorMapImpl();
    ColorMapEntryImpl entry = new ColorMapEntryImpl();
    entry.setColor(ff.literal("#001122"));
    expectedValue2.addColorMapEntry(entry);
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
    assertEquals(expectedValue2.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length);
    field.populateExpression((String) null);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ColorMapImpl(org.geotools.styling.ColorMapImpl) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) ColorMapEntryImpl(org.geotools.styling.ColorMapEntryImpl) ColorMap(org.geotools.styling.ColorMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 3 with FieldConfigColourMap

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

the class FieldConfigColourMapTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#revertToDefaultValue()}.
 */
@Test
public void testRevertToDefaultValue() {
    FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    field.revertToDefaultValue();
    assertNull(field.getColourMap());
    field.createUI();
    field.revertToDefaultValue();
    assertNotNull(field.getColourMap());
    assertTrue(field.getColourMap().getColorMapEntries().length == 0);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 4 with FieldConfigColourMap

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

the class FieldConfigColourMapTest method testGetStringValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#getStringValue()}.
 */
@Test
public void testGetStringValue() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ColorMapEntryImpl entry1 = new ColorMapEntryImpl();
    entry1.setColor(ff.literal("#001122"));
    entry1.setLabel("testlabel");
    entry1.setOpacity(ff.literal(0.42));
    entry1.setQuantity(ff.literal(42));
    ColorMap expectedValue = new ColorMapImpl();
    expectedValue.addColorMapEntry(entry1);
    ColorMapEntryImpl entry2 = new ColorMapEntryImpl();
    entry2.setColor(ff.literal("#551122"));
    entry2.setLabel("testlabel2");
    entry2.setOpacity(ff.literal(0.22));
    entry2.setQuantity(ff.literal(12));
    expectedValue.addColorMapEntry(entry2);
    FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    field.populateField(expectedValue);
    assertTrue(field.getStringValue().compareTo(EncodeColourMap.encode(expectedValue)) == 0);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ColorMapImpl(org.geotools.styling.ColorMapImpl) ColorMapEntryImpl(org.geotools.styling.ColorMapEntryImpl) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) ColorMap(org.geotools.styling.ColorMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 5 with FieldConfigColourMap

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

the class FieldConfigColourMapTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    field.attributeSelection(null);
// Does nothing
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigColourMap (com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap)11 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)10 Geometry (com.vividsolutions.jts.geom.Geometry)10 Test (org.junit.Test)10 ColorMap (org.geotools.styling.ColorMap)4 ColorMapEntryImpl (org.geotools.styling.ColorMapEntryImpl)4 ColorMapImpl (org.geotools.styling.ColorMapImpl)4 FilterFactory (org.opengis.filter.FilterFactory)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 XMLFieldConfigBoolean (com.sldeditor.common.xml.ui.XMLFieldConfigBoolean)1 XMLFieldConfigColour (com.sldeditor.common.xml.ui.XMLFieldConfigColour)1 XMLFieldConfigColourMap (com.sldeditor.common.xml.ui.XMLFieldConfigColourMap)1 XMLFieldConfigDSProperties (com.sldeditor.common.xml.ui.XMLFieldConfigDSProperties)1 XMLFieldConfigDouble (com.sldeditor.common.xml.ui.XMLFieldConfigDouble)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigFeatureTypeConstraint (com.sldeditor.common.xml.ui.XMLFieldConfigFeatureTypeConstraint)1 XMLFieldConfigFont (com.sldeditor.common.xml.ui.XMLFieldConfigFont)1