Package org.geotools.geometry.jts

Examples of org.geotools.geometry.jts.LiteShape2


        TextSymbolizer ts2 = sb.createTextSymbolizer(Color.YELLOW, (Font) null, "name");
        ts2.getOptions().put(TextSymbolizer.GROUP_KEY, "true");

        SimpleFeature f1 = createFeature("label1", L1);
        SimpleFeature f2 = createFeature("label1", L2);
        cache.put(LAYER_ID, ts1, f1, new LiteShape2((Geometry) f1.getDefaultGeometry(), null, null,
                false), ALL_SCALES);
        cache.put(LAYER_ID, ts2, f2, new LiteShape2((Geometry) f2.getDefaultGeometry(), null, null,
                false), ALL_SCALES);

        // two different symbolizers, we should have two
        List<LabelCacheItem> labels = cache.getActiveLabels();
        assertEquals(2, labels.size());
View Full Code Here


        tsGroup.getOptions().put(TextSymbolizer.GROUP_KEY, "true");

        SimpleFeature f1 = createFeature("label1", L1);
        SimpleFeature f2 = createFeature("label1", L2);
        SimpleFeature f3 = createFeature("label1", L3);
        cache.put(LAYER_ID, tsGroup, f1, new LiteShape2((Geometry) f1.getDefaultGeometry(), null, null,
                false), ALL_SCALES);
        cache.put(LAYER_ID, ts, f2, new LiteShape2((Geometry) f2.getDefaultGeometry(), null, null,
                false), ALL_SCALES);
        cache.put(LAYER_ID, tsGroup, f3, new LiteShape2((Geometry) f3.getDefaultGeometry(), null, null,
                false), ALL_SCALES);

        // two different symbolizers, we should have two (the first grouped with the third)
        List<LabelCacheItem> labels = cache.getActiveLabels();
        assertEquals(2, labels.size());
View Full Code Here

        BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        MathTransform transform = ProjectiveTransform.create(new AffineTransform());
        Decimator decimator = new Decimator(transform);
        Point point = new GeometryFactory().createPoint(new Coordinate(10, 10));
        LiteShape2 pointShape = new LiteShape2(point, transform, decimator, false);
        try {
            painter.paint(g2, pointShape, (GraphicLegend) null, 1, false);
            fail();
        } catch (NullPointerException e) {
            assertEquals("ShapePainter has been asked to paint a null legend!!", e.getMessage());
View Full Code Here

        final GraphicLegend legend = (GraphicLegend) rule.getLegend();
       
        // Paint legend using StyledShapePainter
        final Point point = new GeometryFactory().createPoint(
                new Coordinate(width / 2, height / 2));
        final LiteShape2 shape = new LiteShape2(point, null, null, false);
       
        int imageType = testImage.getType();
        if(imageType == BufferedImage.TYPE_CUSTOM) {
            imageType = BufferedImage.TYPE_INT_RGB;
        }
View Full Code Here

        // Set rotation to 45 degrees
        legend.setRotation( ff.literal(45.0) );
       
        // Paint legend using StyledShapePainter
        final Point point = gf.createPoint(new Coordinate(width / 2, height / 2));
        final LiteShape2 shape = new LiteShape2(point, null, null, false);
       
        int imageType = testImage.getType();
        if(imageType == BufferedImage.TYPE_CUSTOM) {
            imageType = BufferedImage.TYPE_INT_RGB;
        }
View Full Code Here

        BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        MathTransform transform = ProjectiveTransform.create(new AffineTransform());
        Decimator decimator = new Decimator(transform);
        Point point = new GeometryFactory().createPoint(new Coordinate(10, 10));
        LiteShape2 pointShape = new LiteShape2(point, transform, decimator, false);
        painter.paint(g2, pointShape, legend, 1, false);
        // check it is correctly painted
        assertEquals(0, image.getRaster().getSample(0, 0, 0));
        assertEquals(64, image.getRaster().getSample(0, 0, 1));
        assertEquals(128, image.getRaster().getSample(0, 0, 2));
View Full Code Here

                        // geometry to make sure the coordinates have been modified once, and then
                        // compute the centroid in the screen space. This is a side effect of the
                        // fact we're modifing the geometry coordinates directly, if we don't get
                        // the reprojected and decimated geometry we risk of transforming it twice
                        // when computing the centroid
                        LiteShape2 first = getTransformedShape(g, sa);
                        if(first != null) {
                            if(projectionHandler != null) {
                                // at the same time, we cannot keep the geometry in screen space because
                                // that would prevent the advanced projection handling to do its work,
                                // to replicate the geometries across the datelines, so we transform
                                // it back to the original
                                Geometry tx = JTS.transform(first.getGeometry(), sa.xform.inverse());
                                return getTransformedShape(RendererUtilities.getCentroid(tx), sa);
                            } else {
                                return getTransformedShape(RendererUtilities.getCentroid(g), null);
                            }
                        } else {
View Full Code Here

                    || !(geom.getFactory().getCoordinateSequenceFactory() instanceof LiteCoordinateSequenceFactory)) {
                int dim = sa.crs != null ? sa.crs.getCoordinateSystem().getDimension() : 2;
                geom = LiteCoordinateSequence.cloneGeometry(geom, dim);
            }

            LiteShape2 shape;
            if(projectionHandler != null && sa != null) {
                // first generalize and transform the geometry into the rendering CRS
                geom = projectionHandler.preProcess(geom);
                if(geom == null) {
                    shape = null;
                } else {
                    // first generalize and transform the geometry into the rendering CRS
                    Decimator d = getDecimator(sa.xform);
                    geom = d.decimateTransformGeneralize(geom, sa.rxform);
                    geom.geometryChanged();
                    // then post process it (provide reverse transform if available)
                    MathTransform reverse = null;
                    if (sa.crsxform != null) {
                        if (sa.crsxform instanceof ConcatenatedTransform
                                && ((ConcatenatedTransform) sa.crsxform).transform1
                                        .getTargetDimensions() >= 3
                                && ((ConcatenatedTransform) sa.crsxform).transform2
                                        .getTargetDimensions() == 2) {
                            reverse = null; // We are downcasting 3D data to 2D data so no inverse is available
                        } else {
                            try {
                                reverse = sa.crsxform.inverse();
                            } catch (Exception cannotReverse) {
                                reverse = null; // reverse transform not available
                            }
                        }
                    }
                    geom = projectionHandler.postProcess(reverse, geom);
                    if(geom == null) {
                        shape = null;
                    } else {
                        // apply the affine transform turning the coordinates into pixels
                        d = new Decimator(-1, -1);
                        geom = d.decimateTransformGeneralize(geom, sa.axform);
   
                        // wrap into a lite shape
                        geom.geometryChanged();
                        shape = new LiteShape2(geom, null, null, false, false);
                    }
                }
            } else {
                MathTransform xform = null;
                if (sa != null)
                    xform = sa.xform;
                shape = new LiteShape2(geom, xform, getDecimator(xform), false, false);
            }

            // cache the result
            geometries.add(originalGeom);
            shapes.add(shape);
View Full Code Here

        if(shape.getGeometry() instanceof MultiPolygon && shape.getGeometry().getNumGeometries() > 1) {
            MultiPolygon mp = (MultiPolygon) shape.getGeometry();
            for (int i = 0; i < mp.getNumGeometries(); i++) {
                Polygon p = (Polygon) mp.getGeometryN(i);
                try {
                    g.fill(new LiteShape2(p, null, null, false, false));
                } catch(Exception e) {
                    // should not really happen, but anyways
                    throw new RuntimeException("Unexpected error occurred while rendering a multipolygon", e);
                }
            }
View Full Code Here

                // only does anything if current stipple intersects the clip region
                if (!clipShape.intersects(translateX, translateY, stippleSize.getWidth(), stippleSize.getHeight()))
                    continue;
               
                // creates a LiteShape2 for the stipple and paints it
                LiteShape2 stippleShape = createStippleShape(stippleSize, translateX, translateY);
                paint(g, stippleShape, graphicFill, scale);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.jts.LiteShape2

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.