Package org.geotools.styling

Examples of org.geotools.styling.Stroke


    public static BufferedImage lineRuleToImage( 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 = newRule.getSymbolizers()[0];
            if (symbolizer instanceof LineSymbolizer) {
                LineSymbolizer lineSymbolizer = (LineSymbolizer) symbolizer;
                stroke = SLDs.stroke(lineSymbolizer);
            }
        }

        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


                if (symbolizer instanceof PointSymbolizer) {
                    PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
                    graphics[0] = pointSymbolizer.getGraphic();
                } else if (symbolizer instanceof LineSymbolizer) {
                    LineSymbolizer lineSymbolizer = (LineSymbolizer) symbolizer;
                    Stroke stroke = lineSymbolizer.getStroke();
                    graphics[0] = stroke.getGraphicStroke();
                } else if (symbolizer instanceof PolygonSymbolizer) {
                    PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
                    Stroke stroke = polygonSymbolizer.getStroke();
                    if (stroke != null)
                        graphics[0] = stroke.getGraphicStroke();
                    Fill fill = polygonSymbolizer.getFill();
                    if (fill != null)
                        graphics[1] = fill.getGraphicFill();
                }
                for( int i = 0; i < graphics.length; i++ ) {
View Full Code Here

        SimpleFeatureType schema = getLayer().getSchema();
        geometryName.setInput(schema);
        String name = DEFAULT_GEOMETRY;

        Stroke stroke = null;
        Fill fill = null;
        Graphic graphic = null;
        TextSymbolizer text = null;
        LabelPlacement placement = null;
View Full Code Here

                    if (graphicalSymbol instanceof ExternalGraphic) {
                        fillExternalGraphicFill = (ExternalGraphic) graphicalSymbol;
                    } else if (graphicalSymbol instanceof Mark) {
                        mark = (Mark) graphicalSymbol;
                        wkMarkNameFill = mark.getWellKnownName().evaluate(null, String.class);
                        Stroke stroke = mark.getStroke();
                        wkMarkColorFill = stroke.getColor().evaluate(null, String.class);
                        wkMarkWidthFill = stroke.getWidth().evaluate(null, String.class);
                        wkMarkSizeFill = fillGraphicFill.getSize().evaluate(null, String.class);
                    }
                }
            }
View Full Code Here

    public void setWkMarkColorFill( String wkMarkColorFill ) {
        this.wkMarkColorFill = wkMarkColorFill;
        checkMarkExists();
        if (wkMarkColorFill != null) {
            Stroke markStroke = mark.getStroke();
            markStroke.setColor(ff.literal(wkMarkColorFill));
        }
    }
View Full Code Here

    public void setWkMarkWidthFill( String wkMarkWidthFill ) {
        this.wkMarkWidthFill = wkMarkWidthFill;
        checkMarkExists();
        if (wkMarkWidthFill != null) {
            Stroke markStroke = mark.getStroke();
            markStroke.setWidth(ff.literal(wkMarkWidthFill));
        }
    }
View Full Code Here

    private void paint( ViewportGraphics g, SimpleFeature feature, LiteShape shape, Symbolizer symb ) {
        if (symb instanceof PolygonSymbolizer) {
            PolygonSymbolizer polySymb = (PolygonSymbolizer) symb;
            double opacity = SLDs.polyFillOpacity(polySymb);
            Color fillColor = SLDs.polyFill(polySymb);
            Stroke stroke = SLDs.stroke(polySymb);
            Color strokeColor = SLDs.polyColor(polySymb);

            int width = SLDs.width(stroke);
            if (width == SLDs.NOTFOUND)
                width = 1;

            if (Double.isNaN(opacity))
                opacity = 1.0;
            if (fillColor != null) {
                fillColor = new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue(), (int) (255 * opacity));
                g.setColor(fillColor);
                g.fill(shape);
            }
            if (stroke != null && strokeColor != null) {
                Graphics2D g2d = g.getGraphics(Graphics2D.class);
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                g.setColor(strokeColor);

                float[] dashArray = stroke.getDashArray();
                Float dashOffset = stroke.getDashOffset().evaluate(null, Float.class);
                if (dashOffset == null) {
                    dashOffset = 0f;
                }
                String cap = stroke.getLineCap().evaluate(null, String.class);
                int capInt = Utilities.sld2awtCap(cap);
                String join = stroke.getLineJoin().evaluate(null, String.class);
                int joinInt = Utilities.sld2awtJoin(join);
                BasicStroke bStroke = new BasicStroke(width, capInt, joinInt, 1f, dashArray, dashOffset);
                g2d.setStroke(bStroke);
                g2d.draw(shape);
            }
        }
        if (symb instanceof LineSymbolizer) {
            LineSymbolizer lineSymbolizer = (LineSymbolizer) symb;
            Color c = SLDs.color(lineSymbolizer);
            int w = SLDs.width(lineSymbolizer);
            Stroke stroke = SLDs.stroke(lineSymbolizer);
            if (c != null && w > 0) {
                Graphics2D g2d = g.getGraphics(Graphics2D.class);
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                g2d.setColor(c);

                float[] dashArray = stroke.getDashArray();
                Float dashOffset = stroke.getDashOffset().evaluate(null, Float.class);
                if (dashOffset == null) {
                    dashOffset = 0f;
                }
                String cap = stroke.getLineCap().evaluate(null, String.class);
                int capInt = Utilities.sld2awtCap(cap);
                String join = stroke.getLineJoin().evaluate(null, String.class);
                int joinInt = Utilities.sld2awtJoin(join);
                BasicStroke bStroke = new BasicStroke(w, capInt, joinInt, 1f, dashArray, dashOffset);
                g2d.setStroke(bStroke);
                g2d.draw(shape);
            }
View Full Code Here

    protected static PointSymbolizer createPointSymbolizer(Color colour) {
        PointSymbolizer symb=styleBuilder.createPointSymbolizer();
        Fill fill = styleBuilder.createFill(colour, 1.0);       

        Stroke outline=styleBuilder.createStroke(Color.BLACK,1,1);

        // check existing default graphics
        if (symb.getGraphic().graphicalSymbols() != null && symb.getGraphic().graphicalSymbols().size() == 1) {
            symb.getGraphic().graphicalSymbols().clear();
        }
View Full Code Here

     */
    protected static LineSymbolizer createLineSymbolizer(Color colour) {
    if (colour == null) {
      colour = createRandomColor();
    }
        Stroke stroke = styleBuilder.createStroke();
        stroke.setColor(styleBuilder.colorExpression(colour));
        stroke.setWidth(styleBuilder.literalExpression(1));

        LineSymbolizer symbolizer = styleBuilder.createLineSymbolizer(stroke);

        return symbolizer;
    }
View Full Code Here

    protected static PolygonSymbolizer createPolygonSymbolizer(Color colour) {
      if (colour == null) {
      colour = createRandomColor();
    }

        Stroke stroke = styleBuilder.createStroke();
        stroke.setColor(styleBuilder.colorExpression(colour));
        stroke.setWidth(styleBuilder.literalExpression(1));

        Fill fill = styleBuilder.createFill();
        fill.setColor(styleBuilder.colorExpression(colour));
        fill.setOpacity(styleBuilder.literalExpression(.5));
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.