Package org.geotools.styling

Examples of org.geotools.styling.NamedLayer


        assertEquals(0, collector.rules.size());
        assertEquals(0, collector.symbolizers.size());
        assertEquals(1, collector.styles.size());
        assertEquals(1, collector.layers.size());

        NamedLayer layer = (NamedLayer) collector.layers.get(0);
        assertEquals("states", layer.getName());
        NamedStyle ns = (NamedStyle) layer.getStyles()[0];
        assertEquals("population", ns.getName());
    }
View Full Code Here


        }
        pages.push(copy);
    }

    public void visit(NamedLayer layer) {
        NamedLayer copy = null;

        Style[] style = layer.getStyles();
        Style[] styleCopy = new Style[style.length];
        int length=style.length;
        for (int i = 0; i < length; i++) {
            if (style[i] != null) {
                style[i].accept(this);
                styleCopy[i] = (Style) pages.pop();
            }
        }

        FeatureTypeConstraint[] lfc = layer.getLayerFeatureConstraints();
        FeatureTypeConstraint[] lfcCopy = new FeatureTypeConstraint[lfc.length];

        length=lfc.length;
        for (int i = 0; i < length; i++) {
            if (lfc[i] != null) {
                lfc[i].accept(this);
                lfcCopy[i] = (FeatureTypeConstraint) pages.pop();
            }
        }

        copy = sf.createNamedLayer();
        copy.setName(layer.getName());
        length=styleCopy.length;
        for (int i = 0; i < length; i++) {
            copy.addStyle(styleCopy[i]);
        }

        copy.setLayerFeatureConstraints(lfcCopy);
        pages.push(copy);
    }
View Full Code Here

    }

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

        NamedLayer layer = (NamedLayer) parse();
        assertNotNull(layer);

        assertEquals("theName", layer.getName());
    }
View Full Code Here

        StyledLayerDescriptor sld = (StyledLayerDescriptor) parser.parse(getClass()
                                                                             .getResourceAsStream("example-sld.xml"));

        assertEquals(1, sld.getStyledLayers().length);

        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals("OCEANSEA_1M:Foundation", layer.getName());
        assertEquals(1, layer.getStyles().length);

        Style style = layer.getStyles()[0];
        assertEquals("GEOSYM", style.getName());
        assertTrue(style.isDefault());
        assertEquals(1, style.getFeatureTypeStyles().length);

        FeatureTypeStyle ftStyle = (FeatureTypeStyle) style.getFeatureTypeStyles()[0];
View Full Code Here

        </StyledLayerDescriptor>*/

        StyledLayerDescriptor sld = (StyledLayerDescriptor) parse("example-sld.xml");
        assertEquals(1, sld.getStyledLayers().length);
       
        NamedLayer l = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals("OCEANSEA_1M:Foundation", l.getName());
       
        assertEquals(1, l.getStyles().length);
        Style s = l.getStyles()[0];
        assertEquals("GEOSYM", s.getName());
        assertTrue(s.isDefault());
       
        assertEquals(1, s.getFeatureTypeStyles().length);
        FeatureTypeStyle fts = s.getFeatureTypeStyles()[0];
View Full Code Here

        PolygonSymbolizer sym = (PolygonSymbolizer) r.symbolizers().get(0);
    }
   
    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

        String file = "example-sld-vendor-option.xml";
        StyledLayerDescriptor sld = (StyledLayerDescriptor) parse(file);
       
        // basic drill down
        assertEquals(1, sld.getStyledLayers().length);
        NamedLayer layer = (NamedLayer) sld.getStyledLayers()[0];
        assertEquals(1, layer.getStyles().length);
        Style style = layer.getStyles()[0];
        assertEquals(1, style.featureTypeStyles().size());
        FeatureTypeStyle fts = style.featureTypeStyles().get(0);
        assertEquals(1, fts.rules().size());
        Rule rule = fts.rules().get(0);
        assertEquals(4,  rule.symbolizers().size());
View Full Code Here

     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
        NamedLayer layer = (NamedLayer) super.parse(instance, node, value);
       
        //TODO: description
        return layer;
    }
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        NamedLayer namedLayer = styleFactory.createNamedLayer();

        //&lt;xsd:element ref="sld:Name"/&gt;
        namedLayer.setName((String) node.getChildValue("Name"));

        //&lt;xsd:element ref="sld:LayerFeatureConstraints" minOccurs="0"/&gt;
        if (node.hasChild("LayerFeatureConstraints")) {
            LayerFeatureConstraints constraints = (LayerFeatureConstraints) node.getChildValue(
                    "LayerFeatureConstraints");
            namedLayer.setLayerFeatureConstraints(constraints.getFeatureTypeConstraints());
        }

        //&lt;xsd:choice minOccurs="0" maxOccurs="unbounded"&gt;
        //  &lt;xsd:element ref="sld:NamedStyle"/&gt;
        //  &lt;xsd:element ref="sld:UserStyle"/&gt;
        //&lt;/xsd:choice&gt;
        for (Iterator itr = node.getChildValues(Style.class).iterator(); itr.hasNext();) {
            namedLayer.addStyle((Style) itr.next());
        }

        return namedLayer;
    }
View Full Code Here

         * @param attrs1
         * @param hints
         * @throws OperationNotSupportedException
         */
        public Object getValue( Element element, ElementValue[] value, Attributes attrs1, Map hints ){
                NamedLayer sld = new NamedLayerImpl();
           
                for (int i = 0; i < value.length; i++) {
                    if ((value[i] == null) || value[i].getElement() == null) {
                        continue;
                    }
   
                    Element e = value[i].getElement();
                    if(elems[NAME].getName().equals(e.getName()))
                        sld.setName((String)value[i].getValue());
   
                    if(elems[LAYERFEATURECONSTRAINTS].getName().equals(e.getName())) {
                        // ignore
                        continue;
                    }
                   
                    if(elems[NAMEDSTYLE].getName().equals(e.getName()))
                        sld.addStyle((NamedStyle)value[i].getValue());
                   
                    if(elems[USERSTYLE].getName().equals(e.getName()))
                        sld.addStyle((Style)value[i].getValue());
                }
               
                return sld;
        }
View Full Code Here

TOP

Related Classes of org.geotools.styling.NamedLayer

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.