Package org.geotools.styling

Examples of org.geotools.styling.ExternalGraphic


            }
           

            for (GraphicalSymbol gs : gr.graphicalSymbols()) {
                if(gs instanceof ExternalGraphic) {
                    ExternalGraphic eg = (ExternalGraphic) gs;
                    Icon icon = null;
                    if(eg.getInlineContent() != null) {
                        icon = eg.getInlineContent();
                    } else {
                        String location = eg.getLocation().toExternalForm();
                        // expand embedded cql expression
                        Expression expanded = ExpressionExtractor.extractCqlExpressions(location);
                        // if not a literal there is an attribute dependency
                        if(!(expanded instanceof Literal)) {
                            estimateAccurate = false;
                            return;
                        }
                       
                        Iterator<ExternalGraphicFactory> it  = DynamicSymbolFactoryFinder.getExternalGraphicFactories();
                        while(it.hasNext() && icon == null) {
                            try {
                                ExternalGraphicFactory factory = it.next();
                                icon = factory.getIcon(null, expanded, eg.getFormat(), imageSize);
                            } catch(Exception e) {
                                LOGGER.log(Level.FINE, "Error occurred evaluating external graphic", e);
                            }
                        }
                    }
View Full Code Here


    List<GraphicalSymbol> symbols = sldGraphic.graphicalSymbols();
    if (symbols == null || symbols.isEmpty()) {
      return null;
    }
    final int length = symbols.size();
    ExternalGraphic eg;
    BufferedImage img = null;
    double dsize;
    AffineTransform scaleTx;
    AffineTransformOp ato;
    BufferedImage scaledImage;
View Full Code Here

        Icon icon = null;
        Mark mark = null;
        Shape shape = null;
        for (GraphicalSymbol symbol : gr.graphicalSymbols()) {
            if(symbol instanceof ExternalGraphic) {
                ExternalGraphic eg = (ExternalGraphic) symbol;
                icon = getIcon(eg, feature, graphicSize);
                if (icon != null) {
                    break;
                }   
            } else if(symbol instanceof Mark) {
View Full Code Here

    Style style = styleBuilder.createStyle();
   
    PointSymbolizer pointSymbolizer = styleBuilder.createPointSymbolizer();
   
    Graphic graphic = styleBuilder.createGraphic();
    ExternalGraphic external = styleBuilder.createExternalGraphic("file:///C:/images/house.gif",
            "image/gif");
    graphic.graphicalSymbols().add(external);
    graphic.graphicalSymbols().add(styleBuilder.createMark("circle"));
   
    pointSymbolizer.setGraphic(graphic);
View Full Code Here

        catch (MalformedURLException huh ){
           
        }
        String format = exgr.getFormat();
        Icon inlineContent = exgr.getInlineContent();
        ExternalGraphic copy;
        if (inlineContent != null) {
            copy = sf.createExternalGraphic(inlineContent, format);
        } else {
            copy = sf.createExternalGraphic(uri, format);
        }
        copy.setCustomProperties( copy(exgr.getCustomProperties()));
       
        if( STRICT && !copy.equals( exgr )){
            throw new IllegalStateException("Was unable to duplicate provided ExternalGraphic:"+exgr );
        }
        pages.push(copy);      
    }
View Full Code Here

        assertTrue(!rule.equals(clone));
    }

    public void testPointSymbolizer() throws Exception {
        URL urlExternal = getClass().getResource("/data/sld/blob.gif");
        ExternalGraphic extg = sb.createExternalGraphic(urlExternal, "image/svg+xml");
        Graphic graphic = sb.createGraphic(extg, null, null);
        PointSymbolizer pointSymb = sb.createPointSymbolizer(graphic);

        pointSymb.accept(visitor);
        PointSymbolizer clone = (PointSymbolizer) visitor.getCopy();
View Full Code Here

        Graphic notEq = sf.getDefaultGraphic();
        assertEqualsContract(clone, notEq, graphic);
    }

    public void testExternalGraphic() {
        ExternalGraphic exGraphic = sf.createExternalGraphic("http://somewhere",
                "image/png");
        ExternalGraphic clone = visitor.copy( exGraphic);
        assertCopy(exGraphic, clone);

        ExternalGraphic notEq = sf.createExternalGraphic("http://somewhereelse",
                "image/jpeg");
        assertEqualsContract(clone, notEq, exGraphic);

        // make sure it works for different format, same url
        ExternalGraphic notEq2 = visitor.copy( clone);
        notEq2.setFormat("image/jpeg");
        assertEqualsContract(clone, notEq2, exGraphic);
    }
View Full Code Here

            public int getIconHeight() {
                return 16;
            }
        };

        ExternalGraphic exGraphic = sf.createExternalGraphic(icon, "image/png");
        ExternalGraphic clone = visitor.copy(exGraphic);
        assertCopy(exGraphic, clone);
        assertSame(exGraphic.getInlineContent(), clone.getInlineContent());

        ExternalGraphic notEq = sf.createExternalGraphic(icon, "image/jpeg");
        assertEqualsContract(clone, notEq, exGraphic);

        // make sure it works for different format, same content
        ExternalGraphic notEq2 = visitor.copy(clone);
        notEq2.setFormat("image/jpeg");
        assertEqualsContract(clone, notEq2, exGraphic);
    }
View Full Code Here

    }
   

    public void testPointSymbolizerWithGeomFunction() throws Exception {
        URL urlExternal = getClass().getResource("/data/sld/blob.gif");
        ExternalGraphic extg = sb.createExternalGraphic(urlExternal, "image/svg+xml");
        Graphic graphic = sb.createGraphic(extg, null, null);
        PointSymbolizer pointSymb = sb.createPointSymbolizer(graphic);
       
        // Set a function as geometry
        Function geomFunc = ff.function("centroid", ff.property("thr_geom"));
View Full Code Here

        f.appendChild(document.createTextNode("image/png"));

        document.getDocumentElement().appendChild(c);
        document.getDocumentElement().appendChild(f);

        ExternalGraphic externalGraphic = (ExternalGraphic) parse();
        assertNotNull(externalGraphic);

        assertEquals("image/png", externalGraphic.getFormat());
        assertImagesEqual(getReferenceImage("inlineContent-image.png"), externalGraphic.getInlineContent());
        assertNull(externalGraphic.getLocation());
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.ExternalGraphic

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.