1234 |
public Point2D inverseTransform(Point2D src, Point2D dst) |
public Point2D inverseTransform(Point2D src, Point2D dst) |
1235 |
throws NoninvertibleTransformException |
throws NoninvertibleTransformException |
1236 |
{ |
{ |
1237 |
double det = getDeterminant(); |
return createInverse().transform(src, dst); |
|
if (det == 0) |
|
|
throw new NoninvertibleTransformException("couldn't invert transform"); |
|
|
if (dst == null) |
|
|
dst = new Point2D.Double(); |
|
|
double x = src.getX(); |
|
|
double y = src.getY(); |
|
|
double nx = (m11 * x + -m10 * y) / det - m02; |
|
|
double ny = (m01 * x + -m00 * y) / det - m12; |
|
|
dst.setLocation(nx, ny); |
|
|
return dst; |
|
1238 |
} |
} |
1239 |
|
|
1240 |
/** |
/** |
1258 |
double[] dstPts, int dstOff, int num) |
double[] dstPts, int dstOff, int num) |
1259 |
throws NoninvertibleTransformException |
throws NoninvertibleTransformException |
1260 |
{ |
{ |
1261 |
double det = getDeterminant(); |
createInverse().transform(srcPts, srcOff, dstPts, dstOff, num); |
|
if (det == 0) |
|
|
throw new NoninvertibleTransformException("couldn't invert transform"); |
|
|
if (srcPts == dstPts && dstOff > srcOff |
|
|
&& num > 1 && srcOff + 2 * num > dstOff) |
|
|
{ |
|
|
double[] d = new double[2 * num]; |
|
|
System.arraycopy(srcPts, srcOff, d, 0, 2 * num); |
|
|
srcPts = d; |
|
|
} |
|
|
while (--num >= 0) |
|
|
{ |
|
|
double x = srcPts[srcOff++]; |
|
|
double y = srcPts[srcOff++]; |
|
|
dstPts[dstOff++] = (m11 * x + -m10 * y) / det - m02; |
|
|
dstPts[dstOff++] = (m01 * x + -m00 * y) / det - m12; |
|
|
} |
|
1262 |
} |
} |
1263 |
|
|
1264 |
/** |
/** |
1333 |
* which only stores points in float precision. |
* which only stores points in float precision. |
1334 |
* |
* |
1335 |
* @param src the shape source to transform |
* @param src the shape source to transform |
1336 |
* @return the shape, transformed by this |
* @return the shape, transformed by this, <code>null</code> if src is |
1337 |
* @throws NullPointerException if src is null |
* <code>null</code>. |
1338 |
* @see GeneralPath#transform(AffineTransform) |
* @see GeneralPath#transform(AffineTransform) |
1339 |
*/ |
*/ |
1340 |
public Shape createTransformedShape(Shape src) |
public Shape createTransformedShape(Shape src) |
1341 |
{ |
{ |
1342 |
|
if(src == null) |
1343 |
|
return null; |
1344 |
GeneralPath p = new GeneralPath(src); |
GeneralPath p = new GeneralPath(src); |
1345 |
p.transform(this); |
p.transform(this); |
1346 |
return p; |
return p; |