Search in sources :

Example 11 with FilterFactory

use of org.opengis.filter.FilterFactory 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);
}
Also used : ColorMapImpl(org.geotools.styling.ColorMapImpl) ColorMapEntryImpl(org.geotools.styling.ColorMapEntryImpl) ColorMap(org.geotools.styling.ColorMap) XMLColourMapEntry(com.sldeditor.common.xml.ui.XMLColourMapEntry) ArrayList(java.util.ArrayList) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 12 with FilterFactory

use of org.opengis.filter.FilterFactory 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 13 with FilterFactory

use of org.opengis.filter.FilterFactory 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 14 with FilterFactory

use of org.opengis.filter.FilterFactory in project sldeditor by robward-scisys.

the class FieldConfigColourMapTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    field.undoAction(null);
    field.redoAction(null);
    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.populateField(expectedValue2);
    UndoManager.getInstance().undo();
    assertEquals(expectedValue1.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length);
    UndoManager.getInstance().redo();
    assertEquals(expectedValue2.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) 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 15 with FilterFactory

use of org.opengis.filter.FilterFactory in project sldeditor by robward-scisys.

the class RasterSymbolizerDetailsTest method testRasterSymbolizerDetailsColourChannel.

/**
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#RasterSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testRasterSymbolizerDetailsColourChannel() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(ff.literal(.5), "ramp");
    SelectedChannelType redChannel = styleFactory.createSelectedChannelType("red", contrastEnhancement);
    SelectedChannelType greenChannel = styleFactory.createSelectedChannelType("green", contrastEnhancement);
    SelectedChannelType blueChannel = styleFactory.createSelectedChannelType("blue", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = redChannel;
    channels[1] = greenChannel;
    channels[2] = blueChannel;
    RasterSymbolizer symbolizer = DefaultSymbols.createDefaultRasterSymbolizer();
    symbolizer.setChannelSelection(styleFactory.createChannelSelection(channels));
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FilterFactory(org.opengis.filter.FilterFactory) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) SelectedChannelType(org.geotools.styling.SelectedChannelType) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Aggregations

FilterFactory (org.opengis.filter.FilterFactory)88 Test (org.junit.Test)72 FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)42 Filter (org.opengis.filter.Filter)38 QueryImpl (ddf.catalog.operation.impl.QueryImpl)33 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)30 Expression (org.opengis.filter.expression.Expression)24 SourceResponse (ddf.catalog.operation.SourceResponse)21 ArrayList (java.util.ArrayList)18 Metacard (ddf.catalog.data.Metacard)17 SolrProviderTest (ddf.catalog.source.solr.SolrProviderTest)17 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)12 SelectedChannelType (org.geotools.styling.SelectedChannelType)12 Date (java.util.Date)11 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)11 ChannelSelection (org.geotools.styling.ChannelSelection)10 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)8 Result (ddf.catalog.data.Result)8 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 QueryResponse (ddf.catalog.operation.QueryResponse)8