use of org.geotools.styling.Description in project sldeditor by robward-scisys.
the class UniqueValueRenderer method convert.
/* (non-Javadoc)
* @see com.sldeditor.convert.esri.renderer.EsriRendererInterface#convert(com.google.gson.JsonObject, java.lang.String, double, double, int)
*/
@Override
public StyledLayerDescriptor convert(JsonObject json, String layerName, double minScale, double maxScale, int transparency) {
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
NamedLayer namedLayer = styleFactory.createNamedLayer();
boolean useDefaultSymbol = false;
JsonElement useDefaultSymbolElement = json.get(UniqueValueRendererKeys.USE_DEFAULTSYMBOL);
if (useDefaultSymbolElement != null) {
useDefaultSymbol = useDefaultSymbolElement.getAsBoolean();
}
JsonElement jsonElement = json.get(CommonRendererKeys.LABEL);
if (jsonElement != null) {
namedLayer.setName(jsonElement.getAsString());
}
sld.addStyledLayer(namedLayer);
Style style = styleFactory.createStyle();
namedLayer.addStyle(style);
List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
// style.setAbstract(json.get(IntermediateFileKeys.DESCRIPTION).getAsString());
FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
ftsList.add(fts);
JsonElement element = json.get(UniqueValueRendererKeys.VALUES);
if (element != null) {
JsonArray valueList = element.getAsJsonArray();
for (int index = 0; index < valueList.size(); index++) {
JsonElement valueElement = valueList.get(index);
if (valueElement != null) {
Rule rule = styleFactory.createRule();
JsonObject valueObj = valueElement.getAsJsonObject();
String value = getString(valueObj, UniqueValueRendererKeys.VALUES_VALUE);
String label = getString(valueObj, UniqueValueRendererKeys.VALUES_LABEL);
rule.setName(label);
createFilter(rule, json.get(UniqueValueRendererKeys.FIELDS), json.get(UniqueValueRendererKeys.FIELD_DELIMETER), value);
// Heading /description
String heading = getString(valueObj, UniqueValueRendererKeys.VALUES_HEADING);
@SuppressWarnings("unused") String description = getString(valueObj, UniqueValueRendererKeys.VALUES_DESCRIPTION);
if ((heading != null) && !heading.isEmpty() || (label != null) && !label.isEmpty()) {
if (label == null) {
label = "";
}
InternationalString titleString = Text.text(label);
if (heading == null) {
heading = "";
}
InternationalString descriptionString = Text.text(heading);
Description descriptionObj = styleFactory.description(titleString, descriptionString);
rule.setDescription(descriptionObj);
}
if (minScale > 0.0) {
rule.setMinScaleDenominator(minScale);
}
if (maxScale > 0.0) {
rule.setMaxScaleDenominator(maxScale);
}
JsonElement jsonSymbolElement = valueObj.get(UniqueValueRendererKeys.VALUES_SYMBOL);
SymbolManager.getInstance().convertSymbols(rule, layerName, transparency, jsonSymbolElement);
if (useDefaultSymbol && value == null) {
rule.setIsElseFilter(true);
}
fts.rules().add(rule);
}
}
}
return sld;
}
use of org.geotools.styling.Description in project sldeditor by robward-scisys.
the class DefaultSymbols method createDefaultTextSymbolizer.
/**
* Creates the default text symbolizer.
*
* @return the text symbolizer
*/
public static TextSymbolizer createDefaultTextSymbolizer() {
Expression fontFamily = ff.literal("Serif");
Expression fontSize = ff.literal(10.0);
Expression fontStyle = ff.literal("normal");
Expression fontWeight = ff.literal("normal");
Expression rotation = ff.literal(0.0);
Expression label = ff.literal("Test");
String geometryFieldName = null;
Expression geometryField = ff.property(geometryFieldName);
String name = Localisation.getString(SLDTreeTools.class, "TreeItem.newText");
AnchorPoint anchor = null;
Displacement displacement = null;
PointPlacement pointPlacement = (PointPlacement) styleFactory.pointPlacement(anchor, displacement, rotation);
Expression fillColour = ff.literal(DEFAULT_COLOUR);
Expression fillColourOpacity = ff.literal(1.0);
Fill fill = styleFactory.fill(null, fillColour, fillColourOpacity);
Halo halo = null;
List<Expression> fontFamilyList = new ArrayList<Expression>();
fontFamilyList.add(fontFamily);
Font font = (Font) styleFactory.font(fontFamilyList, fontStyle, fontWeight, fontSize);
Description description = null;
Unit<Length> unit = null;
TextSymbolizer newTextSymbolizer = (TextSymbolizer) styleFactory.textSymbolizer(name, geometryField, description, unit, label, font, pointPlacement, halo, fill);
return newTextSymbolizer;
}
use of org.geotools.styling.Description in project sldeditor by robward-scisys.
the class StandardPanel method populateStandardData.
/**
* Populate standard data.
*
* @param standardData the standard data
*/
private void populateStandardData(StandardData standardData) {
Description description = standardData.description;
String titleString = "";
String descriptionString = "";
if (description != null) {
InternationalString title = description.getTitle();
if (title != null) {
titleString = title.toString();
}
InternationalString abstractDesc = description.getAbstract();
if (abstractDesc != null) {
descriptionString = abstractDesc.toString();
}
}
if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.NAME) != null) {
fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, standardData.name);
}
if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.TITLE) != null) {
fieldConfigVisitor.populateTextField(FieldIdEnum.TITLE, titleString);
}
if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.DESCRIPTION) != null) {
fieldConfigVisitor.populateTextField(FieldIdEnum.DESCRIPTION, descriptionString);
}
FieldConfigBase uomFieldConfig = fieldConfigManager.get(FieldIdEnum.UOM);
if (uomFieldConfig != null) {
uomFieldConfig.updateAttributeSelection(SelectedSymbol.getInstance().isRasterSymbol());
String uomString = UnitsOfMeasure.getInstance().convert(standardData.unit);
fieldConfigVisitor.populateField(FieldIdEnum.UOM, getFilterFactory().literal(uomString));
}
}
Aggregations