Package org.geotools.styling

Examples of org.geotools.styling.Stroke


      return mark;
    }
  }

  private Stroke createStroke(FeatureStyleInfo featureStyle) {
    Stroke stroke = styleBuilder.createStroke(styleBuilder.literalExpression(featureStyle.getStrokeColor()),
        styleBuilder.literalExpression(featureStyle.getStrokeWidth()),
        styleBuilder.literalExpression(featureStyle.getStrokeOpacity()));
    if (featureStyle.getDashArray() != null) {
      String[] strs = featureStyle.getDashArray().split(",");
      float[] nrs = new float[strs.length];
      for (int i = 0; i < strs.length; i++) {
        try {
          nrs[i] = Float.parseFloat(strs[i]);
        } catch (NumberFormatException e) {
          log.warn("unparseable dash array " + featureStyle.getDashArray(), e);
        }
      }
      stroke.setDashArray(nrs);
    }
    return stroke;
  }
View Full Code Here


    public void visit( PointSymbolizer arg0 ) {
        arg0.getGraphic().accept(this);
    }

    public void visit( LineSymbolizer arg0 ) {
        Stroke stroke = arg0.getStroke();
        if( stroke!=null )
            stroke.accept(this);
    }
View Full Code Here

    public void visit( PolygonSymbolizer arg0 ) {
        Fill fill = arg0.getFill();
        if (fill != null)
            fill.accept(this);
        Stroke stroke = arg0.getStroke();
        if( stroke!=null )
            stroke.accept(this);
    }
View Full Code Here

    public void visit( Mark arg0 ) {
        Fill fill = arg0.getFill();
        if (fill != null)
            fill.accept(this);

        Stroke stroke = arg0.getStroke();
        if( stroke!=null )
            stroke.accept(this);
    }
View Full Code Here

        }

        for( GraphicalSymbol gs : graphic.graphicalSymbols() ) {
            if ((gs != null) && (gs instanceof Mark)) {
                Mark mark = (Mark) gs;
                Stroke stroke = mark.getStroke();
                if (stroke != null) {
                    Color colour = color(stroke);
                    if (colour == null) {
                        return null;
                    }
                    Expression opacity = stroke.getOpacity();
                    if (opacity == null)
                        opacity = ff.literal(1.0);
                    float alpha = (float) Filters.asDouble(opacity);
                    colour = new Color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, alpha);
                    if (colour != null) {
View Full Code Here

    private void setStylingElements( LineSymbolizer symbolizer ) {

        Color colour = null;
        int width = SLDs.NOTFOUND;

        Stroke stroke = symbolizer.getStroke();
        if (stroke != null) {
            colour = SLDs.lineColor(symbolizer);
            width = SLDs.lineWidth(symbolizer);

        }
View Full Code Here

     */
    public void apply() {
        LineSymbolizer symbolizer = (LineSymbolizer) getContent();
        StyleBuilder styleBuilder = getStyleBuilder();

        Stroke stroke = symbolizer.getStroke();
        if (stroke == null) {
            stroke = getStyleBuilder().createStroke();
            symbolizer.setStroke(stroke);
        }

        Color c = lineColourEditor.getColor();

        stroke.setWidth(styleBuilder.literalExpression(lineWidth.getSelection()));
        stroke.setColor(styleBuilder.colorExpression(c));
        stroke.setOpacity(styleBuilder.literalExpression(lineOpacity.getSelection()
                / opacityMaxValueFloat));
        stroke.setLineJoin(styleBuilder.literalExpression(linejoinCombo.getText()));
        stroke.setLineCap(styleBuilder.literalExpression(linecapCombo.getText()));

//      TODO: This functionality to be added later with a better UI...goes with other task
//        if (!lineDashText.getText().equalsIgnoreCase("")
//                && !lineSpaceText.getText().equalsIgnoreCase("")) {
//            float dash = Float.parseFloat(lineDashText.getText());
View Full Code Here

     */
    public void setStroke( Stroke aLine, Mode mode, Color defaultColor ) {
        listen(false);
        try {
            boolean enabled=true;
            Stroke line=aLine;

            if ( line==null ){
                StyleBuilder builder=new StyleBuilder();
                line=builder.createStroke(defaultColor);
                enabled=false;
View Full Code Here

        DuplicatingStyleVisitor copyStyle = new DuplicatingStyleVisitor();
        rule.accept(copyStyle);
        Rule newRule = (Rule) copyStyle.getCopy();

        int pointSize = 0;
        Stroke stroke = null;
        Symbolizer[] symbolizers = newRule.getSymbolizers();
        if (symbolizers.length > 0) {
            Symbolizer symbolizer = newRule.getSymbolizers()[0];
            if (symbolizer instanceof PointSymbolizer) {
                PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
                pointSize = SLDs.pointSize(pointSymbolizer);
                stroke = SLDs.stroke(pointSymbolizer);
            }
        }
        int strokeSize = 0;
        if (stroke != null) {
            strokeSize = SLDs.width(stroke);
            if (strokeSize < 0) {
                strokeSize = 1;
                stroke.setWidth(ff.literal(strokeSize));
            }
        }
        pointSize = pointSize + 2 * strokeSize;
        if (pointSize <= 0) {
            pointSize = width;
View Full Code Here

    public static BufferedImage polygonRuleToImage( final Rule rule, int width, int height ) {
        DuplicatingStyleVisitor copyStyle = new DuplicatingStyleVisitor();
        rule.accept(copyStyle);
        Rule newRule = (Rule) copyStyle.getCopy();

        Stroke stroke = null;
        Symbolizer[] symbolizers = newRule.getSymbolizers();
        if (symbolizers.length > 0) {
            Symbolizer symbolizer = symbolizers[0];
            if (symbolizer instanceof PolygonSymbolizer) {
                PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
                stroke = SLDs.stroke(polygonSymbolizer);
            }
        }
        int strokeSize = 0;
        if (stroke != null) {
            strokeSize = SLDs.width(stroke);
            if (strokeSize < 0) {
                strokeSize = 0;
                stroke.setWidth(ff.literal(strokeSize));
            }
        }

        // pointSize = width;
        BufferedImage finalImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
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.