Package org.geotools.styling

Examples of org.geotools.styling.TextSymbolizer


                if (labelStyles.isEmpty()) {
                    encodeDefaultTextStyle();
                } else {
                    Iterator<TextSymbolizer> iter = labelStyles.iterator();
                    while (iter.hasNext()) {
                        TextSymbolizer sym = (TextSymbolizer) iter.next();
                        try {
                            TextStyle2D style = (TextStyle2D) styleFactory.createStyle(feature,
                                    sym, scaleRange);
                            encodeTextStyle(feature, style, sym);
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for " + sym.toString());
                        }
                    }
                }

                // Lines
                if (!lineStyles.isEmpty()) {
                    Iterator<LineSymbolizer> iter = lineStyles.iterator();
                    while (iter.hasNext()) {
                        LineSymbolizer sym = (LineSymbolizer) iter.next();
                        try {
                            LineStyle2D style = (LineStyle2D) styleFactory.createStyle(feature,
                                    sym, scaleRange);
                            encodeLineStyle(feature, style, sym);
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for " + sym.toString());
                        }
                    }
                }

                // Polygons
                if (!polyStyles.isEmpty()) {
                    Iterator<PolygonSymbolizer> iter = polyStyles.iterator();
                    while (iter.hasNext()) {
                        PolygonSymbolizer sym = (PolygonSymbolizer) iter.next();
                        try {
                            PolygonStyle2D style = (PolygonStyle2D) styleFactory.createStyle(
                                    feature, sym, scaleRange);
                            // The last argument is forced outline
                            encodePolygonStyle(feature, style, sym, !lineStyles.isEmpty());
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for " + sym.toString());
                        }
                    }
                }

            } catch (Exception e) {
View Full Code Here


   *            w3c dom node
   *
   * @return the TextSymbolizer
   */
  protected TextSymbolizer parseTextSymbolizer(Node root) {
    TextSymbolizer symbol = factory.createTextSymbolizer();
    symbol.setFill(null);

    NamedNodeMap namedNodeMap = root.getAttributes();
    Node uomNode = namedNodeMap.getNamedItem(uomString);
    if (uomNode != null) {
      UomOgcMapping uomMapping = UomOgcMapping
          .get(uomNode.getNodeValue());
      symbol.setUnitOfMeasure(uomMapping.getUnit());
    }

    List<Font> fonts = new ArrayList<Font>();
    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(geomString)) {
        symbol.setGeometry(parseGeometry(child));
      } else if (childName.equalsIgnoreCase(fillSt)) {
        symbol.setFill(parseFill(child));
      } else if (childName.equalsIgnoreCase("Label")) {
        if (LOGGER.isLoggable(Level.FINEST))
          LOGGER.finest("parsing label " + child.getNodeValue());
        // the label parser should collapse whitespaces to one, so
        // we call parseCssParameter with trimWhiteSpace=false
        symbol.setLabel(parseCssParameter(child, false));
        if (symbol.getLabel() == null) {
          if (LOGGER.isLoggable(Level.WARNING))
            LOGGER.warning("parsing TextSymbolizer node - couldnt find anything in the Label element!");
        }
      }

      if (childName.equalsIgnoreCase("Font")) {
        fonts.add(parseFont(child));
      } else if (childName.equalsIgnoreCase("LabelPlacement")) {
        symbol.setPlacement(parseLabelPlacement(child));
      } else if (childName.equalsIgnoreCase("Halo")) {
        symbol.setHalo(parseHalo(child));
      } else if (childName.equalsIgnoreCase("Graphic")) {
        if (LOGGER.isLoggable(Level.FINEST))
          LOGGER.finest("Parsing non-standard Graphic in TextSymbolizer");
        if (symbol instanceof TextSymbolizer2) {
          ((TextSymbolizer2) symbol).setGraphic(parseGraphic(child));
        }
      } else if (childName.equalsIgnoreCase("Snippet")) {
        if (LOGGER.isLoggable(Level.FINEST))
          LOGGER.finest("Parsing non-standard Abstract in TextSymbolizer");
        if (symbol instanceof TextSymbolizer2)
          ((TextSymbolizer2) symbol).setSnippet(parseCssParameter(
              child, false));
      } else if (childName.equalsIgnoreCase("FeatureDescription")) {
        if (LOGGER.isLoggable(Level.FINEST))
          LOGGER.finest("Parsing non-standard Description in TextSymbolizer");
        if (symbol instanceof TextSymbolizer2)
          ((TextSymbolizer2) symbol)
              .setFeatureDescription(parseCssParameter(child,
                  false));
      } else if (childName.equalsIgnoreCase("OtherText")) {
        if (LOGGER.isLoggable(Level.FINEST))
          LOGGER.finest("Parsing non-standard OtherText in TextSymbolizer");
        if (symbol instanceof TextSymbolizer2)
          ((TextSymbolizer2) symbol)
              .setOtherText(parseOtherText(child));
      } else if (childName.equalsIgnoreCase("priority")) {
        symbol.setPriority(parseCssParameter(child));
      } else if (childName.equalsIgnoreCase(VendorOptionString)) {
        parseVendorOption(symbol, child);
      }

    }

    symbol.setFonts((Font[]) fonts.toArray(new Font[0]));

    return symbol;
  }
View Full Code Here

                        setDefaultLabelStyle(style);
                    }
                } else {
                    // the XML schema allows only one text style, follow painter's model
                    // and set the last one
                    TextSymbolizer lastTextSymbolizer = (TextSymbolizer) texts.get(texts.size() - 1);
                    setLabelStyle(style, sf, lastTextSymbolizer);
                }

                // handle line styles
                List<Symbolizer> lines = classified.get(LineSymbolizer.class);
View Full Code Here

                if (labelStyles.isEmpty()) {
                    encodeDefaultTextStyle();
                } else {
                    Iterator<TextSymbolizer> iter = labelStyles.iterator();
                    while (iter.hasNext()) {
                        TextSymbolizer sym = (TextSymbolizer) iter.next();
                        try {
                            TextStyle2D style = (TextStyle2D) styleFactory
                                .createStyle(feature, sym, scaleRange);
                            encodeTextStyle(feature, style, sym);
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for "
                                    + sym.toString());
                        }
                    }
                }

                // Lines
                if (!lineStyles.isEmpty()) {
                    Iterator<LineSymbolizer> iter = lineStyles.iterator();
                    while (iter.hasNext()) {
                        LineSymbolizer sym = (LineSymbolizer) iter.next();
                        try {
                            LineStyle2D style = (LineStyle2D) styleFactory
                                    .createStyle(feature, sym, scaleRange);
                            encodeLineStyle(feature, style, sym);
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for "
                                    + sym.toString());
                        }
                    }
                }

                // Polygons
                if (!polyStyles.isEmpty()) {
                    Iterator<PolygonSymbolizer> iter = polyStyles.iterator();
                    while (iter.hasNext()) {
                        PolygonSymbolizer sym = (PolygonSymbolizer) iter.next();
                        try {
                            PolygonStyle2D style = (PolygonStyle2D) styleFactory
                                    .createStyle(feature, sym, scaleRange);
                            // The last argument is forced outline
                            encodePolygonStyle(feature, style, sym, !lineStyles
                                    .isEmpty());
                        } catch (IllegalArgumentException iae) {
                            LOGGER.fine(iae.getMessage() + " for "
                                    + sym.toString());
                        }
                    }
                }

            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.geotools.styling.TextSymbolizer

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.