Package org.geotools.renderer.style

Examples of org.geotools.renderer.style.MarkStyle2D


                PointSymbolizerWrapper tmpPs = new PointSymbolizerWrapper(pointSymbolizer, null);
                tmp = styleFactory.createStyle(feature, pointSymbolizer, new NumberRange(Double.class, Double.NEGATIVE_INFINITY,
                        Double.POSITIVE_INFINITY));
            }
            if (tmp instanceof MarkStyle2D) {
                MarkStyle2D style = (MarkStyle2D) tmp;
                Shape shape2 = style.getTransformedShape(point[0], point[1]);

                if (c == null && fill == null) {
                    // g.setColor(Color.GRAY);
                    // g.fill(shape2);
                }

                if (fill != null) {
                    g.setColor(fill);
                    g.fill(shape2);
                }
                // else {
                // g.setColor(Color.GRAY);
                // g.fill(shape2);
                // }
                if (c != null) {
                    g.setStroke(ViewportGraphics.LINE_SOLID, width);
                    g.setColor(c);
                    g.draw(shape2);
                }
                // else {
                // g.setStroke(ViewportGraphics.LINE_SOLID, width);
                // g.setColor(Color.DARK_GRAY);
                // g.draw(shape2);
                // }
            } else if (tmp instanceof GraphicStyle2D) {
                GraphicStyle2D style = (GraphicStyle2D) tmp;

                RenderedImage image = (RenderedImage) style.getImage();
                g.drawImage(image, (int) (point[0] - ((double) image.getWidth()) / (double) 2),
                        (int) (point[1] - ((double) image.getHeight()) / (double) 2));
            }
        }
    }
View Full Code Here


            SLDStyleFactory styleFactory = new SLDStyleFactory();
            Style2D tmp = styleFactory.createStyle(feature, pointSymbolizer, new NumberRange(Integer.class, 0, imgH));

            if (tmp instanceof MarkStyle2D) {

                MarkStyle2D style = (MarkStyle2D) tmp;
                style.setSize(imgH / 2);
                Shape shape2 = style.getTransformedShape(imgH / 2f, imgH / 2f);

                if (c == null && fill == null) {
                    g2d.setColor(Color.GRAY);
                    g2d.fill(shape2);
                }

                if (fill != null) {
                    g2d.setColor(fill);
                    g2d.fill(shape2);
                } else {
                    g2d.setColor(Color.GRAY);
                    g2d.fill(shape2);
                }
                if (c != null) {
                    g2d.setStroke(new BasicStroke(width));
                    g2d.setColor(c);
                    g2d.draw(shape2);
                } else {
                    g2d.setStroke(new BasicStroke(width));
                    g2d.setColor(Color.DARK_GRAY);
                    g2d.draw(shape2);
                }
            } else if (tmp instanceof GraphicStyle2D) {
                GraphicStyle2D style = (GraphicStyle2D) tmp;

                float rotation = style.getRotation();

                g2d.setTransform(AffineTransform.getRotateInstance(rotation));

                BufferedImage image = style.getImage();
                g2d.drawImage(image, (int) (point[0] - ((double) image.getWidth()) / (double) 2),
                        (int) (point[1] - ((double) image.getHeight()) / (double) 2), null);
            }
        }
    }
View Full Code Here

            shape.getPathIterator(null).currentSegment(point);
            SLDStyleFactory styleFactory=new SLDStyleFactory();
             Style2D tmp = styleFactory.createStyle(feature, pointSymbolizer, new NumberRange(Double.class, Double.MIN_VALUE, Double.MAX_VALUE));
           
             if( tmp instanceof MarkStyle2D ){
                MarkStyle2D style=(MarkStyle2D) tmp;
                Shape shape2 = style.getTransformedShape(point[0], point[1]);

                if( c == null && fill == null ){
                    g.setColor( Color.GRAY );
                    g.fill( shape2 );
                }
               
   
                if( fill != null ){
                    g.setColor( fill );
                    g.fill( shape2 );               
                else{
                    g.setColor( Color.GRAY );
                    g.fill( shape2 );               
                }
                if( c != null ){
                    g.setStroke(ViewportGraphics.LINE_SOLID, width);
                    g.setColor( c );
                    g.draw( shape2 );               
                }else{
                    g.setStroke(ViewportGraphics.LINE_SOLID, width);
                    g.setColor( Color.DARK_GRAY );
                    g.draw( shape2 );
                }
             }else if( tmp instanceof GraphicStyle2D){
                 GraphicStyle2D style=(GraphicStyle2D) tmp;
                
                 float rotation = style.getRotation();
                
                 g.setTransform(AffineTransform.getRotateInstance(rotation));
                
                 RenderedImage image = (RenderedImage)style.getImage();
                 try{
                     g.drawImage(image, (int)(point[0]-((double)image.getWidth())/(double)2), (int)(point[1]-((double)image.getHeight())/(double)2));
                 }catch (Exception e) {
                     g.drawImage(image, 0,0);
                }
View Full Code Here

            shape.getPathIterator(null).currentSegment(point);
            SLDStyleFactory styleFactory=new SLDStyleFactory();
            Style2D tmp = styleFactory.createStyle(feature, pointSymbolizer, NumberRange.create(Double.MIN_VALUE, Double.MAX_VALUE));
            if( tmp instanceof MarkStyle2D ){
                MarkStyle2D style=(MarkStyle2D) tmp;
                Shape shape2 = style.getTransformedShape(point[0], point[1]);
                if( c == null && fill == null ){
                    g.setColor( Color.GRAY );
                    g.fill( shape2 );
                }
                if( fill != null ){
                    g.setColor( fill );
                    g.fill( shape2 );
                else{
                    g.setColor( Color.GRAY );
                    g.fill( shape2 );
                }
                if( c != null ){
                    Stroke str = new BasicStroke(width);
                    g.setStroke(str);
                    g.setColor( c );
                    g.draw( shape2 );
                }else{
                    Stroke str = new BasicStroke(width);
                    g.setStroke(str);
                    g.setColor( Color.DARK_GRAY );
                    g.draw( shape2 );
                }
            }else if( tmp instanceof GraphicStyle2D){
                GraphicStyle2D style=(GraphicStyle2D) tmp;
                float rotation = style.getRotation(); // in radians
                g.setTransform(AffineTransform.getRotateInstance(rotation));
                BufferedImage image = (BufferedImage)style.getImage();
               
                g.drawImage(image, (int)(point[0]-((double)image.getWidth())/(double)2), (int)(point[1]-((double)image.getHeight())/(double)2),null);
            }
        }
    }
View Full Code Here

        } else if (style instanceof MarkStyle2D) {
            PathIterator citer = getPathIterator(shape);

            // get the point onto the shape has to be painted
            float[] coords = new float[2];
            MarkStyle2D ms2d = (MarkStyle2D) style;

            Shape transformedShape ;
            while (!(citer.isDone())) {
                citer.currentSegment(coords);
                transformedShape = ms2d.getTransformedShape(coords[0],
                        coords[1]);
                if (transformedShape != null) {
                    if (ms2d.getFill() != null) {
                        graphics.setPaint(ms2d.getFill());
                        graphics.setComposite(ms2d.getFillComposite());
                        graphics.fill(transformedShape);
                    }

                    if (ms2d.getContour() != null) {
                        graphics.setPaint(ms2d.getContour());
                        graphics.setStroke(ms2d.getStroke());
                        graphics.setComposite(ms2d.getContourComposite());
                        graphics.draw(transformedShape);
                    }
                   
                    if (isLabelObstacle) {
                        labelCache.put(transformedShape.getBounds2D());
View Full Code Here

            BufferedImage image = ((GraphicStyle2D) style).getImage();
            renderImage(graphics, x, y, image, rotation, opacity, isLabelObstacle);
        } else if(style instanceof MarkStyle2D) {
            // almost like the code in the main paint method, but
            // here we don't use the mark composite
            MarkStyle2D ms2d = (MarkStyle2D) style;
            Shape transformedShape = ms2d.getTransformedShape((float) x, (float) y, (float) rotation);
            if (transformedShape != null) {
                if (ms2d.getFill() != null) {
                    graphics.setPaint(ms2d.getFill());
                    graphics.fill(transformedShape);
                }

                if (ms2d.getContour() != null) {
                    graphics.setPaint(ms2d.getContour());
                    graphics.setStroke(ms2d.getStroke());
                    graphics.draw(transformedShape);
                }

                if (isLabelObstacle) {
                    labelCache.put(transformedShape.getBounds2D());
View Full Code Here

        if(width <= 0 || height <= 0) {
            return null;
        }
       
        if(graphic instanceof MarkStyle2D) {
            MarkStyle2D mark = (MarkStyle2D) graphic;
           
            Shape original = mark.getShape();
            Rectangle2D bounds = original.getBounds2D();
            MarkStyle2D resized = (MarkStyle2D) mark.clone();
            if(mode == GraphicResize.PROPORTIONAL) {
                if(width > height) {
                    resized.setSize(Math.round(bounds.getHeight() * width / bounds.getWidth()));
                } else {
                    resized.setSize(height);
                }
            } else {
                TransformedShape tss = new TransformedShape();
                tss.shape = original;
                tss.setTransform(AffineTransform.getScaleInstance(width / bounds.getWidth(), height / bounds.getHeight()));
                resized.setShape(tss);
                resized.setSize(height);
            }
           
            return resized;
        } else if(graphic instanceof IconStyle2D) {
            IconStyle2D iconStyle = (IconStyle2D) graphic;
            IconStyle2D resized = (IconStyle2D) iconStyle.clone();
           
           
            final Icon icon = iconStyle.getIcon();
            AffineTransform at;
            if(mode == GraphicResize.PROPORTIONAL) {
                double factor;
                if(width > height) {
                    factor = width / icon.getIconWidth();
                } else {
                    factor = height / icon.getIconHeight();
                }
                at = AffineTransform.getScaleInstance(factor, factor);
            } else {
                at = AffineTransform.getScaleInstance(width / icon.getIconWidth(),
                        height / icon.getIconHeight());
            }
            resized.setIcon(new TransformedIcon(icon, at));
            return resized;
        } else if(graphic instanceof GraphicStyle2D) {
            GraphicStyle2D gstyle = (GraphicStyle2D) graphic;
            GraphicStyle2D resized = (GraphicStyle2D) graphic.clone();
            BufferedImage image = gstyle.getImage();
           
            AffineTransform at;
            if(mode == GraphicResize.PROPORTIONAL) {
                double factor;
                if(width > height) {
                    factor = width / image.getWidth();
                } else {
                    factor = height / image.getHeight();
                }
                at = AffineTransform.getScaleInstance(factor, factor);
            } else {
                at = AffineTransform.getScaleInstance(width / image.getWidth(),
                        height / image.getHeight());
            }
           
            AffineTransformOp ato = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
            image = ato.filter(image, null);
            resized.setImage(image);
            return resized;
        } else {
            return graphic;
        }
    }
View Full Code Here

                size = ff.literal(is.getIcon().getIconHeight());
            } else if(style instanceof GraphicStyle2D) {
                GraphicStyle2D gs = (GraphicStyle2D) style;
                size = ff.literal(gs.getImage().getHeight());
            } else if(style instanceof MarkStyle2D) {
                MarkStyle2D ms = (MarkStyle2D) style;
                size = ff.literal(ms.getSize());
            }
        }
       
        return rescale(size);
    }
View Full Code Here

TOP

Related Classes of org.geotools.renderer.style.MarkStyle2D

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.