org.apache.pdfbox.util.Matrix.concatenate()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(151)

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

Matrix.concatenate介绍

[英]Concatenates (premultiplies) the given matrix to this matrix.
[中]将给定矩阵连接(预乘)到此矩阵。

代码示例

代码示例来源:origin: apache/pdfbox

/**
 * 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);
}

代码示例来源:origin: apache/pdfbox

/**
 * 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));
}

代码示例来源:origin: apache/pdfbox

/**
 * 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);
}

代码示例来源:origin: apache/pdfbox

/**
 * 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;
}

代码示例来源:origin: apache/pdfbox

/**
 * 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);
}

代码示例来源:origin: apache/tika

@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);
  }
}

代码示例来源:origin: apache/pdfbox

@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);
  }
}

代码示例来源:origin: apache/pdfbox

@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);
    }
  }
}

代码示例来源:origin: apache/tika

@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);
    }
  }
}

代码示例来源:origin: apache/pdfbox

/**
 * 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);
}

代码示例来源:origin: apache/pdfbox

@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);
}

代码示例来源:origin: apache/pdfbox

newPatternMatrix.concatenate(
    Matrix.getTranslateInstance(-pattern.getBBox().getLowerLeftX(),
        -pattern.getBBox().getLowerLeftY()));

代码示例来源:origin: apache/pdfbox

@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());
}

代码示例来源:origin: apache/pdfbox

/**
 * 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);
}

代码示例来源:origin: apache/pdfbox

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);
      }
    }
  }
}

代码示例来源:origin: apache/pdfbox

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);

代码示例来源:origin: apache/pdfbox

initialMatrix = Matrix.concatenate(initialMatrix, patternMatrix);
getGraphicsState().getCurrentTransformationMatrix().concatenate(patternMatrix);

代码示例来源:origin: apache/pdfbox

getGraphicsState().getCurrentTransformationMatrix().concatenate(charProc.getMatrix());

代码示例来源:origin: apache/pdfbox

/**
 * 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);
}

代码示例来源:origin: apache/pdfbox

getGraphicsState().getCurrentTransformationMatrix().concatenate(group.getMatrix());

相关文章