Examples of PDRange


Examples of org.apache.pdfbox.pdmodel.common.PDRange

    {
        //Setup the input values
        ExecutionContext context = new ExecutionContext(OPERATORS);
        for (int i = 0; i < input.length; i++)
        {
            PDRange domain = getDomainForInput(i);
            float value = clipToRange(input[i], domain.getMin(), domain.getMax());
            context.getStack().push(value);
        }

        //Execute the type 4 function.
        instructions.execute(context);

        //Extract the output values
        int numberOfOutputValues = getNumberOfOutputParameters();
        int numberOfActualOutputValues = context.getStack().size();
        if (numberOfActualOutputValues < numberOfOutputValues)
        {
            throw new IllegalStateException("The type 4 function returned "
                    + numberOfActualOutputValues
                    + " values but the Range entry indicates that "
                    + numberOfOutputValues + " values be returned.");
        }
        float[] outputValues = new float[numberOfOutputValues];
        for (int i = numberOfOutputValues - 1; i >= 0; i--)
        {
            PDRange range = getRangeForOutput(i);
            outputValues[i] = context.popReal();
            outputValues[i] = clipToRange(outputValues[i], range.getMin(), range.getMax());
        }

        //Return the resulting array
        return outputValues;
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

        //This function is known as a "stitching" function. Based on the input, it decides which child function to call.
        // All functions in the array are 1-value-input functions
        //See PDF Reference section 3.9.3.
        PDFunction function = null;
        float x = input[0];
        PDRange domain = getDomainForInput(0);
        // clip input value to domain
        x = clipToRange(x, domain.getMin(), domain.getMax());

        COSArray functionsArray = getFunctions();
        int numberOfFunctions = functionsArray.size();
        // This doesn't make sense but it may happen ...
        if (numberOfFunctions == 1)
        {
            function = PDFunction.create(functionsArray.get(0));
            PDRange encRange = getEncodeForParameter(0);
            x = interpolate(x, domain.getMin(), domain.getMax(), encRange.getMin(), encRange.getMax());
        }
        else
        {
            float[] boundsValues = getBounds().toFloatArray();
            int boundsSize = boundsValues.length;
            // create a combined array containing the domain and the bounds values
            // domain.min, bounds[0], bounds[1], ...., bounds[boundsSize-1], domain.max
            float[] partitionValues = new float[boundsSize+2];
            int partitionValuesSize = partitionValues.length;
            partitionValues[0] = domain.getMin();
            partitionValues[partitionValuesSize-1] = domain.getMax();
            System.arraycopy(boundsValues, 0, partitionValues, 1, boundsSize);
            // find the partition
            for (int i=0; i < partitionValuesSize-1; i++)
            {
                if ( x >= partitionValues[i] &&
                        (x < partitionValues[i+1] || (i == partitionValuesSize - 2 && x == partitionValues[i+1])))
                {
                    function = PDFunction.create(functionsArray.get(i));
                    PDRange encRange = getEncodeForParameter(i);
                    x = interpolate(x, partitionValues[i], partitionValues[i+1], encRange.getMin(), encRange.getMax());
                    break;
                }
            }
        }
        float[] functionValues = new float[]{x};
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

     * @return The encode parameter range or null if none is set.
     */
    private PDRange getEncodeForParameter(int n)
    {
        COSArray encodeValues = getEncode();
        return new PDRange( encodeValues, n );
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

    // get the patch list which forms the type 7 shading image from data stream
    private ArrayList<Patch> getTensorPatchList(AffineTransform xform, Matrix ctm) throws IOException
    {
        PDShadingType7 tensorShadingType = (PDShadingType7) patchMeshesShadingType;
        COSDictionary cosDictionary = tensorShadingType.getCOSDictionary();
        PDRange rangeX = tensorShadingType.getDecodeForParameter(0);
        PDRange rangeY = tensorShadingType.getDecodeForParameter(1);
        PDRange[] colRange = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRange[i] = tensorShadingType.getDecodeForParameter(2 + i);
        }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

     * @return The range for this component.
     */
    public PDRange getRangeForOutput(int n)
    {
        COSArray rangeValues = getRangeValues();
        return new PDRange( rangeValues, n );
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

     * @return The domain range for this component.
     */
    public PDRange getDomainForInput(int n)
    {
        COSArray domainValues = getDomainValues();
        return new PDRange( domainValues, n );
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

    // get the patch list which forms the type 6 shading image from data stream
    private ArrayList<Patch> getCoonsPatchList(AffineTransform xform, Matrix ctm) throws IOException
    {
        PDShadingType6 coonsShadingType = (PDShadingType6) patchMeshesShadingType;
        COSDictionary cosDictionary = coonsShadingType.getCOSDictionary();
        PDRange rangeX = coonsShadingType.getDecodeForParameter(0);
        PDRange rangeY = coonsShadingType.getDecodeForParameter(1);
        PDRange[] colRange = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRange[i] = coonsShadingType.getDecodeForParameter(2 + i);
        }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

        assertEquals(100f, pdLab.getBRange().getMax());
        assertEquals("read operations should not change the size of /Lab objects", 0, dict.size());
        dict.toString(); // rev 1571125 did a stack overflow here

        // test setting specific values
        PDRange pdRange = new PDRange();
        pdRange.setMin(-1);
        pdRange.setMax(2);
        pdLab.setARange(pdRange);
        pdRange = new PDRange();
        pdRange.setMin(3);
        pdRange.setMax(4);
        pdLab.setBRange(pdRange);
        assertEquals(-1f, pdLab.getARange().getMin());
        assertEquals(2f, pdLab.getARange().getMax());
        assertEquals(3f, pdLab.getBRange().getMin());
        assertEquals(4f, pdLab.getBRange().getMax());
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

    public PDRange getRangeForComponent(int n)
    {
        COSArray rangeArray = (COSArray) stream.getStream().getDictionaryObject(COSName.RANGE);
        if (rangeArray == null || rangeArray.size() < getNumberOfComponents() * 2)
        {
            return new PDRange(); // 0..1
        }
        return new PDRange(rangeArray, n);
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.common.PDRange

     * @return The a range.
     */
    public PDRange getARange()
    {
        COSArray range = getRangeArray();
        return new PDRange( range, 0 );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.