Package org.geotools.styling

Examples of org.geotools.styling.ExternalGraphic


            if (!g.graphicalSymbols().isEmpty()) {
                if (g.graphicalSymbols().get(0) instanceof Mark) {
                    Mark mark = (Mark) g.graphicalSymbols().get(0);
                    addMarkProperties(prefix, mark, props);
                } else if (g.graphicalSymbols().get(0) instanceof ExternalGraphic) {
                    ExternalGraphic exGraphic = (ExternalGraphic) g.graphicalSymbols().get(0);
                    addExternalGraphicProperties(prefix, exGraphic, props);
                }
            }
        }
View Full Code Here


        checkSingleSymbolizer(style, ls);
    }
   
    @Test
    public void testDynamicSymbolizerStrokeLineSymbolizer() {
        ExternalGraphic dynamicSymbolizer = sb.createExternalGraphic("file://./${myAttribute}.jpeg", "image/jpeg");
        Graphic graphic = sb.createGraphic(dynamicSymbolizer, null, null);
        LineSymbolizer ls = sb.createLineSymbolizer();
        ls.getStroke().setGraphicStroke(graphic);

        Style style = sb.createStyle(ls);
View Full Code Here

        checkSingleSymbolizer(style, ls);
    }
   
    @Test
    public void testStaticGraphicLineSymbolizer() {
        ExternalGraphic dynamicSymbolizer = sb.createExternalGraphic("file://./hello.jpeg", "image/jpeg");
        Graphic graphic = sb.createGraphic(dynamicSymbolizer, null, null);
        LineSymbolizer ls = sb.createLineSymbolizer();
        ls.getStroke().setGraphicStroke(graphic);

        Style style = sb.createStyle(ls);
View Full Code Here

        }
        {
            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

        }
        {
            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

        }
        {
            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/NF.png"));
        }
    }
View Full Code Here

        }
        {
            FeatureTypeStyle fts = assumeSingleElement(result.featureTypeStyles());
            Rule rule = assertSingleElement(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

        }
        {
            FeatureTypeStyle fts = assumeSingleElement(result.featureTypeStyles());
            Rule rule = assertSingleElement(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/bar.png"));
        }
    }
View Full Code Here

            float opacity, int size) {
                return SLD.pointSymbolizer(SLD.createPointStyle(name, stroke, fill, opacity, size));
            }

    protected final PointSymbolizer externalGraphic(String url, String format) {
        ExternalGraphic exGraphic = styleFactory.createExternalGraphic(url, format);
        Graphic graphic = styleFactory.createGraphic(new ExternalGraphic[] { exGraphic }, null, null, null, null, null);
        return styleFactory.createPointSymbolizer(graphic, null);
    }
View Full Code Here

            // if the point symbolizer uses an external graphic use it
            if ((symbolizer.getGraphic() != null)
                    && (symbolizer.getGraphic().getExternalGraphics() != null)
                    && (symbolizer.getGraphic().getExternalGraphics().length > 0)) {
                ExternalGraphic graphic = symbolizer.getGraphic()
                        .getExternalGraphics()[0];

                try {
                    if ("file".equals(graphic.getLocation().getProtocol())) {
                        // it is a local file, reference locally from "styles"
                        // directory
                        File file = DataUtilities.urlToFile(graphic.getLocation());
                        File styles = null;
                        File graphicFile = null;
                        if(file.isAbsolute()) {
                            GeoServerDataDirectory dataDir = (GeoServerDataDirectory) GeoServerExtensions.bean("dataDirectory");
                            // we grab the canonical path to make sure we can compare them, no relative parts in them and so on
                            styles = dataDir.findOrCreateStyleDir().getCanonicalFile();
                            graphicFile = file.getCanonicalFile();
                            file = graphicFile;
                            if(file.getAbsolutePath().startsWith(styles.getAbsolutePath())) {
                                // ok, part of the styles directory, extract only the relative path
                                file = new File(file.getAbsolutePath().substring(styles.getAbsolutePath().length() + 1));
                            } else {
                                // we wont' transform this, other dirs are not published
                                file = null;
                            }
                        }
                       
                        if (file != null && styles != null) {
                            iconHref = ResponseUtils.buildURL(mapContext.getRequest().getBaseUrl(),
                                    "styles/" + styles.toURI().relativize(graphicFile.toURI()),
                                    null, URLType.RESOURCE);
                        }
                    } else if ("http".equals(graphic.getLocation()
                            .getProtocol())) {
                        iconHref = graphic.getLocation().toString();
                    } else {
                        // TODO: should we check for http:// and use it
                        // directly?
                        // other protocols?
                    }
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.