Class PdfType3Function

All Implemented Interfaces:
IPdfFunction

public class PdfType3Function extends AbstractPdfFunction<PdfDictionary>
This class represents Pdf type 3 function that defines a stitching of the subdomains of several 1-input functions to produce a single new 1-input function.

For more info see ISO 32000-1, section 7.10.4 "Type 3 (Stitching) Functions".

  • Field Details

    • DEFAULT_FUNCTION_FACTORY

      private static final IPdfFunctionFactory DEFAULT_FUNCTION_FACTORY
    • functionFactory

      private final IPdfFunctionFactory functionFactory
    • functions

      private List<IPdfFunction> functions
    • bounds

      private double[] bounds
    • encode

      private double[] encode
  • Constructor Details

    • PdfType3Function

      public PdfType3Function(PdfDictionary dict)
      Instantiates a new PdfType3Function instance based on passed PdfDictionary instance.
      Parameters:
      dict - the function dictionary
    • PdfType3Function

      public PdfType3Function(double[] domain, double[] range, List<AbstractPdfFunction<? extends PdfDictionary>> functions, double[] bounds, double[] encode)
      (see ISO-320001 Table 41).
      Parameters:
      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
      functions - The list of functions to stitch*
      bounds - (Required) An array of k − 1 numbers that, in combination with Domain, shall define the intervals to which each function from the Functions array shall apply. Bounds elements shall be in order of increasing value, and each value shall be within the domain defined by Domain.
      encode - (Required) An array of 2 × k numbers that, taken in pairs, shall map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.
    • PdfType3Function

      public PdfType3Function(float[] domain, float[] range, List<AbstractPdfFunction<? extends PdfDictionary>> functions, float[] bounds, float[] encode)
      (see ISO-320001 Table 41).
      Parameters:
      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
      functions - The list of functions to stitch*
      bounds - (Required) An array of k − 1 numbers that, in combination with Domain, shall define the intervals to which each function from the Functions array shall apply. Bounds elements shall be in order of increasing value, and each value shall be within the domain defined by Domain.
      encode - (Required) An array of 2 × k numbers that, taken in pairs, shall map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.
    • PdfType3Function

      PdfType3Function(PdfDictionary dict, IPdfFunctionFactory functionFactory)
  • Method Details

    • getFunctions

      public Collection<IPdfFunction> getFunctions()
      (Required) An array of k 1-input functions that shall make up the stitching function. The output dimensionality of all functions shall be the same, and compatible with the value of Range if Range is present.

      (see ISO-320001 Table 41)

      Returns:
      the list of functions
    • setFunctions

      public void setFunctions(Iterable<AbstractPdfFunction<? extends PdfDictionary>> value)
      (Required) An array of k 1-input functions that shall make up the stitching function. The output dimensionality of all functions shall be the same, and compatible with the value of Range if Range is present.

      (see ISO-320001 Table 41)

      Parameters:
      value - the list of functions
    • getBounds

      public double[] getBounds()
      An array of k − 1 numbers that, in combination with Domain, shall define the intervals to which each function from the Functions array shall apply. Bounds elements shall be in order of increasing value, and each value shall be within the domain defined by Domain.

      (see ISO-320001 Table 41)

      Returns:
      the bounds
    • setBounds

      public void setBounds(double[] value)
      (Required) An array of k − 1 numbers that, in combination with Domain, shall define the intervals to which each function from the Functions array shall apply. Bounds elements shall be in order of increasing value, and each value shall be within the domain defined by Domain.

      (see ISO-320001 Table 41)

      Parameters:
      value - the new set of bounds
    • getEncode

      public double[] getEncode()
      An array of 2 × k numbers that, taken in pairs, shall map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.

      (see ISO-320001 Table 41)

      Returns:
      the encode values
    • setEncode

      public void setEncode(double[] value)
      (Required) An array of 2 × k numbers that, taken in pairs, shall map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.

      (see ISO-320001 Table 41)

      Parameters:
      value - the new set of encodings
    • checkCompatibilityWithColorSpace

      public boolean checkCompatibilityWithColorSpace(PdfColorSpace alternateSpace)
      Description copied from class: AbstractPdfFunction
      Chacks wether the output of the function matches in components with the passed by color space.
      Specified by:
      checkCompatibilityWithColorSpace in interface IPdfFunction
      Overrides:
      checkCompatibilityWithColorSpace in class AbstractPdfFunction<PdfDictionary>
      Parameters:
      alternateSpace - The color space to verify against
      Returns:
      True when compatible
    • getOutputSize

      public int getOutputSize()
      Gets output size of function.

      If Range field is absent, the output size of functions will be returned.

      Specified by:
      getOutputSize in interface IPdfFunction
      Overrides:
      getOutputSize in class AbstractPdfFunction<PdfDictionary>
      Returns:
      output size of function
    • calculate

      public double[] calculate(double[] input)
      Description copied from interface: IPdfFunction
      Calculates one set of input components to one set of output components.
      Parameters:
      input - The input values size must contain IPdfFunction.getInputSize() items
      Returns:
      an array the size of IPdfFunction.getOutputSize() items containing the result
    • calculateSubdomain

      private int calculateSubdomain(double inputValue)
    • getSubdomainBorders

      private double[] getSubdomainBorders(int subdomain)
    • checkAndGetFunctions

      private List<IPdfFunction> checkAndGetFunctions(PdfArray functionsArray)
    • checkAndGetBounds

      private double[] checkAndGetBounds(PdfArray boundsArray)
    • checkAndGetEncode

      private double[] checkAndGetEncode(PdfArray encodeArray)
    • mapValueFromActualRangeToExpected

      private static double mapValueFromActualRangeToExpected(double value, double aStart, double aEnd, double eStart, double eEnd)
      Maps passed value from actual range to expected range.
      Parameters:
      value - the value to map
      aStart - the start of actual range
      aEnd - the end of actual range
      eStart - the start of expected range
      eEnd - the end of expected range
      Returns:
      the mapped value
    • areThreeDoubleEqual

      private static boolean areThreeDoubleEqual(double first, double second, double third)