Java Code Examples for org.geotools.styling.Style#setName()
The following examples show how to use
org.geotools.styling.Style#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: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Creates a default {@link Style} for a featurecollection. * * @return the default style. */ public static Style createDefaultStyle( SimpleFeatureCollection featureCollection ) { GeometryDescriptor geometryDescriptor = featureCollection.getSchema().getGeometryDescriptor(); Style style = null; if (EGeometryType.isPoint(geometryDescriptor)) { style = createDefaultPointStyle(); } else if (EGeometryType.isLine(geometryDescriptor)) { style = createDefaultLineStyle(); } else if (EGeometryType.isPolygon(geometryDescriptor)) { style = createDefaultPolygonStyle(); } if (style != null) { style.setName(featureCollection.getSchema().getTypeName()); } return style; }
Example 2
Source File: StyleTreeItemTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.tree.item.StyleTreeItem#getTreeString(java.lang.Object)}. */ @Test public void testGetTreeString() { StyleTreeItem item = new StyleTreeItem(); String actualValue = item.getTreeString(null, null); String expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.style"), ""); assertTrue(actualValue.compareTo(expectedValue) == 0); Style style = DefaultSymbols.createNewStyle(); actualValue = item.getTreeString(null, style); expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.style"), Localisation.getString(SLDTreeTools.class, "TreeItem.newStyle")); assertTrue(actualValue.compareTo(expectedValue) == 0); style.setName(null); actualValue = item.getTreeString(null, style); expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.style"), ""); assertTrue(actualValue.compareTo(expectedValue) == 0); String expectedName = "test name"; style.setName(expectedName); actualValue = item.getTreeString(null, style); expectedValue = String.format( "%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.style"), expectedName); assertTrue(actualValue.compareTo(expectedValue) == 0); }
Example 3
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Generates a style based on a graphic. * * @param graphicsPath the graphic. * @return the generated style. * @throws IOException */ public static StyleWrapper createStyleFromGraphic( File graphicsPath ) throws IOException { String name = graphicsPath.getName(); ExternalGraphic exGraphic = null; if (name.toLowerCase().endsWith(".png")) { exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/png"); } else if (name.toLowerCase().endsWith(".svg")) { exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml"); } else if (name.toLowerCase().endsWith(".sld")) { StyledLayerDescriptor sld = readStyle(graphicsPath); Style style = SldUtilities.getDefaultStyle(sld); return new StyleWrapper(style); } if (exGraphic == null) { throw new IOException("Style could not be created!"); } Graphic gr = sf.createDefaultGraphic(); gr.graphicalSymbols().clear(); gr.graphicalSymbols().add(exGraphic); Expression size = ff.literal(20); gr.setSize(size); Rule rule = sf.createRule(); PointSymbolizer pointSymbolizer = sf.createPointSymbolizer(gr, null); rule.symbolizers().add(pointSymbolizer); FeatureTypeStyle featureTypeStyle = sf.createFeatureTypeStyle(); featureTypeStyle.rules().add(rule); Style namedStyle = sf.createStyle(); namedStyle.featureTypeStyles().add(featureTypeStyle); namedStyle.setName(FilenameUtils.removeExtension(name)); return new StyleWrapper(namedStyle); }
Example 4
Source File: StyleDetailsTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.StyleDetails#StyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. * Test method for {@link * com.sldeditor.ui.detail.StyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. * Test method for {@link * com.sldeditor.ui.detail.StyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link com.sldeditor.ui.detail.StyleDetails#getFieldDataManager()}. Test * method for {@link com.sldeditor.ui.detail.StyleDetails#isDataPresent()}. Test method for * {@link com.sldeditor.ui.detail.StyleDetails#preLoadSymbol()}. */ @Test public void testStyleDetails() { StyleDetails panel = new StyleDetails(); 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 expectedNameValue = "style test value"; style.setName(expectedNameValue); namedLayer.addStyle(style); FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle(); style.featureTypeStyles().add(fts); sld.layers().add(namedLayer); SelectedSymbol.getInstance().addNewStyledLayer(namedLayer); SelectedSymbol.getInstance().setStyledLayer(namedLayer); SelectedSymbol.getInstance().setStyle(style); panel.populate(SelectedSymbol.getInstance()); panel.dataChanged(null); GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager(); assertNotNull(fieldDataManager); FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME); assertTrue(expectedNameValue.compareTo(nameField.getStringValue()) == 0); assertTrue(panel.isDataPresent()); // Reset to default value panel.preLoadSymbol(); assertTrue("".compareTo(nameField.getStringValue()) == 0); }
Example 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
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 15
Source File: RuleRenderVisitor.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Visit. * * @param style the style */ // CHECKSTYLE:OFF @SuppressWarnings("deprecation") // CHECKSTYLE:ON @Override public void visit(Style style) { Style copy = null; FeatureTypeStyle[] fts = style.getFeatureTypeStyles(); FeatureTypeStyle[] ftsCopy = null; if (this.ftsToRender != null) { ftsCopy = new FeatureTypeStyle[1]; for (int i = 0; i < fts.length; i++) { if (fts[i] != null) { if (fts[i] == this.ftsToRender) { fts[i].accept(this); ftsCopy[0] = (FeatureTypeStyle) pages.pop(); } } } } else { ftsCopy = new FeatureTypeStyle[fts.length]; for (int i = 0; i < fts.length; i++) { if (fts[i] != null) { fts[i].accept(this); ftsCopy[i] = (FeatureTypeStyle) pages.pop(); } } } copy = sf.createStyle(); copy.setAbstract(style.getAbstract()); copy.setName(style.getName()); copy.setTitle(style.getTitle()); copy.setFeatureTypeStyles(ftsCopy); if (STRICT && !copy.equals(style)) { throw new IllegalStateException("Was unable to duplicate provided Style:" + style); } pages.push(copy); }
Example 16
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 17
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 18
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 19
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 20
Source File: DefaultSymbols.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Creates the new style. * * @return the style */ public static Style createNewStyle() { Style style = styleFactory.createStyle(); style.setName("New Style"); return style; }