Package org.geotools.styling

Examples of org.geotools.styling.Graphic


     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        Expression color = null;
        Expression opacity = null;
        Graphic graphicFill = null;

        graphicFill = (Graphic) node.getChildValue("GraphicFill");

        //"fill" (color)
        //"fill-opacity"
View Full Code Here


        //<xsd:choice minOccurs="0">
        //   <xsd:element ref="sld:GraphicFill"/>
        //   <xsd:element ref="sld:GraphicStroke"/>
        //</xsd:choice>
        Graphic graphicFill = (Graphic) node.getChildValue("GraphicFill");
        Graphic graphicStroke = (Graphic) node.getChildValue("GraphicStroke");

        return styleFactory.createStroke(color, width, opacity, lineJoin, lineCap, dash,
            dashOffset, graphicFill, graphicStroke);
    }
View Full Code Here

   
    public void testParseGraphicFill() throws Exception {
        StyledLayerDescriptor sld = (StyledLayerDescriptor) parse("../graphicFill.xml");
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        PolygonSymbolizer ps = (PolygonSymbolizer) layer.getStyles()[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
        Graphic graphicFill = ps.getFill().getGraphicFill();
        assertNotNull(graphicFill);
        ExternalGraphic eg = (ExternalGraphic) graphicFill.graphicalSymbols().get(0);
        assertEquals(new URI("http://maps.google.com/mapfiles/kml/pal2/icon4.png"), eg.getOnlineResource().getLinkage());
       
    }
View Full Code Here

    }

    public void test() throws Exception {
        SLDMockData.graphicFill(document, document);

        Graphic graphic = (Graphic) parse();
        assertNotNull(graphic);
    }
View Full Code Here

        return SE.Graphic;
    }

    @Override
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
        Graphic g = (Graphic) super.parse(instance, node, value);
        if (node.hasChild(AnchorPoint.class)) {
            g.setAnchorPoint((AnchorPoint)node.getChildValue(AnchorPoint.class));
        }
        if (node.hasChild(Displacement.class)) {
            g.setDisplacement((Displacement)node.getChildValue(Displacement.class));
        }
        return g;
    }
View Full Code Here

     * Create a default point style.
     *
     * @return the created style.
     */
    public static Style createPointStyle() {
        Graphic gr = styleFactory.createDefaultGraphic();

        Mark mark = styleFactory.getCircleMark();

        mark.setStroke(styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1)));

        mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN)));

        gr.graphicalSymbols().clear();
        gr.graphicalSymbols().add(mark);
        gr.setSize(filterFactory.literal(5));

        /*
         * Setting the geometryPropertyName arg to null signals that we want to
         * draw the default geomettry of features
         */
 
View Full Code Here

         * @param hints
         * @throws OperationNotSupportedException
         */
        public Object getValue( Element element, ElementValue[] value, Attributes attrs1, Map hints )
                throws OperationNotSupportedException {
          Graphic symbol = StyleFactoryFinder.createStyleFactory().getDefaultGraphic();

            for (int i = 0; i < value.length; i++) {
                if ((value[i] == null) || value[i].getElement() == null) {
                    continue;
                }

                Element e = value[i].getElement();
                if(elems[EXTERNALGRAPHIC].getName().equals(e.getName()))
                    symbol.addExternalGraphic((ExternalGraphic)value[i].getValue());

                if(elems[MARK].getName().equals(e.getName()))
                    symbol.addMark((Mark)value[i].getValue());

                if(elems[OPACITY].getName().equals(e.getName()))
                    symbol.setOpacity((Expression)value[i].getValue());

                if(elems[SIZE].getName().equals(e.getName()))
                    symbol.setSize((Expression)value[i].getValue());

                if(elems[ROTATION].getName().equals(e.getName()))
                    symbol.setRotation((Expression)value[i].getValue());
            }
           
            return symbol;
        }
View Full Code Here

             
        protected void processSymbolizer(SimpleFeature ft, Rule rule,Symbolizer symbolizer) throws IOException{
          super.processSymbolizer(ft, rule,symbolizer);
          if(symbolizer instanceof PointSymbolizer) {
            Mark mark=SLD.mark((PointSymbolizer)symbolizer);
            Graphic graphic=SLD.graphic((PointSymbolizer)symbolizer);
            if(graphic!=null && mark!=null) {
              Object oSize=graphic.getSize().evaluate(null);
              if(oSize!=null)
                size=Double.parseDouble(oSize.toString());
              asCircle=SLD.wellKnownName(mark).toLowerCase().equals("circle");
              if(!asCircle)
                symbol=SLD.wellKnownName(mark).toLowerCase();
View Full Code Here

    private static Style createPointStyle(Color strokeColor, Color fillColor) {
        Mark mark = styleFactory.getCircleMark();
        mark.setStroke(styleFactory.createStroke(filterFactory.literal(strokeColor), filterFactory.literal(2)));
        mark.setFill(styleFactory.createFill(filterFactory.literal(fillColor)));

        Graphic gr = styleFactory.createDefaultGraphic();
        gr.graphicalSymbols().clear();
        gr.graphicalSymbols().add(mark);
        gr.setSize(filterFactory.literal(5));

        /*
         * Setting the geometryPropertyName arg to null signals that we want to
         * draw the default geomettry of features
         */
 
View Full Code Here

       
        public IconProperties isExternalGraphic(MiniRule rule) {
            if (rule.symbolizers.size() != 1) {
                return null;
            }
            Graphic g = rule.symbolizers.get(0).getGraphic();
            if (g == null) {
                return null;
            }
            if (g.graphicalSymbols().size() != 1) {
                return null;
            }
            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.Graphic

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.