Java Code Examples for org.geotools.styling.UserLayer#addUserStyle()
The following examples show how to use
org.geotools.styling.UserLayer#addUserStyle() .
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: UserLayerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.UserLayerDetails#UserLayerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}. * Test method for {@link * com.sldeditor.ui.detail.UserLayerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. * Test method for {@link * com.sldeditor.ui.detail.UserLayerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}. * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#getFieldDataManager()}. Test * method for {@link com.sldeditor.ui.detail.UserLayerDetails#isDataPresent()}. Test method for * {@link com.sldeditor.ui.detail.UserLayerDetails#preLoadSymbol()}. */ @Test public void testUserLayerDetails() { UserLayerDetails panel = new UserLayerDetails(); panel.populate(null); // Set up test data StyledLayerDescriptor sld = DefaultSymbols.createNewSLD(); SelectedSymbol.getInstance().createNewSLD(sld); UserLayer userLayer = DefaultSymbols.createNewUserLayer(); String expectedUserValue = "user layer test value"; userLayer.setName(expectedUserValue); userLayer.addUserStyle(DefaultSymbols.createNewStyle()); sld.layers().add(userLayer); SelectedSymbol.getInstance().addNewStyledLayer(userLayer); SelectedSymbol.getInstance().setStyledLayer(userLayer); panel.populate(SelectedSymbol.getInstance()); panel.dataChanged(null); GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager(); assertNotNull(fieldDataManager); panel.dataChanged(FieldIdEnum.INLINE_FEATURE); FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME); assertTrue(expectedUserValue.compareTo(nameField.getStringValue()) == 0); assertTrue(panel.isDataPresent()); // Reset to default value panel.preLoadSymbol(); assertTrue("".compareTo(nameField.getStringValue()) == 0); }
Example 2
Source File: SldUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Converts a style to its string representation to be written to file. * * @param style the style to convert. * @return the style string. * @throws Exception */ public static String styleToString( Style style ) throws Exception { StyledLayerDescriptor sld = sf.createStyledLayerDescriptor(); UserLayer layer = sf.createUserLayer(); layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null}); sld.addStyledLayer(layer); layer.addUserStyle(style); SLDTransformer aTransformer = new SLDTransformer(); aTransformer.setIndentation(4); String xml = aTransformer.transform(sld); return xml; }
Example 3
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Converts a style to its string representation to be written to file. * * @param style the style to convert. * @return the style string. * @throws Exception */ public static String styleToString( Style style ) throws Exception { StyledLayerDescriptor sld = sf.createStyledLayerDescriptor(); UserLayer layer = sf.createUserLayer(); layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null}); sld.addStyledLayer(layer); layer.addUserStyle(style); SLDTransformer aTransformer = new SLDTransformer(); aTransformer.setIndentation(4); String xml = aTransformer.transform(sld); return xml; }
Example 4
Source File: StyleWrapper.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Converts a style to its string representation to be written to file. * * @param style the style to convert. * @return the style string. * @throws Exception */ public String toXml() throws Exception { StyledLayerDescriptor sld = sf.createStyledLayerDescriptor(); UserLayer layer = sf.createUserLayer(); layer.setLayerFeatureConstraints(new FeatureTypeConstraint[] { null }); sld.addStyledLayer(layer); layer.addUserStyle(style); SLDTransformer aTransformer = new SLDTransformer(); aTransformer.setIndentation(4); String xml = aTransformer.transform(sld); return xml; }
Example 5
Source File: UserLayerDetails.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Update symbol. * * @param changedField the changed field */ private void updateSymbol(FieldIdEnum changedField) { if (!Controller.getInstance().isPopulating()) { UserLayer userLayer = getStyleFactory().createUserLayer(); String name = fieldConfigVisitor.getText(FieldIdEnum.NAME); userLayer.setName(name); // Feature type constraints List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint( FieldIdEnum.LAYER_FEATURE_CONSTRAINTS); if ((ftcList != null) && !ftcList.isEmpty()) { FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()]; userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray)); } // Source GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE); if (group != null) { MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group; OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup(); switch (selectedOption.getId()) { case REMOTE_OWS_OPTION: updateRemoteOWS(userLayer); break; case INLINE_FEATURE_OPTION: updateInlineFeatureOption(userLayer); break; default: break; } } StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer(); if (existingStyledLayer instanceof UserLayerImpl) { UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer; for (Style style : existingUserLayer.userStyles()) { userLayer.addUserStyle(style); } } SelectedSymbol.getInstance().replaceStyledLayer(userLayer); // Update inline data sources if the inline data changed, // reduces creation of datasources updateInLineFeature(changedField); this.fireUpdateSymbol(); } }