forked from geodmms/xdgnjobs

?? ?
2008-08-12 e08301c599a383107211d6aa051f4c42b0c9b250
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/TextElement.java
@@ -12,6 +12,7 @@
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;
@@ -230,6 +231,47 @@
        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();