use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class COSDictionaryMap method convertBasicTypesToMap.
/**
* This will take a COS dictionary and convert it into COSDictionaryMap. All cos
* objects will be converted to their primitive form.
*
* @param map The COS mappings.
* @return A standard java map.
* @throws IOException If there is an error during the conversion.
*/
public static COSDictionaryMap<String, Object> convertBasicTypesToMap(COSDictionary map) throws IOException {
COSDictionaryMap<String, Object> retval = null;
if (map != null) {
Map<String, Object> actualMap = new HashMap<String, Object>();
for (COSName key : map.keySet()) {
COSBase cosObj = map.getDictionaryObject(key);
Object actualObject = null;
if (cosObj instanceof COSString) {
actualObject = ((COSString) cosObj).getString();
} else if (cosObj instanceof COSInteger) {
actualObject = ((COSInteger) cosObj).intValue();
} else if (cosObj instanceof COSName) {
actualObject = ((COSName) cosObj).getName();
} else if (cosObj instanceof COSFloat) {
actualObject = ((COSFloat) cosObj).floatValue();
} else if (cosObj instanceof COSBoolean) {
actualObject = ((COSBoolean) cosObj).getValue() ? Boolean.TRUE : Boolean.FALSE;
} else {
throw new IOException("Error:unknown type of object to convert:" + cosObj);
}
actualMap.put(key.getName(), actualObject);
}
retval = new COSDictionaryMap<String, Object>(actualMap, map);
}
return retval;
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDOutlineItem method getTextColor.
/**
* Get the RGB text color of this node. Default is black and this method
* will never return null.
*
* @return The structure element of this node.
*/
public PDColor getTextColor() {
COSArray csValues = (COSArray) getCOSObject().getDictionaryObject(COSName.C);
if (csValues == null) {
csValues = new COSArray();
csValues.growToSize(3, new COSFloat(0));
getCOSObject().setItem(COSName.C, csValues);
}
return new PDColor(csValues, PDDeviceRGB.INSTANCE);
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDStandardAttributeObject method setArrayOfNumber.
/**
* Sets an array of float numbers.
*
* @param name the attribute name
* @param values the float numbers
*/
protected void setArrayOfNumber(String name, float[] values) {
COSArray array = new COSArray();
for (float value : values) {
array.add(new COSFloat(value));
}
COSBase oldBase = this.getCOSObject().getDictionaryObject(name);
this.getCOSObject().setItem(name, array);
COSBase newBase = this.getCOSObject().getDictionaryObject(name);
this.potentiallyNotifyChanged(oldBase, newBase);
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class Matrix method toCOSArray.
/**
* Returns a COS array which represent the geometric relevant
* components of the matrix. The last column of the matrix is ignored,
* only the first two columns are returned. This is analog to the
* Matrix(COSArray) constructor.
*/
public COSArray toCOSArray() {
COSArray array = new COSArray();
array.add(new COSFloat(single[0]));
array.add(new COSFloat(single[1]));
array.add(new COSFloat(single[3]));
array.add(new COSFloat(single[4]));
array.add(new COSFloat(single[6]));
array.add(new COSFloat(single[7]));
return array;
}
use of com.tom_roush.pdfbox.cos.COSFloat in project PdfBox-Android by TomRoush.
the class PDAbstractPattern method setMatrix.
/**
* Sets the optional Matrix entry for the Pattern.
* @param transform the transformation matrix
*/
public void setMatrix(AffineTransform transform) {
COSArray matrix = new COSArray();
double[] values = new double[6];
transform.getMatrix(values);
for (double v : values) {
matrix.add(new COSFloat((float) v));
}
getCOSObject().setItem(COSName.MATRIX, matrix);
}
Aggregations