Package org.geotools.styling

Examples of org.geotools.styling.UserLayer


     * @return the style string.
     * @throws Exception
     */
    public static String styleToString( Style style ) throws Exception {
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        UserLayer layer = sf.createUserLayer();
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);

        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(4);
        String xml = aTransformer.transform(sld);
        return xml;
View Full Code Here


    }

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

        UserLayer layer = (UserLayer) parse();
        assertNotNull(layer);

        assertEquals("theName", layer.getName());
        assertNotNull(layer.getLayerFeatureConstraints());
        assertEquals(2, layer.getUserStyles().length);
    }
View Full Code Here

     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
        UserLayer layer  = (UserLayer) super.parse(instance, node, value);
       
        //TODO: description
       
        if (node.hasChild("InlineFeature")) {
            SimpleFeatureCollection features = (SimpleFeatureCollection) node.getChildValue("InlineFeature");
            SimpleFeatureType type = features.getSchema();
           
            layer.setInlineFeatureType(type);
            layer.setInlineFeatureDatastore(toDataStore(features));
        }

        //TODO:LayerCoverageConstraints
        return layer;
    }
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        UserLayer userLayer = styleFactory.createUserLayer();

        //&lt;xsd:element ref="sld:Name" minOccurs="0"/&gt;
        if (node.hasChild("Name")) {
            userLayer.setName((String) node.getChildValue("Name"));
        }

        //&lt;xsd:element ref="sld:RemoteOWS" minOccurs="0"/&gt;
        if (node.hasChild("RemoteOWS")) {
            userLayer.setRemoteOWS((RemoteOWS) node.getChildValue("RemoteOWS"));
        }

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

        //&lt;xsd:element ref="sld:UserStyle" maxOccurs="unbounded"/&gt;
        for (Iterator i = node.getChildValues("UserStyle").iterator(); i.hasNext();) {
            userLayer.addUserStyle((Style) i.next());
        }

        return userLayer;
    }
View Full Code Here

     * @throws TransformerException
     */
    private String styleToXML(final Style style) throws TransformerException
    {
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        UserLayer layer = sf.createUserLayer();
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);

        SLDTransformer styleTransform = new SLDTransformer();
        String xml = styleTransform.transform(sld);

        return xml;
View Full Code Here

         * @param hints
         * @throws OperationNotSupportedException
         */
        public Object getValue( Element element, ElementValue[] value, Attributes attrs1, Map hints )
                throws OperationNotSupportedException, SAXException {
                UserLayer sld = new UserLayerImpl();
           
                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[REMOTEOWS].getName().equals(e.getName()))
                        sld.setRemoteOWS((RemoteOWS)value[i].getValue());
                   
                    if(elems[LAYERFEATURECONSTRAINTS].getName().equals(e.getName()))
                        sld.setLayerFeatureConstraints((FeatureTypeConstraint[])value[i].getValue());
                   
                    if(elems[USERSTYLE].getName().equals(e.getName()))
                        sld.addUserStyle((Style)value[i].getValue());
                }
               
                return sld;
        }
View Full Code Here

                parser.setInput(getClass().getResource(styleName));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            StyledLayerDescriptor sld = parser.parseSLD();
            UserLayer layer = (UserLayer) sld.getStyledLayers()[0];
            style = layer.getUserStyles()[0];
            STYLES.put(styleName, style);
        }
        return style;
    }
View Full Code Here

        final List<Style> styles = new ArrayList<Style>();
        MapLayerInfo currLayer = null;
        Style currStyle = null;

        String layerName;
        UserLayer ul;
        for (StyledLayer sl : styledLayers) {
            layerName = sl.getName();

            if (null == layerName) {
                throw new ServiceException("A UserLayer without layer name was passed");
View Full Code Here

            if (sld.getStyledLayers()[i] instanceof NamedLayer) {
                NamedLayer layer = (NamedLayer) sld.getStyledLayers()[i];
                styles = layer.getStyles();
            }
            else if(sld.getStyledLayers()[i] instanceof UserLayer) {
                UserLayer layer = (UserLayer) sld.getStyledLayers()[i];
                styles = layer.getUserStyles();
            }
           
            if (styles != null) {
                for (int j = 0; j < styles.length; i++) {
                    if (!(styles[j] instanceof NamedStyle)) {
View Full Code Here

    else
      return null;
  }

  private StyledLayer parseUserLayer(Node root) {
    UserLayer layer = new UserLayerImpl();
    // LineSymbolizer symbol = factory.createLineSymbolizer();

    NodeList children = root.getChildNodes();
    final int length = children.getLength();
    for (int i = 0; i < length; i++) {
      Node child = children.item(i);
      if ((child == null) || (child.getNodeType() != Node.ELEMENT_NODE)) {
        continue;
      }
      String childName = child.getLocalName();
      if (childName == null) {
        childName = child.getNodeName();
      }

      if (childName.equalsIgnoreCase("InlineFeature")) {
        parseInlineFeature(child, layer);
      } else if (childName.equalsIgnoreCase("UserStyle")) {
        Style user = parseStyle(child);
        layer.addUserStyle(user);
      } else if (childName.equalsIgnoreCase("Name")) {
        String layerName = getFirstChildValue(child);
        layer.setName(layerName);
        if (LOGGER.isLoggable(Level.INFO))
          LOGGER.info("layer name: " + layer.getName());
      } else if (childName.equalsIgnoreCase("RemoteOWS")) {
        RemoteOWS remoteOws = parseRemoteOWS(child);
        layer.setRemoteOWS(remoteOws);
      } else if (childName.equalsIgnoreCase("LayerFeatureConstraints")) {
        layer.setLayerFeatureConstraints(parseLayerFeatureConstraints(child));
      }

    }

    return layer;
View Full Code Here

TOP

Related Classes of org.geotools.styling.UserLayer

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.