@Override public void paintReservedAreas(Graphics2D g2d) { g2d.setStroke(new BasicStroke(0.5f)); g2d.setColor(Color.LIGHT_GRAY); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.XOR)); for (Object bound : qt.queryAll()) { LiteShape ls = new LiteShape((Geometry) bound, new AffineTransform(), false); g2d.draw(ls); } } }
LiteShape shape = new LiteShape(reader.read(wkt), null, false); LOGGER.info("Created symbol from WKT " + wkt); return shape;
LiteShape shape = new LiteShape(geometry, null, false); Shape projectedShape = w2gTransform.createTransformedShape(shape); boolean added = false;
gr.draw(new LiteShape(boundsPoly, at, false)); gr.setStroke(new BasicStroke(0.5f)); gr.setColor(Color.BLUE); gr.draw(new LiteShape(original, at, false)); if (clipped != null) { gr.setStroke(new BasicStroke(2)); if (clipped instanceof Polygon || clipped instanceof MultiPolygon) { gr.setColor(Color.LIGHT_GRAY); gr.fill(new LiteShape(clipped, at, false)); gr.setColor(Color.BLUE); gr.draw(new LiteShape(clipped, at, false));
/** * Given the portion of the linestring associated with the label and label metrics, this method * will compute a proper underline. * * @param lineOffset TODO */ private LiteShape computeCurvedLine(LineString labelLineString, float lineOffset) { Coordinate[] coordinates = labelLineString.getCoordinates(); Coordinate[] parallelCoordinates = new Coordinate[coordinates.length]; double anchorOffset = getLinePlacementYAnchor() * getLineHeight(); for (int i = 0; i < coordinates.length - 1; i++) { // let's compute some basic info for the current segment Coordinate coordinateA = coordinates[i]; Coordinate coordinateB = coordinates[i + 1]; double dx = coordinateB.x - coordinateA.x; double dy = coordinateB.y - coordinateA.y; double length = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); double offset = -(anchorOffset + lineOffset); // compute the parallel coordinates double x1 = coordinateA.x + offset * (coordinateB.y - coordinateA.y) / length; double x2 = coordinateB.x + offset * (coordinateB.y - coordinateA.y) / length; double y1 = coordinateA.y + offset * (coordinateA.x - coordinateB.x) / length; double y2 = coordinateB.y + offset * (coordinateA.x - coordinateB.x) / length; parallelCoordinates[i] = new Coordinate(x1, y1); parallelCoordinates[i + 1] = new Coordinate(x2, y2); } // build the parallel linestring and wrap it in a lite shape LineString lineString = labelLineString.getFactory().createLineString(parallelCoordinates); return new LiteShape(lineString, null, true); }
public void drawFeature( BufferedImage bi, SimpleFeature feature, AffineTransform worldToScreenTransform, boolean drawVertices, Symbolizer symbolizer, MathTransform mathTransform, LiteShape shape) { Graphics graphics = bi.getGraphics(); if (!(symbolizer instanceof RasterSymbolizer)) { Geometry g = findGeometry(feature, symbolizer); if (g == null) return; if (mathTransform != null) { try { g = JTS.transform(g, mathTransform); } catch (Exception e) { // do nothing } } shape.setGeometry(g); paint(bi, feature, shape, symbolizer); if (drawVertices) { double averageDistance = 0; Coordinate[] coords = g.getCoordinates(); java.awt.Point oldP = worldToPixel(coords[0], worldToScreenTransform); for (int i = 1; i < coords.length; i++) { Coordinate coord = coords[i];
public void testLineShape() throws TransformException, FactoryException { GeometryFactory geomFac = new GeometryFactory(); LineString lineString = makeSampleLineString(geomFac, 0, 0); AffineTransform affineTransform = new AffineTransform(); LiteShape lineShape = new LiteShape(lineString, affineTransform, false); assertFalse(lineShape.contains(0, 0)); assertTrue(lineShape.contains(60, 60)); assertFalse(lineShape.contains(50, 50, 10, 10)); assertTrue(lineShape.contains(new java.awt.Point(60, 60))); assertFalse(lineShape.contains(new java.awt.geom.Rectangle2D.Float(50, 50, 10, 10))); assertTrue(lineShape.getBounds2D().equals(new Rectangle2D.Double(50, 50, 80, 250))); assertTrue(lineShape.getBounds().equals(new java.awt.Rectangle(50, 50, 80, 250))); assertTrue(lineShape.intersects(0, 0, 100, 100)); assertTrue(lineShape.intersects(new Rectangle2D.Double(0, 0, 100, 100))); assertFalse(lineShape.intersects(55, 55, 3, 100)); assertFalse(lineShape.intersects(new Rectangle2D.Double(55, 55, 3, 100))); }
public void drawFeature(BufferedImage bi, SimpleFeature feature, AffineTransform worldToScreenTransform, boolean drawVertices, Symbolizer[] symbs, MathTransform mt ) { LiteShape shape = new LiteShape(null, worldToScreenTransform, false); if( symbs==null ) return; for( int m = 0; m < symbs.length; m++ ) { drawFeature(bi, feature, worldToScreenTransform, drawVertices, symbs[m], mt, shape); } }
Shape shape = new LiteShape(bufferedGeomInGridCrs, IDENTITY, generalize);
Shape shape = new LiteShape(bufferedGeomInGridCrs, IDENTITY, generalize);