java.awt.geom.AffineTransform.inverseTransform()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中java.awt.geom.AffineTransform.inverseTransform()方法的一些代码示例,展示了AffineTransform.inverseTransform()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffineTransform.inverseTransform()方法的具体详情如下:
包路径:java.awt.geom.AffineTransform
类名称:AffineTransform
方法名:inverseTransform

AffineTransform.inverseTransform介绍

暂无

代码示例

代码示例来源:origin: dermotte/LIRE

@Override
public float[] applyInverse(float[] point) {
  // the brilliant java.awt.geom.AffineTransform implements transform for float[] but inverseTransform for double[] only...
  double[] double_point = new double[]{point[0], point[1]};
  double[] transformed = new double[2];
  try {
    affine.inverseTransform(double_point, 0, transformed, 0, 1);
  } catch (Exception e) {
    System.err.println("Noninvertible transformation.");
  }
  return new float[]{(float) transformed[0], (float) transformed[1]};
}

代码示例来源:origin: dermotte/LIRE

@Override
public float[] applyInverse(float[] point) {
  // the brilliant java.awt.geom.AffineTransform implements transform for float[] but inverseTransform for double[] only...
  double[] double_point = new double[]{point[0], point[1]};
  double[] transformed = new double[2];
  try {
    affine.inverseTransform(double_point, 0, transformed, 0, 1);
  } catch (Exception e) {
    System.err.println("Noninvertible transformation.");
  }
  return new float[]{(float) transformed[0], (float) transformed[1]};
}

代码示例来源:origin: dermotte/LIRE

@Override
public float[] applyInverse(float[] point) {
  // the brilliant java.awt.geom.AffineTransform implements transform for float[] but inverseTransform for double[] only...
  double[] double_point = new double[]{point[0], point[1]};
  double[] transformed = new double[2];
  try {
    affine.inverseTransform(double_point, 0, transformed, 0, 1);
  } catch (Exception e) {
    System.err.println("Noninvertible transformation.");
  }
  return new float[]{(float) transformed[0], (float) transformed[1]};
}

代码示例来源:origin: dermotte/LIRE

@Override
public float[] applyInverse(float[] point) {
  // the brilliant java.awt.geom.AffineTransform implements transform for float[] but inverseTransform for double[] only...
  double[] double_point = new double[]{point[0], point[1]};
  double[] transformed = new double[2];
  try {
    affine.inverseTransform(double_point, 0, transformed, 0, 1);
  } catch (Exception e) {
    System.err.println("Noninvertible transformation.");
  }
  return new float[]{(float) transformed[0], (float) transformed[1]};
}

代码示例来源:origin: geotools/geotools

/**
 * Inverse transforms a point using the {@link #global} affine transform, and make sure that the
 * result point is outside the grid. This method is used for the transformation of a point which
 * shouldn't be found in the grid.
 *
 * @param source The source coordinate point.
 * @param target The target coordinate point (should not be {@code null}).
 * @throws NoninvertibleTransformException if the transform is non-invertible.
 * @todo Current implementation project an inside point on the nearest border. Could we do
 *     something better?
 */
private void inverseTransform(final Point2D source, final Point2D.Double target)
    throws NoninvertibleTransformException {
  if (global.inverseTransform(source, target) != target) {
    throw new AssertionError(); // Should not happen.
  }
  double x = target.x;
  double y = target.y;
  if (x >= 0 && x < width && y >= 0 && y < height) {
    // Project on the nearest border. TODO: Could we do something better here?
    x -= 0.5 * width;
    y -= 0.5 * height;
    if (Math.abs(x) < Math.abs(y)) {
      target.x = x > 0 ? width : -1;
    } else {
      target.y = y > 0 ? height : -1;
    }
  }
}

代码示例来源:origin: geotools/geotools

point.x = (i & 1) == 0 ? bounds.getMinX() : bounds.getMaxX();
point.y = (i & 2) == 0 ? bounds.getMinY() : bounds.getMaxY();
transform.inverseTransform(point, point);
if (point.x < xmin) xmin = point.x;
if (point.x > xmax) xmax = point.x;

代码示例来源:origin: geotools/geotools

/**
 * Transform a point using the localization grid, transform it back using the inverse of the
 * specified affine transform, and returns the distance between the source and the resulting
 * point. This is used for assertions only.
 *
 * @param index The source point to test.
 * @param tr The affine transform to test.
 * @return The distance in grid coordinate. Should be close to 0.
 */
private double distance(final Point2D index, final AffineTransform tr) {
  try {
    Point2D geoCoord = transform(index, null);
    geoCoord = tr.inverseTransform(geoCoord, geoCoord);
    return geoCoord.distance(index);
  } catch (TransformException exception) {
    // Should not happen
    throw new AssertionError(exception);
  } catch (NoninvertibleTransformException exception) {
    // Not impossible. What should we do? Open question...
    throw new AssertionError(exception);
  }
}

代码示例来源:origin: geotools/geotools

pts[6] = paintArea.getMinX();
pts[7] = paintArea.getMaxY();
worldToScreen.inverseTransform(pts, 0, pts, 0, 4);
double xMin = Double.MAX_VALUE;
double yMin = Double.MAX_VALUE;

代码示例来源:origin: geotools/geotools

pts[6] = paintArea.getMinX();
pts[7] = paintArea.getMaxY();
worldToScreen.inverseTransform(pts, 0, pts, 0, 4);
double xMin = Double.MAX_VALUE;
double yMin = Double.MAX_VALUE;

代码示例来源:origin: geotools/geotools

tr.inverseTransform(source, target);
int previousX = (int) target.x;
int previousY = (int) target.y;
for (int iter = 0; iter < MAX_ITER; iter++) {
  getAffineTransform(target.x, target.y, tr);
  tr.inverseTransform(source, target);
  final int ix = (int) target.x;
  final int iy = (int) target.y;
global.inverseTransform(source, target);
double x, y;
double bestX = x = target.x;
  previousY = (int) y;
  getAffineTransform(x, y, tr);
  tr.inverseTransform(source, target);
  x = target.x;
  y = target.y;

代码示例来源:origin: geotools/geotools

Point2D screenPos = new Point2D.Double(x, y);
Point2D worldPos = new Point2D.Double(x, y);
at.inverseTransform(screenPos, worldPos);
DirectPosition2D fromPos = new DirectPosition2D(worldPos.getX(), worldPos.getY());
DirectPosition2D toPos = new DirectPosition2D();

代码示例来源:origin: com.github.kzwang/lire

@Override
public float[] applyInverse(float[] point) {
  // the brilliant java.awt.geom.AffineTransform implements transform for float[] but inverseTransform for double[] only...
  double[] double_point = new double[]{point[0], point[1]};
  double[] transformed = new double[2];
  try {
    affine.inverseTransform(double_point, 0, transformed, 0, 1);
  } catch (Exception e) {
    System.err.println("Noninvertible transformation.");
  }
  return new float[]{(float) transformed[0], (float) transformed[1]};
}

代码示例来源:origin: com.github.kzwang/lire

@Override
public float[] applyInverse(float[] point) {
  // the brilliant java.awt.geom.AffineTransform implements transform for float[] but inverseTransform for double[] only...
  double[] double_point = new double[]{point[0], point[1]};
  double[] transformed = new double[2];
  try {
    affine.inverseTransform(double_point, 0, transformed, 0, 1);
  } catch (Exception e) {
    System.err.println("Noninvertible transformation.");
  }
  return new float[]{(float) transformed[0], (float) transformed[1]};
}

代码示例来源:origin: geotools/geotools

point2D.x = x;
point2D.y = y;
crsToGrid.inverseTransform(point2D, point2D);
if (area == null || area.contains(point2D)) {
  coordinate.ordinates[xAxis] = point2D.x;

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

@Override
public Point2D inverseTransform(final Point2D point) throws NoninvertibleTransformException {
 final Point2D transformedPoint = new Point2D.Double();
 getAffinTransform().inverseTransform(point, transformedPoint);
 return transformedPoint;
}

代码示例来源:origin: sc.fiji/TrakEM2_

public Point2D.Double inverseTransformPoint(final double px, final double py) {
  final Point2D.Double pSrc = new Point2D.Double(px, py);
  if (this.at.isIdentity()) return pSrc;
  final Point2D.Double pDst = new Point2D.Double();
  try {
    //this.at.createInverse().transform(pSrc, pDst);
    this.at.inverseTransform(pSrc, pDst);
  } catch (NoninvertibleTransformException nite) {
    IJError.print(nite);
  }
  return pDst;
}

代码示例来源:origin: hneemann/Digital

private Vector getPosVector(int x, int y) {
  try {
    Point2D.Double p = new Point2D.Double();
    transform.inverseTransform(new Point(x, y), p);
    return new Vector((int) Math.round(p.getX()), (int) Math.round(p.getY()));
  } catch (NoninvertibleTransformException e1) {
    throw new RuntimeException(e1);
  }
}

代码示例来源:origin: hneemann/Digital

private Vector getPosVector(int x, int y) {
  try {
    Point2D.Double p = new Point2D.Double();
    transform.inverseTransform(new Point(x, y), p);
    return new Vector((int) Math.round(p.getX()), (int) Math.round(p.getY()));
  } catch (NoninvertibleTransformException e1) {
    throw new RuntimeException(e1);
  }
}

代码示例来源:origin: movsim/movsim

static Point2D getTransformed(Point point, AffineTransform transform) throws NoninvertibleTransformException {
  final Point2D transformedPoint = new Point2D.Float();
  // convert from mouse coordinates to vehicle coordinates
  transform.inverseTransform(new Point2D.Float(point.x, point.y), transformedPoint);
  return transformedPoint;
}

代码示例来源:origin: JChemPaint/jchempaint

public Point2d toModelCoordinates(double screenX, double screenY) {
  try {
    double[] dest = new double[2];
    double[] src = new double[] { screenX, screenY };
    transform.inverseTransform(src, 0, dest, 0, 1);
    return new Point2d(dest[0], dest[1]);
  } catch (NoninvertibleTransformException n) {
    return new Point2d(0,0);
  }
}

相关文章