throw new PDFParseException("Type 3 function only accepts a " +
"single input, so Domain should have just 2 elements");
}
// read the Functions array (required)
PDFObject functionsObj = obj.getDictRef("Functions");
if (functionsObj == null) {
throw new PDFParseException("Functions required for function type 3!");
}
PDFObject[] functionsAry = functionsObj.getArray();
functions = new PDFFunction[functionsAry.length];
for (int i = 0; i < functionsAry.length; i++) {
functions[i] = PDFFunction.getFunction(functionsAry[i]);
}
int k = functions.length;
PDFObject domainObj = obj.getDictRef("Domain");
if (domainObj == null) {
throw new PDFParseException("domain required for function type 3!");
}
// read the Bounds array (required)
PDFObject boundsObj = obj.getDictRef("Bounds");
if (boundsObj == null) {
throw new PDFParseException("Bounds required for function type 3!");
}
PDFObject[] boundsAry = boundsObj.getArray();
if (boundsAry.length != k - 1) {
throw new PDFParseException("Bounds array length " +
boundsAry.length + " should be " + (k - 1) +
" with functions array length " +
functions.length);
}
bounds = new float[boundsAry.length];
for (int i = 0; i < boundsAry.length; i++) {
bounds[i] = boundsAry[i].getFloatValue();
}
// read the encode array (required)
PDFObject encodeObj = obj.getDictRef("Encode");
if (encodeObj == null) {
throw new PDFParseException("Encode required for function type 3!");
}
PDFObject[] encodeAry = encodeObj.getArray();
if (encodeAry.length != 2 * k) {
throw new PDFParseException("There should be " + (2 * k) +
" values in Encode for the given number of functions.");
}
encode = new float[encodeAry.length];