@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); } } }
return getPathIterator(at);
/** * Converts the Rectangle2D passed as parameter in a jts Geometry object * * @param r the rectangle to be converted * @return a geometry with the same vertices as the rectangle */ private Geometry rectangleToGeometry(Rectangle2D r) { return createRectangle(r.getMinX(), r.getMinY(), r.getWidth(), r.getHeight()); }
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))); }
shape.setGeometry(g);
/** * Tests if the interior of the <code>Shape</code> intersects the interior of a specified <code> * Rectangle2D</code>. This method might conservatively return <code>true</code> when: * * <ul> * <li>there is a high probability that the <code>Rectangle2D</code> and the <code>Shape * </code> intersect, but * <li>the calculations to accurately determine this intersection are prohibitively expensive. * </ul> * * This means that this method might return <code>true</code> even though the <code>Rectangle2D * </code> does not intersect the <code>Shape</code>. * * @param r the specified <code>Rectangle2D</code> * @return <code>true</code> if the interior of the <code>Shape</code> and the interior of the * specified <code>Rectangle2D</code> intersect, or are both highly likely to intersect and * intersection calculations would be too expensive to perform; <code>false</code> * otherwise. * @see #intersects(double, double, double, double) */ public boolean intersects(Rectangle2D r) { Geometry rect = rectangleToGeometry(r); return geometry.intersects(rect); }
/** * Creates a new LiteShape object. * * @param geom - the wrapped geometry * @param at - the transformation applied to the geometry in order to get to the shape points * @param generalize - set to true if the geometry need to be generalized during rendering */ public LiteShape(Geometry geom, AffineTransform at, boolean generalize) { if (geom != null) this.geometry = getGeometryFactory().createGeometry(geom); this.affineTransform = at; this.generalize = generalize; if (at == null) { yScale = xScale = 1; return; } xScale = (float) Math.sqrt( (at.getScaleX() * at.getScaleX()) + (at.getShearX() * at.getShearX())); yScale = (float) Math.sqrt( (at.getScaleY() * at.getScaleY()) + (at.getShearY() * at.getShearY())); }
/** * Tests if the interior of the <code>Shape</code> entirely contains the specified <code> * Rectangle2D</code>. This method might conservatively return <code>false</code> when: * * <ul> * <li>the <code>intersect</code> method returns <code>true</code> and * <li>the calculations to determine whether or not the <code>Shape</code> entirely contains * the <code>Rectangle2D</code> are prohibitively expensive. * </ul> * * This means that this method might return <code>false</code> even though the <code>Shape * </code> contains the <code>Rectangle2D</code>. The <code>Area</code> class can be used to * perform more accurate computations of geometric intersection for any <code>Shape</code> * object if a more precise answer is required. * * @param r The specified <code>Rectangle2D</code> * @return <code>true</code> if the interior of the <code>Shape</code> entirely contains the * <code>Rectangle2D</code>; <code>false</code> otherwise or, if the <code>Shape</code> * contains the <code>Rectangle2D</code> and the <code>intersects</code> method returns * <code>true</code> and the containment calculations would be too expensive to perform. * @see #contains(double, double, double, double) */ public boolean contains(Rectangle2D r) { Geometry rect = rectangleToGeometry(r); return geometry.contains(rect); }
/** * Creates a new LiteShape object. * * @param geom - the wrapped geometry * @param at - the transformation applied to the geometry in order to get to the shape points * @param generalize - set to true if the geometry need to be generalized * during rendering * */ public LiteShape(Geometry geom, AffineTransform at, boolean generalize) { if( geom!=null) this.geometry =getGeometryFactory().createGeometry(geom); this.affineTransform = at; this.generalize = generalize; if (at==null){ yScale=xScale=1; return; } xScale = (float) Math.sqrt( (at.getScaleX() * at.getScaleX()) + (at.getShearX() * at.getShearX())); yScale = (float) Math.sqrt( (at.getScaleY() * at.getScaleY()) + (at.getShearY() * at.getShearY())); }
LiteShape shape = new LiteShape(reader.read(wkt), null, false); LOGGER.info("Created symbol from WKT " + wkt); return shape;
@Override public PathIterator getPathIterator(AffineTransform at) { return new TranslatedIterator(super.getPathIterator(at)); }
Geometry rect = createRectangle(x, y, w, h);
Geometry rect = rectangleToGeometry(r);
/** * Creates a new LiteShape object. * * @param geom - the wrapped geometry * @param at - the transformation applied to the geometry in order to get to the shape points * @param generalize - set to true if the geometry need to be generalized * during rendering * */ public LiteShape(Geometry geom, AffineTransform at, boolean generalize) { if( geom!=null) this.geometry =getGeometryFactory().createGeometry(geom); this.affineTransform = at; this.generalize = generalize; if (at==null){ yScale=xScale=1; return; } xScale = (float) Math.sqrt( (at.getScaleX() * at.getScaleX()) + (at.getShearX() * at.getShearX())); yScale = (float) Math.sqrt( (at.getScaleY() * at.getScaleY()) + (at.getShearY() * at.getShearY())); }
LiteShape shape = new LiteShape(geometry, null, false); Shape projectedShape = w2gTransform.createTransformedShape(shape); boolean added = false;
shape.getPathIterator(null).currentSegment(point); SLDStyleFactory styleFactory = new SLDStyleFactory(); Style2D tmp =
Geometry rect = createRectangle(x, y, w, h);
Geometry rect = rectangleToGeometry(r);
/** * 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); }
return getPathIterator(at);