Java Code Examples for org.geotools.styling.FeatureTypeStyle#setName()
The following examples show how to use
org.geotools.styling.FeatureTypeStyle#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RuleDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.RuleDetails#RuleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. * Test method for {@link * com.sldeditor.ui.detail.RuleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. Test * method for {@link * com.sldeditor.ui.detail.RuleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link com.sldeditor.ui.detail.RuleDetails#getFieldDataManager()}. Test * method for {@link com.sldeditor.ui.detail.RuleDetails#isDataPresent()}. Test method for * {@link com.sldeditor.ui.detail.RuleDetails#preLoadSymbol()}. */ @Test public void testRuleDetails() { RuleDetails panel = new RuleDetails(); 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 expectedNameValue = "rule test value"; rule.setName(expectedNameValue); Symbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); 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); panel.populate(SelectedSymbol.getInstance()); GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager(); assertNotNull(fieldDataManager); FieldConfigString filterField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.FILTER); String filterString = "STATE_ABBR >= 'B' AND STATE_ABBR <= 'O'"; filterField.populateField(filterString); GroupConfig groupConfig = (GroupConfig) fieldDataManager.getGroup(RuleDetails.class, GroupIdEnum.SCALE); groupConfig.enable(true); panel.dataChanged(null); FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME); String actualValue = nameField.getStringValue(); assertTrue(expectedNameValue.compareTo(actualValue) == 0); assertTrue(panel.isDataPresent()); // Reset to default value panel.preLoadSymbol(); actualValue = nameField.getStringValue(); assertTrue("".compareTo(actualValue) == 0); }
Example 2
Source File: SLDUtilsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Test public void testFindRule() { StyledLayerDescriptor sld = DefaultSymbols.createNewSLD(); NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer(); sld.layers().add(DefaultSymbols.createNewNamedLayer()); sld.layers().add(namedLayer); String expectedNamedLayer = "namedLayer"; namedLayer.setName(expectedNamedLayer); Style style = DefaultSymbols.createNewStyle(); String expectedStyleLayer = "style"; style.setName(expectedStyleLayer); namedLayer.addStyle(DefaultSymbols.createNewStyle()); namedLayer.addStyle(style); FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle(); String expectedFeatureTypeStyleLayer = "feature type style"; fts.setName(expectedFeatureTypeStyleLayer); style.featureTypeStyles().add(DefaultSymbols.createNewFeatureTypeStyle()); style.featureTypeStyles().add(fts); Rule rule = DefaultSymbols.createNewRule(); fts.rules().add(DefaultSymbols.createNewRule()); fts.rules().add(rule); String expectedRule = "rule"; rule.setName(expectedRule); String expectedSymbolizer = "text symbolizer"; TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer(); symbolizer.setName(expectedSymbolizer); rule.symbolizers().add(DefaultSymbols.createDefaultPolygonSymbolizer()); rule.symbolizers().add(symbolizer); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Font font = styleFactory.createFont( ff.literal("abc"), ff.literal("normal"), ff.literal("normal"), ff.literal(10)); symbolizer.setFont(font); DuplicatingStyleVisitor duplicate = new DuplicatingStyleVisitor(); duplicate.visit(sld); StyledLayerDescriptor sldCopy = (StyledLayerDescriptor) duplicate.getCopy(); Rule actualRule = SLDUtils.findRule(sld, rule, sldCopy); assertNotNull(actualRule); assertEquals(rule.getName(), actualRule.getName()); actualRule = SLDUtils.findRule(sld, null, sldCopy); assertNull(actualRule); actualRule = SLDUtils.findRule(sld, rule, null); assertNull(actualRule); }
Example 3
Source File: SLDUtilsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Test public void testFindSymbolizer() { StyledLayerDescriptor sld = DefaultSymbols.createNewSLD(); NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer(); sld.layers().add(DefaultSymbols.createNewNamedLayer()); sld.layers().add(namedLayer); String expectedNamedLayer = "namedLayer"; namedLayer.setName(expectedNamedLayer); Style style = DefaultSymbols.createNewStyle(); String expectedStyleLayer = "style"; style.setName(expectedStyleLayer); namedLayer.addStyle(DefaultSymbols.createNewStyle()); namedLayer.addStyle(style); FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle(); String expectedFeatureTypeStyleLayer = "feature type style"; fts.setName(expectedFeatureTypeStyleLayer); style.featureTypeStyles().add(DefaultSymbols.createNewFeatureTypeStyle()); style.featureTypeStyles().add(fts); Rule rule = DefaultSymbols.createNewRule(); fts.rules().add(DefaultSymbols.createNewRule()); fts.rules().add(rule); String expectedRule = "rule"; rule.setName(expectedRule); String expectedSymbolizer = "text symbolizer"; TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer(); symbolizer.setName(expectedSymbolizer); rule.symbolizers().add(DefaultSymbols.createDefaultPolygonSymbolizer()); rule.symbolizers().add(symbolizer); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Font font = styleFactory.createFont( ff.literal("abc"), ff.literal("normal"), ff.literal("normal"), ff.literal(10)); symbolizer.setFont(font); DuplicatingStyleVisitor duplicate = new DuplicatingStyleVisitor(); duplicate.visit(sld); StyledLayerDescriptor sldCopy = (StyledLayerDescriptor) duplicate.getCopy(); Symbolizer actualSymbolizer = SLDUtils.findSymbolizer(sld, symbolizer, sldCopy); assertNotNull(actualSymbolizer); assertEquals( symbolizer.getLabel().toString(), ((TextSymbolizer) actualSymbolizer).getLabel().toString()); actualSymbolizer = SLDUtils.findSymbolizer(sld, null, sldCopy); assertNull(actualSymbolizer); actualSymbolizer = SLDUtils.findSymbolizer(sld, symbolizer, null); assertNull(actualSymbolizer); }
Example 4
Source File: SelectedSymbolTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.common.data.SelectedSymbol#removeRule(org.geotools.styling.Rule)}. */ @Test public void testReplacment() { SelectedSymbol.destroyInstance(); SelectedSymbol instance = SelectedSymbol.getInstance(); Rule rule = DefaultSymbols.createNewRule(); FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle(); Style style = DefaultSymbols.createNewStyle(); NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer(); StyledLayerDescriptor sld = DefaultSymbols.createNewSLD(); PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); instance.createNewSLD(sld); instance.setSld(sld); instance.addNewStyledLayer(namedLayer); instance.setStyledLayer(namedLayer); instance.addNewStyle(style); instance.setStyle(style); instance.addNewFeatureTypeStyle(fts); instance.setFeatureTypeStyle(fts); instance.addNewRule(rule); instance.setRule(rule); instance.addSymbolizerToRule(polygonSymbolizer); instance.addNewRule(DefaultSymbols.createNewRule()); instance.setSymbolizer(polygonSymbolizer); LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer(); DummySLDTreeUpdated dummyTreeUpdated = new DummySLDTreeUpdated(); instance.setTreeUpdateListener(dummyTreeUpdated); instance.replaceSymbolizer(lineSymbolizer); assertEquals(lineSymbolizer, instance.getSymbolizer()); assertEquals(dummyTreeUpdated.objectOld, polygonSymbolizer); assertEquals(dummyTreeUpdated.objectNew, lineSymbolizer); Rule newRule = DefaultSymbols.createNewRule(); newRule.setTitle("Replacement rule"); instance.replaceRule(newRule); assertEquals(newRule, instance.getRule()); assertNull(instance.getSymbolizer()); FeatureTypeStyle newFts = DefaultSymbols.createNewFeatureTypeStyle(); newFts.setName("Replacement fts"); instance.replaceFeatureTypeStyle(newFts); assertEquals(newFts, instance.getFeatureTypeStyle()); assertNull(instance.getRule()); Style newStyle = DefaultSymbols.createNewStyle(); newStyle.setName("Replacement style"); instance.replaceStyle(newStyle); assertEquals(newStyle, instance.getStyle()); assertNull(instance.getRule()); NamedLayer newNamedLayer = DefaultSymbols.createNewNamedLayer(); newNamedLayer.setName("Replacement named layer"); instance.replaceStyledLayer(newNamedLayer); assertEquals(newNamedLayer, instance.getStyledLayer()); assertNull(instance.getStyle()); }
Example 5
Source File: RasterSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * 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); OverlapBehavior overlapBehavior = OverlapBehavior.EARLIEST_ON_TOP; symbolizer.setOverlapBehavior(overlapBehavior); ShadedRelief shadedRelief = styleFactory.createShadedRelief(ff.literal(0.75)); symbolizer.setShadedRelief(shadedRelief); 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(); }
Example 6
Source File: RasterSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * 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 testRasterSymbolizerDetailsGreyChannel() { 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); RasterSymbolizer symbolizer = DefaultSymbols.createDefaultRasterSymbolizer(); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(ff.literal(.5), "ramp"); SelectedChannelType greyChannel = styleFactory.createSelectedChannelType("grey", contrastEnhancement); symbolizer.setChannelSelection(styleFactory.channelSelection(greyChannel)); 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(); }
Example 7
Source File: LineSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.LineSymbolizerDetails#LineSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. * Test method for {@link * com.sldeditor.ui.detail.LineSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. * Test method for {@link * com.sldeditor.ui.detail.LineSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#getFieldDataManager()}. * Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#isDataPresent()}. Test * method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#preLoadSymbol()}. */ @Test public void testLineSymbolizerDetails() { LineSymbolizerDetails panel = new LineSymbolizerDetails(); 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); LineSymbolizer symbolizer = DefaultSymbols.createDefaultLineSymbolizer(); 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(); }
Example 8
Source File: PolygonSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.PolygonSymbolizerDetails#PolygonSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. * Test method for {@link * com.sldeditor.ui.detail.PolygonSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. * Test method for {@link * com.sldeditor.ui.detail.PolygonSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link * com.sldeditor.ui.detail.PolygonSymbolizerDetails#getFieldDataManager()}. Test method for * {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#isDataPresent()}. Test method for * {@link com.sldeditor.ui.detail.PolygonSymbolizerDetails#preLoadSymbol()}. */ @Test public void testPolygonSymbolizerDetails() { PolygonSymbolizerDetails panel = new PolygonSymbolizerDetails(); 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); PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); 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(); }
Example 9
Source File: RuleDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Test public void testRuleEditFilter() { TestRuleDetails panel = new TestRuleDetails(); 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 expectedNameValue = "rule test value"; rule.setName(expectedNameValue); Symbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); rule.symbolizers().add(symbolizer); fts.rules().add(rule); sld.layers().add(namedLayer); SelectedSymbol.getInstance().setRule(rule); panel.populate(SelectedSymbol.getInstance()); StyledLayerDescriptor sld2 = DefaultSymbols.createNewSLD(); SelectedSymbol.getInstance().createNewSLD(sld2); NamedLayer namedLayer2 = DefaultSymbols.createNewNamedLayer(); namedLayer2.setName(expectedNameLayerValue); Style style2 = DefaultSymbols.createNewStyle(); style2.setName(expectedNameStyleValue); namedLayer2.addStyle(style2); FeatureTypeStyle fts2 = DefaultSymbols.createNewFeatureTypeStyle(); fts2.setName(expectedNameFTSValue); style2.featureTypeStyles().add(fts2); Rule rule2 = DefaultSymbols.createNewRule(); rule2.setName(expectedNameValue); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Filter filter = ff.equal(ff.literal(1), ff.literal(2), false); rule2.setFilter(filter); rule2.symbolizers().add(symbolizer); fts2.rules().add(rule2); sld2.layers().add(namedLayer2); SelectedSymbol.getInstance().setRule(rule2); GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager(); assertNotNull(fieldDataManager); int undoListSize = UndoManager.getInstance().getUndoListSize(); ExpressionPanelFactory.setTestMode(); panel.editFilter(FieldIdEnum.FILTER); FieldConfigString filterField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.FILTER); String expectedString1 = "[ 1 = 2 ]"; assertEquals(expectedString1, filterField.getStringValue()); assertEquals(undoListSize + 1, UndoManager.getInstance().getUndoListSize()); panel.clearFilter(FieldIdEnum.FILTER); assertEquals(undoListSize + 2, UndoManager.getInstance().getUndoListSize()); String expectedString2 = ""; assertEquals(expectedString2, filterField.getStringValue()); UndoManager.getInstance().undo(); assertEquals(expectedString1, filterField.getStringValue()); UndoManager.getInstance().redo(); assertEquals(expectedString2, filterField.getStringValue()); ExpressionPanelFactory.destroyInstance(); }
Example 10
Source File: BatchUpdateFontUtilsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.tool.batchupdatefont.BatchUpdateFontUtils#containsFonts(com.sldeditor.common.SLDDataInterface)}. */ @Test public void testContainsFonts() { 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); TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer(); String expectedNameValue = "symbolizer test value"; symbolizer.setName(expectedNameValue); rule.symbolizers().add(DefaultSymbols.createDefaultPointSymbolizer()); fts.rules().add(rule); sld.layers().add(namedLayer); SLDWriterInterface sldWriter = SLDWriterFactory.createWriter(null); String sldContents = sldWriter.encodeSLD(null, sld); SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), sldContents); // Empty sld List<BatchUpdateFontData> actualList = BatchUpdateFontUtils.containsFonts(null); assertNull(actualList); // No fonts actualList = BatchUpdateFontUtils.containsFonts(sldData); assertNull(actualList); // With textsymbolizer rule.symbolizers().add(symbolizer); sldContents = sldWriter.encodeSLD(null, sld); sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), sldContents); actualList = BatchUpdateFontUtils.containsFonts(sldData); assertEquals(1, actualList.size()); assertEquals(rule.getName(), actualList.get(0).getRuleName()); // Bump up the code coverage sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), "empty"); actualList = BatchUpdateFontUtils.containsFonts(sldData); assertNull(actualList); }
Example 11
Source File: StrokeDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.StrokeDetails#StrokeDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. */ @Test public void testStrokeDetailsPolygon() { StrokeDetails panel = new StrokeDetails(); 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 expectedNameValue = "rule test value"; rule.setName(expectedNameValue); PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); 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); FieldConfigSymbolType symbolTypeField = (FieldConfigSymbolType) fieldDataManager.get(FieldIdEnum.STROKE_STYLE); symbolTypeField.populateField("circle"); double expectedAngle = 14.5; FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.STROKE_SYMBOL_ANGLE); angleField.populateField(expectedAngle); FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY); double opacity = 0.15; opacityField.populateField(opacity); FieldConfigString dashField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.STROKE_DASH_ARRAY); String dashArray = "1 2"; dashField.populateField(dashArray); panel.dataChanged(null); double actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - expectedAngle) < 0.01); assertTrue(panel.isDataPresent()); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - opacity) < 0.01); // Reset to default value panel.preLoadSymbol(); actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - 0.0) < 0.01); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - 1.0) < 0.01); }
Example 12
Source File: StrokeDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.StrokeDetails#StrokeDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. */ @Test public void testStrokeDetailsCircle() { StrokeDetails panel = new StrokeDetails(); 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 expectedNameValue = "rule test value"; rule.setName(expectedNameValue); PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer(); 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); FieldConfigSymbolType symbolTypeField = (FieldConfigSymbolType) fieldDataManager.get(FieldIdEnum.STROKE_STYLE); symbolTypeField.populateField("circle"); double expectedAngle = 14.5; FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.STROKE_SYMBOL_ANGLE); angleField.populateField(expectedAngle); FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY); double opacity = 0.15; opacityField.populateField(opacity); FieldConfigString dashField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.STROKE_DASH_ARRAY); String dashArray = "1 2"; dashField.populateField(dashArray); panel.dataChanged(null); double actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - expectedAngle) < 0.01); assertFalse(panel.isDataPresent()); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - opacity) < 0.01); // Reset to default value panel.preLoadSymbol(); actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - 0.0) < 0.01); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - 1.0) < 0.01); }
Example 13
Source File: FeatureTypeStyleDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.FeatureTypeStyleDetails#FeatureTypeStyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. * Test method for {@link * com.sldeditor.ui.detail.FeatureTypeStyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. * Test method for {@link * com.sldeditor.ui.detail.FeatureTypeStyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link * com.sldeditor.ui.detail.FeatureTypeStyleDetails#getFieldDataManager()}. Test method for * {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#isDataPresent()}. Test method for * {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#preLoadSymbol()}. */ @Test public void testFeatureTypeStyleDetails() { FeatureTypeStyleDetails panel = new FeatureTypeStyleDetails(); 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 expectedNameValue = "feature type style test value"; fts.setName(expectedNameValue); style.featureTypeStyles().add(fts); Rule rule = DefaultSymbols.createNewRule(); String expectedRuleNameValue = "rule test value"; rule.setName(expectedRuleNameValue); fts.rules().add(rule); sld.layers().add(namedLayer); SelectedSymbol.getInstance().addNewStyledLayer(namedLayer); SelectedSymbol.getInstance().setStyledLayer(namedLayer); SelectedSymbol.getInstance().setStyle(style); SelectedSymbol.getInstance().setFeatureTypeStyle(fts); panel.populate(SelectedSymbol.getInstance()); panel.dataChanged(null); GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager(); assertNotNull(fieldDataManager); FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME); String actualValue = nameField.getStringValue(); assertTrue(expectedNameValue.compareTo(actualValue) == 0); assertTrue(panel.isDataPresent()); // Reset to default value panel.preLoadSymbol(); actualValue = nameField.getStringValue(); assertTrue("".compareTo(actualValue) == 0); }
Example 14
Source File: PointFillDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.PointFillDetailsTest#FillDetails(java.lang.Class, * com.sldeditor.filter.v2.function.FunctionNameInterface)}. */ @Test public void testFillDetailsPoint() { PointFillDetails panel = new PointFillDetails(); 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 expectedNameValue = "rule test value"; rule.setName(expectedNameValue); PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer(); 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); double expectedAngle = 14.5; FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.ANGLE); angleField.populateField(expectedAngle); FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY); double opacity = 0.15; opacityField.populateField(opacity); panel.dataChanged(FieldIdEnum.UNKNOWN); double actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - expectedAngle) < 0.01); assertTrue(panel.isDataPresent()); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - opacity) < 0.01); // Reset to default value panel.preLoadSymbol(); actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - 0.0) < 0.01); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - 1.0) < 0.01); }
Example 15
Source File: PolygonFillDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.PolygonFillDetailsTest#PolygonFillDetailsTest(java.lang.Class, * com.sldeditor.filter.v2.function.FunctionNameInterface)}. */ @Test public void testFillDetailsPolygon() { StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); PolygonFillDetails panel = new PolygonFillDetails(); 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 expectedNameValue = "rule test value"; rule.setName(expectedNameValue); PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer(); 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); double expectedAngle = 14.5; FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.ANGLE); angleField.populateField(expectedAngle); FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY); double opacity = 0.15; opacityField.populateField(opacity); panel.dataChanged(FieldIdEnum.UNKNOWN); double actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - expectedAngle) < 0.01); assertTrue(panel.isDataPresent()); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - opacity) < 0.01); // Reset to default value panel.preLoadSymbol(); actualValue = angleField.getDoubleValue(); assertTrue(Math.abs(actualValue - 0.0) < 0.01); actualValue = opacityField.getDoubleValue(); assertTrue(Math.abs(actualValue - 1.0) < 0.01); // Increase the coverage, set the fill Fill fill = styleFactory.createFill(ff.literal("#123456")); Graphic graphic = styleFactory.createDefaultGraphic(); fill.setGraphicFill(graphic); symbolizer.setFill(fill); panel.populate(SelectedSymbol.getInstance()); Graphic graphic2 = styleFactory.createDefaultGraphic(); graphic2.setDisplacement(styleFactory.createDisplacement(ff.literal(6.0), ff.literal(7.0))); graphic2.setAnchorPoint(styleFactory.anchorPoint(ff.literal(6.0), ff.literal(7.0))); Fill fill2 = styleFactory.createFill(ff.literal("#123456")); fill2.setGraphicFill(graphic2); symbolizer.setFill(fill2); panel.populate(SelectedSymbol.getInstance()); symbolizer.setFill(null); panel.populate(SelectedSymbol.getInstance()); }
Example 16
Source File: PointSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.PointSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. * Test method for {@link * com.sldeditor.ui.detail.PointSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#getFieldDataManager()}. * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#isDataPresent()}. Test * method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#preLoadSymbol()}. Test * method for {@link * com.sldeditor.ui.detail.PointSymbolizerDetails#PointSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. */ @Test public void testPointSymbolizerDetails() { SelectedSymbol.destroyInstance(); PointSymbolizerDetails panel = new PointSymbolizerDetails(); 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); PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer(); 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 descriptionField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.DESCRIPTION); assertNull(descriptionField); assertTrue(panel.isDataPresent()); // Reset to default value panel.preLoadSymbol(); }
Example 17
Source File: TextSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.TextSymbolizerDetails#TextSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. * Test method for {@link * com.sldeditor.ui.detail.TextSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. * Test method for {@link * com.sldeditor.ui.detail.TextSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#getFieldDataManager()}. * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#isDataPresent()}. Test * method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#preLoadSymbol()}. */ @Test public void testTextSymbolizerDetails() { TextSymbolizerDetails panel = new TextSymbolizerDetails(); 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); TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer(); 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(); }
Example 18
Source File: FeatureTypeStyleTreeItemTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.tree.item.FeatureTypeStyleTreeItem#getTreeString(java.lang.Object)}. */ @Test public void testGetTreeString() { FeatureTypeStyleTreeItem item = new FeatureTypeStyleTreeItem(); String actualValue = item.getTreeString(null, null); String expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.featureTypeStyle"), ""); assertTrue(actualValue.compareTo(expectedValue) == 0); FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle(); actualValue = item.getTreeString(null, fts); // Default feature type style sets name = name! expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.featureTypeStyle"), "name"); assertTrue(actualValue.compareTo(expectedValue) == 0); fts.setName(null); actualValue = item.getTreeString(null, fts); // Default feature type style sets name = name! expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.featureTypeStyle"), ""); assertTrue(actualValue.compareTo(expectedValue) == 0); String expectedName = "test name"; fts.setName(expectedName); actualValue = item.getTreeString(null, fts); expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.featureTypeStyle"), expectedName); assertTrue(actualValue.compareTo(expectedValue) == 0); }