Search in sources :

Example 26 with StyleFactoryImpl

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

the class VOGeoServerContrastEnhancementNormalizeGreyTest method testVOGeoServerContrastEnhancementNormalizeGrey.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGrey#VOGeoServerContrastEnhancementNormalizeGrey(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGrey#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
 */
@Test
public void testVOGeoServerContrastEnhancementNormalizeGrey() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    VOGeoServerContrastEnhancementNormalizeGrey testObj = new VOGeoServerContrastEnhancementNormalizeGrey(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_GREY_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 : VOGeoServerContrastEnhancementNormalizeGrey(com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGrey) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ChannelSelection(org.geotools.styling.ChannelSelection) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) Box(javax.swing.Box) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) Test(org.junit.Test)

Example 27 with StyleFactoryImpl

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

the class VOGeoServerTextSpacingTest method testVOGeoServerTextSpacingTest.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSpacingTest#VOGeoServerTextSpacingTest(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testVOGeoServerTextSpacingTest() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    TextSymbolizer2 textSymbolizer = null;
    VOGeoServerTextSpacing testObj = new VOGeoServerTextSpacing(panel.getClass());
    testObj.setParentPanel(panel);
    testObj.populate(textSymbolizer);
    testObj.updateSymbol(textSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    textSymbolizer = (TextSymbolizer2) styleFactory.createTextSymbolizer();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Literal featureDescription = ff.literal("feature description");
    textSymbolizer.setFeatureDescription(featureDescription);
    OtherText otherText = new OtherTextImpl();
    otherText.setTarget("target");
    Literal otherTextExpression = ff.literal("other text");
    otherText.setText(otherTextExpression);
    textSymbolizer.setOtherText(otherText);
    Literal snippet = ff.literal("snippet");
    textSymbolizer.setSnippet(snippet);
    // Try with marker symbol
    Graphic graphic = styleFactory.createDefaultGraphic();
    graphic.graphicalSymbols().add(styleFactory.createMark());
    textSymbolizer.setGraphic(graphic);
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Try with external graphic
    graphic = styleFactory.createDefaultGraphic();
    try {
        graphic.graphicalSymbols().add(styleFactory.createExternalGraphic(new File("test.png").toURI().toURL(), "png"));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    textSymbolizer.setGraphic(graphic);
    textSymbolizer.getOptions().put("wordSpacing", String.valueOf(42));
    textSymbolizer.getOptions().put("charSpacing", String.valueOf(21));
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Find minimum version with textSymbolizer2 values set
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    testObj.getMinimumVersion(null, textSymbolizer, vendorOptionsPresentList);
    assertEquals(2, vendorOptionsPresentList.size());
    // Find minimum version with no textSymbolizer2 values set
    vendorOptionsPresentList.clear();
    testObj.getMinimumVersion(null, styleFactory.createTextSymbolizer(), vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Get the code coverage values up
    testObj.populate(SelectedSymbol.getInstance());
    PolygonSymbolizer polygon = null;
    testObj.populate(polygon);
    testObj.updateSymbol(polygon);
    FeatureTypeStyle fts = null;
    testObj.populate(fts);
    testObj.updateSymbol(fts);
    RasterSymbolizer raster = null;
    testObj.populate(raster);
    testObj.updateSymbol(raster);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) MalformedURLException(java.net.MalformedURLException) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) ArrayList(java.util.ArrayList) OtherText(org.geotools.styling.OtherText) FilterFactory(org.opengis.filter.FilterFactory) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) OtherTextImpl(org.geotools.styling.OtherTextImpl) TextSymbolizer2(org.geotools.styling.TextSymbolizer2) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Literal(org.opengis.filter.expression.Literal) VOGeoServerTextSpacing(com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSpacing) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) File(java.io.File) TextSymbolizerDetails(com.sldeditor.ui.detail.TextSymbolizerDetails) Test(org.junit.Test)

Example 28 with StyleFactoryImpl

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

the class VOGeoServerFTSCompositeTest method testVOGeoServerFTSComposite.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSComposite#VOGeoServerFTSComposite(java.lang.Class)}.
 */
@Test
public void testVOGeoServerFTSComposite() {
    Class<FeatureTypeStyleDetails> panelId = FeatureTypeStyleDetails.class;
    VOGeoServerFTSComposite obj = new VOGeoServerFTSComposite(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 = "copy,0.42";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE, expectedValue);
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    obj.populate(fts);
    obj.updateSymbol(fts);
    String actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE);
    assertEquals(actualValue, expectedValue);
    // No opacity
    expectedValue = "source-in";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE);
    assertEquals(actualValue, expectedValue);
    // Invalid string
    expectedValue = "invalid";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE);
    assertEquals(actualValue, "copy");
    // 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_OPACITY);
}
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) VOGeoServerFTSComposite(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSComposite) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Test(org.junit.Test)

Example 29 with StyleFactoryImpl

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

the class VOGeoServerFTSRuleEvaluationTest method testVOGeoServerFTSRuleEvaluation.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSRuleEvaluationTest#VOGeoServerFTSRuleEvaluationTest(java.lang.Class)}.
 */
@Test
public void testVOGeoServerFTSRuleEvaluation() {
    Class<FeatureTypeStyleDetails> panelId = FeatureTypeStyleDetails.class;
    VOGeoServerFTSRuleEvaluation obj = new VOGeoServerFTSRuleEvaluation(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.4.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 - first
    String expectedValue = "first";
    fts.getOptions().put(FeatureTypeStyle.KEY_EVALUATION_MODE, expectedValue);
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    obj.populate(fts);
    obj.updateSymbol(fts);
    String actualValue = fts.getOptions().get(FeatureTypeStyle.KEY_EVALUATION_MODE);
    assertEquals(actualValue, expectedValue);
    // Valid string - all
    expectedValue = "all";
    fts.getOptions().put(FeatureTypeStyle.KEY_EVALUATION_MODE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.KEY_EVALUATION_MODE);
    assertEquals(actualValue, expectedValue);
    // Invalid string
    expectedValue = "invalid";
    fts.getOptions().put(FeatureTypeStyle.KEY_EVALUATION_MODE, expectedValue);
    obj.populate(fts);
    obj.updateSymbol(fts);
    actualValue = fts.getOptions().get(FeatureTypeStyle.KEY_EVALUATION_MODE);
    assertEquals("all", 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_RULE_EVALUATION_OPTION);
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) VOGeoServerFTSRuleEvaluation(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSRuleEvaluation) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) FeatureTypeStyleDetails(com.sldeditor.ui.detail.FeatureTypeStyleDetails) ArrayList(java.util.ArrayList) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Test(org.junit.Test)

Example 30 with StyleFactoryImpl

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

the class VendorOptionFTSFactoryTest method testVendorOptionFTSFactory.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VendorOptionFTSFactory#VendorOptionFTSFactory(java.lang.Class)}.
 */
@Test
public void testVendorOptionFTSFactory() {
    VendorOptionFTSFactory obj = new VendorOptionFTSFactory(FeatureTypeStyleDetails.class);
    int expectedNoOfVO = 4;
    assertEquals(expectedNoOfVO, obj.getVendorOptionList().size());
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Valid string
    String expectedValue = "exclude,0.12";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE, expectedValue);
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    assertEquals(expectedNoOfVO, obj.getVendorOptionInfoList().size());
    assertEquals(1, obj.getVendorOptionList(VOGeoServerFTSComposite.class.getName()).size());
    GraphicPanelFieldManager fieldMgr = new GraphicPanelFieldManager(FeatureTypeStyleDetails.class);
    obj.getFieldDataManager(fieldMgr);
    obj.populate(fts);
    obj.updateSymbol(fts);
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ArrayList(java.util.ArrayList) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) VOGeoServerFTSComposite(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSComposite) VendorOptionFTSFactory(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VendorOptionFTSFactory) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) 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