/** * Convenience method to create a translating instance. * * @param tx The x translating operator. * @param ty The y translating operator. * @return A new matrix with just the x/y translating. * @deprecated Use {@link #getTranslateInstance} instead. */ @Deprecated public static Matrix getTranslatingInstance(float tx, float ty) { return getTranslateInstance(tx, ty); }
/** * Applies a text position adjustment from the TJ operator. May be overridden in subclasses. * * @param tx x-translation * @param ty y-translation */ protected void applyTextAdjustment(float tx, float ty) throws IOException { // update the text matrix textMatrix.concatenate(Matrix.getTranslateInstance(tx, ty)); }
/** * Translates this matrix by the given ammount. * * @param tx x-translation * @param ty y-translation */ public void translate(float tx, float ty) { Matrix m = Matrix.getTranslateInstance(tx, ty); concatenate(m); }
/** * The Tm operator. Sets the text matrix to the given translation values. * A current text matrix will be replaced with the new one. * @param tx The translation value in x-direction. * @param ty The translation value in y-direction. * @throws IOException If there is an error writing to the stream. * @deprecated Use {@link #setTextMatrix(Matrix)} instead. */ @Deprecated public void setTextTranslation(double tx, double ty) throws IOException { setTextMatrix(Matrix.getTranslateInstance((float) tx, (float) ty)); }
/** * Translates this matrix by the given vector. * * @param vector 2D vector */ public void translate(Vector vector) { Matrix m = Matrix.getTranslateInstance(vector.getX(), vector.getY()); concatenate(m); }
GeneralPath p = r.transform(Matrix.getTranslateInstance(-cropBox.getLowerLeftX(), cropBox.getLowerLeftY())); Shape s = flip.createTransformedShape(p); graphics.setColor(Color.green);
Matrix.getTranslateInstance(-pattern.getBBox().getLowerLeftX(), -pattern.getBBox().getLowerLeftY()));
/** * This will initialize and process the contents of the stream. * * @param page the page to process * @throws java.io.IOException if there is an error accessing the stream. */ @Override public void processPage(PDPage page) throws IOException { this.pageRotation = page.getRotation(); this.pageSize = page.getCropBox(); if (Float.compare(pageSize.getLowerLeftX(), 0) == 0 && Float.compare(pageSize.getLowerLeftY(), 0) == 0) { translateMatrix = null; } else { // translation matrix for cropbox translateMatrix = Matrix.getTranslateInstance(-pageSize.getLowerLeftX(), -pageSize.getLowerLeftY()); } super.processPage(page); }
private void drawCheck(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException { PDRectangle bbox = adjustRectAndBBox(annotation, 20, 19); float min = Math.min(bbox.getWidth(), bbox.getHeight()); contentStream.setMiterLimit(4); contentStream.setLineJoinStyle(1); contentStream.setLineCapStyle(0); contentStream.setLineWidth(0.59f); // value from Adobe contentStream.transform(Matrix.getScaleInstance(0.001f * min / 0.8f, 0.001f * min / 0.8f)); contentStream.transform(Matrix.getTranslateInstance(0, 50)); // we get the shape of a Zapf Dingbats check (0x2714) and use that one. // Adobe uses a different font (which one?), or created the shape from scratch. GeneralPath path = PDType1Font.ZAPF_DINGBATS.getPath("a20"); addPath(contentStream, path); contentStream.fillAndStroke(); }
private void drawRightPointer(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException { PDRectangle bbox = adjustRectAndBBox(annotation, 20, 17); float min = Math.min(bbox.getWidth(), bbox.getHeight()); contentStream.setMiterLimit(4); contentStream.setLineJoinStyle(1); contentStream.setLineCapStyle(0); contentStream.setLineWidth(0.59f); // value from Adobe contentStream.transform(Matrix.getScaleInstance(0.001f * min / 0.8f, 0.001f * min / 0.8f)); contentStream.transform(Matrix.getTranslateInstance(0, 50)); // we get the shape of a Zapf Dingbats right pointer (0x27A4) and use that one. // Adobe uses a different font (which one?), or created the shape from scratch. GeneralPath path = PDType1Font.ZAPF_DINGBATS.getPath("a174"); addPath(contentStream, path); contentStream.fillAndStroke(); }
private void drawCrossHairs(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException { PDRectangle bbox = adjustRectAndBBox(annotation, 20, 20); float min = Math.min(bbox.getWidth(), bbox.getHeight()); contentStream.setMiterLimit(4); contentStream.setLineJoinStyle(0); contentStream.setLineCapStyle(0); contentStream.setLineWidth(0.61f); // value from Adobe contentStream.transform(Matrix.getScaleInstance(0.001f * min / 1.5f, 0.001f * min / 1.5f)); contentStream.transform(Matrix.getTranslateInstance(0, 50)); // we get the shape of a Symbol crosshair (0x2295) and use that one. // Adobe uses a different font (which one?), or created the shape from scratch. GeneralPath path = PDType1Font.SYMBOL.getPath("circleplus"); addPath(contentStream, path); contentStream.fillAndStroke(); }
Matrix a = Matrix.getTranslateInstance(rect.getLowerLeftX(), rect.getLowerLeftY()); a.concatenate(Matrix.getScaleInstance((float)(rect.getWidth() / transformedBox.getWidth()), (float)(rect.getHeight() / transformedBox.getHeight()))); a.concatenate(Matrix.getTranslateInstance((float) -transformedBox.getX(), (float) -transformedBox.getY()));
private void drawNewParagraph(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException { adjustRectAndBBox(annotation, 13, 20); contentStream.setMiterLimit(4); contentStream.setLineJoinStyle(0); contentStream.setLineCapStyle(0); contentStream.setLineWidth(0.59f); // value from Adobe // small triangle (values from Adobe) contentStream.moveTo(6.4995f, 20); contentStream.lineTo(0.295f, 7.287f); contentStream.lineTo(12.705f, 7.287f); contentStream.closeAndFillAndStroke(); // rescale and translate so that "NP" fits below the triangle // values gathered by trial and error contentStream.transform(Matrix.getScaleInstance(0.001f * 4, 0.001f * 4)); contentStream.transform(Matrix.getTranslateInstance(200, 0)); addPath(contentStream, PDType1Font.HELVETICA_BOLD.getPath("N")); contentStream.transform(Matrix.getTranslateInstance(1300, 0)); addPath(contentStream, PDType1Font.HELVETICA_BOLD.getPath("P")); contentStream.fill(); }
textMatrix.concatenate(Matrix.getTranslateInstance(tx, ty));
cs.transform(Matrix.getTranslateInstance(-fontBBox.getLowerLeftX(), -fontBBox.getLowerLeftY())); try
contentStream.setTextMatrix(Matrix.getTranslateInstance(centerX, centerY));
contentStream.transform(Matrix.getTranslateInstance(500, 375));
contentStream.transform(Matrix.getTranslateInstance(200, 300));
contentStream.transform(Matrix.getTranslateInstance(850, 900));
contentStream.transform(Matrix.getTranslateInstance(500, -300));