Class Function


  • public class Function
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int bitsPerSample
      Required for Type 0: Number of Bits used to represent each sample value.
      private java.util.List<java.lang.Float> bounds
      Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply.
      private float[] cOne
      Required For Type 2: An Array of n Doubles defining the function result when x=1.
      private float[] cZero
      Required For Type 2: An Array of n Doubles defining the function result when x=0.
      private byte[] datasource  
      private java.util.List<java.lang.Double> domain
      Required: 2 * m Array of Double numbers which are possible inputs to the function
      private java.util.List<java.lang.Double> encode
      Optional for Type 0: A 2 * m array of Doubles which provides a linear mapping of input values to the domain.
      private java.util.List<Function> functions
      Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function.
      private int functionType
      Required: The Type of function (0,2,3,4) default is 0.
      private double interpolationExponentN
      Required for Type 2: The interpolation exponent.
      private int order
      Optional for Type 0: order of interpolation between samples.
      private java.util.List<java.lang.Double> range
      Required: 2 * n Array of Double numbers which are possible outputs to the function
      private java.util.List<java.lang.Integer> size  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Function​(int functionType, java.util.List<java.lang.Double> domain, java.util.List<java.lang.Double> range)  
        Function​(java.util.List<java.lang.Double> domain, java.util.List<java.lang.Double> range, float[] cZero, float[] cOne, double interpolationExponentN)
      create an complete Function object of Type 2, an Exponential Interpolation function.
        Function​(java.util.List<java.lang.Double> domain, java.util.List<java.lang.Double> range, java.util.List<java.lang.Double> encode, byte[] datasource, int bitsPerSample, java.util.List<java.lang.Integer> size)  
        Function​(java.util.List<java.lang.Double> domain, java.util.List<java.lang.Double> range, java.util.List<Function> functions, java.util.List<java.lang.Float> bounds, java.util.List<java.lang.Double> encode)
      create an complete Function object of Type 3, a Stitching function.
    • Field Detail

      • functionType

        private int functionType
        Required: The Type of function (0,2,3,4) default is 0.
      • domain

        private java.util.List<java.lang.Double> domain
        Required: 2 * m Array of Double numbers which are possible inputs to the function
      • range

        private java.util.List<java.lang.Double> range
        Required: 2 * n Array of Double numbers which are possible outputs to the function
      • bitsPerSample

        private int bitsPerSample
        Required for Type 0: Number of Bits used to represent each sample value. Limited to 1,2,4,8,12,16,24, or 32
      • order

        private int order
        Optional for Type 0: order of interpolation between samples. Limited to linear (1) or cubic (3). Default is 1
      • encode

        private java.util.List<java.lang.Double> encode
        Optional for Type 0: A 2 * m array of Doubles which provides a linear mapping of input values to the domain. Required for Type 3: A 2 * k array of Doubles that, taken in pairs, map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function. Should be two values per function, usually (0,1), as in [0 1 0 1] for 2 functions.
      • cZero

        private float[] cZero
        Required For Type 2: An Array of n Doubles defining the function result when x=0. Default is [0].
      • cOne

        private float[] cOne
        Required For Type 2: An Array of n Doubles defining the function result when x=1. Default is [1].
      • interpolationExponentN

        private double interpolationExponentN
        Required for Type 2: The interpolation exponent. Each value x will return n results. Must be greater than 0.
      • functions

        private java.util.List<Function> functions
        Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function.
      • bounds

        private java.util.List<java.lang.Float> bounds
        Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply. Bounds elements must be in order of increasing magnitude, and each value must be within the value of Domain. k is the number of functions. If you pass null, it will output (1/k) in an array of k-1 elements. This makes each function responsible for an equal amount of the stitching function. It makes the gradient even.
      • datasource

        private byte[] datasource
      • size

        private java.util.List<java.lang.Integer> size
    • Constructor Detail

      • Function

        public Function​(java.util.List<java.lang.Double> domain,
                        java.util.List<java.lang.Double> range,
                        float[] cZero,
                        float[] cOne,
                        double interpolationExponentN)
        create an complete Function object of Type 2, an Exponential Interpolation function. Use null for an optional object parameter if you choose not to use it. For optional int parameters, pass the default.
        Parameters:
        domain - List objects of Double objects. This is the domain of the function. See page 264 of the PDF 1.3 Spec.
        range - List of Doubles that is the Range of the function. See page 264 of the PDF 1.3 Spec.
        cZero - This is a vector of Double objects which defines the function result when x=0. This attribute is optional. It's described on page 268 of the PDF 1.3 spec.
        cOne - This is a vector of Double objects which defines the function result when x=1. This attribute is optional. It's described on page 268 of the PDF 1.3 spec.
        interpolationExponentN - This is the inerpolation exponent. This attribute is required. PDF Spec page 268
      • Function

        public Function​(java.util.List<java.lang.Double> domain,
                        java.util.List<java.lang.Double> range,
                        java.util.List<Function> functions,
                        java.util.List<java.lang.Float> bounds,
                        java.util.List<java.lang.Double> encode)
        create an complete Function object of Type 3, a Stitching function. Use null for an optional object parameter if you choose not to use it. For optional int parameters, pass the default.
        Parameters:
        domain - List objects of Double objects. This is the domain of the function. See page 264 of the PDF 1.3 Spec.
        range - List objects of Double objects. This is the Range of the function. See page 264 of the PDF 1.3 Spec.
        functions - A List of the PDFFunction objects that the stitching function stitches. This attributed is required. It is described on page 269 of the PDF spec.
        bounds - This is a vector of Doubles representing the numbers that, in conjunction with Domain define the intervals to which each function from the 'functions' object applies. It must be in order of increasing magnitude, and each must be within Domain. It basically sets how much of the gradient each function handles. This attributed is required. It's described on page 269 of the PDF 1.3 spec.
        encode - List objects of Double objects. This is the linear mapping of input values intop the domain of the function's sample table. Default is hard to represent in ascii, but basically [0 (Size0 1) 0 (Size1 1)...]. This attribute is required. See page 270 in the PDF 1.3 spec.
      • Function

        private Function​(int functionType,
                         java.util.List<java.lang.Double> domain,
                         java.util.List<java.lang.Double> range)
      • Function

        public Function​(java.util.List<java.lang.Double> domain,
                        java.util.List<java.lang.Double> range,
                        java.util.List<java.lang.Double> encode,
                        byte[] datasource,
                        int bitsPerSample,
                        java.util.List<java.lang.Integer> size)
    • Method Detail

      • setCZero

        public void setCZero​(float[] cZero)
      • setCOne

        public void setCOne​(float[] cOne)
      • makeEncode

        private java.util.List<java.lang.Double> makeEncode​(java.util.List<java.lang.Double> encode)
      • getFunctionType

        public int getFunctionType()
        Gets the function type
      • getBounds

        public java.util.List<java.lang.Float> getBounds()
        Gets the function bounds
      • getDomain

        public java.util.List<java.lang.Double> getDomain()
        The function domain
      • getEncode

        public java.util.List<java.lang.Double> getEncode()
        Gets the function encoding
      • getFunctions

        public java.util.List<Function> getFunctions()
        Gets the sub-functions
      • getBitsPerSample

        public int getBitsPerSample()
        Gets the bits per sample of the function
      • getInterpolationExponentN

        public double getInterpolationExponentN()
        Gets the interpolation exponent of the function
      • getOrder

        public int getOrder()
        Gets the function order
      • getRange

        public java.util.List<java.lang.Double> getRange()
        Gets the function range
      • getCZero

        public float[] getCZero()
        Gets the function C0 value (color for gradient)
      • getCOne

        public float[] getCOne()
        Gets the function C1 value (color for gradient)
      • outputBitsPerSample

        private void outputBitsPerSample​(java.lang.StringBuilder out)
      • outputOrder

        private void outputOrder​(java.lang.StringBuilder out)
      • outputInterpolationExponentN

        private void outputInterpolationExponentN​(java.lang.StringBuilder out,
                                                  GradientMaker.DoubleFormatter doubleFormatter)