⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdf417.java

📁 著名IDAutomation公司的JAVA条码控件源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        int ai[] = new int[abyte0.length];
        int ai1[] = new int[30];
        int i1 = 0;
        int j1 = 2;
        while(i1 < abyte0.length)
        {
            String s = "1";
            for(int k1 = 0; k1 < 44 && i1 < abyte0.length; i1++)
            {
                s = s + (char)abyte0[i1];
                k1++;
            }

            BigInteger biginteger = new BigInteger(s);
            int i2 = 0;
            for(; biginteger.compareTo(new BigInteger("0")) != 0; biginteger = biginteger.divide(new BigInteger("900")))
                ai1[i2++] = biginteger.mod(new BigInteger("900")).intValue();

            for(int j2 = 1; j2 <= i2; j2++)
            {
                ai[j1++] = ai1[i2 - j2];
                k++;
            }

        }
        k = k + 2 + j;
        int l = k / i;
        if(mod(k, i) != 0.0D)
            l++;
        if(l < 3)
            l = 3;
        if(l > 90)
            return null;
        if(l > PDFRows)
        {
            runtimeRows = l;
        } else
        {
            l = PDFRows;
            runtimeRows = PDFRows;
        }
        k = l * i;
        if(k > 928)
            return null;
        while(j1 < k - j)
            ai[j1++] = 900;
        ai[0] = j1;
        ai[1] = 902;
        genEC(ai, j1);
        int ai2[] = new int[k];
        for(int l1 = 0; l1 < k; l1++)
            ai2[l1] = ai[l1];

        return ai2;
    }

    protected int[] PDF417_compact_text(byte abyte0[], int i)
    {
        int j = (int)Math.pow(2D, PDFECLevel + 1);
        int k = 0;
        String s = "A";
        String s1 = "A";
        boolean flag = false;
        boolean flag1 = false;
        String s3 = "A";
        if(i < 1 || i > 30)
            i = 1;
        int ai[] = new int[1000 + abyte0.length * 3];
        int k1 = 0;
        int l1 = 0;
        boolean flag2 = false;
        while(k1 < abyte0.length)
        {
            int i1 = findChar(textCodes, "" + (char)abyte0[k1]);
            k1++;
            if(i1 >= 0)
            {
                if(s3.compareTo("B") == 0 && s.compareTo("A") == 0)
                    s = "B";
                String s2 = textCodes[i1][1];
                int j1 = (new Integer(s2.substring(1, s2.length()))).intValue();
                s2 = "" + s2.charAt(0);
                boolean flag3 = false;
                if(s2.compareTo(s) == 0)
                {
                    ai[l1++] = j1;
                    flag3 = true;
                }
                if(s2.compareTo("D") == 0 && !flag3)
                {
                    ai[l1++] = 29;
                    ai[l1++] = j1;
                    flag3 = true;
                }
                if(s2.compareTo("C") == 0 && s.compareTo("C") != 0 && !flag3)
                {
                    ai[l1++] = 28;
                    ai[l1++] = j1;
                    flag3 = true;
                    s = "C";
                }
                if(s2.compareTo("B") == 0 && s.compareTo("B") != 0 && !flag3)
                {
                    ai[l1++] = 27;
                    ai[l1++] = j1;
                    flag3 = true;
                    s = "B";
                    s3 = "B";
                }
                if(s2.compareTo("A") == 0 && s.compareTo("A") != 0 && !flag3)
                {
                    if(s.compareTo("B") == 0)
                        ai[l1++] = 27;
                    if(s.compareTo("C") == 0)
                    {
                        ai[l1++] = 28;
                        s3 = "A";
                    }
                    ai[l1++] = j1;
                    boolean flag4 = true;
                    s = "A";
                }
            }
        }
        if(mod(l1, 2D) != 0.0D)
            ai[l1++] = 29;
        k = l1 / 2 + 1 + j;
        int i2 = l1 / 2 + 1;
        int l = k / i;
        if(mod(k, i) != 0.0D)
            l++;
        if(l < 3)
            l = 3;
        if(l > 90)
            return null;
        if(l > PDFRows)
        {
            runtimeRows = l;
        } else
        {
            l = PDFRows;
            runtimeRows = PDFRows;
        }
        k = l * i;
        if(k > 928)
            return null;
        int j2 = k - j - i2;
        for(int k2 = 0; k2 < j2; k2++)
        {
            ai[l1++] = 30;
            ai[l1++] = 0;
        }

        int ai1[] = new int[k];
        ai1[0] = k - j;
        for(int l2 = 1; l2 <= l1; l2++)
            if(mod(l2 - 1, 2D) == 0.0D)
                ai1[(l2 - 1) / 2 + 1] = ai[l2 - 1];
            else
                ai1[l2 / 2] = ai1[(l2 - 1) / 2 + 1] * 30 + ai[l2 - 1];

        genEC(ai1, ai1.length - j);
        return ai1;
    }

    protected void genEC(int ai[], int i)
    {
        int j = (int)Math.pow(2D, PDFECLevel + 1);
        int ai1[] = new int[j];
        boolean flag = false;
        boolean flag1 = false;
        boolean flag2 = false;
        for(int k = 0; k < j; k++)
            ai1[k] = 0;

        for(int l = 0; l < i; l++)
        {
            int j1 = (int)mod(ai[l] + ai1[j - 1], 929D);
            for(int k2 = j - 1; k2 >= 1; k2--)
            {
                int k1 = (int)mod(j1 * coef[PDFECLevel][k2], 929D);
                int i2 = 929 - k1;
                ai1[k2] = (int)mod(ai1[k2 - 1] + i2, 929D);
            }

            int l1 = (int)mod(j1 * coef[PDFECLevel][0], 929D);
            int j2 = 929 - l1;
            ai1[0] = (int)mod(j2, 929D);
        }

        for(int l2 = j - 1; l2 >= 0; l2--)
            if(ai1[l2] != 0)
                ai1[l2] = 929 - ai1[l2];

        for(int i1 = 0; i1 < j; i1++)
            ai[i + i1] = ai1[j - (i1 + 1)];

    }

    protected void addBar(Graphics g, int i, boolean flag, int j)
    {
        if(flag)
        {
            g.setColor(barColor);
            g.fillRect(currentX, topMarginPixels + j, i, (barHeightPixels + extraHeight) - j);
        }
        currentX = currentX + i;
    }

    protected void paintChar(Graphics g, String s, String s1)
    {
        paintChar2(g, s, s1, 0);
    }

    protected void paintChar2(Graphics g, String s, String s1, int i)
    {
        for(int j = 0; j < s.length(); j++)
        {
            char c = s.charAt(j);
            char c1 = s1.charAt(j);
            if(c1 == 'n')
                addBar(g, narrowBarPixels, c == 'b', i);
            if(c1 == 'w')
                addBar(g, widthBarPixels, c == 'b', i);
            if(c1 == '1')
                addBar(g, narrowBarPixels, c == 'b', i);
            if(c1 == '2')
                addBar(g, narrowBarPixels * 2, c == 'b', i);
            if(c1 == '3')
                addBar(g, narrowBarPixels * 3, c == 'b', i);
            if(c1 == '4')
                addBar(g, narrowBarPixels * 4, c == 'b', i);
        }

    }

    protected void calculateSizes()
    {
        int i = 0;
        if(binaryCode != null)
            i = binaryCode.length;
        if(binaryCode == null)
            i = code.length();
        narrowBarCM = X;
        widthBarCM = X * N;
        if(narrowBarCM != 0.0D)
            narrowBarPixels = (int)(narrowBarCM * (double)resolution);
        if(widthBarCM != 0.0D)
            widthBarPixels = (int)(widthBarCM * (double)resolution);
        if(narrowBarPixels <= 0)
            narrowBarPixels = 1;
        barHeightPixels = (int)((double)narrowBarPixels * XtoYRatio);
        if(widthBarPixels <= 1)
            widthBarPixels = 2;
    }

    public void paint(Graphics g)
    {
        Graphics g1 = g;
        Image image = null;
        if(rotate != 0)
        {
            String s = System.getProperty("java.version");
            if(s.indexOf("1.0") == 0 || s.indexOf("1.1") == 0)
            {
                image = createImage(getSize().width, getSize().height);
                g1 = image.getGraphics();
            } else
            {
                IDAImageCreator idaimagecreator = new IDAImageCreator();
                image = idaimagecreator.getImage(getSize().width, getSize().height);
                g1 = idaimagecreator.getGraphics();
            }
        }
        g.setColor(backColor);
        g.fillRect(0, 0, getSize().width, getSize().height);
        paintBasis(g1);
        if(rotate != 0)
        {
            int i = currentX + leftMarginPixels;
            int j = currentY + topMarginPixels;
            Image image1 = rotate(image, rotate, i, j);
            if(image1 == null)
                g.drawImage(image, 0, 0, null);
            else
                g.drawImage(image1, 0, 0, null);
        }
    }

    protected Image rotate(Image image, int i, int j, int k)
    {
        int l = image.getWidth(null);
        int i1 = image.getHeight(null);
        if(j > l)
            j = l;
        if(k > i1)
            k = i1;
        int ai[] = new int[l * i1];
        int ai1[] = new int[j * k];
        PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, l, i1, ai, 0, l);
        try
        {
            pixelgrabber.grabPixels();
        }
        catch(InterruptedException interruptedexception)
        {
            System.err.println("interrupted waiting for pixels!");
            return null;
        }
        if((pixelgrabber.getStatus(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -