use of org.geotools.feature.NameImpl in project hale by halestudio.
the class StyleHelper method getRandomStyles.
/**
* Returns a default style for the given type.
*
* @param dataSetTypes type definitions associated to their data set
* @return the style
*/
public static Style getRandomStyles(SetMultimap<DataSet, TypeDefinition> dataSetTypes) {
int defWidth = StylePreferences.getDefaultWidth();
Style style = styleFactory.createStyle();
for (Entry<DataSet, TypeDefinition> entry : dataSetTypes.entries()) {
DataSet dataSet = entry.getKey();
TypeDefinition typeDef = entry.getValue();
FeatureTypeStyle fts;
// TODO based on default geometry?
// polygon is always OK as it contains stroke and fill
// Color color = generateRandomColor(Color.WHITE);
float saturation;
float brightness;
switch(dataSet) {
case TRANSFORMED:
saturation = 0.8f;
brightness = 0.6f;
break;
case SOURCE:
default:
saturation = 0.75f;
brightness = 0.8f;
break;
}
Color color = generateRandomColor(saturation, brightness);
fts = createPolygonStyle(color, defWidth);
fts.featureTypeNames().add(new NameImpl(getFeatureTypeName(typeDef)));
style.featureTypeStyles().add(fts);
}
return style;
}
use of org.geotools.feature.NameImpl in project hale by halestudio.
the class StyleHelper method getDefaultStyle.
/**
* Returns a default style for the given type.
*
* @param typeDef the type definition
* @param dataSet the data set (if known)
* @return the style
*/
public static FeatureTypeStyle getDefaultStyle(TypeDefinition typeDef, @Nullable DataSet dataSet) {
// GeometrySchemaService gss = (GeometrySchemaService) PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// List<QName> geomPath = gss.getDefaultGeometry(typeDef);
// TODO determine default style from default geometry?
Color defColor;
if (dataSet != null) {
defColor = StylePreferences.getDefaultColor(dataSet);
} else {
defColor = Color.DARK_GRAY;
}
int defWidth = StylePreferences.getDefaultWidth();
FeatureTypeStyle result;
// XXX for now create a polygon style in any case, as it contains fill
// and stroke
// if (type != null) {
// if (type.isAssignableFrom(Polygon.class)
// || type.isAssignableFrom(MultiPolygon.class)) {
result = createPolygonStyle(defColor, defWidth);
// } else if (type.isAssignableFrom(LineString.class)
// || type.isAssignableFrom(MultiLineString.class)) {
// result = createLineStyle(defColor, defWidth);
// } else {
// result = createPointStyle(defColor, defWidth);
// }
// }
// else {
// result = createPointStyle(defColor, defWidth);
// }
// XXX StyleBuilder does not support feature type names with namespace
// QName name = getFeatureTypeName(typeDef);
// result.featureTypeNames().add(new NameImpl(name.getNamespaceURI(), name.getLocalPart()));
result.featureTypeNames().add(new NameImpl(getFeatureTypeName(typeDef)));
return result;
}
use of org.geotools.feature.NameImpl in project ddf by codice.
the class CswQueryFactory method normalizeSortBy.
private SortBy normalizeSortBy(SortBy cswSortBy) {
if (cswSortBy == null || cswSortBy.getPropertyName() == null) {
return null;
}
String propertyName = cswSortBy.getPropertyName().getPropertyName();
if (propertyName == null) {
LOGGER.debug("Property in SortBy Field is null");
return null;
}
NamespaceSupport namespaceContext = cswSortBy.getPropertyName().getNamespaceContext();
if (!attributeRegistry.lookup(propertyName).isPresent() && !cswRecordMap.hasProperty(propertyName, namespaceContext)) {
LOGGER.debug("Property {} is not a valid SortBy Field", propertyName);
return null;
}
String name = cswRecordMap.getProperty(propertyName, namespaceContext);
PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
return new SortByImpl(propName, cswSortBy.getSortOrder());
}
use of org.geotools.feature.NameImpl in project ddf by codice.
the class CswQueryFactory method buildSort.
private SortBy[] buildSort(SortByType sort) throws CswException {
if (sort == null || sort.getSortProperty() == null) {
return null;
}
SortBy[] sortByArr = parseSortBy(sort);
if (sortByArr == null || sortByArr.length == 0) {
return null;
}
List<SortBy> sortBys = new ArrayList<>(sortByArr.length);
for (SortBy cswSortBy : sortByArr) {
if (cswSortBy.getPropertyName() == null) {
LOGGER.debug("No property name in primary sort criteria");
return null;
}
String name = cswSortBy.getPropertyName().getPropertyName();
PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
SortBy sortBy = new SortByImpl(propName, cswSortBy.getSortOrder());
sortBys.add(sortBy);
}
if (sortBys.isEmpty()) {
return null;
}
return sortBys.toArray(new SortBy[0]);
}
use of org.geotools.feature.NameImpl in project sldeditor by robward-scisys.
the class FieldConfigBase method attributeUpdated.
/**
* Attribute updated.
*
* @param attributeName the attribute name
*/
@Override
public void attributeUpdated(String attributeName) {
expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
NameImpl name = new NameImpl(attributeName);
setCachedExpression(new AttributeExpressionImpl(name));
setValueFieldState();
fireDataChanged();
}
Aggregations