use of org.geotools.styling.UserLayerImpl 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.UserLayerImpl 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.UserLayerImpl in project sldeditor by robward-scisys.
the class UserLayerDetails 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 UserLayerImpl) {
UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, userLayer.getName());
// Feature layer constraint
List<FeatureTypeConstraint> ftcList = userLayer.layerFeatureConstraints();
fieldConfigVisitor.populateFieldTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
// Source
GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
if (group != null) {
MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
if (userLayer.getInlineFeatureDatastore() == null) {
userLayerSourceGroup.setOption(GroupIdEnum.REMOTE_OWS_OPTION);
// Remote OWS
String service = "";
String onlineResource = "";
RemoteOWS remoteOWS = userLayer.getRemoteOWS();
if (remoteOWS != null) {
service = remoteOWS.getService();
onlineResource = remoteOWS.getOnlineResource();
}
fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_SERVICE, service);
fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE, onlineResource);
} else {
userLayerSourceGroup.setOption(GroupIdEnum.INLINE_FEATURE_OPTION);
// Inline features
fieldConfigVisitor.populateUserLayer(FieldIdEnum.INLINE_FEATURE, userLayer);
}
}
}
}
}
use of org.geotools.styling.UserLayerImpl in project sldeditor by robward-scisys.
the class UserLayerTreeItem method getTreeString.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.tree.item.SLDTreeItemInterface#getTreeString(javax.swing.tree.DefaultMutableTreeNode, java.lang.Object)
*/
@Override
public String getTreeString(DefaultMutableTreeNode node, Object nodeObject) {
UserLayerImpl userLayer = (UserLayerImpl) nodeObject;
String name = "";
if (userLayer != null) {
if (userLayer.getName() != null) {
name = userLayer.getName();
}
}
return String.format("%s : %s", TITLE, name);
}
use of org.geotools.styling.UserLayerImpl in project sldeditor by robward-scisys.
the class SLDTree method populateSLD.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.tree.UpdateTreeStructureInterface#populateSLD()
*/
@Override
public void populateSLD() {
reset();
SelectedSymbol selectedSymbol = SelectedSymbol.getInstance();
if (selectedSymbol != null) {
StyledLayerDescriptor sld = selectedSymbol.getSld();
rootNode.setUserObject(sld);
treeModel.nodeChanged(rootNode);
if (sld != null) {
List<StyledLayer> styledLayerList = sld.layers();
if (styledLayerList != null) {
for (StyledLayer styledLayer : styledLayerList) {
DefaultMutableTreeNode styledLayerTreeNode = null;
List<Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
styleList = namedLayerImpl.styles();
styledLayerTreeNode = addObject(rootNode, namedLayerImpl, true);
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
styleList = userLayerImpl.userStyles();
styledLayerTreeNode = addObject(rootNode, userLayerImpl, true);
}
if (styleList != null) {
for (Style style : styleList) {
DefaultMutableTreeNode styleTreeNode = addObject(styledLayerTreeNode, style, true);
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
DefaultMutableTreeNode ftsTreeNode = addObject(styleTreeNode, fts, true);
for (Rule rule : fts.rules()) {
DefaultMutableTreeNode ruleTreeNode = addObject(ftsTreeNode, rule, true);
for (Symbolizer symbolizer : rule.symbolizers()) {
DefaultMutableTreeNode symbolizerTreeNode = addObject(ruleTreeNode, symbolizer, true);
if ((symbolizer instanceof PointSymbolizer) || (symbolizer instanceof PolygonSymbolizer)) {
addObject(symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getFill(symbolizer), true);
}
if ((symbolizer instanceof PolygonSymbolizer) || (symbolizer instanceof LineSymbolizer)) {
addObject(symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getStroke(symbolizer), true);
}
if (symbolizer instanceof RasterSymbolizer) {
handleRasterSymbolizer(symbolizer, symbolizerTreeNode);
}
}
}
}
}
}
}
}
}
}
}
Aggregations