Search in sources :

Example 66 with PointSymbolizer

use of org.geotools.styling.PointSymbolizer 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)

Example 67 with PointSymbolizer

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

the class StyledInstanceMarker method strokeStyle.

/**
 * retrieves the stroke for the map marker
 *
 * @param rule a certain rule to apply, maybe null
 * @param context the InstanceWayPoint, wich gets marked
 */
private synchronized void strokeStyle(Rule rule, InstanceWaypoint context) {
    // retrieve stroke
    Stroke stroke = null;
    for (int i = 0; rule != null && stroke == null && i < rule.getSymbolizers().length; i++) {
        if (rule.getSymbolizers()[i] instanceof LineSymbolizer) {
            stroke = SLD.stroke((LineSymbolizer) rule.getSymbolizers()[i]);
        } else if (rule.getSymbolizers()[i] instanceof PolygonSymbolizer) {
            stroke = SLD.stroke((PolygonSymbolizer) rule.getSymbolizers()[i]);
        } else if (rule.getSymbolizers()[i] instanceof PointSymbolizer) {
            stroke = SLD.stroke((PointSymbolizer) rule.getSymbolizers()[i]);
        }
    }
    // if we have a stroke now
    if (stroke != null) {
        // XXX is there any Geotools stroke to AWT stroke lib/code
        // somewhere?!
        // XXX have a look at the renderer code (StreamingRenderer)
        // stroke color
        Color sldColor = SLD.color(stroke);
        double opacity = SLD.opacity(stroke);
        if (Double.isNaN(opacity)) {
            // fall back to default opacity
            opacity = StyleHelper.DEFAULT_FILL_OPACITY;
        }
        if (sldColor != null) {
            styleStrokeColor = new Color(sldColor.getRed(), sldColor.getGreen(), sldColor.getBlue(), (int) (opacity * 255));
        } else {
            styleStrokeColor = super.getBorderColor(context);
        }
        // stroke width
        int strokeWidth = SLD.width(stroke);
        if (strokeWidth == SLD.NOTFOUND) {
            // fall back to default width
            strokeWidth = StylePreferences.getDefaultWidth();
        }
        styleStroke = new BasicStroke(strokeWidth);
    } else {
        styleStroke = null;
        styleStrokeColor = null;
    }
}
Also used : BasicStroke(java.awt.BasicStroke) PointSymbolizer(org.geotools.styling.PointSymbolizer) BasicStroke(java.awt.BasicStroke) Stroke(org.geotools.styling.Stroke) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Color(java.awt.Color) Point(org.locationtech.jts.geom.Point) SelectableWaypoint(de.fhg.igd.mapviewer.waypoints.SelectableWaypoint) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Aggregations

PointSymbolizer (org.geotools.styling.PointSymbolizer)67 Test (org.junit.Test)32 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)25 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)23 LineSymbolizer (org.geotools.styling.LineSymbolizer)23 Style (org.geotools.styling.Style)22 Rule (org.geotools.styling.Rule)19 Graphic (org.geotools.styling.Graphic)16 NamedLayer (org.geotools.styling.NamedLayer)13 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)13 Symbolizer (org.geotools.styling.Symbolizer)12 TextSymbolizer (org.geotools.styling.TextSymbolizer)10 GraphicalSymbol (org.opengis.style.GraphicalSymbol)9 SLDTreeLeafPoint (com.sldeditor.common.tree.leaf.SLDTreeLeafPoint)8 MarkImpl (org.geotools.styling.MarkImpl)8 FeatureStyle (org.polymap.core.style.model.FeatureStyle)7 PointStyle (org.polymap.core.style.model.feature.PointStyle)7 Fill (org.geotools.styling.Fill)6 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)6 ArrayList (java.util.ArrayList)5