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

📄 modulefactory.java

📁 这是个国外JAVA爱好者写的条形码生成器
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        C_KEYS.add("15"); C_SET.put("15", new Module(new int[] {1, 1, 3, 2, 2, 2}));
        C_KEYS.add("16"); C_SET.put("16", new Module(new int[] {1, 2, 3, 1, 2, 2}));
        C_KEYS.add("17"); C_SET.put("17", new Module(new int[] {1, 2, 3, 2, 2, 1}));
        C_KEYS.add("18"); C_SET.put("18", new Module(new int[] {2, 2, 3, 2, 1, 1}));
        C_KEYS.add("19"); C_SET.put("19", new Module(new int[] {2, 2, 1, 1, 3, 2}));
        C_KEYS.add("20"); C_SET.put("20", new Module(new int[] {2, 2, 1, 2, 3, 1}));
        C_KEYS.add("21"); C_SET.put("21", new Module(new int[] {2, 1, 3, 2, 1, 2}));
        C_KEYS.add("22"); C_SET.put("22", new Module(new int[] {2, 2, 3, 1, 1, 2}));
        C_KEYS.add("23"); C_SET.put("23", new Module(new int[] {3, 1, 2, 1, 3, 1}));
        C_KEYS.add("24"); C_SET.put("24", new Module(new int[] {3, 1, 1, 2, 2, 2}));
        C_KEYS.add("25"); C_SET.put("25", new Module(new int[] {3, 2, 1, 1, 2, 2}));
        C_KEYS.add("26"); C_SET.put("26", new Module(new int[] {3, 2, 1, 2, 2, 1}));
        C_KEYS.add("27"); C_SET.put("27", new Module(new int[] {3, 1, 2, 2, 1, 2}));
        C_KEYS.add("28"); C_SET.put("28", new Module(new int[] {3, 2, 2, 1, 1, 2}));
        C_KEYS.add("29"); C_SET.put("29", new Module(new int[] {3, 2, 2, 2, 1, 1}));
        C_KEYS.add("30"); C_SET.put("30", new Module(new int[] {2, 1, 2, 1, 2, 3}));
        C_KEYS.add("31"); C_SET.put("31", new Module(new int[] {2, 1, 2, 3, 2, 1}));
        C_KEYS.add("32"); C_SET.put("32", new Module(new int[] {2, 3, 2, 1, 2, 1}));
        C_KEYS.add("33"); C_SET.put("33", new Module(new int[] {1, 1, 1, 3, 2, 3}));
        C_KEYS.add("34"); C_SET.put("34", new Module(new int[] {1, 3, 1, 1, 2, 3}));
        C_KEYS.add("35"); C_SET.put("35", new Module(new int[] {1, 3, 1, 3, 2, 1}));
        C_KEYS.add("36"); C_SET.put("36", new Module(new int[] {1, 1, 2, 3, 1, 3}));
        C_KEYS.add("37"); C_SET.put("37", new Module(new int[] {1, 3, 2, 1, 1, 3}));
        C_KEYS.add("38"); C_SET.put("38", new Module(new int[] {1, 3, 2, 3, 1, 1}));
        C_KEYS.add("39"); C_SET.put("39", new Module(new int[] {2, 1, 1, 3, 1, 3}));
        C_KEYS.add("40"); C_SET.put("40", new Module(new int[] {2, 3, 1, 1, 1, 3}));
        C_KEYS.add("41"); C_SET.put("41", new Module(new int[] {2, 3, 1, 3, 1, 1}));
        C_KEYS.add("42"); C_SET.put("42", new Module(new int[] {1, 1, 2, 1, 3, 3}));
        C_KEYS.add("43"); C_SET.put("43", new Module(new int[] {1, 1, 2, 3, 3, 1}));
        C_KEYS.add("44"); C_SET.put("44", new Module(new int[] {1, 3, 2, 1, 3, 1}));
        C_KEYS.add("45"); C_SET.put("45", new Module(new int[] {1, 1, 3, 1, 2, 3}));
        C_KEYS.add("46"); C_SET.put("46", new Module(new int[] {1, 1, 3, 3, 2, 1}));
        C_KEYS.add("47"); C_SET.put("47", new Module(new int[] {1, 3, 3, 1, 2, 1}));
        C_KEYS.add("48"); C_SET.put("48", new Module(new int[] {3, 1, 3, 1, 2, 1}));
        C_KEYS.add("49"); C_SET.put("49", new Module(new int[] {2, 1, 1, 3, 3, 1}));
        C_KEYS.add("50"); C_SET.put("50", new Module(new int[] {2, 3, 1, 1, 3, 1}));
        C_KEYS.add("51"); C_SET.put("51", new Module(new int[] {2, 1, 3, 1, 1, 3}));
        C_KEYS.add("52"); C_SET.put("52", new Module(new int[] {2, 1, 3, 3, 1, 1}));
        C_KEYS.add("53"); C_SET.put("53", new Module(new int[] {2, 1, 3, 1, 3, 1}));
        C_KEYS.add("54"); C_SET.put("54", new Module(new int[] {3, 1, 1, 1, 2, 3}));
        C_KEYS.add("55"); C_SET.put("55", new Module(new int[] {3, 1, 1, 3, 2, 1}));
        C_KEYS.add("56"); C_SET.put("56", new Module(new int[] {3, 3, 1, 1, 2, 1}));
        C_KEYS.add("57"); C_SET.put("57", new Module(new int[] {3, 1, 2, 1, 1, 3}));
        C_KEYS.add("58"); C_SET.put("58", new Module(new int[] {3, 1, 2, 3, 1, 1}));
        C_KEYS.add("59"); C_SET.put("59", new Module(new int[] {3, 3, 2, 1, 1, 1}));
        C_KEYS.add("60"); C_SET.put("60", new Module(new int[] {3, 1, 4, 1, 1, 1}));
        C_KEYS.add("61"); C_SET.put("61", new Module(new int[] {2, 2, 1, 4, 1, 1}));
        C_KEYS.add("62"); C_SET.put("62", new Module(new int[] {4, 3, 1, 1, 1, 1}));
        C_KEYS.add("63"); C_SET.put("63", new Module(new int[] {1, 1, 1, 2, 2, 4}));
        C_KEYS.add("64"); C_SET.put("64", new Module(new int[] {1, 1, 1, 4, 2, 2}));
        C_KEYS.add("65"); C_SET.put("65", new Module(new int[] {1, 2, 1, 1, 2, 4}));
        C_KEYS.add("66"); C_SET.put("66", new Module(new int[] {1, 2, 1, 4, 2, 1}));
        C_KEYS.add("67"); C_SET.put("67", new Module(new int[] {1, 4, 1, 1, 2, 2}));
        C_KEYS.add("68"); C_SET.put("68", new Module(new int[] {1, 4, 1, 2, 2, 1}));
        C_KEYS.add("69"); C_SET.put("69", new Module(new int[] {1, 1, 2, 2, 1, 4}));
        C_KEYS.add("70"); C_SET.put("70", new Module(new int[] {1, 1, 2, 4, 1, 2}));
        C_KEYS.add("71"); C_SET.put("71", new Module(new int[] {1, 2, 2, 1, 1, 4}));
        C_KEYS.add("72"); C_SET.put("72", new Module(new int[] {1, 2, 2, 4, 1, 1}));
        C_KEYS.add("73"); C_SET.put("73", new Module(new int[] {1, 4, 2, 1, 1, 2}));
        C_KEYS.add("74"); C_SET.put("74", new Module(new int[] {1, 4, 2, 2, 1, 1}));
        C_KEYS.add("75"); C_SET.put("75", new Module(new int[] {2, 4, 1, 2, 1, 1}));
        C_KEYS.add("76"); C_SET.put("76", new Module(new int[] {2, 2, 1, 1, 1, 4}));
        C_KEYS.add("77"); C_SET.put("77", new Module(new int[] {4, 1, 3, 1, 1, 1}));
        C_KEYS.add("78"); C_SET.put("78", new Module(new int[] {2, 4, 1, 1, 1, 2}));
        C_KEYS.add("79"); C_SET.put("79", new Module(new int[] {1, 3, 4, 1, 1, 1}));
        C_KEYS.add("80"); C_SET.put("80", new Module(new int[] {1, 1, 1, 2, 4, 2}));
        C_KEYS.add("81"); C_SET.put("81", new Module(new int[] {1, 2, 1, 1, 4, 2}));
        C_KEYS.add("82"); C_SET.put("82", new Module(new int[] {1, 2, 1, 2, 4, 1}));
        C_KEYS.add("83"); C_SET.put("83", new Module(new int[] {1, 1, 4, 2, 1, 2}));
        C_KEYS.add("84"); C_SET.put("84", new Module(new int[] {1, 2, 4, 1, 1, 2}));
        C_KEYS.add("85"); C_SET.put("85", new Module(new int[] {1, 2, 4, 2, 1, 1}));
        C_KEYS.add("86"); C_SET.put("86", new Module(new int[] {4, 1, 1, 2, 1, 2}));
        C_KEYS.add("87"); C_SET.put("87", new Module(new int[] {4, 2, 1, 1, 1, 2}));
        C_KEYS.add("88"); C_SET.put("88", new Module(new int[] {4, 2, 1, 2, 1, 1}));
        C_KEYS.add("89"); C_SET.put("89", new Module(new int[] {2, 1, 2, 1, 4, 1}));
        C_KEYS.add("90"); C_SET.put("90", new Module(new int[] {2, 1, 4, 1, 2, 1}));
        C_KEYS.add("91"); C_SET.put("91", new Module(new int[] {4, 1, 2, 1, 2, 1}));
        C_KEYS.add("92"); C_SET.put("92", new Module(new int[] {1, 1, 1, 1, 4, 3}));
        C_KEYS.add("93"); C_SET.put("93", new Module(new int[] {1, 1, 1, 3, 4, 1}));
        C_KEYS.add("94"); C_SET.put("94", new Module(new int[] {1, 3, 1, 1, 4, 1}));
        C_KEYS.add("95"); C_SET.put("95", new Module(new int[] {1, 1, 4, 1, 1, 3}));
        C_KEYS.add("96"); C_SET.put("96", new Module(new int[] {1, 1, 4, 3, 1, 1}));
        C_KEYS.add("97"); C_SET.put("97", new Module(new int[] {4, 1, 1, 1, 1, 3}));
        C_KEYS.add("98"); C_SET.put("98", new Module(new int[] {4, 1, 1, 3, 1, 1}));
        C_KEYS.add("99"); C_SET.put("99", new Module(new int[] {1, 1, 3, 1, 4, 1}));
        C_KEYS.add("\310");
        C_SET.put("\310", new CodeChangeModule(new int[] {1, 1, 4, 1, 3, 1}, Code128Barcode.B)); // CODE B
        C_KEYS.add("\311");
        C_SET.put("\311", new CodeChangeModule(new int[] {3, 1, 1, 1, 4, 1}, Code128Barcode.A)); // CODE A
        C_KEYS.add("\312");
        C_SET.put("\312", new Module(new int[] {4, 1, 1, 1, 3, 1}));
    }
    
    /**
     * Returns the module that represents the specified character and character set.
     * @param key The data character to get the encoding module for
     * @param mode The character set mode that is currently in use (A, B or C)
     * @return The module that encodes the given char in the given character set
     */
    public static Module getModule(String key, int mode) {
        Module module = null;
        switch (mode) {
            case Code128Barcode.A:
                module = (Module) A_SET.get(key);
                break;
            case Code128Barcode.B:
                module = (Module) B_SET.get(key);
                break;
            case Code128Barcode.C:
                module = (Module) C_SET.get(key);
                break;
        }
        if (module != null) {
            module.setSymbol(key);
        }
        return module;
    }
    
    /**
     * Returns the index of the given character in the encoding tables. This is used
     * when calculating the checksum.
     * @param key The data character sequence to get the index for
     * @param mode The character set mode that is currently in use (A, B or C)
     * @return The index for the given key
     */
    public static int getIndex(String key, int mode) {
        List keys = getKeys(mode);
        return keys.indexOf(key);
    }
    
    /**
     * Returns the encoded module at the given index position. This is used to
     * get the encoded checksum character.
     * @param index The index to get the module for
     * @param mode The character set mode that is currently in use (A, B or C)
     * @return The module at the specified index
     */
    public static Module getModuleForIndex(int index, int mode) {
        List keys = getKeys(mode);
        return getModule((String) keys.get(index), mode);
    }
    
    private static List getKeys(int mode) {
        switch (mode) {
            case Code128Barcode.A:
                return A_KEYS;
            case Code128Barcode.C:
                return C_KEYS;
        }
        return B_KEYS;
    }
}

⌨️ 快捷键说明

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