Search in sources :

Example 6 with FeatureTypeStyle

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;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) Filter(org.opengis.filter.Filter) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) LineSymbolizer(org.geotools.styling.LineSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 7 with FeatureTypeStyle

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;
    }
}
Also used : Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 8 with FeatureTypeStyle

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;
}
Also used : FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 9 with FeatureTypeStyle

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;
}
Also used : SchemaSpace(eu.esdihumboldt.hale.common.schema.model.SchemaSpace) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 10 with FeatureTypeStyle

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;
}
Also used : Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Aggregations

FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)110 Style (org.geotools.styling.Style)81 Rule (org.geotools.styling.Rule)65 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)43 Test (org.junit.Test)42 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)24 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)21 LineSymbolizer (org.geotools.styling.LineSymbolizer)20 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)17 Symbolizer (org.geotools.styling.Symbolizer)16 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)15 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)14 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)12 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)12 TextSymbolizer (org.geotools.styling.TextSymbolizer)12 UserLayerImpl (org.geotools.styling.UserLayerImpl)12 ArrayList (java.util.ArrayList)11 LineStyle (org.polymap.core.style.model.feature.LineStyle)11