Class AbstractPdfFunctionPdfDictionary>

java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper
com.itextpdf.kernel.pdf.function.AbstractPdfFunction
Type Parameters:
T - Either a PdfDictionary or a PdfStream
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 Details

    • AbstractPdfFunction

      protected AbstractPdfFunction (T pdfObject, int functionType, double[] domain, double[] range)
      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

      protected AbstractPdfFunction (T pdfObject)
      Constructs a PdfFunction from an existing PdfObject.
      Parameters:
      pdfObject - Either a PdfDictionary or a PdfStream
  • Method Details

    • getFunctionType

      public int getFunctionType()
      The function type, (see ISO-320001 Table 38).
      Specified by:
      getFunctionType in interface IPdfFunction
      Returns:
      The function type, either 0, 2, 3 or 4
    • checkCompatibilityWithColorSpace

      public boolean checkCompatibilityWithColorSpace (PdfColorSpace alternateSpace)
      Chacks wether the output of the function matches in components with the passed by color space.
      Specified by:
      checkCompatibilityWithColorSpace in interface IPdfFunction
      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 interface IPdfFunction
      Returns:
      The number of input components
    • getOutputSize

      public int getOutputSize()
      The number of output components.
      Specified by:
      getOutputSize in interface IPdfFunction
      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 interface IPdfFunction
      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 interface IPdfFunction
      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 interface IPdfFunction
      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 interface IPdfFunction
      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 interface IPdfFunction
      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 interface IPdfFunction
      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 interface IPdfFunction
      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 interface IPdfFunction
      Parameters:
      input - the output values to be clipped
      Returns:
      the values clipped between the boundaries defined in the range
    • getAsPdfObject

      public PdfObject getAsPdfObject()
      Specified by:
      getAsPdfObject in interface IPdfFunction
    • clip

      protected static double[] clip (double[] values, double[] limits)
    • normalize

      protected static double[] normalize (double[] values, double[] limits)