| | |
| | | package com.ximple.eofms.filter; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.CoordinateArrays; |
| | | import com.vividsolutions.jts.geom.Envelope; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.Point; |
| | | import com.ximple.eofms.util.*; |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | |
| | | import org.opengis.feature.simple.SimpleFeatureType; |
| | | |
| | | import javax.swing.event.EventListenerList; |
| | | import java.awt.geom.AffineTransform; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | |
| | | } else { |
| | | gobj = txtElement.toGeometry(geometryFactory); |
| | | } |
| | | |
| | | if (gobj instanceof Point) { |
| | | Coordinate p = gobj.getCoordinate(); |
| | | double width = txtElement.getTextWidth(); |
| | | double height = txtElement.getTextHeight(); |
| | | |
| | | AffineTransform at = new AffineTransform(); |
| | | at.translate(width, height); |
| | | at.setToRotation(angle, p.x, p.y); |
| | | at.scale(1, 1); |
| | | |
| | | Envelope envelope = new Envelope(p); |
| | | envelope.expandBy(width / 2, height / 2); |
| | | |
| | | double[] srcPt = new double[8]; |
| | | double[] dstPt = new double[8]; |
| | | srcPt[0] = envelope.getMinX(); |
| | | srcPt[1] = envelope.getMinY(); |
| | | srcPt[2] = envelope.getMinX(); |
| | | srcPt[3] = envelope.getMaxY(); |
| | | srcPt[4] = envelope.getMaxX(); |
| | | srcPt[5] = envelope.getMaxY(); |
| | | srcPt[6] = envelope.getMaxX(); |
| | | srcPt[7] = envelope.getMinY(); |
| | | |
| | | at.transform(srcPt, 0, dstPt, 0, 4); |
| | | |
| | | Coordinate[] coords = new Coordinate[4]; |
| | | for (int i = 0; i < 4; i++) { |
| | | coords[i] = new Coordinate(dstPt[i*2], dstPt[i*2+1]); |
| | | } |
| | | int srid = gobj.getSRID(); |
| | | gobj = geometryFactory.createPolygon(geometryFactory.createLinearRing(coords), null); |
| | | if (gobj.getSRID() != srid) { |
| | | gobj.setSRID(srid); |
| | | } |
| | | } else { |
| | | gobj = null; |
| | | } |
| | | |
| | | if (gobj != null) |
| | | feature = SimpleFeatureBuilder.build(featureType, new Object[]{ |
| | | gobj, |