Package org.geotools.geometry.jts

Examples of org.geotools.geometry.jts.LiteShape2


  @Override
  public void draw(Graphics2D graphics, MapContent map, MapViewport viewport) {
    MathTransform worldtoScreen = createAffineTransform(viewport);
    for (Geometry geometry : geometries) {
      LiteShape2 shape;
      try {
        Geometry screenGeom = JTS.transform(geometry, worldtoScreen);
        shape = new LiteShape2(screenGeom, null, null, false);
        NumberRange<Double> range = NumberRange.create(0d, 100d);

        Style2D style2D = styleFactory.createStyle(null, style.featureTypeStyles().get(0).rules().get(0)
            .symbolizers().get(0), range);
        painter.paint(graphics, shape, style2D, 1d);
View Full Code Here


          RescaleStyleVisitor rescaler = new RescaleStyleVisitor(scale);
          rescaler.visit(symbolizer);
          rescaled = (Symbolizer) rescaler.getCopy();
        }
        Style2D style2d = styleFactory.createStyle(sample, rescaled, scaleRange);
        LiteShape2 shape = createShape(symbolizer, w, h);
        if (style2d != null) {
          STYLED_SHAPE_PAINTER.paint(g2d, shape, style2d, 1.0);
        }
      }
    }
View Full Code Here

          coords.add(new Coordinate(0.75 * w, 0.25 * h));
          coords.add(new Coordinate(0.25 * w, 0.75 * h));
          coords.add(new Coordinate(w, h));
          LineString linestring = geometryFactory.createLineString(
              coords.toArray(new Coordinate[coords.size()]));
          line = new LiteShape2(linestring, null, null, false);
        }
        return line;
      } else if (symbolizer instanceof PolygonSymbolizer) {
        if (polygon == null) {
          List<Coordinate> coords = new ArrayList<Coordinate>();
          coords.add(new Coordinate(0, 0));
          coords.add(new Coordinate(w, 0));
          coords.add(new Coordinate(w, h));
          coords.add(new Coordinate(0, h));
          coords.add(new Coordinate(0, 0));
          LinearRing ring = geometryFactory.createLinearRing(coords.toArray(new Coordinate[coords.size()]));
          Polygon p = geometryFactory.createPolygon(ring, null);
          polygon = new LiteShape2(p, null, null, false);
        }
        return polygon;
      } else if (symbolizer instanceof PointSymbolizer) {
        if (point == null) {
          Coordinate coord = new Coordinate(w / 2, h / 2);
          Point p = geometryFactory.createPoint(coord);
          point = new LiteShape2(p, null, null, false);
        }
        return point;
      } else {
        return null;
      }
View Full Code Here

            MathTransform transform = CRS.findMathTransform(crs, getCRS(), true);
            MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
            MathTransform toScreen = factory.createAffineTransform(new GeneralMatrix(
                    worldToScreenTransform()));
            transform = factory.createConcatenatedTransform(transform, toScreen);
            return new LiteShape2(geometry, transform, new Decimator(transform), false);
        } catch (FactoryException e) {
            return null;
        } catch( TransformException e){
            return null;
        }
View Full Code Here

                            "It is not legal to have a RasterSymbolizer here"
                            );
                } else {
                    Style2D style2d =
                        styleFactory.createStyle(sampleFeature, symbolizer, scaleRange);
                    LiteShape2 shape = getSampleShape(symbolizer, w, h);

                    if (style2d != null) {
                        shapePainter.paint(g2d, shape, style2d, scaleDenominator);
                    }
                }
View Full Code Here

     *
     * @throws IllegalArgumentException if an unknown symbolizer impl was
     *         passed in.
     */
    private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth, int legendHeight) {
        LiteShape2 sampleShape;
        final float hpad = (legendWidth * LegendUtils.hpaddingFactor);
        final float vpad = (legendHeight * LegendUtils.vpaddingFactor);

        if (symbolizer instanceof LineSymbolizer) {
            if (this.sampleLine == null) {
                Coordinate[] coords = {
                        new Coordinate(hpad, legendHeight - vpad),
                        new Coordinate(legendWidth - hpad, vpad)
                    };
                LineString geom = geomFac.createLineString(coords);

                try {
                    this.sampleLine = new LiteShape2(geom, null, null, false);
                } catch (Exception e) {
                    this.sampleLine = null;
                }
            }

            sampleShape = this.sampleLine;
        } else if ((symbolizer instanceof PolygonSymbolizer)
                || (symbolizer instanceof RasterSymbolizer)) {
            if (this.sampleRect == null) {
                final float w = legendWidth - (2 * hpad);
                final float h = legendHeight - (2 * vpad);

                Coordinate[] coords = {
                        new Coordinate(hpad, vpad), new Coordinate(hpad, vpad + h),
                        new Coordinate(hpad + w, vpad + h), new Coordinate(hpad + w, vpad),
                        new Coordinate(hpad, vpad)
                    };
                LinearRing shell = geomFac.createLinearRing(coords);
                Polygon geom = geomFac.createPolygon(shell, null);

                try {
                    this.sampleRect = new LiteShape2(geom, null, null, false);
                } catch (Exception e) {
                    this.sampleRect = null;
                }
            }

            sampleShape = this.sampleRect;
        } else if (symbolizer instanceof PointSymbolizer || symbolizer instanceof TextSymbolizer) {
            if (this.samplePoint == null) {
                Coordinate coord = new Coordinate(legendWidth / 2, legendHeight / 2);

                try {
                    this.samplePoint = new LiteShape2(geomFac.createPoint(coord), null, null, false);
                } catch (Exception e) {
                    this.samplePoint = null;
                }
            }

View Full Code Here

                if (symbolizer instanceof RasterSymbolizer) {
                   throw new IllegalStateException("It is not legal to have a RasterSymbolizer here");
                } else {
                    Style2D style2d = styleFactory.createStyle(sampleFeature, symbolizer, scaleRange);
                    LiteShape2 shape = getSampleShape(symbolizer, w, h);

                    if (style2d != null) {
                        shapePainter.paint(graphics, shape, style2d, scaleDenominator);
                    }
                }
View Full Code Here

     *
     * @throws IllegalArgumentException if an unknown symbolizer impl was
     *         passed in.
     */
    private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth, int legendHeight) {
        LiteShape2 sampleShape;
        final float hpad = (legendWidth * LegendUtils.hpaddingFactor);
        final float vpad = (legendHeight * LegendUtils.vpaddingFactor);

        if (symbolizer instanceof LineSymbolizer) {
            if (this.sampleLine == null) {
                Coordinate[] coords = {
                        new Coordinate(hpad, legendHeight - vpad),
                        new Coordinate(legendWidth - hpad, vpad)
                    };
                LineString geom = geomFac.createLineString(coords);

                try {
                    this.sampleLine = new LiteShape2(geom, null, null, false);
                } catch (Exception e) {
                    this.sampleLine = null;
                }
            }

            sampleShape = this.sampleLine;
        } else if ((symbolizer instanceof PolygonSymbolizer)
                || (symbolizer instanceof RasterSymbolizer)) {
            if (this.sampleRect == null) {
                final float w = legendWidth - (2 * hpad);
                final float h = legendHeight - (2 * vpad);

                Coordinate[] coords = {
                        new Coordinate(hpad, vpad), new Coordinate(hpad, vpad + h),
                        new Coordinate(hpad + w, vpad + h), new Coordinate(hpad + w, vpad),
                        new Coordinate(hpad, vpad)
                    };
                LinearRing shell = geomFac.createLinearRing(coords);
                Polygon geom = geomFac.createPolygon(shell, null);

                try {
                    this.sampleRect = new LiteShape2(geom, null, null, false);
                } catch (Exception e) {
                    this.sampleRect = null;
                }
            }

            sampleShape = this.sampleRect;
        } else if (symbolizer instanceof PointSymbolizer || symbolizer instanceof TextSymbolizer) {
            if (this.samplePoint == null) {
                Coordinate coord = new Coordinate(legendWidth / 2, legendHeight / 2);

                try {
                    this.samplePoint = new LiteShape2(geomFac.createPoint(coord), null, null, false);
                } catch (Exception e) {
                    this.samplePoint = null;
                }
            }

View Full Code Here

                new FontRenderContext(new AffineTransform(),
                        RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT,
                        RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT));
        style = new TextStyle2D();
        style.setFont(new Font("Serif", Font.PLAIN, 10));
        shape = new LiteShape2(
                geometryFactory.createPoint(new Coordinate(10, 10)),
                ProjectiveTransform.create(new AffineTransform()), null, false);
        symbolizer = styleFactory.createTextSymbolizer();
    }
View Full Code Here

    public void testSimpleGrouping() throws Exception {
        TextSymbolizer ts = sb.createTextSymbolizer(Color.BLACK, (Font) null, "name");
        ts.getOptions().put(TextSymbolizer.GROUP_KEY, "true");
        SimpleFeature f1 = createFeature("label1", L1);
        SimpleFeature f2 = createFeature("label1", L2);
        cache.put(LAYER_ID, ts, 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);

        // we have just one
        List<LabelCacheItem> labels = cache.getActiveLabels();
        assertEquals(1, labels.size());
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.