/** * Returns a path which represents this rectangle having been transformed by the given matrix. * Note that the resulting path need not be rectangular. */ public GeneralPath transform(Matrix matrix) { float x1 = getLowerLeftX(); float y1 = getLowerLeftY(); float x2 = getUpperRightX(); float y2 = getUpperRightY(); Point2D.Float p0 = matrix.transformPoint(x1, y1); Point2D.Float p1 = matrix.transformPoint(x2, y1); Point2D.Float p2 = matrix.transformPoint(x2, y2); Point2D.Float p3 = matrix.transformPoint(x1, y2); GeneralPath path = new GeneralPath(); path.moveTo(p0.getX(), p0.getY()); path.lineTo(p1.getX(), p1.getY()); path.lineTo(p2.getX(), p2.getY()); path.lineTo(p3.getX(), p3.getY()); path.closePath(); return path; }
float dstY = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax()); LOG.debug("coord: " + String.format("[%06X,%06X] -> [%f,%f]", x, y, dstX, dstY)); Point2D p = matrix.transformPoint(dstX, dstY); xform.transform(p, p);
float px = interpolate(x, maxSrcCoord, rangeX.getMin(), rangeX.getMax()); float py = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax()); Point2D p = matrix.transformPoint(px, py); xform.transform(p, p); points[i] = p;
if (font instanceof PDType3Font) height = font.getFontMatrix().transformPoint(0, glyphHeight).y;
Point2D.Float point2D = matrix.transformPoint(rect.getWidth(), rect.getHeight());
bbox = new PDRectangle(-rd, -rd, rect.getWidth() + 2 * rd, rect.getHeight() + 2 * rd); Matrix matrix = annotation.getNormalAppearanceStream().getMatrix(); matrix.transformPoint(rd, rd); annotation.getNormalAppearanceStream().setMatrix(matrix.createAffineTransform()); PDRectangle rect2 = new PDRectangle(rect.getLowerLeftX() - rd, rect.getLowerLeftY() - rd,
/** * Returns a path which represents this rectangle having been transformed by the given matrix. * Note that the resulting path need not be rectangular. */ public GeneralPath transform(Matrix matrix) { float x1 = getLowerLeftX(); float y1 = getLowerLeftY(); float x2 = getUpperRightX(); float y2 = getUpperRightY(); Point2D.Float p0 = matrix.transformPoint(x1, y1); Point2D.Float p1 = matrix.transformPoint(x2, y1); Point2D.Float p2 = matrix.transformPoint(x2, y2); Point2D.Float p3 = matrix.transformPoint(x1, y2); GeneralPath path = new GeneralPath(); path.moveTo(p0.getX(), p0.getY()); path.lineTo(p1.getX(), p1.getY()); path.lineTo(p2.getX(), p2.getY()); path.lineTo(p3.getX(), p3.getY()); path.closePath(); return path; }
/** * Returns a path which represents this rectangle having been transformed by the given matrix. Note that the * resulting path need not be rectangular. * * @param matrix the matrix to be used for the transformation. * * @return the resulting path. */ public GeneralPath transform(Matrix matrix) { float x1 = getLowerLeftX(); float y1 = getLowerLeftY(); float x2 = getUpperRightX(); float y2 = getUpperRightY(); Point2D.Float p0 = matrix.transformPoint(x1, y1); Point2D.Float p1 = matrix.transformPoint(x2, y1); Point2D.Float p2 = matrix.transformPoint(x2, y2); Point2D.Float p3 = matrix.transformPoint(x1, y2); GeneralPath path = new GeneralPath(); path.moveTo(p0.getX(), p0.getY()); path.lineTo(p1.getX(), p1.getY()); path.lineTo(p2.getX(), p2.getY()); path.lineTo(p3.getX(), p3.getY()); path.closePath(); return path; }
float dstY = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax()); LOG.debug("coord: " + String.format("[%06X,%06X] -> [%f,%f]", x, y, dstX, dstY)); Point2D p = matrix.transformPoint(dstX, dstY); xform.transform(p, p);
PDDocument document = PDDocument.load(resource); PDPage page = document.getDocumentCatalog().getPages().get(0); PDPageContentStream cs = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.PREPEND, false, false); Matrix matrix = Matrix.getRotateInstance(Math.toRadians(45), 0, 0); cs.transform(matrix); cs.close(); PDRectangle cropBox = page.getCropBox(); float cx = (cropBox.getLowerLeftX() + cropBox.getUpperRightX()) / 2; float cy = (cropBox.getLowerLeftY() + cropBox.getUpperRightY()) / 2; Point2D.Float newC = matrix.transformPoint(cx, cy); float tx = (float)newC.getX() - cx; float ty = (float)newC.getY() - cy; page.setCropBox(new PDRectangle(cropBox.getLowerLeftX() + tx, cropBox.getLowerLeftY() + ty, cropBox.getWidth(), cropBox.getHeight())); PDRectangle mediaBox = page.getMediaBox(); page.setMediaBox(new PDRectangle(mediaBox.getLowerLeftX() + tx, mediaBox.getLowerLeftY() + ty, mediaBox.getWidth(), mediaBox.getHeight()));
float dstY = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax()); LOG.debug("coord: " + String.format("[%06X,%06X] -> [%f,%f]", x, y, dstX, dstY)); Point2D p = matrix.transformPoint(dstX, dstY); xform.transform(p, p);
float px = interpolate(x, maxSrcCoord, rangeX.getMin(), rangeX.getMax()); float py = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax()); Point2D p = matrix.transformPoint(px, py); xform.transform(p, p); points[i] = p;
float px = interpolate(x, maxSrcCoord, rangeX.getMin(), rangeX.getMax()); float py = interpolate(y, maxSrcCoord, rangeY.getMin(), rangeY.getMax()); Point2D p = matrix.transformPoint(px, py); xform.transform(p, p); points[i] = p;
Point2D.Float point2D = matrix.transformPoint(rect.getWidth(), rect.getHeight());
Point2D.Float point2D = matrix.transformPoint(rect.getWidth(), rect.getHeight());
if (font instanceof PDType3Font) height = font.getFontMatrix().transformPoint(0, glyphHeight).y;
if (font instanceof PDType3Font) height = font.getFontMatrix().transformPoint(0, glyphHeight).y;
if (font instanceof PDType3Font) height = font.getFontMatrix().transformPoint(0, glyphHeight).y;