List of usage examples for java.awt.geom AffineTransform transform
public Point2D transform(Point2D ptSrc, Point2D ptDst)
From source file:org.uva.itast.blended.omr.pages.PageImage.java
/** * Use alignment information to transform from milimeters to pixel coordinates at the preferred resolution for this page * @param x/*from w w w. j a v a 2 s.com*/ * @return */ public Point toPixels(double x, double y) { AffineTransform alignment = getAllignmentInfo(); Point2D coord = new Point2D.Double(x, y); Point coordTransformed = new Point(); alignment.transform(coord, coordTransformed); return coordTransformed; }
From source file:org.uva.itast.blended.omr.pages.PageImage.java
public Point toPixelsPoint(double x, double y) { AffineTransform alignment = getAllignmentInfo(); alignment.setToScale(getPreferredHorizontalResolution(), getPreferredVerticalResolution()); Point2D coord = new Point2D.Double(x, y); Point coordTransformed = new Point(); alignment.transform(coord, coordTransformed); return coordTransformed; }
From source file:org.uva.itast.blended.omr.pages.PageImage.java
/** * Convert from pixel-space to paper-space. * Paper-space refers to logical area of the paper in the image. * Pixel-space refers to entire area of the image that contains the image of the paper. (Maybe with offset and rotation) * @param i/*www.ja v a2 s. co m*/ * @param j * @return * @throws NoninvertibleTransformException */ public Point2D toMilimeters(int i, int j) { try { AffineTransform tr = getAllignmentInfo(); AffineTransform inv; inv = tr.createInverse(); Point2D pixeles = new Point(i, j); Point2D dest = new Point2D.Double(); return inv.transform(pixeles, dest); } catch (NoninvertibleTransformException e) { throw new RuntimeException("error page definition.", e); } }
From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java
private static AffineTransform findTranslation(AffineTransform at, BufferedImage bi) { Point2D p2din, p2dout;// ww w . j a va2s . c om p2din = new Point2D.Double(0.0, 0.0); p2dout = at.transform(p2din, null); double ytrans = p2dout.getY(); p2din = new Point2D.Double(0, bi.getHeight()); p2dout = at.transform(p2din, null); double xtrans = p2dout.getX(); AffineTransform tat = new AffineTransform(); tat.translate(-xtrans, -ytrans); return tat; }
From source file:tufts.vue.LWComponent.java
/** @return our shape, full transformed into map coords and ultimate scale when drawn at 100% map zoom * this is used for portal clipping, and will be imperfect for some scaled shapes, such as RountRect's * This only works for raw shapes that are RectangularShapes -- other Shape types just return the bounding * box in map coordinates (e.g., a link shape) *///from ww w . j a va 2s .c o m public RectangularShape getMapShape() { // Will not work for shapes like RoundRect when scaled -- e..g, corner scaling will be off final Shape s = getZeroShape(); // if (getMapScale() != 1f && s instanceof RectangularShape) { // todo: do if any transform, not just scale if (s instanceof RectangularShape) { // todo: cache this: only need to updaate if location, size or scale changes // (Also, on the scale or location change of any parent!) RectangularShape rshape = (RectangularShape) s; rshape = (RectangularShape) rshape.clone(); AffineTransform a = getZeroTransform(); Point2D.Float loc = new Point2D.Float(); a.transform(loc, loc); rshape.setFrame(loc.x, loc.y, rshape.getWidth() * a.getScaleX(), rshape.getHeight() * a.getScaleY()); //System.out.println("TRANSFORMED SHAPE: " + rshape + " for " + this); return rshape; } else { return getMapBounds(); } }