public void applyChanges(DynamicVectorLayerConfiguration layerConfig) { Map<String, Object> props = new HashMap<String, Object>(); props.put(SldUtils.FILLCOLOR, picker.getValueAsString()); props.put(SldUtils.STROKECOLOR, picker.getValueAsString()); props.put(SldUtils.FILLOPACITY, 0.5f); props.put(SldUtils.STROKEOPACITY, 1f); props.put(SldUtils.STYLENAME, "".equals(label.getValueAsString()) ? "default" : label.getValueAsString()); props.put(SldUtils.LABELFEATURENAME, layerConfig.getClientVectorLayerInfo().getNamedStyleInfo().getLabelStyle() .getLabelAttributeName()); layerConfig.getClientVectorLayerInfo().getNamedStyleInfo() .setUserStyle(SldUtils.createSimpleSldStyle(layerConfig, props)); // layerConfig.getClientVectorLayerInfo().getNamedStyleInfo().getFeatureStyles().clear(); // don't use these! }
/** * Applies default values to all properties that have not been set. * * @since 1.10.0 */ public void applyDefaults() { if (getName() == null) { setName(DEFAULT_NAME); } if (getFeatureStyles().size() == 0) { getFeatureStyles().add(new FeatureStyleInfo()); } for (FeatureStyleInfo featureStyle : getFeatureStyles()) { featureStyle.applyDefaults(); } if (getLabelStyle().getLabelAttributeName() == null) { getLabelStyle().setLabelAttributeName(LabelStyleInfo.ATTRIBUTE_NAME_ID); } getLabelStyle().getBackgroundStyle().applyDefaults(); getLabelStyle().getFontStyle().applyDefaults(); }
public void setData(DynamicVectorLayerConfiguration layerConfig) { this.layerConfig = layerConfig; FeatureInfo fi = layerConfig.getClientVectorLayerInfo().getFeatureInfo(); String labelFieldName = layerConfig.getClientVectorLayerInfo().getNamedStyleInfo().getLabelStyle() .getLabelAttributeName(); PrimitiveAttributeInfo idField = fi.getIdentifier(); for (AttributeInfo ai : fi.getAttributes()) { if (ai instanceof PrimitiveAttributeInfo) { ListGridRecord lgr = new ListGridRecord(); PrimitiveAttributeInfo pai = (PrimitiveAttributeInfo) ai; lgr.setAttribute(FLD_NAME, pai.getName()); lgr.setAttribute(FLD_TYPE, pai.getType().toString()); lgr.setAttribute(FLD_IDENTIFYING, pai.isIdentifying()); lgr.setAttribute(FLD_IDFIELD, (pai.equals(idField))); lgr.setAttribute(FLD_LABELFIELD, pai.getName().equals(labelFieldName)); lgr.setAttribute(FLD_LABEL, pai.getLabel()); lgr.setAttribute(FLD_OBJECT, pai); grid.addData(lgr); if (pai.getName().equals(labelFieldName)) { currentLabelField = lgr; } if (pai.equals(idField)) { currentIdField = lgr; } if (!pai.isHidden()) { grid.selectRecord(lgr); } } // else unsupported } }