Package org.geotools.styling

Examples of org.geotools.styling.ExternalGraphic


                }
                for( int i = 0; i < graphics.length; i++ ) {
                    if (graphics[i] != null) {
                        for( GraphicalSymbol gs : graphics[i].graphicalSymbols() ) {
                            if ((gs != null) && (gs instanceof ExternalGraphic)) {
                                ExternalGraphic externalGraphic = (ExternalGraphic) gs;
                                gList.add(externalGraphic);
                            }
                        }
                    }
                }
View Full Code Here


     */
    public static List<ExternalGraphic> externalGraphicsFromGraphic( Graphic graphic ) {
        List<ExternalGraphic> gList = new ArrayList<ExternalGraphic>();
        for( GraphicalSymbol gs : graphic.graphicalSymbols() ) {
            if ((gs != null) && (gs instanceof ExternalGraphic)) {
                ExternalGraphic externalGraphic = (ExternalGraphic) gs;
                gList.add(externalGraphic);
            }
        }
        return gList;
    }
View Full Code Here

        }

        PointSymbolizer pointSymbolizer = Utilities.pointSymbolizerFromRule(rule);
        Graphic graphic = SLDs.graphic(pointSymbolizer);
        graphic.graphicalSymbols().clear();
        ExternalGraphic exGraphic = sf.createExternalGraphic(externalGraphicsUrl, format);

        graphic.graphicalSymbols().add(exGraphic);
    }
View Full Code Here

     * @return the generated style.
     * @throws IOException
     */
    public static StyleWrapper createStyleFromGraphic( File graphicsPath ) throws IOException {
        String name = graphicsPath.getName();
        ExternalGraphic exGraphic = null;
        if (name.toLowerCase().endsWith(".png")) {
            exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/png");
        } else if (name.toLowerCase().endsWith(".svg")) {
            exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml");
        } else if (name.toLowerCase().endsWith(".sld")) {
View Full Code Here

        public void visit( Graphic gr ) {
            List<GraphicalSymbol> graphicalSymbols = gr.graphicalSymbols();
            for( GraphicalSymbol graphicalSymbol : graphicalSymbols ) {
                if (graphicalSymbol instanceof ExternalGraphic) {
                    ExternalGraphic ext = (ExternalGraphic) graphicalSymbol;
                    ext.accept(this);
                }
            }
        }
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 = new File(graphic.getLocation().getFile());
                        iconHref = RequestUtils.baseURL(mapContext.getRequest()
                                .getHttpServletRequest())
                                + "styles/" + file.getName();
                    } 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

        Graphic graphic = this.styleBuilder.createGraphic();
        graphic.graphicalSymbols().clear();
        if (styleJson.has(JSON_EXTERNAL_GRAPHIC)) {
            String externalGraphicUrl = validateURL(styleJson.getString(JSON_EXTERNAL_GRAPHIC));
            final String graphicFormat = getGraphicFormat(externalGraphicUrl, styleJson);
            final ExternalGraphic externalGraphic = this.styleBuilder.createExternalGraphic(externalGraphicUrl, graphicFormat);

            graphic.graphicalSymbols().add(externalGraphic);
        }

        if (styleJson.has(JSON_GRAPHIC_NAME)) {
View Full Code Here

        final List<GraphicalSymbol> graphicalSymbols = graphic.graphicalSymbols();

        assertEquals(1, graphicalSymbols.size());

        ExternalGraphic externalGraphic = (ExternalGraphic) graphicalSymbols.get(0);
        assertEquals("image/png", externalGraphic.getFormat());
        assertEquals(getFile("mark.png"), new File(externalGraphic.getLocation().toURI()));
    }
View Full Code Here

    }

    private static Style createPointStyle() {
        StyleFactory sf = CommonFactoryFinder.getStyleFactory();
        URL iconUrl = ScreenMapShapefileTest.class.getResource("icon.png");
        ExternalGraphic icon = sf.createExternalGraphic(iconUrl, "image/png");
        Graphic graphic = sf.createGraphic(new ExternalGraphic[] { icon }, null, null, null, null,
                null);
        PointSymbolizer symbolizer = sf.createPointSymbolizer(graphic, "the_geom");

        Rule rule = sf.createRule();
View Full Code Here

        legend.setRotation(0);
        legend.setOpacity(1);
        Style pStyle = RendererBaseTest.loadStyle(this, "externalGraphic.sld");
        URL url = StreamingRenderer.class.getResource("test-data/");
        StyleFactory sf = CommonFactoryFinder.getStyleFactory(null);
        ExternalGraphic eg = sf.createExternalGraphic(url + "icon64.png", "image/png");
        legend.addExternalGraphic(eg);
        BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        MathTransform transform = ProjectiveTransform.create(new AffineTransform());
        Decimator decimator = new Decimator(transform);
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.