Package com.itextpdf.kernel.pdf.function
Class AbstractPdfFunctionPdfDictionary>
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper
com.itextpdf.kernel.pdf.function.AbstractPdfFunction
- Type Parameters:
-
T- Either aPdfDictionaryor aPdfStream
- All Implemented Interfaces:
-
IPdfFunction
- Direct Known Subclasses:
-
PdfType0Function,PdfType2Function,PdfType3Function,PdfType4Function
public abstract class AbstractPdfFunctionPdfDictionary> extends PdfObjectWrapper implements IPdfFunction
The abstract PdfFunction class that represents the Function Dictionary or Stream PDF object. Holds common properties and methods and a factory method. (see ISO-320001 Chapter 7.10)
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractPdfFunction(T pdfObject) Constructs a PdfFunction from an existing PdfObject.protectedAbstractPdfFunction(T pdfObject, int functionType, double[] domain, double[] range) Constructs a PdfFunction from a new PdfObject. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]calculateFromByteArray(byte[] bytes, int offset, int length, int wordSizeInputLength, int wordSizeOutputLength) Performs the calculation in bulk on a set of raw data and returns a new set of raw data.byte[]calculateFromByteArray(byte[] bytes, int offset, int length, int wordSizeInputLength, int wordSizeOutputLength, BaseInputOutPutConvertors.IInputConversionFunction inputConvertor, BaseInputOutPutConvertors.IOutputConversionFunction outputConvertor) Performs the calculation in bulk on a set of raw data and returns a new set of raw data.booleancheckCompatibilityWithColorSpace(PdfColorSpace alternateSpace) Chacks wether the output of the function matches in components with the passed by color space.protected static double[]clip(double[] values, double[] limits) double[]clipInput(double[] input) Clip input values to the allowed domain.double[]clipOutput(double[] input) Clip output values to the allowed range, if there is a range.protected static double[]convertFloatArrayToDoubleArray(float[] array) double[]The valid input domain, input will be clipped to this domain contains a min max pair per input component.intThe function type, (see ISO-320001 Table 38).intThe number of input components.intThe number of output components.double[]getRange()the valid output range, output will be clipped to this range contains a min max pair per output component.protected booleanDefines if the object behind this wrapper must be an indirect object in the resultant document.protected static double[]normalize(double[] values, double[] limits) voidsetDomain(double[] value) The valid input domain, input will be clipped to this domain contains a min max pair per input component.voidsetRange(double[] value) the valid output range, output will be clipped to this range contains a min max pair per output component.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidReleaseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.itextpdf.kernel.pdf.function.IPdfFunction
calculate
-
Constructor Details
-
AbstractPdfFunction
Constructs a PdfFunction from a new PdfObject.- Parameters:
-
pdfObject- The new, empty, object, created in a concrete implementation -
functionType- The function type, can be 0, 2, 3 or 4 -
domain- the valid input domain, input will be clipped to this domain contains a min max pair per input component -
range- the valid output range, oputput will be clipped to this range contains a min max pair per output component
-
AbstractPdfFunction
Constructs a PdfFunction from an existing PdfObject.- Parameters:
-
pdfObject- Either aPdfDictionaryor aPdfStream
-
-
Method Details
-
getFunctionType
public int getFunctionType()The function type, (see ISO-320001 Table 38).- Specified by:
-
getFunctionTypein interfaceIPdfFunction - Returns:
- The function type, either 0, 2, 3 or 4
-
checkCompatibilityWithColorSpace
Chacks wether the output of the function matches in components with the passed by color space.- Specified by:
-
checkCompatibilityWithColorSpacein interfaceIPdfFunction - Parameters:
-
alternateSpace- The color space to verify against - Returns:
- True when compatible
-
getInputSize
public int getInputSize()The number of input components.- Specified by:
-
getInputSizein interfaceIPdfFunction - Returns:
- The number of input components
-
getOutputSize
public int getOutputSize()The number of output components.- Specified by:
-
getOutputSizein interfaceIPdfFunction - Returns:
- The number of output components
-
getDomain
public double[] getDomain()The valid input domain, input will be clipped to this domain contains a min max pair per input component.(see ISO-320001 Table 38)
- Specified by:
-
getDomainin interfaceIPdfFunction - Returns:
- the input domain
-
setDomain
public void setDomain(double[] value) The valid input domain, input will be clipped to this domain contains a min max pair per input component.(see ISO-320001 Table 38)
- Specified by:
-
setDomainin interfaceIPdfFunction - Parameters:
-
value- the new set of limits
-
getRange
public double[] getRange()the valid output range, output will be clipped to this range contains a min max pair per output component.(see ISO-320001 Table 38)
- Specified by:
-
getRangein interfaceIPdfFunction - Returns:
- the output range
-
setRange
public void setRange(double[] value) the valid output range, output will be clipped to this range contains a min max pair per output component.(see ISO-320001 Table 38)
- Specified by:
-
setRangein interfaceIPdfFunction - Parameters:
-
value- the new set of limts
-
calculateFromByteArray
public byte[] calculateFromByteArray(byte[] bytes, int offset, int length, int wordSizeInputLength, int wordSizeOutputLength) throws IOException Performs the calculation in bulk on a set of raw data and returns a new set of raw data.- Specified by:
-
calculateFromByteArrayin interfaceIPdfFunction - Parameters:
-
bytes- The uninterpreted set of data to be transformed -
offset- Where to start converting the data -
length- How many of the input bytes should be converted -
wordSizeInputLength- How many bytes represents one input value -
wordSizeOutputLength- How many bytes represents one output value - Returns:
- the transformed result as a raw byte array
- Throws:
-
IOException- on data reading errors
-
calculateFromByteArray
public byte[] calculateFromByteArray(byte[] bytes, int offset, int length, int wordSizeInputLength, int wordSizeOutputLength, BaseInputOutPutConvertors.IInputConversionFunction inputConvertor, BaseInputOutPutConvertors.IOutputConversionFunction outputConvertor) throws IOException Performs the calculation in bulk on a set of raw data and returns a new set of raw data.- Specified by:
-
calculateFromByteArrayin interfaceIPdfFunction - Parameters:
-
bytes- The uninterpreted set of data to be transformed -
offset- Where to start converting the data -
length- How many of the input bytes should be converted -
wordSizeInputLength- How many bytes represents one input value -
wordSizeOutputLength- How many bytes represents one output value -
inputConvertor- a custom input convertor -
outputConvertor- a custom output convertor - Returns:
- the transformed result as a raw byte array
- Throws:
-
IOException- on data reading errors
-
clipInput
public double[] clipInput(double[] input) Clip input values to the allowed domain.(see ISO-320001 Table 38)
- Specified by:
-
clipInputin interfaceIPdfFunction - Parameters:
-
input- the input values to be clipped - Returns:
- the values clipped between the boundaries defined in the domain
-
clipOutput
public double[] clipOutput(double[] input) Clip output values to the allowed range, if there is a range.(see ISO-320001 Table 38)
- Specified by:
-
clipOutputin interfaceIPdfFunction - Parameters:
-
input- the output values to be clipped - Returns:
- the values clipped between the boundaries defined in the range
-
getAsPdfObject
- Specified by:
-
getAsPdfObjectin interfaceIPdfFunction
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapperDefines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
-
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<T extends PdfDictionary> - Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
clip
protected static double[] clip(double[] values, double[] limits) -
normalize
protected static double[] normalize(double[] values, double[] limits) -
convertFloatArrayToDoubleArray
protected static double[] convertFloatArrayToDoubleArray(float[] array)
-