/** * 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(); }
private LabelStyleInfo createRandomLabelStyle(String attributeName) { LabelStyleInfo style = new LabelStyleInfo(); style.setBackgroundStyle(createRandomPolygonStyle()); FontStyleInfo fontStyle = new FontStyleInfo(); fontStyle.setColor(style.getBackgroundStyle().getStrokeColor()); fontStyle.setFamily("Verdana"); fontStyle.setOpacity(1F); fontStyle.setSize(8); fontStyle.setWeight("normal"); fontStyle.setStyle("normal"); style.setFontStyle(fontStyle); style.setLabelAttributeName(attributeName); return style; }
return false; if (labelStyle != null ? !labelStyle.equals(that.labelStyle) : that.labelStyle != null) { return false;
Font font = new Font("Helvetica", Font.ITALIC, 10); Color fontColor = Color.black; if (labelType.getFontStyle() != null) { fontColor = context .getColor(labelType.getFontStyle().getColor(), labelType.getFontStyle().getOpacity()); if (labelType.getBackgroundStyle() != null) { bgColor = context.getColor(labelType.getBackgroundStyle().getFillColor(), labelType .getBackgroundStyle().getFillOpacity()); if (labelType.getBackgroundStyle() != null) { borderColor = context.getColor(labelType.getBackgroundStyle().getStrokeColor(), labelType .getBackgroundStyle().getStrokeOpacity()); if (labelType.getBackgroundStyle() != null) { linewidth = labelType.getBackgroundStyle().getStrokeWidth();
private NamedStyleInfo getDefaultStyleInfo(LayerType type, String clientLayerName, String labelAttributeName) { NamedStyleInfo nsi = null; switch (type) { case POINT: case MULTIPOINT: nsi = pointStyle; break; case LINESTRING: case MULTILINESTRING: nsi = lineStyle; break; default: nsi = polygonStyle; break; } nsi = cloneService.clone(nsi); if (nsi.getLabelStyle() == null || nsi.getFeatureStyles().size() < 1) { log.warn("NamedStyleInfo is invalid (LabelStyle should not be null " + "& there should be at least one FeatureStyle.)"); } else { nsi.getLabelStyle().setLabelAttributeName(labelAttributeName); nsi.getFeatureStyles().get(0).setName(clientLayerName + "_FeatureStyle_0"); nsi.setName(clientLayerName + "_Style"); } return nsi; }
VectorLayerRasterizingInfo vectorRasterizingInfo = (VectorLayerRasterizingInfo) clientLayerInfo .getWidgetInfo(VectorLayerRasterizingInfo.WIDGET_KEY); int origSize = vectorRasterizingInfo.getStyle().getLabelStyle().getFontStyle().getSize(); vectorRasterizingInfo.getStyle().getLabelStyle().getFontStyle() .setSize(origSize * request.getDpi() / 96);
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! }
private NamedStyleInfo getDefaultStyleInfo(LayerType type, String clientLayerName, String labelAttributeName) { NamedStyleInfo nsi = null; switch (type) { case POINT: case MULTIPOINT: nsi = pointStyle; break; case LINESTRING: case MULTILINESTRING: nsi = lineStyle; break; default: nsi = polygonStyle; break; } nsi = cloneService.clone(nsi); if (nsi.getLabelStyle() == null || nsi.getFeatureStyles().size() < 1) { LOG.warn("NamedStyleInfo is invalid (LabelStyle should not be null " + "& there should be at least one FeatureStyle.)"); } else { nsi.getLabelStyle().setLabelAttributeName(labelAttributeName); nsi.getFeatureStyles().get(0).setName(clientLayerName + "_FeatureStyle_0"); nsi.setName(clientLayerName + "_Style"); } return nsi; }
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 } }
public DynamicVectorLayerConfiguration getData() { if (currentIdField == null || currentLabelField == null) { return null; } FeatureInfo fi = layerConfig.getClientVectorLayerInfo().getFeatureInfo(); fi.setIdentifier((PrimitiveAttributeInfo) currentIdField.getAttributeAsObject(FLD_OBJECT)); layerConfig.getClientVectorLayerInfo().getNamedStyleInfo().getLabelStyle() .setLabelAttributeName(currentLabelField.getAttributeAsString(FLD_NAME)); for (ListGridRecord r : grid.getRecords()) { PrimitiveAttributeInfo pai = (PrimitiveAttributeInfo) r.getAttributeAsObject(FLD_OBJECT); pai.setLabel(r.getAttributeAsString(FLD_LABEL)); pai.setIdentifying(r.getAttributeAsBoolean(FLD_IDENTIFYING)); pai.setHidden(!grid.isSelected(r)); pai.setType(PrimitiveType.fromValue(r.getAttributeAsString(FLD_TYPE))); } return layerConfig; }