本文整理汇总了Java中org.apache.pdfbox.util.Matrix.getTranslateX方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.getTranslateX方法的具体用法?Java Matrix.getTranslateX怎么用?Java Matrix.getTranslateX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pdfbox.util.Matrix
的用法示例。
在下文中一共展示了Matrix.getTranslateX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOperator
import org.apache.pdfbox.util.Matrix; //导入方法依赖的package包/类
@Override
protected void processOperator(Operator operator, List<COSBase> operands) throws IOException
{
if (replacement != null)
{
boolean copy = true;
if (TjTJ.contains(operator.getName()))
{
Matrix transformation = getTextMatrix().multiply(getGraphicsState().getCurrentTransformationMatrix());
float xPos = transformation.getTranslateX();
float yPos = transformation.getTranslateY();
for (HelloSignField field : fields)
{
if (field.inField(xPos, yPos))
{
copy = false;
}
}
}
if (copy)
{
replacement.writeTokens(operands);
replacement.writeToken(operator);
}
}
super.processOperator(operator, operands);
}
示例2: process
import org.apache.pdfbox.util.Matrix; //导入方法依赖的package包/类
/**
* process : BI : begin inline image.
*
* @param operator
* The operator that is being executed.
* @param arguments
* List
* @throws IOException
* If there is an error displaying the inline image.
*/
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
Matrix ctm = context.getCurrentTransformationMatrix();
COSDictionary params = operator.getImageParameters();
int width = params.getInt(COSName.W, COSName.WIDTH, -1);
int height = params.getInt(COSName.H, COSName.HEIGHT, -1);
// TODO: use transform().
float minX = ctm.getTranslateX();
float maxX = minX + (width * ctm.getScaleX());
float minY = ctm.getTranslateY();
float maxY = minY + (height * ctm.getScaleY());
// Type3 streams may contain BI operands, but we don't wan't to consider
// those.
if (!context.isType3Stream()) {
// Rectangle boundBox = new SimpleRectangle(minX, minY, maxX, maxY);
Rectangle boundBox = SimpleRectangle.from2Vertices(
new SimplePoint(minX, minY),
new SimplePoint(maxX, maxY));
PDImage image = new PDInlineImage(operator.getImageParameters(),
operator.getImageData(), context.getResources());
PdfBoxColor exclusiveColor = getExclusiveColor(image.getImage());
if (exclusiveColor != null) {
PdfBoxShape shape = new PdfBoxShape(context.getCurrentPage());
shape.setRectangle(boundBox);
shape.setColor(exclusiveColor);
context.showShape(shape);
} else {
PdfBoxFigure figure = new PdfBoxFigure(context.getCurrentPage());
figure.setRectangle(boundBox);
context.showFigure(figure);
}
}
}
示例3: getDefaultBoundingBox
import org.apache.pdfbox.util.Matrix; //导入方法依赖的package包/类
/**
* Returns an approximate bounding box for a glyph with a font, for which no
* glyph metrics exist.
*
* @param code
* the character
* @param font
* the font.
* @param trm
* the current text rendering matrix.
* @return the bounding box.
* @throws IOException
* if obtaining the defualt bounding box fails.
*/
protected Rectangle getDefaultBoundingBox(int code, PDFont font, Matrix trm)
throws IOException {
PDGraphicsState state = getGraphicsState();
Matrix ctm = state.getCurrentTransformationMatrix();
Matrix textMatrix = getTextMatrix();
Vector displacement = font.getDisplacement(code);
float fontSize = state.getTextState().getFontSize();
float horizScaling = state.getTextState().getHorizontalScaling() / 100f;
float tx = displacement.getX() * fontSize * horizScaling;
float ty = 0;
// (modified) combined displacement matrix
Matrix td = Matrix.getTranslateInstance(tx, ty);
// (modified) text rendering matrix
Matrix nextTrm = td.multiply(textMatrix).multiply(ctm);
// 1/2 the bbox is used as the height todo: why?
float glyphHeight = font.getBoundingBox().getHeight() / 2;
// transformPoint from glyph space -> text space
float height = font.getFontMatrix().transformPoint(0, glyphHeight).y;
float dyDisplay = height * trm.getScalingFactorY();
float minX = trm.getTranslateX();
float minY = trm.getTranslateY();
float maxX = nextTrm.getTranslateX();
float maxY = minY + dyDisplay;
return new SimpleRectangle(minX, minY, maxX, maxY);
}