| | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | import com.vividsolutions.jts.geom.CoordinateList; |
| | | |
| | | import com.ximple.util.DgnUtility; |
| | | |
| | |
| | | return factory.createPoint(getUserOrigin()); |
| | | } |
| | | |
| | | public Geometry toAnchorGeometry(GeometryFactory factory) |
| | | { |
| | | if (getText() == null) |
| | | { |
| | | return factory.createMultiPoint(new Coordinate[] {}); |
| | | } |
| | | |
| | | return factory.createMultiPoint(toAnchorCoordinates()); |
| | | } |
| | | |
| | | public Coordinate[] toAnchorCoordinates() |
| | | { |
| | | CoordinateList result = new CoordinateList(); |
| | | int len = getText().trim().length(); |
| | | if (len == 0) return result.toCoordinateArray(); |
| | | |
| | | double width = getUserWidth(); |
| | | double height = getUserHeight(); |
| | | double angle = Math.toRadians(getRotationAngle()); |
| | | |
| | | AffineTransform at = new AffineTransform(); |
| | | at.translate(width, height); |
| | | Coordinate p = getOrigin(); |
| | | at.setToRotation(angle, p.x, p.y); |
| | | at.scale(1, 1); |
| | | |
| | | for (int i = 0; i < len; i++) |
| | | { |
| | | double[] srcPt = new double[2]; |
| | | double[] dstPt = new double[2]; |
| | | |
| | | srcPt[0] = p.x + width * i; |
| | | srcPt[1] = p.y; |
| | | |
| | | at.transform(srcPt, 0, dstPt, 0, 1); |
| | | result.add(new Coordinate(dstPt[0], dstPt[1]), true); |
| | | } |
| | | |
| | | return result.toCoordinateArray(); |
| | | } |
| | | |
| | | private double getUserWidth() |
| | | { |
| | | int just = getJustification(); |