use of org.geotools.styling.FeatureTypeStyle in project hale by halestudio.
the class RuleStylePage method createEditor.
/**
* Create a rule editor
*
* @param rule the rule
* @param parent the parent composite
*
* @return the {@link Rule} editor
*/
private Editor<Rule> createEditor(Rule rule, Composite parent) {
TypeDefinition type = getParent().getType();
Filter filter = rule.getFilter();
Symbolizer symbolizer = null;
Symbolizer[] symbolizers = rule.getSymbolizers();
if (symbolizers != null && symbolizers.length > 0) {
symbolizer = symbolizers[0];
}
if (symbolizer == null) {
// fallback if there is no symbolizer defined
FeatureTypeStyle fts = StyleHelper.getDefaultStyle(type, getParent().getDataSet());
symbolizer = fts.rules().get(0).getSymbolizers()[0];
}
Editor<Rule> editor;
if (symbolizer instanceof PointSymbolizer) {
editor = createEditor(parent, type, filter, PointSymbolizer.class, (PointSymbolizer) symbolizer);
} else if (symbolizer instanceof PolygonSymbolizer) {
editor = createEditor(parent, type, filter, PolygonSymbolizer.class, (PolygonSymbolizer) symbolizer);
} else {
// TODO support other symbolizers
// default: LineSymbolizer
editor = createEditor(parent, type, filter, LineSymbolizer.class, (LineSymbolizer) symbolizer);
}
return editor;
}
use of org.geotools.styling.FeatureTypeStyle in project hale by halestudio.
the class StyleServiceImpl method getDefinedStyle.
/**
* @see StyleService#getDefinedStyle(TypeDefinition)
*/
@Override
public Style getDefinedStyle(TypeDefinition type) {
FeatureTypeStyle fts = styles.get(type);
if (fts != null) {
Style style = styleFactory.createStyle();
style.featureTypeStyles().add(fts);
return style;
} else {
return null;
}
}
use of org.geotools.styling.FeatureTypeStyle in project hale by halestudio.
the class StyleServiceImpl method addStyle.
/*
* private Collection<TypeDefinition> findFallbackTypes(){
* Collection<TypeDefinition> result = new ArrayList<TypeDefinition>();
*
* TypeIndex typeIndexSource =
* schemaService.getSchemas(SchemaSpaceID.SOURCE); TypeIndex typeIndexTarget
* = schemaService.getSchemas(SchemaSpaceID.TARGET);
*
* for (TypeDefinition type : typeIndexSource.getMappingRelevantTypes()){
* result.add(type); } for (TypeDefinition type :
* typeIndexTarget.getMappingRelevantTypes()){ result.add(type); } return
* result; }
*/
/**
* Add a type style.
*
* @param type the type definition
* @param fts the type style
* @return if the style definitions were changed
*/
private boolean addStyle(TypeDefinition type, FeatureTypeStyle fts) {
boolean somethingHappened = false;
FeatureTypeStyle old = this.styles.get(type);
if (old != null) {
if (!old.equals(fts)) {
// $NON-NLS-1$
_log.info("Replacing style for feature type " + type.getName());
somethingHappened = true;
}
} else {
// $NON-NLS-1$
_log.info("Adding style for feature type " + type.getName());
somethingHappened = true;
}
this.styles.put(type, fts);
return somethingHappened;
}
use of org.geotools.styling.FeatureTypeStyle in project hale by halestudio.
the class StyleServiceImpl method getStyle.
private Style getStyle(final DataSet dataset, boolean selected) {
SchemaSpace schemas = schemaService.getSchemas((dataset == DataSet.SOURCE) ? (SchemaSpaceID.SOURCE) : (SchemaSpaceID.TARGET));
Style style = styleFactory.createStyle();
for (TypeDefinition type : schemas.getMappingRelevantTypes()) {
if (!type.getConstraint(AbstractFlag.class).isEnabled()) {
// only add styles for non-abstract feature types
FeatureTypeStyle fts = styles.get(type);
if (fts == null) {
if (fbStyle != null) {
fts = fbStyle;
} else {
fts = StyleHelper.getDefaultStyle(type, dataset);
}
}
if (selected) {
fts = getSelectedStyle(fts);
}
style.featureTypeStyles().add(fts);
}
}
return style;
}
use of org.geotools.styling.FeatureTypeStyle in project hale by halestudio.
the class StyleServiceImpl method getNamedStyle.
// StyleService methods ....................................................
/**
* @see StyleService#getNamedStyle(String)
*/
@Override
public Style getNamedStyle(String name) {
Style style = styleFactory.createStyle();
for (FeatureTypeStyle fts : this.styles.values()) {
// name
if (fts.getName().equals(name)) {
style = styleFactory.createStyle();
style.featureTypeStyles().add(fts);
break;
}
}
return style;
}
Aggregations