Package org.geotools.styling

Examples of org.geotools.styling.PolygonSymbolizer


                // 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


        int numClasses = 10;
        List <Rule> rules =  builder.equalIntervalClassification(pointCollection, "foo", numClasses, false);
        builder.polygonStyle(rules, new BlueColorRamp(), false);
        Rule ruleOne = rules.get(0);
        assertTrue(ruleOne.getSymbolizers()[0] instanceof PolygonSymbolizer);
        PolygonSymbolizer symbolizer = (PolygonSymbolizer)ruleOne.getSymbolizers()[0];
        assertEquals(new Color(0, 0, 49), symbolizer.getFill().getColor().evaluate(null, Color.class));
        assertNotNull(ruleOne.getFilter());
        assertEquals(numClasses, rules.size());
    }
View Full Code Here

    @Test
    public void testPolygonStyleReverse() throws Exception {
        int numClasses = 10;
        List <Rule> rules =  builder.equalIntervalClassification(pointCollection, "foo", numClasses, false);
        builder.polygonStyle(rules, new BlueColorRamp(), true);
        PolygonSymbolizer symbolizer = (PolygonSymbolizer)rules.get(0).getSymbolizers()[0];
        assertEquals(new Color(0, 0, 224), symbolizer.getFill().getColor().evaluate(null, Color.class));
        assertEquals(numClasses, rules.size());
    }
View Full Code Here

   *            w3c dom node
   *
   * @return the polygon symbolizer
   */
  protected PolygonSymbolizer parsePolygonSymbolizer(Node root) {
    PolygonSymbolizer symbol = new PolygonSymbolizerImpl3D();
    symbol.setFill((Fill) null);
    symbol.setStroke((Stroke) null);

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

    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(strokeString)) {
        symbol.setStroke(parseStroke(child));
      } else if (childName.equalsIgnoreCase(fillSt)) {
        Fill fill = parseFill(child);
        symbol.setFill(parseFill(child));
      } else if (childName.equalsIgnoreCase(VendorOptionString)) {
        parseVendorOption(symbol, child);
      }
    }
    return symbol;
View Full Code Here

                boolean forceOutiline = lines.size() == 0;
                List<Symbolizer> polygons = classified.get(PolygonSymbolizer.class);
                if(polygons.size() > 0) {
                    // the XML schema allows only one polygon style, follow painter's model
                    // and set the last one
                    PolygonSymbolizer lastPolygonSymbolizer = (PolygonSymbolizer) polygons.get(polygons.size() - 1);
                    setPolygonStyle(style, sf, lastPolygonSymbolizer, forceOutiline);
                }
            }

            return feature;
View Full Code Here

        Stroke markStroke = sb.createStroke();
        markStroke.setWidth(sb.getFilterFactory().property("myAttribute"));
        Mark mark = sb.createMark("square");
        mark.setStroke(markStroke);
        Graphic graphic = sb.createGraphic(null, mark, null);
        PolygonSymbolizer ps = sb.createPolygonSymbolizer();
        ps.getFill().setGraphicFill(graphic);

        Style style = sb.createStyle(ps);
        style.accept(visitor);
        Style copy = (Style) visitor.getCopy();
        assertNull(copy);
View Full Code Here

     * the area in which he clicked is fully transparent
     */
    @Override
    public void visit(PolygonSymbolizer poly) {
        super.visit(poly);
        PolygonSymbolizer copy = (PolygonSymbolizer) pages.peek();
        Fill fill = copy.getFill();
        if (fill == null) {
            copy.setFill(sb.createFill());
        }
        Stroke stroke = copy.getStroke();
        addStrokeSymbolizerIfNecessary(stroke);
        addGeometryExpression(poly.getGeometry(), geometriesOnPolygonSymbolizer);
    }
View Full Code Here

    public void testSEStyleWithRelativePath() throws IOException {
        StyleInfo si = getCatalog().getStyleByName("relative");

        assertNotNull(si);
        Style style = si.getStyle();
        PolygonSymbolizer ps = (PolygonSymbolizer) style.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
        ExternalGraphic eg = (ExternalGraphic) ps.getFill().getGraphicFill().graphicalSymbols().get(0);
        URI uri = eg.getOnlineResource().getLinkage();
        assertNotNull(uri);
        File actual = DataUtilities.urlToFile(uri.toURL()).getCanonicalFile();
        assertEquals(rockFillSymbolFile, actual);
    }
View Full Code Here

                // 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

                LOGGER.info("Empty PolygonSymbolizer, using default fill and stroke.");
            }

            final StringBuffer styleString = new StringBuffer();

            PolygonSymbolizer polySym = (PolygonSymbolizer) sym;

            // ** LABEL **
            styleString.append("<IconStyle>");

            if (!vectorNameDescription) { // if they don't want
                // attributes
                styleString.append("<color>#00ffffff</color>"); // fully
                // transparent
            }

            styleString.append("<Icon><href>root://icons/palette-3.png</href><x>224</x><w>32</w><h>32</h></Icon>");
            styleString.append("</IconStyle>");

            // ** FILL **
            styleString.append("<PolyStyle><color>");

            if (polySym.getFill() != null) // if they specified a fill
            {
                int opacity = 255; // default to full opacity

                if (polySym.getFill().getOpacity() != null) {
                    float op = getOpacity(polySym.getFill().getOpacity());
                    opacity = (new Float(255 * op)).intValue();
                }

                Paint p = ((PolygonStyle2D) style).getFill();

                if (p instanceof Color) {
                    styleString.append("#").append(intToHex(opacity)).append(
                            colorToHex((Color) p)); // transparancy needs to
                    // come from the opacity
                    // value.
                } else {
                    styleString.append("#ffaaaaaa"); // should not occure in
                    // normal parsing
                }
            } else { // no fill specified, make transparent
                styleString.append("#00aaaaaa");
            }

            // if there is an outline, specify that we have one, then style it
            styleString.append("</color>");

            if (polySym.getStroke() != null) {
                styleString.append("<outline>1</outline>");
            } else {
                styleString.append("<outline>0</outline>");
            }

            styleString.append("</PolyStyle>");

            // ** OUTLINE **
            if (polySym.getStroke() != null) // if there is an outline
            {
                styleString.append("<LineStyle><color>");

                int opacity = 255; // default to full opacity

                if (polySym.getStroke().getOpacity() != null) {
                    float op = getOpacity(polySym.getStroke().getOpacity());
                    opacity = (new Float(255 * op)).intValue();
                }

                Paint p = ((PolygonStyle2D) style).getContour();

                if (p instanceof Color) {
                    styleString.append("#").append(intToHex(opacity)).append(
                            colorToHex((Color) p)); // transparancy needs to
                    // come from the opacity
                    // value.
                } else {
                    styleString.append("#ffaaaaaa"); // should not occure in
                    // normal parsing
                }

                styleString.append("</color>");

                // stroke width
                if (polySym.getStroke().getWidth() != null) {
                    int width = getWidth(polySym.getStroke().getWidth());
                    styleString.append("<width>").append(width).append(
                            "</width>");
                }

                styleString.append("</LineStyle>");
View Full Code Here

TOP

Related Classes of org.geotools.styling.PolygonSymbolizer

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.