Example usage for com.lowagie.text.pdf Barcode128 setX

List of usage examples for com.lowagie.text.pdf Barcode128 setX

Introduction

In this page you can find the example usage for com.lowagie.text.pdf Barcode128 setX.

Prototype

public void setX(float x) 

Source Link

Document

Sets the minimum bar width.

Usage

From source file:org.tellervo.desktop.util.labels.PDFLabelMaker.java

License:Open Source License

public void addLabelsForSamples(List<TridasSample> samples) {

    // Loop through samples in list
    for (TridasSample s : samples) {
        Barcode128 barcode = new LabBarcode(LabBarcode.Type.SAMPLE,
                UUID.fromString(s.getIdentifier().getValue().toString()));

        // if it's tiny, hide the label
        if (margins.getLabelHeight() * .80f < barcode.getBarHeight()) {
            barcode.setBarHeight(margins.getLabelHeight() * .45f);
            barcode.setX(1.8f);
            barcode.setN(10f);//from   www  .j  a  va  2s . c o  m
            barcode.setSize(10f);
            barcode.setBaseline(10f);
            barcode.setBarHeight(50f);
            barcode.setFont(null);
        } else {
            barcode.setBarHeight(margins.getLabelHeight() * .45f);
            barcode.setX(0.6f);
            barcode.setSize(4.0f);

        }

        PdfPCell lbcell = new PdfPCell();

        lbcell.setVerticalAlignment(Element.ALIGN_TOP);
        lbcell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        Phrase p = new Phrase();

        String labelText;
        TridasGenericField labcodeField = GenericFieldUtils.findField(s, "tellervo.internal.labcodeText");

        if (labcodeField == null) {
            log.warn("labcode missing from sample.  Can't print!");
            continue;
        }
        labelText = (labcodeField != null) ? labcodeField.getValue() : s.getTitle();

        p.add(new Chunk(labelText, labelfont));
        //p.add(new Chunk("bbb", labelfont));
        //p.add(new Chunk(s.getIdentifier().getValue().toString(), uuidfont));

        //barcode.setFont(null);
        Image img = barcode.createImageWithBarcode(contentb, Color.black, Color.gray);

        PdfPCell labcell = new PdfPCell();

        if (App.getLabName() != null) {
            labcell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            labcell.setVerticalAlignment(Element.ALIGN_TOP);
            Phrase labPhrase = new Phrase(App.getLabName().toUpperCase(), tinyfont);
            labcell.addElement(labPhrase);
        }
        addCell(labcell);

        PdfPCell bccell = new PdfPCell();
        bccell.setHorizontalAlignment(Element.ALIGN_MIDDLE);

        bccell.addElement(img);
        bccell.addElement(p);
        addCell(bccell);

        lbcell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        lbcell.addElement(p);
        addCell(lbcell);

        //addCell(new PdfPCell());

        /**   PdfPTable tbl = new PdfPTable(2);
                   
           tbl.addCell(bccell);
           tbl.addCell(lbcell);*/

    }

}