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 aPdfDictionary
or 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
ModifierConstructorDescriptionprotected
AbstractPdfFunction
(T pdfObject) Constructs a PdfFunction from an existing PdfObject.protected
AbstractPdfFunction
(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.boolean
checkCompatibilityWithColorSpace
(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.int
The function type, (see ISO-320001 Table 38).int
The number of input components.int
The 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 boolean
Defines if the object behind this wrapper must be an indirect object in the resultant document.protected static double[]
normalize
(double[] values, double[] limits) void
setDomain
(double[] value) The valid input domain, input will be clipped to this domain contains a min max pair per input component.void
setRange
(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, unsetForbidRelease
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 aPdfDictionary
or aPdfStream
-
-
Method Details
-
getFunctionType
public int getFunctionType()The function type, (see ISO-320001 Table 38).- Specified by:
-
getFunctionType
in 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:
-
checkCompatibilityWithColorSpace
in interfaceIPdfFunction
- Parameters:
-
alternateSpace
- The color space to verify against - Returns:
- True when compatible
-
getInputSize
public int getInputSize()The number of input components.- Specified by:
-
getInputSize
in interfaceIPdfFunction
- Returns:
- The number of input components
-
getOutputSize
public int getOutputSize()The number of output components.- Specified by:
-
getOutputSize
in 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:
-
getDomain
in 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:
-
setDomain
in 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:
-
getRange
in 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:
-
setRange
in 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:
-
calculateFromByteArray
in 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:
-
calculateFromByteArray
in 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:
-
clipInput
in 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:
-
clipOutput
in interfaceIPdfFunction
- Parameters:
-
input
- the output values to be clipped - Returns:
- the values clipped between the boundaries defined in the range
-
getAsPdfObject
- Specified by:
-
getAsPdfObject
in interfaceIPdfFunction
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapper
Defines 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:
-
isWrappedObjectMustBeIndirect
in 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)
-