Package org.geotools.styling

Examples of org.geotools.styling.Stroke


   
    /**
     * Create a Style to draw line features
     */
    private static Style createLineStyle(Color strokeColor) {
        Stroke stroke = styleFactory.createStroke(
                filterFactory.literal(strokeColor),
                filterFactory.literal(1));

        /*
         * Setting the geometryPropertyName arg to null signals that we want to
View Full Code Here


        }
    }

    private Mark injectMark(String key, Mark mark) {
        final Expression wellKnownName;
        final Stroke stroke;
        final Fill fill;
        final Expression size = null; // size and fill are handled only at the PointSymbolizer level - bug?
        final Expression rotation = null;
       
        if (mark.getWellKnownName() == null || isStatic(mark.getWellKnownName())) {
View Full Code Here

    return null;
  }

  /** Internal parse method - made protected for unit testing */
  protected Stroke parseStroke(Node root) {
    Stroke stroke = factory.getDefaultStroke();
    NodeList list = findElements(((Element) root), "GraphicFill");
    int length = list.getLength();
    if (length > 0) {
      if (LOGGER.isLoggable(Level.FINEST))
        LOGGER.finest("stroke: found a graphic fill " + list.item(0));

      NodeList kids = list.item(0).getChildNodes();

      for (int i = 0; i < kids.getLength(); i++) {
        Node child = kids.item(i);

        if ((child == null)
            || (child.getNodeType() != Node.ELEMENT_NODE)) {
          continue;
        }
        String childName = child.getLocalName();
        if (childName == null) {
          childName = child.getNodeName();
        }
        if (childName.equalsIgnoreCase(graphicSt)) {
          Graphic g = parseGraphic(child);
          if (LOGGER.isLoggable(Level.FINEST))
            LOGGER.finest("setting stroke graphicfill with " + g);
          stroke.setGraphicFill(g);
        }
      }
    }

    list = findElements(((Element) root), "GraphicStroke");
    length = list.getLength();
    if (length > 0) {
      if (LOGGER.isLoggable(Level.FINEST))
        LOGGER.finest("stroke: found a graphic stroke " + list.item(0));

      NodeList kids = list.item(0).getChildNodes();

      for (int i = 0; i < kids.getLength(); i++) {
        Node child = kids.item(i);

        if ((child == null)
            || (child.getNodeType() != Node.ELEMENT_NODE)) {
          continue;
        }
        String childName = child.getLocalName();
        if (childName == null) {
          childName = child.getNodeName();
        }
        if (childName.equalsIgnoreCase(graphicSt)) {
          Graphic g = parseGraphic(child);
          if (LOGGER.isLoggable(Level.FINEST))
            LOGGER.finest("setting stroke graphicStroke with " + g);
          stroke.setGraphicStroke(g);
        }
      }
    }

    list = findElements(((Element) root), "CssParameter");
    length = list.getLength();
    for (int i = 0; i < length; i++) {
      Node child = list.item(i);

      if ((child == null) || (child.getNodeType() != Node.ELEMENT_NODE)) {
        continue;
      }

      if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("now I am processing " + child);
      }

      Element param = (Element) child;
      org.w3c.dom.NamedNodeMap map = param.getAttributes();
      final int mapLength = map.getLength();
      if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("attributes " + map.toString());
      }

      for (int k = 0; k < mapLength; k++) {
        String res = map.item(k).getNodeValue();

        if (LOGGER.isLoggable(Level.FINEST)) {
          LOGGER.finest("processing attribute " + res);
        }
        // process the css entry
        //
        if (res.equalsIgnoreCase(strokeString)) {
          Expression color = parseParameterValueExpression(child,
              false);
          stroke.setColor(color);
        } else if (res.equalsIgnoreCase("width")
            || res.equalsIgnoreCase("stroke-width")) {
          Expression width = parseParameterValueExpression(child,
              false);
          stroke.setWidth(width);
        } else if (res.equalsIgnoreCase(opacityString)
            || res.equalsIgnoreCase("stroke-opacity")) {
          Expression opacity = parseParameterValueExpression(child,
              false);
          stroke.setOpacity(opacity);
        } else if (res.equalsIgnoreCase("linecap")
            || res.equalsIgnoreCase("stroke-linecap")) {
          // since these are system-dependent just pass them through
          // and hope.
          stroke.setLineCap(parseCssParameter(child));
        } else if (res.equalsIgnoreCase("linejoin")
            || res.equalsIgnoreCase("stroke-linejoin")) {
          // since these are system-dependent just pass them through
          // and hope.
          stroke.setLineJoin(parseCssParameter(child));
        } else if (res.equalsIgnoreCase("dasharray")
            || res.equalsIgnoreCase("stroke-dasharray")) {
          String dashString = null;
          if (child.getChildNodes().getLength() == 1
              && child.getFirstChild().getNodeType() == Node.TEXT_NODE) {
            dashString = getFirstChildValue(child);
          } else {
            Expression definition = parseCssParameter(child);
            if (definition instanceof Literal) {
              dashString = ((Literal) definition).getValue()
                  .toString();
            } else {
              LOGGER.warning("Only literal stroke-dasharray supported at this time:"
                  + definition);
            }
          }
          if (dashString != null) {
            StringTokenizer stok = new StringTokenizer(
                dashString.trim(), " ");
            float[] dashes = new float[stok.countTokens()];
            for (int l = 0; l < dashes.length; l++) {
              dashes[l] = Float.parseFloat(stok.nextToken());
            }
            stroke.setDashArray(dashes);
          } else {
            LOGGER.fine("Unable to parse stroke-dasharray");
          }
        } else if (res.equalsIgnoreCase("dashoffset")
            || res.equalsIgnoreCase("stroke-dashoffset")) {
          stroke.setDashOffset(parseCssParameter(child));
        }
      }
    }

    return stroke;
View Full Code Here

        assertNull(copy);
    }
   
    @Test
    public void testDynamicStrokeInGraphicMark() {
        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);
        LineSymbolizer ls = sb.createLineSymbolizer();
        ls.getStroke().setGraphicStroke(graphic);
View Full Code Here

        checkSingleSymbolizer(style, ls);
    }
   
    @Test // this one should fail now??
    public void testDynamicStrokeInGraphicFill() {
        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);
View Full Code Here

        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

    @Override
    public void visit(LineSymbolizer line) {
        super.visit(line);
        LineSymbolizer copy = (LineSymbolizer) pages.peek();
        Stroke stroke = copy.getStroke();
        addStrokeSymbolizerIfNecessary(stroke);
        addGeometryExpression(line.getGeometry(), geometriesOnLineSymbolizer);
    }
View Full Code Here

        }
    }

    private Mark injectMark(String key, Mark mark) {
        final Expression wellKnownName;
        final Stroke stroke;
        final Fill fill;
        final Expression size = null; // size and fill are handled only at the PointSymbolizer level - bug?
        final Expression rotation = null;
       
        if (mark.getWellKnownName() == null || isStatic(mark.getWellKnownName())) {
View Full Code Here

TOP

Related Classes of org.geotools.styling.Stroke

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.