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

📄 barcodesymbol.java

📁 遗传算法改进神经网络源程序 该小程序可以添加条形码功能到你的网页或者applet上,这个applet把大写字母和数字转换为标准的条形码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

package com.bokai.barcodes;


// Referenced classes of package com.bokai.barcodes:
//            Barcode, BarcodeDataTriplet, BarcodeSpec, Bars, 
//            CharDef, CalcCharDefState

class BarcodeSymbol
{
    class BarCharEnumerator
    {

        boolean nextBars(Bars bars, CharDef chardef)
        {
            CharDef chardef1 = chardef;
            if(_acText == null || _acText.length == 0)
                return false;
            if((_spec.bdStyle & 0x400) != 0 && (_acText2 == null || _acText2.length == 0))
                return false;
            if((!_bInAddOn && (_spec.bdStyle & 2) == 0 || (_spec.bdStyle2 & 2) == 0) && (_cPrevChars > 0 || _bPrevSpecialChar))
                _nmPrev += _spec.bdInterCharExt;
            int l1;
            if(_spec.hasCalcCharDefSmart())
            {
                chardef1 = _spec.calcCharDefSmart(_acText, _calcState);
                if(chardef1 != null)
                {
                    l1 = _calcState.barStyle;
                } else
                {
                    l1 = 0;
                    return false;
                }
            } else
            {
                if(!_bInAddOn)
                {
                    l1 = 4;
                    if(_cPrevChars == 0 && !_bPrevSpecialChar)
                        l1 |= 1;
                } else
                {
                    l1 = 8;
                    if(_cPrevChars == 0 && !_bPrevSpecialChar)
                        l1 |= 2;
                }
                if(_cPrevChars == 0 && (!_bInAddOn && (_spec.bdStyle & 0x1000) != 0 || _bInAddOn && (_spec.bdStyle2 & 0x1000) != 0) && _bPrevSpecialChar && !_bPrev2ndStartChar)
                {
                    if(!_bInAddOn)
                    {
                        chardef1 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, -5);
                        if((_spec.bdStyle & 0x800) != 0 && (_spec.bdLongBars & 1) != 0)
                            l1 |= 0x10;
                    } else
                    {
                        chardef1 = _spec.calcCharDef2(_spec.bdCharset2, _spec.bdCharsetSel2, _acText2, -5);
                    }
                    _bPrevSpecialChar = true;
                    _bPrev2ndStartChar = true;
                } else
                if(_cPrevChars == 0 && (!_bInAddOn && (_spec.bdStyle & 8) != 0 || _bInAddOn && (_spec.bdStyle2 & 8) != 0) && !_bPrevSpecialChar)
                {
                    if(!_bInAddOn)
                    {
                        chardef1 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, -1);
                        if((_spec.bdStyle & 0x800) != 0 && (_spec.bdLongBars & 1) != 0)
                            l1 |= 0x10;
                    } else
                    {
                        chardef1 = _spec.calcCharDef2(_spec.bdCharset2, _spec.bdCharsetSel2, _acText2, -1);
                    }
                    _bPrevSpecialChar = true;
                } else
                if(!_bInAddOn && (_spec.bdStyle & 0x20) != 0 && _cPrevChars == _spec.bdCentralCharInd && !_bPrevSpecialChar)
                {
                    if(!_bInAddOn)
                    {
                        chardef1 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, -2);
                        if((_spec.bdStyle & 0x800) != 0 && (_spec.bdLongBars & 4) != 0)
                            l1 |= 0x10;
                    } else
                    {
                        chardef1 = _spec.calcCharDef2(_spec.bdCharset2, _spec.bdCharsetSel2, _acText2, -2);
                    }
                    _bPrevSpecialChar = true;
                } else
                if((!_bInAddOn && (_spec.bdStyle & 0x10) != 0 && _cPrevChars == _acText.length || _bInAddOn && (_spec.bdStyle2 & 0x10) != 0 && _cPrevChars == _acText2.length) && !_bPrevSpecialChar)
                {
                    if(!_bInAddOn)
                    {
                        chardef1 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, -3);
                        if((_spec.bdStyle & 0x800) != 0 && (_spec.bdLongBars & 2) != 0)
                            l1 |= 0x10;
                    } else
                    {
                        chardef1 = _spec.calcCharDef2(_spec.bdCharset2, _spec.bdCharsetSel2, _acText2, -3);
                    }
                    _bPrevSpecialChar = true;
                } else
                if((!_bInAddOn && (_spec.bdStyle & 0x40) != 0 || _bInAddOn && (_spec.bdStyle2 & 0x40) != 0) && !_bPrevSpecialChar && (!_bInAddOn && _cPrevChars < _acText.length || _bInAddOn && _cPrevChars < _acText2.length))
                {
                    if(!_bInAddOn)
                        chardef1 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, -4);
                    else
                        chardef1 = _spec.calcCharDef2(_spec.bdCharset2, _spec.bdCharsetSel2, _acText2, -4);
                    _bPrevSpecialChar = true;
                } else
                if((!_bInAddOn && _cPrevChars < _acText.length || _bInAddOn && _cPrevChars < _acText2.length) && (!_bInAddOn && (_spec.bdStyle & 1) != 0 || _bInAddOn && (_spec.bdStyle2 & 1) != 0))
                {
                    CharDef chardef2;
                    CharDef chardef4;
                    if(!_bInAddOn)
                    {
                        chardef2 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, _cPrevChars);
                        chardef4 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, _cPrevChars + 1);
                    } else
                    {
                        chardef2 = _spec.calcCharDef2(_spec.bdCharset, _spec.bdCharsetSel2, _acText2, _cPrevChars);
                        chardef4 = _spec.calcCharDef2(_spec.bdCharset, _spec.bdCharsetSel2, _acText2, _cPrevChars + 1);
                    }
                    chardef1.setCharCode(chardef2.getCharCode());
                    chardef1._BCSETNUMSTRIPE(_spec.bdCharBitNum << 1);
                    chardef1.setStripes(0);
                    for(int i = 0; i < _spec.bdCharBitNum; i++)
                    {
                        int l = chardef4.BCGETSTRIPE(i);
                        l = CharDef._BCTURNSTRIPETOSPACE(l);
                        chardef1._BCSETSTRIPE(i * 2, l);
                        l = chardef2.BCGETSTRIPE(i);
                        chardef1._BCSETSTRIPE(i * 2 + 1, l);
                    }

                    _cPrevChars += 2;
                    _bPrevSpecialChar = false;
                } else
                if(!_bInAddOn && _cPrevChars < _acText.length || _bInAddOn && _cPrevChars < _acText2.length)
                {
                    CharDef chardef3 = null;
                    int j;
                    if(!_bInAddOn)
                    {
                        for(j = _cPrevChars; j < _acText.length; j++)
                        {
                            chardef3 = _spec.calcCharDef(_spec.bdCharset, _spec.bdCharsetSel, _acText, j);
                            if(chardef3 != null)
                                break;
                        }

                        if(_cPrevChars == 0 && (_spec.bdStyle & 0x800) != 0 && (_spec.bdLongBars & 8) != 0)
                            l1 |= 0x10;
                        else
                        if(j == _acText.length - 1 && (_spec.bdStyle & 0x800) != 0 && (_spec.bdLongBars & 0x10) != 0)
                            l1 |= 0x10;
                    } else
                    {
                        for(j = _cPrevChars; j < _acText2.length; j++)
                        {
                            chardef3 = _spec.calcCharDef2(_spec.bdCharset2, _spec.bdCharsetSel2, _acText2, j);
                            if(chardef3 != null)
                                break;
                        }

                    }
                    if(chardef3 != null)
                    {
                        _cPrevChars = j + 1;
                        chardef1 = chardef;
                        chardef1.copyFrom(chardef3);
                        chardef1._BCSETNUMSTRIPE(_spec.bdCharBitNum);
                        _bPrevSpecialChar = false;
                    } else
                    {
                        _cPrevChars = j;
                        return nextBars(bars, chardef);
                    }
                } else
                if(!_bInAddOn && (_spec.bdStyle & 0x400) != 0)
                {
                    _bInAddOn = true;
                    _cPrevChars = 0;
                    _bPrevSpecialChar = false;
                    _bPrev2ndStartChar = false;
                    _nmPrev += _spec.bdCentralMargin * _spec.bdBarExt[0];
                    return nextBars(bars, chardef);
                } else
                {
                    l1 = 0;
                    return false;
                }
            }
            int j1 = _nmPrev;
            int k1 = 0;
            for(int k = 0; k < chardef1.BCGETNUMSTRIPE(); k++)
            {
                int i1 = chardef1.BCGETSTRIPE(k);
                if(CharDef.BCSTRIPEISBAR(i1))
                {
                    if((_spec.bdStyle & 0x10000) != 0)
                        k1 += _spec.bdBarExt[0];
                    else
                        k1 += _spec.bdBarExt[CharDef.BCSTRIPEWTHIND(i1)];
                } else
                if((_spec.bdStyle & 0x10000) != 0)
                    k1 += _spec.bdSpaceExt[0];
                else
                    k1 += _spec.bdSpaceExt[CharDef.BCSTRIPEWTHIND(i1)];
            }

            _nmPrev = j1 + k1;
            bars.setAll(chardef1, j1, k1, l1);
            return true;
        }

        int _nmPrev;
        int _cPrevChars;
        boolean _bPrevSpecialChar;
        boolean _bPrev2ndStartChar;
        boolean _bInAddOn;
        CalcCharDefState _calcState;

        BarCharEnumerator()
        {
            _cPrevChars = 0;
            _nmPrev = _spec.bdLeftMargin * _spec.bdBarExt[0];
            _bPrevSpecialChar = false;
            _bPrev2ndStartChar = false;
            _bInAddOn = false;
            _calcState = new CalcCharDefState();
            _calcState.setAll(-1, 0, 0, 0);
        }
    }


    BarcodeSymbol(BarcodeSpec barcodespec)
    {
        _spec = barcodespec;
        BarcodeDataTriplet barcodedatatriplet = _spec.getDefaultFullData();
        _acText = null;
        _acText2 = null;
        _acOriginalText = null;
        _acText = new char[barcodedatatriplet.data.length];
        System.arraycopy(barcodedatatriplet.data, 0, _acText, 0, barcodedatatriplet.data.length);
        if(barcodedatatriplet.addOnData != null)
        {
            _acText2 = new char[barcodedatatriplet.addOnData.length];
            System.arraycopy(barcodedatatriplet.addOnData, 0, _acText2, 0, barcodedatatriplet.addOnData.length);
        }
        if(barcodedatatriplet.originalData != null)
        {
            _acOriginalText = new char[barcodedatatriplet.originalData.length];
            System.arraycopy(barcodedatatriplet.originalData, 0, _acOriginalText, 0, barcodedatatriplet.originalData.length);
        }
    }

    BarcodeSymbol(String s)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        this((BarcodeSpec)Class.forName(s).newInstance());
    }

    BarCharEnumerator enumerateBars()
    {
        return new BarCharEnumerator();
    }

    char[] getAddOnText(int i, long l)

⌨️ 快捷键说明

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