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 Detail

      • bounds

        private double[] bounds
      • encode

        private double[] encode
    • Constructor Detail

      • 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,
                                java.util.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,
                                java.util.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.
    • Method Detail

      • getFunctions

        public java.util.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​(java.lang.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
      • 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 java.util.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)