Search in sources :

Example 61 with Symbolizer

use of org.geotools.styling.Symbolizer in project hale by halestudio.

the class RuleStylePage method addRule.

/**
 * Add a new {@link Rule}
 */
protected void addRule() {
    SymbolizerDialog symDlg = new SymbolizerDialog(getShell());
    symDlg.open();
    Symbolizer symbolizer = symDlg.getSymbolizer();
    if (symbolizer != null) {
        Rule rule = styleBuilder.createRule(symbolizer);
        RuleItem item = new RuleItem(rule);
        rules.add(item);
        listViewer.add(item);
        updateButtonState();
        changed = true;
    }
}
Also used : 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)

Example 62 with Symbolizer

use of org.geotools.styling.Symbolizer in project hale by halestudio.

the class SimpleLineStylePage method createControl.

/**
 * @see IDialogPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    // create new controls
    Composite page = new Composite(parent, SWT.NONE);
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    page.setLayout(layout);
    Style style = getParent().getStyle();
    LineSymbolizer line = null;
    try {
        Symbolizer[] symbolizers = SLD.symbolizers(style);
        for (Symbolizer symbol : symbolizers) {
            if (symbol instanceof LineSymbolizer) {
                line = (LineSymbolizer) symbol;
                break;
            }
        }
    } catch (Exception e) {
    // ignore
    }
    if (line == null) {
        line = styleBuilder.createLineSymbolizer();
    }
    lineEditor = new LineSymbolizerEditor(page, line);
    setControl(page);
}
Also used : LineSymbolizerEditor(eu.esdihumboldt.hale.ui.style.editors.LineSymbolizerEditor) Composite(org.eclipse.swt.widgets.Composite) RowLayout(org.eclipse.swt.layout.RowLayout) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 63 with Symbolizer

use of org.geotools.styling.Symbolizer in project hale by halestudio.

the class StyleServiceImpl method getSelectedStyle.

/**
 * Convert the given style for selection
 *
 * @param fts the feature type style to convert
 *
 * @return the converted feature type style
 */
private FeatureTypeStyle getSelectedStyle(FeatureTypeStyle fts) {
    List<Rule> rules = fts.rules();
    List<Rule> newRules = new ArrayList<Rule>();
    for (Rule rule : rules) {
        Symbolizer[] symbolizers = rule.getSymbolizers();
        List<Symbolizer> newSymbolizers = new ArrayList<Symbolizer>();
        for (Symbolizer symbolizer : symbolizers) {
            // get symbolizers
            List<Symbolizer> addSymbolizers = getSelectionSymbolizers(symbolizer);
            if (addSymbolizers != null) {
                newSymbolizers.addAll(addSymbolizers);
            }
        }
        // create new rule
        Rule newRule = styleBuilder.createRule(newSymbolizers.toArray(new Symbolizer[newSymbolizers.size()]));
        newRule.setFilter(rule.getFilter());
        newRule.setElseFilter(rule.isElseFilter());
        newRule.setName(rule.getName());
        newRules.add(newRule);
    }
    // TODO Handle case if there is more than one featureTypeName
    return styleBuilder.createFeatureTypeStyle(fts.featureTypeNames().stream().findFirst().orElse(new NameImpl("Feature")).getLocalPart(), newRules.toArray(new Rule[newRules.size()]));
}
Also used : NameImpl(org.geotools.feature.NameImpl) ArrayList(java.util.ArrayList) 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)

Example 64 with Symbolizer

use of org.geotools.styling.Symbolizer in project hale by halestudio.

the class StyleServiceImpl method getSelectionSymbolizers.

/**
 * Get the symbolizers representing the given symbolizer for a selection
 *
 * @param symbolizer the symbolizer
 *
 * @return the selection symbolizers
 */
private List<Symbolizer> getSelectionSymbolizers(Symbolizer symbolizer) {
    List<Symbolizer> result = new ArrayList<Symbolizer>();
    Color color = StylePreferences.getSelectionColor();
    int width = StylePreferences.getSelectionWidth();
    if (symbolizer instanceof PolygonSymbolizer) {
        result.add(StyleHelper.createPolygonSymbolizer(color, width));
    } else if (symbolizer instanceof LineSymbolizer) {
        result.add(StyleHelper.createLineSymbolizer(color, width));
    } else if (symbolizer instanceof PointSymbolizer) {
        result.add(StyleHelper.mutatePointSymbolizer((PointSymbolizer) symbolizer, color, width));
    // result.add(createPointSymbolizer(color, width));
    } else {
    // do not fall-back to original symbolizer cause we are painting
    // over it
    // result.add(symbolizer);
    }
    return result;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Color(java.awt.Color) LineSymbolizer(org.geotools.styling.LineSymbolizer) ArrayList(java.util.ArrayList) LineSymbolizer(org.geotools.styling.LineSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer)

Example 65 with Symbolizer

use of org.geotools.styling.Symbolizer in project hale by halestudio.

the class SimplePointStylePage method createControl.

/**
 * @see IDialogPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    // create new controls
    Composite page = new Composite(parent, SWT.NONE);
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    page.setLayout(layout);
    Style style = getParent().getStyle();
    PointSymbolizer point = null;
    try {
        Symbolizer[] symbolizers = SLD.symbolizers(style);
        for (Symbolizer symbol : symbolizers) {
            if (symbol instanceof LineSymbolizer) {
                point = (PointSymbolizer) symbol;
                break;
            }
        }
    } catch (Exception e) {
    // ignore
    }
    if (point == null) {
        point = styleBuilder.createPointSymbolizer();
    }
    pointEditor = new PointSymbolizerEditor(page, point);
    setControl(page);
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) Composite(org.eclipse.swt.widgets.Composite) PointSymbolizerEditor(eu.esdihumboldt.hale.ui.style.editors.PointSymbolizerEditor) RowLayout(org.eclipse.swt.layout.RowLayout) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Aggregations

Symbolizer (org.geotools.styling.Symbolizer)65 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)30 LineSymbolizer (org.geotools.styling.LineSymbolizer)29 PointSymbolizer (org.geotools.styling.PointSymbolizer)28 Rule (org.geotools.styling.Rule)22 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)20 Style (org.geotools.styling.Style)19 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)16 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)15 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 StyledLayer (org.geotools.styling.StyledLayer)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 JsonObject (com.google.gson.JsonObject)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 NamedLayer (org.geotools.styling.NamedLayer)8 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)8 JsonElement (com.google.gson.JsonElement)7 Stroke (org.geotools.styling.Stroke)6 JsonArray (com.google.gson.JsonArray)5