org.jpedal.function.FunctionFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of OpenViewerFX Show documentation
Show all versions of OpenViewerFX Show documentation
An Open Source JavaFX PDF Viewer
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2016 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ---------------
* FunctionFactory.java
* ---------------
*/
package org.jpedal.function;
import org.jpedal.color.ColorspaceFactory;
import org.jpedal.io.PdfObjectReader;
import org.jpedal.objects.raw.PdfArrayIterator;
import org.jpedal.objects.raw.PdfDictionary;
import org.jpedal.objects.raw.PdfObject;
/**
* return the correct PDF function - all implement PDF function interface
*/
public class FunctionFactory {
/**
* Get the correct Function for the shading objct
* @param currentPdfFile :: Current PDF File data
* @return The required function
*/
public static PDFFunction getFunction(final PdfObject functionObj, final PdfObjectReader currentPdfFile) {
PDFFunction newFunction=null;
final byte[] stream=functionObj.getDecodedStream();
final float[] domain=functionObj.getFloatArray(PdfDictionary.Domain);
final float[] range=functionObj.getFloatArray(PdfDictionary.Range);
final int type =functionObj.getInt(PdfDictionary.FunctionType);
final int bits=functionObj.getInt(PdfDictionary.BitsPerSample);
final float[] decode=functionObj.getFloatArray(PdfDictionary.Decode);
final float[] C0=functionObj.getFloatArray(PdfDictionary.C0);
final float[] C1=functionObj.getFloatArray(PdfDictionary.C1);
final int[] size=functionObj.getIntArray(PdfDictionary.Size);
final float[] encode=functionObj.getFloatArray(PdfDictionary.Encode);
final float[] bounds=functionObj.getFloatArray(PdfDictionary.Bounds);
//set order
float N=0;
final float newN=functionObj.getFloatNumber(PdfDictionary.N);
if(newN!=-1) {
N = newN;
}
final PdfArrayIterator keys=functionObj.getMixedArray(PdfDictionary.Functions);
int functionCount=0;
if(keys!=null) {
functionCount = keys.getTokenCount();
}
PDFFunction[] functions=null;
if(keys!=null){
final PdfObject[] subFunction=new PdfObject[functionCount];
for(int i=0;i
© 2015 - 2024 Weber Informatics LLC | Privacy Policy