Search in sources :

Example 11 with StyleFactoryImpl

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

the class ExtentModelTest method testGetExtentList.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#getExtentList()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#removeEntries(int, int)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#populate(org.geotools.styling.Extent[])}.
 */
@Test
public void testGetExtentList() {
    TestModelUpdate testUpdate = new TestModelUpdate();
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    ExtentModel model = new ExtentModel(testUpdate);
    Extent[] extentArray = null;
    model.populate(extentArray);
    extentArray = new Extent[5];
    extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1");
    extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2");
    extentArray[2] = styleFactory.createExtent("extent 3", "3 3 3 3");
    extentArray[3] = styleFactory.createExtent("extent 4", "4 4 4 4");
    extentArray[4] = styleFactory.createExtent("extent 5", "5 5 5 5");
    model.populate(extentArray);
    List<Extent> actualList = model.getExtentList();
    assertEquals(5, actualList.size());
    assertTrue(actualList.get(2).getName().compareTo("extent 3") == 0);
    assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
    model.removeEntries(-1, 2);
    assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
    model.removeEntries(2, 22);
    assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
    model.removeEntries(22, 2);
    assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
    model.removeEntries(2, 2);
    assertTrue(testUpdate.hasExtentUpdatedBeenCalled());
    actualList = model.getExtentList();
    assertEquals(4, actualList.size());
    assertTrue(actualList.get(2).getName().compareTo("extent 4") == 0);
}
Also used : StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ExtentModel(com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel) Extent(org.geotools.styling.Extent) Test(org.junit.Test)

Example 12 with StyleFactoryImpl

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

the class FeatureTypeConstraintModelTest method testPopulate.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#populate(java.util.List)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#removeEntries(int, int)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#getFeatureTypeConstraint(int)}.
 */
@Test
public void testPopulate() {
    TestModelUpdate testUpdate = new TestModelUpdate();
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(testUpdate);
    List<FeatureTypeConstraint> ftcList = null;
    model.populate(ftcList);
    ftcList = new ArrayList<FeatureTypeConstraint>();
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc1", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc2", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc3", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc4", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc5", Filter.INCLUDE, new Extent[0]));
    model.populate(ftcList);
    List<FeatureTypeConstraint> actualList = model.getFeatureTypeConstraint();
    assertEquals(5, actualList.size());
    assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc3") == 0);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(-1, 2);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(2, 22);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(22, 2);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(2, 2);
    assertTrue(testUpdate.hasFTCUpdatedBeenCalled());
    actualList = model.getFeatureTypeConstraint();
    assertEquals(4, actualList.size());
    assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc4") == 0);
    assertNull(model.getFeatureTypeConstraint(-1));
    assertNull(model.getFeatureTypeConstraint(6));
    FeatureTypeConstraint actualFTC = model.getFeatureTypeConstraint(1);
    assertTrue(actualFTC.getFeatureTypeName().compareTo("ftc2") == 0);
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Extent(org.geotools.styling.Extent) FeatureTypeConstraintModel(com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel) Test(org.junit.Test)

Example 13 with StyleFactoryImpl

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

the class VOGeoServerFTSCompositeBaseTest method testVOGeoServerFTSCompositeBase.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSCompositeBase#VOGeoServerFTSCompositeBase(java.lang.Class)}.
 */
@Test
public void testVOGeoServerFTSCompositeBase() {
    Class<FeatureTypeStyleDetails> panelId = FeatureTypeStyleDetails.class;
    VOGeoServerFTSCompositeBase obj = new VOGeoServerFTSCompositeBase(panelId);
    assertEquals(panelId, obj.getPanelId());
    assertNotNull(obj.getFieldDataManager());
    assertNotNull(obj.getPanel());
    assertTrue(obj.isDataPresent());
    assertNotNull(obj.getVendorOptionInfo());
    // Check getVendorOptionVersion
    VendorOptionVersion vendorOption = obj.getVendorOption();
    assertEquals(GeoServerVendorOption.class, vendorOption.getClassType());
    String actualVersionString = vendorOption.getEarliest().getVersionString();
    String expectedVersionString = "2.7.0";
    assertEquals(expectedVersionString, actualVersionString);
    obj.setParentPanel(null);
    assertNull(obj.getParentPanel());
    obj.preLoadSymbol();
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    String testString = "test";
    obj.getMinimumVersion(null, testString, vendorOptionsPresentList);
    assertTrue(vendorOptionsPresentList.isEmpty());
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Valid string
    String expectedValue = "true";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    obj.populate(fts);
    obj.updateSymbol(fts);
    String actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
    assertEquals(actualValue, expectedValue);
    // No opacity
    expectedValue = "false";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
    assertEquals(actualValue, expectedValue);
    // Invalid string
    expectedValue = "invalid";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
    assertEquals("false", actualValue);
    // Increase code coverage
    obj.populate((PolygonSymbolizer) null);
    obj.updateSymbol((PolygonSymbolizer) null);
    obj.populate((RasterSymbolizer) null);
    obj.updateSymbol((RasterSymbolizer) null);
    obj.populate((TextSymbolizer) null);
    obj.updateSymbol((TextSymbolizer) null);
    obj.populate((SelectedSymbol) null);
    obj.dataChanged(FieldIdEnum.VO_FTS_COMPOSITE_BASE_BOOL);
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) FeatureTypeStyleDetails(com.sldeditor.ui.detail.FeatureTypeStyleDetails) ArrayList(java.util.ArrayList) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) VOGeoServerFTSCompositeBase(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSCompositeBase) Test(org.junit.Test)

Example 14 with StyleFactoryImpl

use of org.geotools.styling.StyleFactoryImpl 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)

Example 15 with StyleFactoryImpl

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

the class VOGeoServerContrastEnhancementNormalizeGreenTest method testVOGeoServerContrastEnhancementNormalizeGreen.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#VOGeoServerContrastEnhancementNormalizeGreen(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
 */
@Test
public void testVOGeoServerContrastEnhancementNormalizeGreen() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    VOGeoServerContrastEnhancementNormalizeGreen testObj = new VOGeoServerContrastEnhancementNormalizeGreen(panel.getClass(), panel);
    RasterSymbolizer rasterSymbolizer = null;
    testObj.setParentPanel(panel);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    rasterSymbolizer = styleFactory.createRasterSymbolizer();
    GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_METHOD);
    assertNotNull(constrastMethodGroup);
    MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
    Box box = Box.createVerticalBox();
    constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId());
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC);
    ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer);
    Controller.getInstance().setPopulating(true);
    panel.populate(SelectedSymbol.getInstance());
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Error
    channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Increase code coverage
    testObj.populate((SelectedSymbol) null);
    testObj.populate((TextSymbolizer) null);
    testObj.populate((PolygonSymbolizer) null);
    testObj.updateSymbol((TextSymbolizer) null);
    testObj.updateSymbol((PolygonSymbolizer) null);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
    testObj.dataChanged(FieldIdEnum.DESCRIPTION);
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ChannelSelection(org.geotools.styling.ChannelSelection) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) VOGeoServerContrastEnhancementNormalizeGreen(com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen) Box(javax.swing.Box) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) Test(org.junit.Test)

Aggregations

StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)43 Test (org.junit.Test)43 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)23 SLDTreeTools (com.sldeditor.ui.tree.SLDTreeTools)16 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)16 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)12 ArrayList (java.util.ArrayList)11 FilterFactory (org.opengis.filter.FilterFactory)11 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)10 Rule (org.geotools.styling.Rule)8 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)7 NamedLayer (org.geotools.styling.NamedLayer)7 Style (org.geotools.styling.Style)7 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)6 TreeSelectionData (com.sldeditor.TreeSelectionData)5 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)5 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)5 Box (javax.swing.Box)5 ChannelSelection (org.geotools.styling.ChannelSelection)5 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)4