Package org.geotools.styling

Examples of org.geotools.styling.Symbolizer


        protected void processRule(SimpleFeature ft,Rule rule)
            throws IOException {
                  
          Symbolizer[] symbolizers=rule.getSymbolizers();
          for(int i=0;i<symbolizers.length;i++) {
            Symbolizer symbolizer=symbolizers[i];
            // process any given symbolizer
            processSymbolizer(ft,rule,symbolizer);
          }
        }
View Full Code Here


                LinkedList<PolygonSymbolizer> polyStyles = new LinkedList<PolygonSymbolizer>();
                // * Not used: <kml:BalloonStyle>
                // * Not used: <kml:ListStyle>

                for (int i = 0; i < symbolizers.length; i++) {
                    Symbolizer sym = symbolizers[i];
                    if (sym instanceof PointSymbolizer) {
                        iconStyles.add((PointSymbolizer) sym);
                    } else if (sym instanceof TextSymbolizer) {
                        labelStyles.add((TextSymbolizer) sym);
                    } else if (sym instanceof LineSymbolizer) {
                        lineStyles.add((LineSymbolizer) sym);
                    } else if (sym instanceof PolygonSymbolizer) {
                        polyStyles.add((PolygonSymbolizer) sym);
                    }
                    LOGGER.finer(new StringBuffer("Adding symbolizer ").append(sym).toString());
                }

                // Points / Icons
                if (iconStyles.isEmpty()) {
                    // Add a default point symbolizer, so people have something
                    // to click on
                    encodeDefaultIconStyle(feature);
                } else {
                    IconProperties properties = IconPropertyExtractor.extractProperties(wholeStyle, feature);
                    encodeIconStyle(wholeStyle, properties);
                }

                // Labels / Text
                if (labelStyles.isEmpty()) {
                    encodeDefaultTextStyle();
                } else {
                    Iterator<TextSymbolizer> iter = labelStyles.iterator();
                    while (iter.hasNext()) {
                        TextSymbolizer sym = (TextSymbolizer) iter.next();
                        try {
                            TextStyle2D style = (TextStyle2D) styleFactory.createStyle(feature,
                                    sym, scaleRange);
                            encodeTextStyle(feature, style, sym);
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for " + sym.toString());
                        }
                    }
                }

                // Lines
                if (!lineStyles.isEmpty()) {
                    Iterator<LineSymbolizer> iter = lineStyles.iterator();
                    while (iter.hasNext()) {
                        LineSymbolizer sym = (LineSymbolizer) iter.next();
                        try {
                            LineStyle2D style = (LineStyle2D) styleFactory.createStyle(feature,
                                    sym, scaleRange);
                            encodeLineStyle(feature, style, sym);
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for " + sym.toString());
                        }
                    }
                }

                // Polygons
                if (!polyStyles.isEmpty()) {
                    Iterator<PolygonSymbolizer> iter = polyStyles.iterator();
                    while (iter.hasNext()) {
                        PolygonSymbolizer sym = (PolygonSymbolizer) iter.next();
                        try {
                            PolygonStyle2D style = (PolygonStyle2D) styleFactory.createStyle(
                                    feature, sym, scaleRange);
                            // The last argument is forced outline
                            encodePolygonStyle(feature, style, sym, !lineStyles.isEmpty());
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for " + sym.toString());
                        }
                    }
                }

            } catch (Exception e) {
View Full Code Here

        Symbolizer[] symbolizers = rule.getSymbolizers();

        if (symbolizers != null) {
            for (int i = 0; i < symbolizers.length; i++) {
                Symbolizer symbolizer = symbolizers[i];
                symbolizer.accept(this);
            }
        }
    }
View Full Code Here

                    } else {

                   
                        for (int sIdx = 0; sIdx < symbolizers.length; sIdx++) {
                            Symbolizer symbolizer = symbolizers[sIdx];
                           
                            if (symbolizer instanceof RasterSymbolizer) {
                                // skip it
                            } else {
                                // rescale symbols if needed
View Full Code Here

   
        for (int i = 0; i < ruleCount; i++) {
            Feature sample = getSampleFeatureForRule(featureType, feature, rules[i]);
            final Symbolizer[] symbolizers = rules[i].getSymbolizers();
            for (int sIdx = 0; sIdx < symbolizers.length; sIdx++) {
                final Symbolizer symbolizer = symbolizers[sIdx];
                if (symbolizer instanceof PointSymbolizer) {
                    double size = getPointSymbolizerSize(sample,
                            (PointSymbolizer) symbolizer, Math.min(width, height));
                    if (size < minSize) {
                        minSize = size;
View Full Code Here

        // looking at the requested symbolizers (we chose the one with the max
        // dimensionality and create a congruent sample)
        if (sample == null) {
            int dimensionality = 1;
            for (int sIdx = 0; sIdx < symbolizers.length; sIdx++) {
                final Symbolizer symbolizer = symbolizers[sIdx];
                if (LineSymbolizer.class.isAssignableFrom(symbolizer.getClass())) {
                    dimensionality = 2;
                }
                if (PolygonSymbolizer.class.isAssignableFrom(symbolizer.getClass())) {
                    dimensionality = 3;
                }
            }
            return createSampleFeature(featureType, dimensionality);
        } else {
View Full Code Here

    @Test
    public void testSimplePointStyle() throws Exception{
        Style result;
        {
            Symbolizer symb = grayCircle();
            Style input = styleFromRules(catchAllRule(symb));
            Map<String, String> properties = new HashMap<String, String>();
            properties.put("0.0.0", "");
           
            result = IconPropertyInjector.injectProperties(input, properties);
        }
        {
            FeatureTypeStyle fts = assertSingleElement(result.featureTypeStyles());
            Rule rule = assertSingleElement(fts.rules());
            PointSymbolizer symb = assertSingleElement(rule.symbolizers(), PointSymbolizer.class);
            assertSingleElement(symb.getGraphic().graphicalSymbols(), Mark.class);
        }
    }
View Full Code Here

   
    @Test
    public void testSimplePointStyleOff() throws Exception{
        Style result;
        {
            Symbolizer symb = grayCircle();
            Style input = styleFromRules(catchAllRule(symb));
            Map<String, String> properties = new HashMap<String, String>();
            //properties.put("0.0.0", "");
           
            result = IconPropertyInjector.injectProperties(input, properties);
View Full Code Here

   
    @Test
    public void testSimpleGraphicStyle() throws Exception{
        Style result;
        {
            Symbolizer symb = this.externalGraphic("http://example.com/foo.png", "image/png");
            Style input = styleFromRules(catchAllRule(symb));
            Map<String, String> properties = new HashMap<String, String>();
            properties.put("0.0.0", "");
           
            result = IconPropertyInjector.injectProperties(input, properties);
        }
        {
            FeatureTypeStyle fts = assumeSingleElement(result.featureTypeStyles());
            Rule rule = assumeSingleElement(fts.rules());
            PointSymbolizer symb = assertSingleElement(rule.symbolizers(), PointSymbolizer.class);
            ExternalGraphic eg = assertSingleElement(symb.getGraphic().graphicalSymbols(), ExternalGraphic.class);
            assertThat(eg.getOnlineResource().getLinkage().toString(), is("http://example.com/foo.png"));
        }
    }
View Full Code Here

   
    @Test
    public void testSubstitutedGraphicStyle() throws Exception{
        Style result;
        {
            Symbolizer symb = this.externalGraphic("http://example.com/${PROV_ABBR}.png", "image/png");
            Style input = styleFromRules(catchAllRule(symb));
            Map<String, String> properties = new HashMap<String, String>();
            properties.put("0.0.0", "");
            properties.put("0.0.0.url", "http://example.com/BC.png");
           
            result = IconPropertyInjector.injectProperties(input, properties);
        }
        {
            FeatureTypeStyle fts = assumeSingleElement(result.featureTypeStyles());
            Rule rule = assumeSingleElement(fts.rules());
            PointSymbolizer symb = assertSingleElement(rule.symbolizers(), PointSymbolizer.class);
            ExternalGraphic eg = assertSingleElement(symb.getGraphic().graphicalSymbols(), ExternalGraphic.class);
            assertThat(eg.getOnlineResource().getLinkage().toString(), is("http://example.com/BC.png"));
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.Symbolizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.