public void parse(PDFObject shaderObj) throws IOException
{
// read the axis coordinates (required)
PDFObject coordsObj = shaderObj.getDictRef("Coords");
if (coordsObj == null) {
throw new PDFParseException("No coordinates found!");
}
PDFObject[] coords = coordsObj.getArray();
Point2D start = new Point2D.Float(coords[0].getFloatValue(),
coords[1].getFloatValue());
Point2D end = new Point2D.Float(coords[2].getFloatValue(),
coords[3].getFloatValue());
setAxisStart(start);
setAxisEnd(end);
// read the domain (optional)
PDFObject domainObj = shaderObj.getDictRef("Domain");
if (domainObj != null) {
PDFObject[] domain = domainObj.getArray();
setMinT(domain[0].getFloatValue());
setMaxT(domain[1].getFloatValue());
}
// read the functions (required)
PDFObject functionObj = shaderObj.getDictRef("Function");
if (functionObj == null) {
throw new PDFParseException("No function defined for shader!");
}
PDFObject[] functionArray = functionObj.getArray();
PDFFunction[] functions = new PDFFunction[functionArray.length];
for (int i = 0; i < functions.length; i++) {
functions[i] = PDFFunction.getFunction(functionArray[i]);