/** * 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); }
/** * 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)); }
/** * Rotares this matrix by the given factors. * * @param theta The angle of rotation measured in radians */ public void rotate(double theta) { Matrix m = Matrix.getRotateInstance(theta, 0, 0); concatenate(m); }
/** * Produces a copy of the first matrix, with the second matrix concatenated. * * @param a The matrix to copy. * @param b The matrix to concatenate. */ public static Matrix concatenate(Matrix a, Matrix b) { Matrix copy = a.clone(); copy.concatenate(b); return copy; }
/** * Scales this matrix by the given factors. * * @param sx x-scale * @param sy y-scale */ public void scale(float sx, float sy) { Matrix m = Matrix.getScaleInstance(sx, sy); concatenate(m); }
@Override protected void processTextPosition(TextPosition text) { Matrix m = text.getTextMatrix(); m.concatenate(text.getFont().getFontMatrix()); int angle = (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY()))); angle = (angle + 360) % 360; angles.add(angle); } }
@Override protected void processTextPosition(TextPosition text) { Matrix m = text.getTextMatrix(); m.concatenate(text.getFont().getFontMatrix()); int angle = (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY()))); angle = (angle + 360) % 360; angles.add(angle); } }
@Override protected void processTextPosition(TextPosition text) { Matrix m = text.getTextMatrix(); m.concatenate(text.getFont().getFontMatrix()); int angle = (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY()))); if (angle == 0) { super.processTextPosition(text); } } }
@Override protected void processTextPosition(TextPosition text) { Matrix m = text.getTextMatrix(); m.concatenate(text.getFont().getFontMatrix()); int angle = (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY()))); if (angle == 0) { super.processTextPosition(text); } } }
/** * 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); }
@Override public void process(Operator operator, List<COSBase> arguments) throws IOException { if (arguments.size() < 6) { throw new MissingOperandException(operator, arguments); } if (!checkArrayTypesClass(arguments, COSNumber.class)) { return; } // concatenate matrix to current transformation matrix COSNumber a = (COSNumber) arguments.get(0); COSNumber b = (COSNumber) arguments.get(1); COSNumber c = (COSNumber) arguments.get(2); COSNumber d = (COSNumber) arguments.get(3); COSNumber e = (COSNumber) arguments.get(4); COSNumber f = (COSNumber) arguments.get(5); Matrix matrix = new Matrix(a.floatValue(), b.floatValue(), c.floatValue(), d.floatValue(), e.floatValue(), f.floatValue()); context.getGraphicsState().getCurrentTransformationMatrix().concatenate(matrix); }
newPatternMatrix.concatenate( Matrix.getTranslateInstance(-pattern.getBBox().getLowerLeftX(), -pattern.getBBox().getLowerLeftY()));
@Override public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException { if (arguments.size() < 2) { throw new MissingOperandException(operator, arguments); } Matrix textLineMatrix = context.getTextLineMatrix(); if (textLineMatrix == null) { LOG.warn("TextLineMatrix is null, " + getName() + " operator will be ignored"); return; } COSBase base0 = arguments.get(0); COSBase base1 = arguments.get(1); if (!(base0 instanceof COSNumber)) { return; } if (!(base1 instanceof COSNumber)) { return; } COSNumber x = (COSNumber) base0; COSNumber y = (COSNumber) base1; Matrix matrix = new Matrix(1, 0, 0, 1, x.floatValue(), y.floatValue()); textLineMatrix.concatenate(matrix); context.setTextMatrix(textLineMatrix.clone()); }
/** * Creates a new tiling Paint. The parameters color and colorSpace must be null for a colored * tiling Paint (because it has its own colors), and non null for an uncolored tiling Paint. * * @param drawer renderer to render the page * @param pattern tiling pattern dictionary * @param colorSpace color space for this tiling * @param color color for this tiling * @param xform device scale transform * * @throws java.io.IOException if something goes wrong while drawing the pattern */ TilingPaint(PageDrawer drawer, PDTilingPattern pattern, PDColorSpace colorSpace, PDColor color, AffineTransform xform) throws IOException { // pattern space -> user space patternMatrix = Matrix.concatenate(drawer.getInitialMatrix(), pattern.getMatrix()); Rectangle2D anchorRect = getAnchorRect(pattern); paint = new TexturePaint(getImage(drawer, pattern, colorSpace, color, xform, anchorRect), anchorRect); }
private void intersectShadingBBox(PDColor color, Area area) throws IOException { if (color.getColorSpace() instanceof PDPattern) { PDColorSpace colorSpace = color.getColorSpace(); PDAbstractPattern pat = ((PDPattern) colorSpace).getPattern(color); if (pat instanceof PDShadingPattern) { PDShading shading = ((PDShadingPattern) pat).getShading(); PDRectangle bbox = shading.getBBox(); if (bbox != null) { Matrix m = Matrix.concatenate(getInitialMatrix(), pat.getMatrix()); Area bboxArea = new Area(bbox.transform(m)); area.intersect(bboxArea); } } } }
a.concatenate(Matrix.getScaleInstance((float)(rect.getWidth() / transformedBox.getWidth()), (float)(rect.getHeight() / transformedBox.getHeight()))); a.concatenate(Matrix.getTranslateInstance((float) -transformedBox.getX(), (float) -transformedBox.getY())); Matrix aa = Matrix.concatenate(a, matrix);
initialMatrix = Matrix.concatenate(initialMatrix, patternMatrix); getGraphicsState().getCurrentTransformationMatrix().concatenate(patternMatrix);
getGraphicsState().getCurrentTransformationMatrix().concatenate(charProc.getMatrix());
/** * Process a content stream. * * @param contentStream the content stream * @throws IOException if there is an exception while processing the stream */ private void processStream(PDContentStream contentStream) throws IOException { PDResources parent = pushResources(contentStream); Stack<PDGraphicsState> savedStack = saveGraphicsStack(); Matrix parentMatrix = initialMatrix; // transform the CTM using the stream's matrix getGraphicsState().getCurrentTransformationMatrix().concatenate(contentStream.getMatrix()); // the stream's initial matrix includes the parent CTM, e.g. this allows a scaled form initialMatrix = getGraphicsState().getCurrentTransformationMatrix().clone(); // clip to bounding box PDRectangle bbox = contentStream.getBBox(); clipToRect(bbox); processStreamOperators(contentStream); initialMatrix = parentMatrix; restoreGraphicsStack(savedStack); popResources(parent); }
getGraphicsState().getCurrentTransformationMatrix().concatenate(group.getMatrix());