本文整理汇总了Java中org.apache.pdfbox.cos.COSNumber类的典型用法代码示例。如果您正苦于以下问题:Java COSNumber类的具体用法?Java COSNumber怎么用?Java COSNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
COSNumber类属于org.apache.pdfbox.cos包,在下文中一共展示了COSNumber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.size() < 6) {
throw new MissingOperandException(operator, arguments);
}
// 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.getCurrentTransformationMatrix().concatenate(matrix);
}
示例2: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
COSNumber w = (COSNumber) operands.get(2);
COSNumber h = (COSNumber) operands.get(3);
Point lowerLeft = new SimplePoint(x.floatValue(), y.floatValue());
Point upperRight = new SimplePoint(w.floatValue() + lowerLeft.getX(),
h.floatValue() + lowerLeft.getY());
context.transform(lowerLeft);
context.transform(upperRight);
// To ensure that the path is created in the right direction,
// we have to create it by combining single lines instead of
// creating a simple rectangle
GeneralPath path = context.getLinePath();
path.moveTo(lowerLeft.getX(), lowerLeft.getY());
path.lineTo(upperRight.getX(), lowerLeft.getY());
path.lineTo(upperRight.getX(), upperRight.getY());
path.lineTo(lowerLeft.getX(), upperRight.getY());
path.lineTo(lowerLeft.getX(), lowerLeft.getY());
}
示例3: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x2 = (COSNumber) operands.get(0);
COSNumber y2 = (COSNumber) operands.get(1);
COSNumber x3 = (COSNumber) operands.get(2);
COSNumber y3 = (COSNumber) operands.get(3);
Point2D currentPoint = context.getLinePath().getCurrentPoint();
Point point2 = new SimplePoint(x2.floatValue(), y2.floatValue());
Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
context.transform(point2);
context.transform(point3);
if (currentPoint == null) {
context.getLinePath().moveTo(point3.getX(), point3.getY());
} else {
context.getLinePath().curveTo(
(float) currentPoint.getX(), (float) currentPoint.getY(),
point2.getX(), point2.getY(), point3.getX(), point3.getY());
}
}
示例4: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x1 = (COSNumber) operands.get(0);
COSNumber y1 = (COSNumber) operands.get(1);
COSNumber x3 = (COSNumber) operands.get(2);
COSNumber y3 = (COSNumber) operands.get(3);
Point point1 = new SimplePoint(x1.floatValue(), y1.floatValue());
Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
context.transform(point1);
context.transform(point3);
context.getLinePath().curveTo(point1.getX(), point1.getY(),
point3.getX(), point3.getY(), point3.getX(), point3.getY());
}
示例5: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x1 = (COSNumber) operands.get(0);
COSNumber y1 = (COSNumber) operands.get(1);
COSNumber x2 = (COSNumber) operands.get(2);
COSNumber y2 = (COSNumber) operands.get(3);
COSNumber x3 = (COSNumber) operands.get(4);
COSNumber y3 = (COSNumber) operands.get(5);
Point point1 = new SimplePoint(x1.floatValue(), y1.floatValue());
Point point2 = new SimplePoint(x2.floatValue(), y2.floatValue());
Point point3 = new SimplePoint(x3.floatValue(), y3.floatValue());
context.transform(point1);
context.transform(point2);
context.transform(point3);
if (context.getLinePath().getCurrentPoint() == null) {
context.getLinePath().moveTo(point3.getX(), point3.getY());
} else {
context.getLinePath().curveTo(point1.getX(), point1.getY(),
point2.getX(), point2.getY(), point3.getX(), point3.getY());
}
}
示例6: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws MissingOperandException {
if (arguments.size() < 6) {
throw new MissingOperandException(operator, arguments);
}
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);
// Set both matrices to
// [ a b 0
// c d 0
// e f 1 ]
Matrix matrix = new Matrix(a.floatValue(), b.floatValue(),
c.floatValue(), d.floatValue(), e.floatValue(), f.floatValue());
context.setTextMatrix(matrix);
context.setTextLineMatrix(matrix.clone());
}
示例7: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws MissingOperandException {
if (arguments.size() < 2) {
throw new MissingOperandException(operator, arguments);
}
Matrix tlm = context.getTextLineMatrix();
if (tlm == null) {
return;
}
COSNumber tx = (COSNumber) arguments.get(0);
COSNumber ty = (COSNumber) arguments.get(1);
Matrix matrix = new Matrix(1, 0, 0, 1, tx.floatValue(), ty.floatValue());
tlm.concatenate(matrix);
context.setTextMatrix(tlm.clone());
}
示例8: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands) throws IOException {
if (operands.size() < 4) {
throw new MissingOperandException(operator, operands);
}
if (!checkArrayTypesClass(operands, COSNumber.class)) {
return;
}
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
COSNumber w = (COSNumber) operands.get(2);
COSNumber h = (COSNumber) operands.get(3);
float x1 = x.floatValue();
float y1 = y.floatValue();
// create a pair of coordinates for the transformation
float x2 = w.floatValue() + x1;
float y2 = h.floatValue() + y1;
Point2D p0 = context.transformedPoint(x1, y1);
Point2D p1 = context.transformedPoint(x2, y1);
Point2D p2 = context.transformedPoint(x2, y2);
Point2D p3 = context.transformedPoint(x1, y2);
// to ensure that the path is created in the right direction, we have to create
// it by combining single lines instead of creating a simple rectangle
linePath.moveTo((float) p0.getX(), (float) p0.getY());
linePath.lineTo((float) p1.getX(), (float) p1.getY());
linePath.lineTo((float) p2.getX(), (float) p2.getY());
linePath.lineTo((float) p3.getX(), (float) p3.getY());
// close the subpath instead of adding the last line so that a possible set line
// cap style isn't taken into account at the "beginning" of the rectangle
linePath.closePath();
}
示例9: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
// append straight line segment from the current point to the point.
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
Point point = new SimplePoint(x.floatValue(), y.floatValue());
context.transform(point);
context.getLinePath().lineTo(point.getX(), point.getY());
}
示例10: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> operands)
throws IOException {
COSNumber x = (COSNumber) operands.get(0);
COSNumber y = (COSNumber) operands.get(1);
Point point = new SimplePoint(x.floatValue(), y.floatValue());
context.transform(point);
context.getLinePath().moveTo(point.getX(), point.getY());
}
示例11: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.size() < 6) {
throw new MissingOperandException(operator, arguments);
}
// Set glyph with and bounding box for type 3 font
// COSNumber hDisplacement = (COSNumber) arguments.get(0);
// COSNumber vDisplacement = (COSNumber) arguments.get(1);
COSNumber llx = (COSNumber) arguments.get(2);
COSNumber lly = (COSNumber) arguments.get(3);
COSNumber urx = (COSNumber) arguments.get(4);
COSNumber ury = (COSNumber) arguments.get(5);
Point lowerLeft = new SimplePoint(llx.floatValue(), lly.floatValue());
Point upperRight = new SimplePoint(urx.floatValue(), ury.floatValue());
context.transform(lowerLeft);
context.transform(upperRight);
float minX = Math.min(lowerLeft.getX(), upperRight.getX());
float minY = Math.min(lowerLeft.getY(), upperRight.getY());
float maxX = Math.max(lowerLeft.getX(), upperRight.getX());
float maxY = Math.max(lowerLeft.getY(), upperRight.getY());
Rectangle boundingBox = new SimpleRectangle(minX, minY, maxX, maxY);
context.setCurrentType3GlyphBoundingBox(boundingBox);
}
示例12: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.isEmpty()) {
throw new MissingOperandException(operator, arguments);
}
// there are some documents which are incorrectly structured, and have
// a wrong number of arguments to this, so we will assume the last argument
// in the list
Object charSpacing = arguments.get(arguments.size() - 1);
if (charSpacing instanceof COSNumber) {
COSNumber characterSpacing = (COSNumber) charSpacing;
PDTextState textState = context.getGraphicsState().getTextState();
textState.setCharacterSpacing(characterSpacing.floatValue());
}
}
示例13: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
@Override
public void process(Operator operator, List<COSBase> arguments)
throws IOException {
if (arguments.isEmpty()) {
throw new MissingOperandException(operator, arguments);
}
PDTextState textState = context.getGraphicsState().getTextState();
float fontSize = textState.getFontSize();
float horizontalScaling = textState.getHorizontalScaling() / 100f;
boolean isVertical = textState.getFont().isVertical();
COSArray array = (COSArray) arguments.get(0);
for (COSBase obj : array) {
if (obj instanceof COSNumber) {
float tj = ((COSNumber) obj).floatValue();
// calculate the combined displacements
float tx, ty;
if (isVertical) {
tx = 0;
ty = -tj / 1000 * fontSize;
} else {
tx = -tj / 1000 * fontSize * horizontalScaling;
ty = 0;
}
Matrix translate = Matrix.getTranslateInstance(tx, ty);
context.getTextMatrix().concatenate(translate);
} else if (obj instanceof COSString) {
List<COSBase> args = new ArrayList<COSBase>();
args.add(obj);
context.processOperator("Tj", args);
} else {
throw new IOException("Unknown type in array for TJ operation:" + obj);
}
}
}
示例14: process
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
public void process(PDFOperator operator, List<COSBase> arguments)
{
COSNumber x = (COSNumber) arguments.get(0);
COSNumber y = (COSNumber) arguments.get(1);
COSNumber w = (COSNumber) arguments.get(2);
COSNumber h = (COSNumber) arguments.get(3);
double x1 = x.doubleValue();
double y1 = y.doubleValue();
// create a pair of coordinates for the transformation
double x2 = w.doubleValue() + x1;
double y2 = h.doubleValue() + y1;
Point2D p0 = transformedPoint(x1, y1);
Point2D p1 = transformedPoint(x2, y1);
Point2D p2 = transformedPoint(x2, y2);
Point2D p3 = transformedPoint(x1, y2);
rectangles.add(new TransformedRectangle(p0, p1, p2, p3));
}
示例15: intValue
import org.apache.pdfbox.cos.COSNumber; //导入依赖的package包/类
/**
* Obtains a number from a PDF number value
* @param value the PDF value of the Integer or Fload type
* @return the corresponging numeric value
*/
protected int intValue(COSBase value)
{
if (value instanceof COSNumber)
return ((COSNumber) value).intValue();
else
return 0;
}