Package org.geotools.styling

Examples of org.geotools.styling.ExternalGraphic


        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());
        assertNotNull(externalGraphic.getInlineContent());
        assertEquals(1, externalGraphic.getInlineContent().getIconWidth());
        assertEquals(1, externalGraphic.getInlineContent().getIconHeight());
        assertNull(externalGraphic.getLocation());
    }
View Full Code Here


       
        Graphic g = sym.getGraphic();
        assertEquals(15.0, g.getSize().evaluate(null, Double.class));
        assertEquals(2, g.getExternalGraphics().length);
       
        ExternalGraphic eg = g.getExternalGraphics()[0];
        assertEquals("http://www.vendor.com/geosym/2267.svg", eg.getLocation().toString());
        assertEquals("image/svg+xml", eg.getFormat());
       
        eg = g.getExternalGraphics()[1];
        assertEquals("http://www.vendor.com/geosym/2267.png", eg.getLocation().toString());
        assertEquals("image/png", eg.getFormat());
    }
View Full Code Here

        Graphic g = sym.getGraphic();
        assertEquals(15.0, g.getSize().evaluate(null, Double.class));
        assertEquals(1, g.graphicalSymbols().size());

        ExternalGraphic eg = (ExternalGraphic) g.graphicalSymbols().get(0);
        assertNull(eg.getLocation());
        assertEquals("image/png", eg.getFormat());
        assertImagesEqual(referenceImage, eg.getInlineContent());
        assertNull(eg.getLocation());
    }
View Full Code Here

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

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

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

        assertEquals(getClass().getResource("eclipse.png"), externalGraphic.getLocation());
        assertEquals("image/png", externalGraphic.getFormat());
    }
View Full Code Here

     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
        ExternalGraphic g;
        if (node.hasChild("InlineContent")) {
            String format = (String) node.getChildValue("Format");
            Icon icon = (Icon) node.getChildValue("InlineContent");
            g = styleFactory.createExternalGraphic(icon, format);
        } else {
View Full Code Here

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

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

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

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

    private boolean hasDynamicGraphic(Graphic gr) {
        // not a fixed size, let's see if it has dynamic graphics inside
        for (GraphicalSymbol gs : gr.graphicalSymbols()) {
            if (gs instanceof ExternalGraphic) {
                ExternalGraphic eg = (ExternalGraphic) gs;
                try {
                    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)) {
                            return true;
                        }

                        Iterator<ExternalGraphicFactory> it = DynamicSymbolFactoryFinder
                                .getExternalGraphicFactories();
                        while (it.hasNext()) {
                            try {
                                icon = it.next().getIcon(null, expanded, eg.getFormat(), 16);
                            } catch (Exception e) {
                                LOGGER.log(Level.FINE,
                                        "Error occurred evaluating external graphic", e);
                            }
                        }
View Full Code Here

            }

            // no fixed size, proceed
            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);

                        Iterator<ExternalGraphicFactory> it = DynamicSymbolFactoryFinder
                                .getExternalGraphicFactories();
                        while (it.hasNext()) {
                            try {
                                icon = it.next().getIcon(feature, expanded, eg.getFormat(), -1);
                            } catch (Exception e) {
                                LOGGER.log(Level.FINE,
                                        "Error occurred evaluating external graphic", e);
                            }
                        }
View Full Code Here

          LOGGER.warning("can't parse " + uri
              + " as a java resource present in the classpath");
      }
    }

    ExternalGraphic extgraph;
    if (url == null) {
      extgraph = factory.createExternalGraphic(uri, format);
    } else {
      extgraph = factory.createExternalGraphic(url, format);
    }
    extgraph.setCustomProperties(paramList);
    return extgraph;
  }
View Full Code Here

            }
            GraphicalSymbol gSym = g.graphicalSymbols().get(0);
            if (! (gSym instanceof ExternalGraphic)) {
                return null;
            }
            ExternalGraphic exGraphic = (ExternalGraphic) gSym;
            try {
                Double opacity = g.getOpacity().evaluate(feature, Double.class);
                Double size = 1d*Icons.getExternalSize(exGraphic, feature);
                if (size != null) size = size / Icons.DEFAULT_SYMBOL_SIZE;
                Double rotation = g.getRotation().evaluate(feature, Double.class);
                Expression urlExpression = ExpressionExtractor.extractCqlExpressions(exGraphic.getLocation().toExternalForm());
                return IconProperties.externalReference(opacity, size, rotation, urlExpression.evaluate(feature, String.class));
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        }
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.