Package org.apache.pdfbox.pdmodel.common

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


    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

    private ArrayList<ShadedTriangle> getTriangleList(AffineTransform xform, Matrix ctm) throws IOException
    {
        ArrayList<ShadedTriangle> list = new ArrayList<ShadedTriangle>();
        PDShadingType5 latticeTriangleShadingType = (PDShadingType5) shading;
        COSDictionary cosDictionary = latticeTriangleShadingType.getCOSDictionary();
        PDRange rangeX = latticeTriangleShadingType.getDecodeForParameter(0);
        PDRange rangeY = latticeTriangleShadingType.getDecodeForParameter(1);
        int numPerRow = latticeTriangleShadingType.getVerticesPerRow();
        PDRange[] colRange = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRange[i] = latticeTriangleShadingType.getDecodeForParameter(2 + i);
View Full Code Here

     * @return The a range.
     */
    public PDRange getARange()
    {
        COSArray range = getRangeArray();
        return new PDRange( range, 0 );
    }
View Full Code Here

     * @return The b range.
     */
    public PDRange getBRange()
    {
        COSArray range = getRangeArray();
        return new PDRange( range, 1 );
    }
View Full Code Here

     *
     * @return The encode parameter range or null if none is set.
     */
    public PDRange getEncodeForParameter( int paramNum )
    {
        PDRange retval = null;
        COSArray encodeValues = getEncodeValues();
        if( encodeValues != null && encodeValues.size() >= paramNum*2+1 )
        {
            retval = new PDRange(encodeValues, paramNum );
        }
        return retval;
    }
View Full Code Here

     *
     * @return The decode parameter range or null if none is set.
     */
    public PDRange getDecodeForParameter( int paramNum )
    {
        PDRange retval = null;
        COSArray decodeValues = getDecodeValues();
        if( decodeValues != null && decodeValues.size() >= paramNum*2+1 )
        {
            retval = new PDRange(decodeValues, paramNum );
        }
        return retval;
    }
View Full Code Here

        int numberOfInputValues = inputValues.length;
        int numberOfOutputValues = getNumberOfOutputParameters();
        int[] intInputValuesPrevious = new int[numberOfInputValues];
        int[] intInputValuesNext = new int[numberOfInputValues];
        for (int i=0; i<numberOfInputValues; i++) {
            PDRange domain = getDomainForInput(i);
            PDRange encode = getEncodeForParameter(i);
            inputValues[i] = clipToRange(inputValues[i], domain.getMin(), domain.getMax());
            inputValues[i] = interpolate(inputValues[i], domain.getMin(), domain.getMax(), encode.getMin(), encode.getMax());
            inputValues[i] = clipToRange(inputValues[i], 0, sizeValues[i]-1);
            intInputValuesPrevious[i] = (int)Math.floor(inputValues[i]);
            intInputValuesNext[i] = (int)Math.ceil(inputValues[i]);
        }
        float[] outputValuesPrevious = null;
        float[] outputValuesNext = null;
        outputValuesPrevious = getSample(intInputValuesPrevious);
        outputValuesNext = getSample(intInputValuesNext);
        float[] outputValues = new float[numberOfOutputValues];
        for (int i=0;i<numberOfOutputValues;i++)
        {
            PDRange range = getRangeForOutput(i);
            PDRange decode = getDecodeForParameter(i);
            // TODO using only a linear interpolation.
            // See "Order" entry in table 3.36 of the PDF reference
            outputValues[i] = (outputValuesPrevious[i] + outputValuesNext[i]) / 2;
            outputValues[i] = interpolate(outputValues[i], 0, (float)Math.pow(2, bitsPerSample), decode.getMin(), decode.getMax());
            outputValues[i] = clipToRange(outputValues[i], range.getMin(), range.getMax());
        }

        COSArray result = new COSArray();
        result.setFloatArray(outputValues);
View Full Code Here

    {
        //This function is known as a "stitching" function. Based on the input, it decides which child function to call.
        //See PDF Reference section 3.9.3.
        PDFunction function = null;
        float x = ((COSFloat)input.get(0)).floatValue();
        PDRange domain = getDomainForInput(1);
        // clip input value to domain
        x = clipToRange(x, domain.getMin(), domain.getMax());

        float[] boundsValues = getBounds().toFloatArray();
        int boundsSize = boundsValues.length;
        if (boundsSize == 0 || x < boundsValues[0])
        {
            function = PDFunction.create(getFunctions().get(0));
            PDRange encode = getEncodeForParameter(0);
            if (boundsSize == 0)
            {
                x = interpolate(x, domain.getMin(), domain.getMax(), encode.getMin(), encode.getMax());
            }
            else
            {
                x = interpolate(x, domain.getMin(), boundsValues[0], encode.getMin(), encode.getMax());
            }
        }
        else
        {
            for (int i=0; i<boundsSize-1; i++)
            {
                if ( x >= boundsValues[i] && x < boundsValues[i+1] )
                {
                    function = PDFunction.create(getFunctions().get(i+1));
                    PDRange encode = getEncodeForParameter(i+1);
                    x = interpolate(x, boundsValues[i], boundsValues[i+1], encode.getMin(), encode.getMax());
                    break;
                }
            }
            if(function==null) //must be in last partition
            {
                function = PDFunction.create(getFunctions().get(boundsSize+1));
                PDRange encode = getEncodeForParameter(boundsSize+1);
                x = interpolate(x, boundsValues[boundsSize-1], domain.getMax(), encode.getMin(), encode.getMax());
            }
        }
        COSArray functionValues = new COSArray();
        functionValues.add(new COSFloat(x));
        COSArray functionResult = function.eval(functionValues);
View Full Code Here

     * @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

TOP

Related Classes of org.apache.pdfbox.pdmodel.common.PDRange

Copyright © 2018 www.massapicom. 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.