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

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

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

Matrix.getScalingFactorX介绍

[英]Returns the x-scaling factor of this matrix. This is calculated from the scale and shear.
[中]返回此矩阵的x比例因子。这是根据比例和剪力计算得出的。

代码示例

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

/**
 * This will get the X scaling factor. This is dependent on the current transformation matrix
 * (set by the "cm" operator), the text matrix (set by the "Tm" operator) and the font size (set
 * by the "Tf" operator).
 *
 * @return The X scaling factor.
 */
public float getXScale()
{
  return textMatrix.getScalingFactorX();
}

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

private BufferedImage adjustImage(BufferedImage gray) throws IOException
{
  AffineTransform at = new AffineTransform(xform);
  Matrix m = new Matrix(at);
  at.scale(1.0 / Math.abs(m.getScalingFactorX()), 1.0 / Math.abs(m.getScalingFactorY()));
  Rectangle originalBounds = new Rectangle(gray.getWidth(), gray.getHeight());
  Rectangle2D transformedBounds = at.createTransformedShape(originalBounds).getBounds2D();
  at.preConcatenate(AffineTransform.getTranslateInstance(-transformedBounds.getMinX(), 
      -transformedBounds.getMinY()));
  
  int width = (int) Math.ceil(transformedBounds.getWidth());
  int height = (int) Math.ceil(transformedBounds.getHeight());
  BufferedImage transformedGray = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); 
  
  Graphics2D g2 = (Graphics2D) transformedGray.getGraphics();
  g2.drawImage(gray, at, null);
  g2.dispose();
  return transformedGray;
}

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

private void adjustRectangle(Rectangle2D r)
{
  Matrix m = new Matrix(xform);
  double scaleX = Math.abs(m.getScalingFactorX());
  double scaleY = Math.abs(m.getScalingFactorY());
  AffineTransform adjustedTransform = new AffineTransform(xform);
  adjustedTransform.scale(1.0 / scaleX, 1.0 / scaleY);
  r.setRect(adjustedTransform.createTransformedShape(r).getBounds2D());
}

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

public Rectangle2D getBounds()
  {
    Point2D size = new Point2D.Double(pageSize.getWidth(), pageSize.getHeight());
    // apply the underlying Graphics2D device's DPI transform and y-axis flip
    Matrix m = new Matrix(xform);
    AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY()));
    size = dpiTransform.transform(size, size);
    // Flip y
    return new Rectangle2D.Double(minX - pageSize.getLowerLeftX() * Math.abs(m.getScalingFactorX()),
        size.getY() - minY - height + pageSize.getLowerLeftY() * Math.abs(m.getScalingFactorY()),
        width, height);
  }
}

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

/**
 * Not called in TexturePaint subclasses, which is why we wrap TexturePaint.
 */
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
                 AffineTransform xform, RenderingHints hints)
{
  AffineTransform xformPattern = (AffineTransform)xform.clone();
  // applies the pattern matrix with scaling removed
  AffineTransform patternNoScale = patternMatrix.createAffineTransform();
  patternNoScale.scale(1 / patternMatrix.getScalingFactorX(),
             1 / patternMatrix.getScalingFactorY());
  xformPattern.concatenate(patternNoScale);
  return paint.createContext(cm, deviceBounds, userBounds, xformPattern, hints);
}

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

float xScale = Math.abs(xformMatrix.getScalingFactorX());
float yScale = Math.abs(xformMatrix.getScalingFactorY());
width *= xScale;
    Math.abs(patternMatrix.getScalingFactorX()),
    Math.abs(patternMatrix.getScalingFactorY()));

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

float xScale = patternMatrix.getScalingFactorX();
float yScale = patternMatrix.getScalingFactorY();
float width = xStep * xScale;

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

AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY()));
Rectangle2D bounds = dpiTransform.createTransformedShape(clip.getBounds2D()).getBounds2D();
xform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY()));
PDRectangle pageSizeOriginal = pageSize;
pageSize = new PDRectangle(minX / Math.abs(m.getScalingFactorX()), 
              minY / Math.abs(m.getScalingFactorY()),
      (float) bounds.getWidth() / Math.abs(m.getScalingFactorX()),
      (float) bounds.getHeight() / Math.abs(m.getScalingFactorY()));
int clipWindingRuleOriginal = clipWindingRule;

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

float imageXScale = ctmNew.getScalingFactorX();
float imageYScale = ctmNew.getScalingFactorY();

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

float xScale = Math.abs(m.getScalingFactorX());
float yScale = Math.abs(m.getScalingFactorY());

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

text.getWidthDirAdj() / text.getTextMatrix().getScalingFactorX(),
    text.getHeightDir() / text.getTextMatrix().getScalingFactorY());
Shape s = at.createTransformedShape(rect);

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

text.getWidthDirAdj() / text.getTextMatrix().getScalingFactorX(),
    text.getHeightDir() / text.getTextMatrix().getScalingFactorY());
graphics.setColor(Color.red);

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

/**
 * This will get the X scaling factor. This is dependent on the current transformation matrix
 * (set by the "cm" operator), the text matrix (set by the "Tm" operator) and the font size (set
 * by the "Tf" operator).
 *
 * @return The X scaling factor.
 */
public float getXScale()
{
  return textMatrix.getScalingFactorX();
}

代码示例来源:origin: com.github.lafa.pdfbox/pdfbox

/**
 * This will get the X scaling factor. This is dependent on the current transformation matrix
 * (set by the "cm" operator), the text matrix (set by the "Tm" operator) and the font size (set
 * by the "Tf" operator).
 *
 * @return The X scaling factor.
 */
public float getXScale()
{
  return textMatrix.getScalingFactorX();
}

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

float spaceWidthDisplay = spaceWidthText * textRenderingMatrix.getScalingFactorX();
    Math.abs(dyDisplay), dxDisplay,
    Math.abs(spaceWidthDisplay), unicode, new int[] { code } , font, fontSize,
    (int)(fontSize * textMatrix.getScalingFactorX())));

代码示例来源:origin: io.committed.krill/krill

/**
 * Calculate font size.
 *
 * @param textMatrix
 *          the text matrix
 * @param textState
 *          the text state
 * @return the float
 */
private static float calculateFontSize(Matrix textMatrix, PDTextState textState) {
 return textState.getFontSize() * textMatrix.getScalingFactorX();
}

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

private void adjustRectangle(Rectangle2D r)
{
  Matrix m = new Matrix(xform);
  double scaleX = m.getScalingFactorX();
  double scaleY = m.getScalingFactorY();
  
  AffineTransform adjustedTransform = new AffineTransform(xform);
  adjustedTransform.scale(1.0 / scaleX, 1.0 / scaleY);
  r.setRect(adjustedTransform.createTransformedShape(r).getBounds2D());
}

代码示例来源:origin: com.github.lafa.pdfbox/pdfbox

public Rectangle2D getBounds()
  {
    Point2D size = new Point2D.Double(pageSize.getWidth(), pageSize.getHeight());
    // apply the underlying Graphics2D device's DPI transform and y-axis flip
    Matrix m = new Matrix(xform);
    AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY()));
    size = dpiTransform.transform(size, size);
    // Flip y
    return new Rectangle2D.Double(minX - pageSize.getLowerLeftX() * m.getScalingFactorX(),
        size.getY() - minY - height + pageSize.getLowerLeftY() * m.getScalingFactorY(),
        width, height);
  }
}

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

public Rectangle2D getBounds()
  {
    Point2D size = new Point2D.Double(pageSize.getWidth(), pageSize.getHeight());
    // apply the underlying Graphics2D device's DPI transform and y-axis flip
    Matrix m = new Matrix(xform);
    AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY()));
    size = dpiTransform.transform(size, size);
    // Flip y
    return new Rectangle2D.Double(minX - pageSize.getLowerLeftX() * m.getScalingFactorX(),
        size.getY() - minY - height + pageSize.getLowerLeftY() * m.getScalingFactorY(),
        width, height);
  }
}

代码示例来源:origin: stackoverflow.com

Matrix ctmNew = getGraphicsState().getCurrentTransformationMatrix();
float imageXScale = ctmNew.getScalingFactorX();
float imageYScale = ctmNew.getScalingFactorY();

// position in user space units. 1 unit = 1/72 inch at 72 dpi
System.out.println("position in PDF = " + ctmNew.getTranslateX() + ", " + ctmNew.getTranslateY() + " in user space units");

相关文章