use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class CurveToReplicateInitialPoint method process.
@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 x2 = (COSNumber) operands.get(0);
COSNumber y2 = (COSNumber) operands.get(1);
COSNumber x3 = (COSNumber) operands.get(2);
COSNumber y3 = (COSNumber) operands.get(3);
PointF currentPoint = context.getCurrentPoint();
PointF point2 = context.transformedPoint(x2.floatValue(), y2.floatValue());
PointF point3 = context.transformedPoint(x3.floatValue(), y3.floatValue());
if (currentPoint == null) {
Log.w("PdfBox-Android", "curveTo (" + point3.x + "," + point3.y + ") without initial MoveTo");
context.moveTo(point3.x, point3.y);
} else {
context.curveTo((float) currentPoint.x, (float) currentPoint.y, point2.x, point2.y, point3.x, point3.y);
}
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class PDStandardAttributeObject method getNumberOrArrayOfNumber.
/**
* Gets a number or an array of numbers.
*
* @param name the attribute name
* @param defaultValue the default value
* @return a Float or an array of floats
*/
protected Object getNumberOrArrayOfNumber(String name, float defaultValue) {
COSBase v = this.getCOSObject().getDictionaryObject(name);
if (v instanceof COSArray) {
COSArray array = (COSArray) v;
float[] values = new float[array.size()];
for (int i = 0; i < array.size(); i++) {
COSBase item = array.getObject(i);
if (item instanceof COSNumber) {
values[i] = ((COSNumber) item).floatValue();
}
}
return values;
}
if (v instanceof COSNumber) {
return ((COSNumber) v).floatValue();
}
if (defaultValue == UNSPECIFIED) {
return null;
}
return defaultValue;
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class PDExtendedGraphicsState method getFloatItem.
/**
* This will get a float item from the dictionary.
*
* @param key The key to the item.
*
* @return The value for that item.
*/
private Float getFloatItem(COSName key) {
Float retval = null;
COSBase base = dict.getDictionaryObject(key);
if (base instanceof COSNumber) {
COSNumber value = (COSNumber) base;
retval = value.floatValue();
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class PDDefaultAppearanceString method processSetFont.
/**
* Process the set font and font size operator.
*
* @param operands the font name and size
* @throws IOException in case there are missing operators or the font is not within the resources
*/
private void processSetFont(List<COSBase> operands) throws IOException {
if (operands.size() < 2) {
throw new IOException("Missing operands for set font operator " + Arrays.toString(operands.toArray()));
}
COSBase base0 = operands.get(0);
COSBase base1 = operands.get(1);
if (!(base0 instanceof COSName)) {
return;
}
if (!(base1 instanceof COSNumber)) {
return;
}
COSName fontName = (COSName) base0;
PDFont font = defaultResources.getFont(fontName);
float fontSize = ((COSNumber) base1).floatValue();
// todo: handle cases where font == null with special mapping logic (see PDFBOX-2661)
if (font == null) {
throw new IOException("Could not find font: /" + fontName.getName());
}
setFontName(fontName);
setFont(font);
setFontSize(fontSize);
}
use of com.tom_roush.pdfbox.cos.COSNumber in project PdfBox-Android by TomRoush.
the class PDVariableText method getQ.
/**
* This will get the 'quadding' or justification of the text to be displayed.
*
* This is an inheritable attribute.
* <br>
* 0 - Left (default)<br>
* 1 - Centered<br>
* 2 - Right<br>
* Please see the QUADDING_CONSTANTS.
*
* @return The justification of the text strings.
*/
public int getQ() {
int retval = 0;
COSNumber number = (COSNumber) getInheritableAttribute(COSName.Q);
if (number != null) {
retval = number.intValue();
}
return retval;
}
Aggregations