Search in sources :

Example 11 with Rule

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

the class StyledInstanceMarker method initStyle.

/**
 * Initialize the style information.
 *
 * @param context the context
 */
private synchronized void initStyle(InstanceWaypoint context) {
    if (!styleInitialized.compareAndSet(false, true)) {
        // already initialized
        return;
    }
    // check if there is a Rule from the Rulestyle-Page and apply to the
    // instancemarker on the map
    // performs a special task if the found symbolizer is a point symbolizer
    Rule honoredRule = honorRules(context);
    pointSymbolizer = null;
    for (Symbolizer sym : honoredRule.symbolizers()) {
        if (sym instanceof PointSymbolizer) {
            pointSymbolizer = (PointSymbolizer) sym;
            break;
        }
    }
    fillStyle(honoredRule, context);
    strokeStyle(honoredRule, context);
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) Rule(org.geotools.styling.Rule) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer)

Example 12 with Rule

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

the class StyledInstanceMarker method sortRules.

/**
 * Sorts an array of rules, so the else-filter-rules are at the end
 *
 * @param rules an array of Rules
 * @return a new array of Rules with sorted elements
 */
private Rule[] sortRules(Rule[] rules) {
    ArrayList<Rule> temp = new ArrayList<Rule>();
    for (int i = 0; i < rules.length; i++) {
        if (!rules[i].isElseFilter()) {
            temp.add(rules[i]);
        }
    }
    for (int i = 0; i < rules.length; i++) {
        if (rules[i].isElseFilter()) {
            temp.add(rules[i]);
        }
    }
    Rule[] newRules = new Rule[temp.size()];
    return temp.toArray(newRules);
}
Also used : ArrayList(java.util.ArrayList) Rule(org.geotools.styling.Rule) SelectableWaypoint(de.fhg.igd.mapviewer.waypoints.SelectableWaypoint) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 13 with Rule

use of org.geotools.styling.Rule in project sldeditor by robward-scisys.

the class MXDParser method processLabelRenderer.

/**
 * Gets the label renderer.
 *
 * @param sld the sld
 * @param labelRenderArrayElement the label render array element
 * @param transparency the transparency
 */
private void processLabelRenderer(StyledLayerDescriptor sld, JsonArray labelRenderArrayElement, int transparency) {
    if (sld != null) {
        if (labelRenderArrayElement != null) {
            List<StyledLayer> styledLayers = sld.layers();
            if (!styledLayers.isEmpty()) {
                if (styledLayers.get(0) instanceof NamedLayer) {
                    NamedLayer namedLayer = (NamedLayer) styledLayers.get(0);
                    List<Style> styleList = namedLayer.styles();
                    if (!styleList.isEmpty()) {
                        List<FeatureTypeStyle> ftsList = styleList.get(0).featureTypeStyles();
                        if (!ftsList.isEmpty()) {
                            List<Rule> ruleList = ftsList.get(0).rules();
                            List<Rule> newLabelRuleList = new ArrayList<Rule>();
                            for (int index = 0; index < labelRenderArrayElement.size(); index++) {
                                JsonElement labelRenderElement = labelRenderArrayElement.get(index);
                                JsonObject renderer = labelRenderElement.getAsJsonObject();
                                boolean found = false;
                                for (String labelRendererType : labelRendererMap.keySet()) {
                                    JsonElement obj = renderer.get(labelRendererType);
                                    if (obj != null) {
                                        EsriLabelRendererInterface esriLabelRenderer = labelRendererMap.get(labelRendererType);
                                        if (esriLabelRenderer != null) {
                                            for (Rule rule : ruleList) {
                                                esriLabelRenderer.convert(newLabelRuleList, rule, obj, transparency);
                                            }
                                        }
                                        found = true;
                                        break;
                                    }
                                }
                                if (!found) {
                                    ConsoleManager.getInstance().error(this, "Unsupported label renderer : " + SymbolUtils.extractName(labelRenderElement));
                                }
                            }
                            ruleList.addAll(newLabelRuleList);
                        }
                    }
                }
            }
        }
    }
}
Also used : StyledLayer(org.geotools.styling.StyledLayer) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) EsriLabelRendererInterface(com.sldeditor.exportdata.esri.label.EsriLabelRendererInterface) JsonElement(com.google.gson.JsonElement) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 14 with Rule

use of org.geotools.styling.Rule in project sldeditor by robward-scisys.

the class SLDTreeSymbolizerButtonStateTest method testLine.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#setGeometryType(com.sldeditor.datasource.impl.GeometryTypeEnum)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isMarkerVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isLineVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isPolygonVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isRasterVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isTextVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlineLineVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlinePolygonVisible(java.lang.Object, java.lang.Object)}.
 */
@Test
public void testLine() {
    SLDTreeSymbolizerButtonState obj = new SLDTreeSymbolizerButtonState();
    obj.setGeometryType(GeometryTypeEnum.LINE);
    obj.showSymbolizerButtons();
    assertFalse(obj.isLineVisible(null, null));
    assertFalse(obj.isMarkerVisible(null, null));
    assertFalse(obj.isPolygonVisible(null, null));
    assertFalse(obj.isRasterVisible(null, null));
    assertFalse(obj.isTextVisible(null, null));
    assertFalse(obj.isImageOutlineLineVisible(null, null));
    assertFalse(obj.isImageOutlinePolygonVisible(null, null));
    Rule rule = DefaultSymbols.createNewRule();
    assertTrue(obj.isLineVisible(null, rule));
    assertTrue(obj.isTextVisible(null, rule));
}
Also used : SLDTreeSymbolizerButtonState(com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Example 15 with Rule

use of org.geotools.styling.Rule in project sldeditor by robward-scisys.

the class SLDTreeSymbolizerButtonStateTest method testMarker.

/**
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#setGeometryType(com.sldeditor.datasource.impl.GeometryTypeEnum)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isMarkerVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isLineVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isPolygonVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isRasterVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isTextVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlineLineVisible(java.lang.Object, java.lang.Object)}.
 * Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlinePolygonVisible(java.lang.Object, java.lang.Object)}.
 */
@Test
public void testMarker() {
    SLDTreeSymbolizerButtonState obj = new SLDTreeSymbolizerButtonState();
    obj.setGeometryType(GeometryTypeEnum.POINT);
    obj.showSymbolizerButtons();
    assertFalse(obj.isLineVisible(null, null));
    assertFalse(obj.isMarkerVisible(null, null));
    assertFalse(obj.isPolygonVisible(null, null));
    assertFalse(obj.isRasterVisible(null, null));
    assertFalse(obj.isTextVisible(null, null));
    assertFalse(obj.isImageOutlineLineVisible(null, null));
    assertFalse(obj.isImageOutlinePolygonVisible(null, null));
    Rule rule = DefaultSymbols.createNewRule();
    assertTrue(obj.isMarkerVisible(null, rule));
    assertTrue(obj.isTextVisible(null, rule));
}
Also used : SLDTreeSymbolizerButtonState(com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Aggregations

Rule (org.geotools.styling.Rule)110 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)65 Style (org.geotools.styling.Style)60 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)51 Test (org.junit.Test)48 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)28 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)26 LineSymbolizer (org.geotools.styling.LineSymbolizer)24 Symbolizer (org.geotools.styling.Symbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)19 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)16 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)16 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)13 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)11 ArrayList (java.util.ArrayList)11 Filter (org.opengis.filter.Filter)11 UserLayerImpl (org.geotools.styling.UserLayerImpl)10 DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)8