use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class SelectedSymbol method addNewStyle.
/**
* Adds the new style.
*
* @param style the style
*/
public void addNewStyle(Style style) {
if (this.symbolData.getStyledLayer() == null) {
ConsoleManager.getInstance().error(this, "styledLayer == null");
} else {
if (this.symbolData.getStyledLayer() instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) this.symbolData.getStyledLayer();
List<Style> styleList = namedLayer.styles();
styleList.add(style);
} else if (this.symbolData.getStyledLayer() instanceof UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) this.symbolData.getStyledLayer();
List<Style> styleList = userLayer.userStyles();
styleList.add(style);
}
}
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class MinimumVersion method findMinimumVersion.
/**
* Find minimum version.
*
* @param sld the sld
*/
public void findMinimumVersion(StyledLayerDescriptor sld) {
vendorOptionsPresentList.clear();
Object parentObj = null;
if ((sld != null) && (uiMgr != null)) {
uiMgr.getMinimumVersion(parentObj, sld, vendorOptionsPresentList);
List<StyledLayer> styledLayerList = sld.layers();
if (styledLayerList != null) {
parentObj = sld;
for (StyledLayer styledLayer : styledLayerList) {
uiMgr.getMinimumVersion(parentObj, styledLayer, vendorOptionsPresentList);
List<Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
styleList = namedLayerImpl.styles();
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
styleList = userLayerImpl.userStyles();
}
if (styleList != null) {
parentObj = styledLayer;
for (Style style : styleList) {
uiMgr.getMinimumVersion(parentObj, style, vendorOptionsPresentList);
parentObj = style;
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
uiMgr.getMinimumVersion(parentObj, fts, vendorOptionsPresentList);
parentObj = fts;
for (Rule rule : fts.rules()) {
uiMgr.getMinimumVersion(parentObj, rule, vendorOptionsPresentList);
parentObj = rule;
for (Symbolizer symbolizer : rule.symbolizers()) {
uiMgr.getMinimumVersion(parentObj, symbolizer, vendorOptionsPresentList);
}
}
}
}
}
}
}
}
removeStrictSLD();
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class ExtractValidFieldTypes method fieldTypesUpdated.
/**
* Evaluate fields types.
*
* @return true, field types updated
*/
public static boolean fieldTypesUpdated() {
boolean fieldsUpdated = false;
SLDStyleFactory styleFactory = new SLDStyleFactory();
StyledLayerDescriptor sld = SelectedSymbol.getInstance().getSld();
if (sld != null) {
List<StyledLayer> styledLayerList = sld.layers();
for (StyledLayer styledLayer : styledLayerList) {
List<org.geotools.styling.Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
styleList = namedLayerImpl.styles();
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
styleList = userLayerImpl.userStyles();
}
if (styleList != null) {
for (Style style : styleList) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (Symbolizer symbolizer : rule.symbolizers()) {
FeatureSource<SimpleFeatureType, SimpleFeature> featureList = DataSourceFactory.getDataSource().getFeatureSource();
if (featureList != null) {
Object drawMe = null;
try {
drawMe = featureList.getFeatures().features().next();
} catch (NoSuchElementException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
styleFactory.createStyle(drawMe, symbolizer);
} catch (IllegalArgumentException e) {
String message = e.getMessage();
if (message.startsWith(UNABLE_TO_DECODE_PREFIX) && message.endsWith(UNABLE_TO_DECODE_SUFFIX)) {
String fieldName = message.substring(UNABLE_TO_DECODE_PREFIX.length(), message.length() - UNABLE_TO_DECODE_SUFFIX.length());
DataSourceFactory.getDataSource().updateFieldType(fieldName, Long.class);
fieldsUpdated = true;
} else {
ConsoleManager.getInstance().exception(ExtractValidFieldTypes.class, e);
}
}
}
}
}
}
}
}
}
}
return fieldsUpdated;
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class BatchUpdateFontUtils method containsFonts.
/**
* Contains font details.
*
* @param sldData the sld data
* @return the scale sld data
*/
public static List<BatchUpdateFontData> containsFonts(SLDDataInterface sldData) {
List<BatchUpdateFontData> dataList = null;
if (sldData != null) {
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
if (sld != null) {
List<StyledLayer> styledLayerList = sld.layers();
if (sld != null) {
for (StyledLayer styledLayer : styledLayerList) {
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
for (Style style : namedLayerImpl.styles()) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof TextSymbolizer) {
TextSymbolizer textSymbol = (TextSymbolizer) symbolizer;
Font font = textSymbol.getFont();
if (font != null) {
if (dataList == null) {
dataList = new ArrayList<BatchUpdateFontData>();
}
BatchUpdateFontData fontSLDData = new BatchUpdateFontData(sld, sldData);
fontSLDData.setNamedLayer(namedLayerImpl.getName());
fontSLDData.setFeatureTypeStyle(fts.getName());
fontSLDData.setStyle(style.getName());
fontSLDData.setRule(rule);
fontSLDData.setSymbolizer(textSymbol);
fontSLDData.setFont(font);
dataList.add(fontSLDData);
}
}
}
}
}
}
}
}
}
}
}
return dataList;
}
use of org.geotools.styling.NamedLayerImpl in project sldeditor by robward-scisys.
the class NamedLayerDetails method populate.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
if (selectedSymbol != null) {
StyledLayer styledLayer = selectedSymbol.getStyledLayer();
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, namedLayer.getName());
// Feature layer constraint
List<FeatureTypeConstraint> ftcList = namedLayer.layerFeatureConstraints();
fieldConfigVisitor.populateFieldTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
}
}
}
Aggregations