本文整理了Java中org.apache.pdfbox.util.Matrix.createAffineTransform()
方法的一些代码示例,展示了Matrix.createAffineTransform()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.createAffineTransform()
方法的具体详情如下:
包路径:org.apache.pdfbox.util.Matrix
类名称:Matrix
方法名:createAffineTransform
[英]Create an affine transform from this matrix's values.
[中]从该矩阵的值创建仿射变换。
代码示例来源:origin: apache/pdfbox
@Override
protected void showFontGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode,
Vector displacement) throws IOException
{
AffineTransform at = textRenderingMatrix.createAffineTransform();
at.concatenate(font.getFontMatrix().createAffineTransform());
// create cache if it does not exist
PDVectorFont vectorFont = ((PDVectorFont)font);
GlyphCache cache = glyphCaches.get(font);
if (cache == null)
{
cache = new GlyphCache(vectorFont);
glyphCaches.put(font, cache);
}
GeneralPath path = cache.getPathForCharacterCode(code);
drawGlyph(path, font, code, displacement, at);
}
代码示例来源:origin: apache/pdfbox
/**
* The cm operator. Concatenates the given matrix with the CTM.
*
* @param matrix the transformation matrix
* @throws IOException If there is an error writing to the stream.
*/
public void transform(Matrix matrix) throws IOException
{
if (inTextMode)
{
throw new IllegalStateException("Error: Modifying the current transformation matrix is not allowed within text objects.");
}
writeAffineTransform(matrix.createAffineTransform());
writeOperator("cm");
}
代码示例来源:origin: apache/pdfbox
/**
* The Tm operator. Sets the text matrix to the given values.
* A current text matrix will be replaced with the new one.
*
* @param matrix the transformation matrix
* @throws IOException If there is an error writing to the stream.
* @throws IllegalStateException If the method was not allowed to be called at this time.
*/
public void setTextMatrix(Matrix matrix) throws IOException
{
if (!inTextMode)
{
throw new IllegalStateException("Error: must call beginText() before setTextMatrix");
}
writeAffineTransform(matrix.createAffineTransform());
writeOperator("Tm");
}
代码示例来源:origin: apache/pdfbox
/**
* Transforms a point using the CTM.
*/
public Point2D.Float transformedPoint(float x, float y)
{
float[] position = { x, y };
getGraphicsState().getCurrentTransformationMatrix().createAffineTransform()
.transform(position, 0, position, 0, 1);
return new Point2D.Float(position[0], position[1]);
}
代码示例来源:origin: apache/pdfbox
/**
* Glyph bounding boxes.
*/
@Override
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode,
Vector displacement) throws IOException
{
// draw glyph
super.showGlyph(textRenderingMatrix, font, code, unicode, displacement);
// bbox in EM -> user units
Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1);
AffineTransform at = textRenderingMatrix.createAffineTransform();
bbox = at.createTransformedShape(bbox);
// save
Graphics2D graphics = getGraphics();
Color color = graphics.getColor();
Stroke stroke = graphics.getStroke();
Shape clip = graphics.getClip();
// draw
graphics.setClip(graphics.getDeviceConfiguration().getBounds());
graphics.setColor(Color.RED);
graphics.setStroke(new BasicStroke(.5f));
graphics.draw(bbox);
// restore
graphics.setStroke(stroke);
graphics.setColor(color);
graphics.setClip(clip);
}
代码示例来源: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
AffineTransform at = textRenderingMatrix.createAffineTransform();
at.concatenate(font.getFontMatrix().createAffineTransform());
代码示例来源:origin: apache/pdfbox
rat = shading.getMatrix().createAffineTransform().createInverse();
rat.concatenate(matrix.createAffineTransform().createInverse());
rat.concatenate(xform.createInverse());
代码示例来源:origin: apache/pdfbox
private AffineTransform calculateMatrix(PDRectangle bbox, int rotation)
{
if (rotation == 0)
{
return new AffineTransform();
}
float tx = 0, ty = 0;
switch (rotation)
{
case 90:
tx = bbox.getUpperRightY();
break;
case 180:
tx = bbox.getUpperRightY();
ty = bbox.getUpperRightX();
break;
case 270:
ty = bbox.getUpperRightX();
break;
default:
break;
}
Matrix matrix = Matrix.getRotateInstance(Math.toRadians(rotation), tx, ty);
return matrix.createAffineTransform();
}
代码示例来源:origin: apache/pdfbox
at.concatenate(text.getTextMatrix().createAffineTransform());
at.concatenate(text.getTextMatrix().createAffineTransform());
at.concatenate(font.getFontMatrix().createAffineTransform());
代码示例来源:origin: apache/pdfbox
AffineTransform at = text.getTextMatrix().createAffineTransform();
at.concatenate(font.getFontMatrix().createAffineTransform());
代码示例来源:origin: apache/pdfbox
rat = matrix.createAffineTransform().createInverse();
rat.concatenate(xform.createInverse());
shadingToDevice.concatenate(matrix.createAffineTransform());
代码示例来源:origin: apache/pdfbox
/**
* Draw an image at the origin with the given transformation matrix.
*
* @param image The image to draw.
* @param matrix The transformation matrix to apply to the image.
*
* @throws IOException If there is an error writing to the stream.
* @throws IllegalStateException If the method was called within a text block.
*/
public void drawImage(PDImageXObject image, Matrix matrix) throws IOException
{
if (inTextMode)
{
throw new IllegalStateException("Error: drawImage is not allowed within a text block.");
}
saveGraphicsState();
AffineTransform transform = matrix.createAffineTransform();
transform(new Matrix(transform));
writeOperand(resources.add(image));
writeOperator("Do");
restoreGraphicsState();
}
代码示例来源:origin: apache/pdfbox
rat = matrix.createAffineTransform().createInverse();
rat.concatenate(xform.createInverse());
shadingToDevice.concatenate(matrix.createAffineTransform());
代码示例来源:origin: apache/pdfbox
private Shape calculateGlyphBounds(Matrix textRenderingMatrix, PDFont font, int code) throws IOException
AffineTransform at = textRenderingMatrix.createAffineTransform();
at.concatenate(font.getFontMatrix().createAffineTransform());
if (font instanceof PDType3Font)
代码示例来源:origin: apache/pdfbox
fontMatrixTransform = getFontMatrix().createAffineTransform();
fontMatrixTransform.scale(1000, 1000);
代码示例来源:origin: apache/pdfbox
isDamaged = fontIsDamaged;
fontMatrixTransform = getFontMatrix().createAffineTransform();
fontMatrixTransform.scale(1000, 1000);
代码示例来源:origin: apache/pdfbox
AffineTransform at = matrix.createAffineTransform();
PDRectangle mediaBox = page.getMediaBox();
PDRectangle cropBox = page.getCropBox();
代码示例来源:origin: apache/pdfbox
try
AffineTransform at = font.getFontMatrix().createAffineTransform();
if (!at.isIdentity())
代码示例来源:origin: apache/pdfbox
Matrix matrix = annotation.getNormalAppearanceStream().getMatrix();
matrix.transformPoint(rd, rd);
annotation.getNormalAppearanceStream().setMatrix(matrix.createAffineTransform());
PDRectangle rect2 = new PDRectangle(rect.getLowerLeftX() - rd, rect.getLowerLeftY() - rd,
rect.getWidth() + 2 * rd, rect.getHeight() + 2 * rd);
内容来源于网络,如有侵权,请联系作者删除!