• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BarcodeDimension类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.krysalis.barcode4j.BarcodeDimension的典型用法代码示例。如果您正苦于以下问题:Java BarcodeDimension类的具体用法?Java BarcodeDimension怎么用?Java BarcodeDimension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BarcodeDimension类属于org.krysalis.barcode4j包,在下文中一共展示了BarcodeDimension类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getBarcode

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
private static Image getBarcode(String value, AbstractBarcodeBean barcode) {

        BarcodeDimension dim = barcode.calcDimensions(value);
        int width = (int) dim.getWidth(0) + 20;
        int height = (int) dim.getHeight(0);

        BufferedImage imgtext = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = imgtext.createGraphics();

        g2d.setColor(Color.WHITE);
        g2d.fillRect(0, 0, width, height);

        g2d.setColor(Color.BLACK);

        try {
            barcode.generateBarcode(new Java2DCanvasProvider(g2d, 0), value);
        } catch (IllegalArgumentException e) {
            g2d.drawRect(0, 0, width - 1, height - 1);
            g2d.drawString(value, 2, height - 3);
        }

        g2d.dispose();

        return imgtext;
    }
 
开发者ID:nordpos,项目名称:nordpos,代码行数:26,代码来源:BarcodeImage.java


示例2: establishDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public void establishDimensions(BarcodeDimension dim) {
    super.establishDimensions(dim);
    int orientation = BarcodeDimension.normalizeOrientation(getOrientation());
    double w = dim.getWidthPlusQuiet(orientation);
    double h = dim.getHeightPlusQuiet(orientation);
    this.g2d = (Graphics2D)this.g2d.create();
    switch (orientation) {
    case 90:
        g2d.rotate(-Math.PI / 2);
        g2d.translate(-h, 0);
        break;
    case 180:
        g2d.rotate(-Math.PI);
        g2d.translate(-w, -h);
        break;
    case 270:
        g2d.rotate(-Math.PI * 1.5);
        g2d.translate(0, -w);
        break;
    default:
        //nop
    }
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:25,代码来源:Java2DCanvasProvider.java


示例3: prepareGraphics2D

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/**
 * Prepares a Graphics2D object for painting on a given BufferedImage. The
 * coordinate system is adjusted to the demands of the Java2DCanvasProvider.
 * @param image the BufferedImage instance
 * @param dim the barcode dimensions
 * @param orientation the barcode orientation (0, 90, 180, 270)
 * @param antiAlias true enables anti-aliasing
 * @return the Graphics2D object to paint on
 */
public static Graphics2D prepareGraphics2D(BufferedImage image, 
            BarcodeDimension dim, int orientation,
            boolean antiAlias) {
    Graphics2D g2d = image.createGraphics();
    if (antiAlias) {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
            RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, 
                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }
    g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
        RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    g2d.setBackground(Color.white);
    g2d.setColor(Color.black);
    g2d.clearRect(0, 0, image.getWidth(), image.getHeight());
    g2d.scale(image.getWidth() / dim.getWidthPlusQuiet(orientation), 
            image.getHeight() / dim.getHeightPlusQuiet(orientation));
    return g2d;
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:29,代码来源:BitmapBuilder.java


示例4: calcDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/**
 * @see org.krysalis.barcode4j.BarcodeGenerator#calcDimensions(String)
 */
public BarcodeDimension calcDimensions(String msg) {

    int sourceCodeWords = PDF417HighLevelEncoder.encodeHighLevel(msg).length();
    Dimension dimension = PDF417LogicImpl.determineDimensions(this,
            sourceCodeWords);

    if (dimension == null) {
        throw new IllegalArgumentException("Unable to fit message in columns");
    }

    double width = (17 * dimension.width + 69) * getModuleWidth();
    double height = (getBarHeight() * dimension.height);
    double qzh = (hasQuietZone() ? getQuietZone() : 0);
    double qzv = (hasQuietZone() ? getVerticalQuietZone() : 0);
    return new BarcodeDimension(width, height,
            width + (2 * qzh), height + (2 * qzv),
            qzh, qzv);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:22,代码来源:PDF417Bean.java


示例5: calcDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/**
 * @see org.krysalis.barcode4j.BarcodeGenerator#calcDimensions(String)
 */
public BarcodeDimension calcDimensions(String msg) {
    int msgLen = msg.length();
    if (getChecksumMode() == ChecksumMode.CP_ADD) {
        msgLen++;
    }
    if ((msgLen % 2) != 0) {
        msgLen++; //Compensate for odd number of characters
    }
    final double charwidth = 2 * wideFactor + 3;
    final double width = ((msgLen * charwidth) + 6 + wideFactor) * moduleWidth;
    final double qz = (hasQuietZone() ? quietZone : 0);
    return new BarcodeDimension(width, getHeight(), 
            width + (2 * qz), getHeight(), 
            quietZone, 0.0);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:19,代码来源:Interleaved2Of5Bean.java


示例6: calcDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public BarcodeDimension calcDimensions(String msg) {
    int msgLen = msg.length();
    if (getChecksumMode() == ChecksumMode.CP_ADD) {
        msgLen++;
    }
    if ((msgLen % 2) != 0) {
        msgLen++; //Compensate for odd number of characters
    }
    final double charwidth = 2 * getWideFactor() + 3;
    final double width = ((msgLen * charwidth) + 6 + getWideFactor()) * getModuleWidth();
    final double qz = getQuietZone();
    final double vBearerBar = (isBearerBox() ? getBearerBarWidth() : 0.0);
    return new BarcodeDimension(width, getHeight(),
            width + (2 * qz) + (2 * vBearerBar), getHeight() + (2 * getBearerBarWidth()),
            vBearerBar + getQuietZone(), getBearerBarWidth());
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:18,代码来源:ITF14Bean.java


示例7: calcDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public BarcodeDimension calcDimensions(String msg) {
    String encoded;
    try {
        encoded = DataMatrixHighLevelEncoder.encodeHighLevel(msg,
                shape, getMinSize(), getMaxSize());
    } catch (IOException e) {
        throw new IllegalArgumentException("Cannot fetch data: " + e.getLocalizedMessage());
    }
    DataMatrixSymbolInfo symbolInfo = DataMatrixSymbolInfo.lookup(encoded.length(), shape);

    double width = symbolInfo.getSymbolWidth() * getModuleWidth();
    double height = symbolInfo.getSymbolHeight() * getBarHeight();
    double qzh = (hasQuietZone() ? getQuietZone() : 0);
    double qzv = (hasQuietZone() ? getVerticalQuietZone() : 0);
    return new BarcodeDimension(width, height,
            width + (2 * qzh), height + (2 * qzv),
            qzh, qzv);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:20,代码来源:DataMatrixBean.java


示例8: getDimension

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
public Point2D getDimension(Point2D view) {
    Configuration cfg = ConfigurationUtil.buildConfiguration(this.doc);
    try {
        String msg = ConfigurationUtil.getMessage(cfg);
        msg = MessageUtil.unescapeUnicode(msg);

        int orientation = cfg.getAttributeAsInteger("orientation", 0);
        orientation = BarcodeDimension.normalizeOrientation(orientation);

        BarcodeGenerator bargen = BarcodeUtil.getInstance().
                createBarcodeGenerator(cfg);
        String expandedMsg = VariableUtil.getExpandedMessage((PageInfo)null, msg);
        BarcodeDimension bardim = bargen.calcDimensions(expandedMsg);
        float w = (float)UnitConv.mm2pt(bardim.getWidthPlusQuiet(orientation));
        float h = (float)UnitConv.mm2pt(bardim.getHeightPlusQuiet(orientation));
        return new Point2D.Float(w, h);
    } catch (ConfigurationException ce) {
        ce.printStackTrace();
    } catch (BarcodeException be) {
        be.printStackTrace();
    }
    return null;
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:24,代码来源:BarcodeElement.java


示例9: renderUsingEPS

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
private void renderUsingEPS(RendererContext context, BarcodeGenerator bargen,
            String msg, int orientation) throws IOException {
    PSGenerator gen = (PSGenerator)context.getProperty(PS_GENERATOR);
    ByteArrayOutputStream baout = new ByteArrayOutputStream(1024);
    EPSCanvasProvider canvas = new EPSCanvasProvider(baout, orientation);
    bargen.generateBarcode(canvas, msg);
    canvas.finish();

    final BarcodeDimension barDim = canvas.getDimensions();
    float bw = (float)UnitConv.mm2pt(barDim.getWidthPlusQuiet(orientation));
    float bh = (float)UnitConv.mm2pt(barDim.getHeightPlusQuiet(orientation));

    float width = ((Integer)context.getProperty(WIDTH)).intValue() / 1000f;
    float height = ((Integer)context.getProperty(HEIGHT)).intValue() / 1000f;
    float x = ((Integer)context.getProperty(XPOS)).intValue() / 1000f;
    float y = ((Integer)context.getProperty(YPOS)).intValue() / 1000f;

    if (DEBUG) {
        System.out.println(" --> EPS");
    }
    PSImageUtils.renderEPS(new java.io.ByteArrayInputStream(baout.toByteArray()),
            "Barcode:" + msg,
            new Rectangle2D.Float(x, y, width, height),
            new Rectangle2D.Float(0, 0, bw, bh),
            gen);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:27,代码来源:BarcodeXMLHandler.java


示例10: paint

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
public void paint(Graphics2D g2d, Rectangle2D area) {
    double w = area.getWidth();
    double h = area.getHeight();

    //Fit in paint area and
    //set up for the CanvasProvider's internal coordinate system (mm-based)
    g2d.translate(area.getX(), area.getY());
    BarcodeDimension bardim = barcodeImage.getBarcodeDimension();
    double bsx = w / bardim.getWidthPlusQuiet(orientation);
    double bsy = h / bardim.getHeightPlusQuiet(orientation);
    g2d.scale(bsx, bsy);

    g2d.setColor(Color.BLACK);
    Java2DCanvasProvider canvas = new Java2DCanvasProvider(g2d, orientation);
    bargen.generateBarcode(canvas, msg);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:17,代码来源:ImageConverterBarcode2G2D.java


示例11: render

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
@Override
public void render(Graphics2D grx, Rectangle2D rectangle) throws JRException {
    
    if (barcode == null || code == null || code.equals("")) {
        throw new JRException("Barcode not defined");
    }
    
    try {
        
        BarcodeDimension dimension = barcode.calcDimensions(code);
        Rectangle2D barcodeDim = dimension.getBoundingRect();
        
        Graphics2D graphics = (Graphics2D) grx.create();
        graphics.translate(rectangle.getX(), rectangle.getY());
        graphics.scale(rectangle.getWidth() / barcodeDim.getWidth(), 
                rectangle.getHeight() / barcodeDim.getHeight());

        Java2DCanvasProvider canvasProvider = new Java2DCanvasProvider(graphics, 0);
        barcode.generateBarcode(canvasProvider, code);
        
    } catch (Throwable e) {
        throw new JRException("Error while generating barcode", e);
    }
}
 
开发者ID:maxdelo77,项目名称:replyit-master-3.2-final,代码行数:25,代码来源:BarcodeRenderer.java


示例12: getBarcode

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
private static Image getBarcode(String value, AbstractBarcodeBean barcode) {
    
    barcode.setModuleWidth(1.0); 
    barcode.setBarHeight(40.0);
    barcode.setFontSize(10.0);
    barcode.setQuietZone(10.0);
    barcode.doQuietZone(true);                
    BarcodeDimension dim = barcode.calcDimensions(value);
    int width = (int) dim.getWidth(0) + 20;
    int height = (int) dim.getHeight(0);        
    
    BufferedImage imgtext = new BufferedImage(width, height,  BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = imgtext.createGraphics();
    
    g2d.setColor(Color.WHITE);
    g2d.fillRect(0, 0, width, height);
    
    g2d.setColor(Color.BLACK);
    
    try {
        barcode.generateBarcode(new Java2DCanvasProvider(g2d, 0), value);
    } catch (IllegalArgumentException e) {
        g2d.drawRect(0, 0, width - 1, height - 1);
        g2d.drawString(value, 2, height - 3);
    }
    
    g2d.dispose();
    
    return imgtext;  
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:31,代码来源:BarcodeImage.java


示例13: establishDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public void establishDimensions(BarcodeDimension dim) {
    super.establishDimensions(dim);
    this.image = BitmapBuilder.prepareImage(dim, getOrientation(),
            this.resolution, this.imageType);
    this.delegate = new Java2DCanvasProvider(
        BitmapBuilder.prepareGraphics2D(this.image, dim, getOrientation(),
                this.antiAlias), getOrientation());
    this.delegate.establishDimensions(dim);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:11,代码来源:BitmapCanvasProvider.java


示例14: prepareImage

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/**
 * Prepares a BufferedImage to paint to.
 * @param dim the barcode dimensions
 * @param orientation the barcode orientation (0, 90, 180, 270)
 * @param resolution the desired image resolution (dots per inch)
 * @param imageType the desired image type (Values: BufferedImage.TYPE_*)
 * @return the requested BufferedImage
 */
public static BufferedImage prepareImage(BarcodeDimension dim,
                    int orientation,
                    int resolution, int imageType) {
    int bmw = UnitConv.mm2px(dim.getWidthPlusQuiet(orientation), resolution);
    int bmh = UnitConv.mm2px(dim.getHeightPlusQuiet(orientation), resolution);
    BufferedImage bi = new BufferedImage(
            bmw,
            bmh,
            imageType);
    return bi;
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:20,代码来源:BitmapBuilder.java


示例15: getImage

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/**
 * Generates a barcode as bitmap image.
 * @param bargen the BarcodeGenerator to use
 * @param msg the message to encode
 * @param resolution the desired image resolution (dots per inch)
 * @return the requested BufferedImage
 */
public static BufferedImage getImage(BarcodeGenerator bargen, String msg, int resolution) {
    BarcodeDimension dim = bargen.calcDimensions(msg);
    BufferedImage bi = prepareImage(dim, resolution, BufferedImage.TYPE_BYTE_GRAY);
    int orientation = 0;
    Graphics2D g2d = prepareGraphics2D(bi, dim, orientation, true);
    Java2DCanvasProvider provider = new Java2DCanvasProvider(g2d, orientation);
    bargen.generateBarcode(provider, msg);
    bi.flush();
    return bi;
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:18,代码来源:BitmapBuilder.java


示例16: establishDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public void establishDimensions(BarcodeDimension dim) {
    super.establishDimensions(dim);
    int orientation = BarcodeDimension.normalizeOrientation(getOrientation());
    Element svg = (Element)doc.getDocumentElement();
    svg.setAttribute("width", addUnit(dim.getWidthPlusQuiet(orientation)));
    svg.setAttribute("height", addUnit(dim.getHeightPlusQuiet(orientation)));
    String w = getDecimalFormat().format(dim.getWidthPlusQuiet(orientation));
    String h = getDecimalFormat().format(dim.getHeightPlusQuiet(orientation));
    svg.setAttribute("viewBox", "0 0 " + w + " " + h);
    String transform;
    switch (orientation) {
    case 90:
        transform = "rotate(-90) translate(-" + h + ")";
        break;
    case 180:
        transform = "rotate(-180) translate(-" + w + " -" + h + ")";
        break;
    case 270:
        transform = "rotate(-270) translate(0 -" + w + ")";
        break;
    default:
        transform = null;
    }
    if (transform != null) {
        detailGroup.setAttribute("transform", transform);
    }
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:29,代码来源:SVGCanvasProvider.java


示例17: establishDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public void establishDimensions(BarcodeDimension dim) {
    super.establishDimensions(dim);
    int orientation = BarcodeDimension.normalizeOrientation(getOrientation());
    if (firstError != null) {
        return;
    }
    this.height = dim.getHeightPlusQuiet();
    try {
        writeHeader(dim.getWidthPlusQuiet(orientation),
                dim.getHeightPlusQuiet(orientation));
        String w = formatmm(dim.getWidthPlusQuiet());
        String h = formatmm(dim.getHeightPlusQuiet());
        switch (orientation) {
        case 90:
            writer.write("90 rotate 0" + " -" + h + " translate\n");
            break;
        case 180:
            writer.write("180 rotate -" + w + " -" + h + " translate\n");
            break;
        case 270:
            writer.write("270 rotate -" + w + " 0 translate\n");
            break;
        default:
            //nop
        }
    } catch (IOException ioe) {
        firstError = ioe;
    }
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:31,代码来源:EPSCanvasProvider.java


示例18: calcDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public BarcodeDimension calcDimensions(String msg) {
    String modMsg = RoyalMailCBCLogicImpl.removeStartStop(msg);
    int additional = (getChecksumMode() == ChecksumMode.CP_ADD 
            || getChecksumMode() == ChecksumMode.CP_AUTO) ? 1 : 0;
    final int len = modMsg.length() + additional;
    final double width = (((len * 4) + 2) * moduleWidth) 
            + (((len * 4) + 1) * getIntercharGapWidth());
    final double qzh = (hasQuietZone() ? getQuietZone() : 0);        
    final double qzv = (hasQuietZone() ? getVerticalQuietZone() : 0);        
    return new BarcodeDimension(width, getBarHeight(), 
            width + (2 * qzh), getBarHeight() + (2 * qzv), 
            qzh, qzv);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:15,代码来源:RoyalMailCBCBean.java


示例19: calcDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public BarcodeDimension calcDimensions(String msg) {
    final int barCount = 65;
    final double width = (barCount * getModuleWidth()) 
            + ((barCount - 1) * getIntercharGapWidth());
    final double qzh = (hasQuietZone() ? getQuietZone() : 0);
    final double qzv = (hasQuietZone() ? getVerticalQuietZone() : 0);
    return new BarcodeDimension(width, getHeight(), 
            width + (2 * qzh), getHeight() + (2 * qzv), 
            qzh, qzv);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:12,代码来源:USPSIntelligentMailBean.java


示例20: calcDimensions

import org.krysalis.barcode4j.BarcodeDimension; //导入依赖的package包/类
/** {@inheritDoc} */
public BarcodeDimension calcDimensions(String msg) {
    double width = 0.0;
    for (int i = 0; i < msg.length(); i++) {
        if (i > 0) {
            width += moduleWidth; //Intercharacter gap
        }
        width += calcCharWidth(msg.charAt(i));
    }
    final double qz = (hasQuietZone() ? quietZone : 0);
    return new BarcodeDimension(width, getHeight(),
            width + (2 * qz), getHeight(),
            quietZone, 0.0);
}
 
开发者ID:thanakrit,项目名称:barcode4j,代码行数:15,代码来源:CodabarBean.java



注:本文中的org.krysalis.barcode4j.BarcodeDimension类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StatusLineElementProvider类代码示例发布时间:2022-05-22
下一篇:
Java Vine类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap