Example usage for com.lowagie.text FontFactory getFont

List of usage examples for com.lowagie.text FontFactory getFont

Introduction

In this page you can find the example usage for com.lowagie.text FontFactory getFont.

Prototype


public static Font getFont(String fontname, float size) 

Source Link

Document

Constructs a Font-object.

Usage

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

public void addSongChordsSimple(Song s) throws DocumentException {

    // If we don't have the chords saved, skip it
    if (s.getChordsSimplified().trim().equals(""))
        return;//  ww w . j  a  va  2  s  .com

    addSongHeader(s);

    Paragraph p;

    p = new Paragraph("("
            + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS SIMPLE") + ")",
            FontFactory.getFont(FontFactory.HELVETICA, 8));
    document.add(p);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    String text[] = s.getChordsSimplified().replace(Song.CHORUS_MARK, " ").replace(Song.SLIDE_BREAK, " ")
            .split("\n");

    addSongChords(text);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    if (exportGuitarTabs) {
        p = new Paragraph(s.getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD));
        guitarTabs.add(p);

        p = new Paragraph("("
                + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS COMPLETE")
                + ")", FontFactory.getFont(FontFactory.HELVETICA, 8));
        guitarTabs.add(p);

        guitarTabs.addAll(addChordsShape(Song.getUsedChords(s.getChordsSimplified())));
    }

    document.newPage();

}

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

public void addSongChordsComplete(Song s) throws DocumentException {

    // If we don't have the chords saved, skip it
    if (s.getChordsComplete().trim().equals(""))
        return;/*w  ww. j  a  va2 s . c o  m*/

    addSongHeader(s);

    Paragraph p;

    p = new Paragraph(
            "(" + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS COMPLETE")
                    + ")",
            FontFactory.getFont(FontFactory.HELVETICA, 8));
    document.add(p);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    String text[] = s.getChordsComplete().replace(Song.CHORUS_MARK, " ").replace(Song.SLIDE_BREAK, " ")
            .split("\n");
    addSongChords(text);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    if (exportGuitarTabs) {
        p = new Paragraph(s.getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD));
        guitarTabs.add(p);
        p = new Paragraph("("
                + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS COMPLETE")
                + ")", FontFactory.getFont(FontFactory.HELVETICA, 8));
        guitarTabs.add(p);

        guitarTabs.addAll(addChordsShape(Song.getUsedChords(s.getChordsComplete())));
    }

    document.newPage();

}

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

private LinkedList<Paragraph> addChordsShape(ArrayList<String> chordsName) throws DocumentException {
    ChordsDB chordsDB = ChordsDB.getInstance();
    String notCatalogued = "";
    LinkedList<Chunk> images = new LinkedList<Chunk>();
    LinkedList<File> filesToDelete = new LinkedList<File>();
    LinkedList<Paragraph> ret = new LinkedList<Paragraph>();

    for (int i = 0; i < chordsName.size(); i++) {
        Chord chord = chordsDB.getChordByName(chordsName.get(i));
        if (chord != null) {
            ChordShapePanel csp = new ChordShapePanel(2, chord.getName(), chord.getShape());
            BufferedImage im = csp.createImage();
            try {
                File tmp = File.createTempFile("datasoul-img", ".png");
                tmp.deleteOnExit();//from w  w w.ja  va 2s.  com
                filesToDelete.add(tmp);

                ImageIO.write(im, "png", tmp);
                Chunk c = new Chunk(Image.getInstance(tmp.getAbsolutePath()), 0, 0, false);
                images.add(c);
            } catch (IOException e) {
                JOptionPane.showMessageDialog(null, java.util.ResourceBundle
                        .getBundle("datasoul/internationalize").getString("INTERNAL ERROR: ") + e.getMessage());
            }
        } else {
            notCatalogued += chordsName.get(i);
        }
    }

    Paragraph p = new Paragraph();

    if (!images.isEmpty()) {
        for (Chunk c : images) {
            p.add(c);
        }
        p.setLeading(images.getFirst().getImage().getScaledHeight());
        p.setKeepTogether(true);
    }

    ret.add(p);

    if (!notCatalogued.equals("")) {
        p = new Paragraph(
                java.util.ResourceBundle.getBundle("datasoul/internationalize")
                        .getString("THE FOLLOWING CHORDS ARE NOT CATALOGED: ") + notCatalogued,
                FontFactory.getFont(FontFactory.HELVETICA, 8));
        ret.add(p);
    }

    for (File f : filesToDelete) {
        try {
            f.delete();
        } catch (Exception e) {
            //ignore, it will be deleted on exit
        }
    }

    return ret;
}

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

public void addGuitarTabs() throws DocumentException {

    document.newPage();// w  w w . j  a va  2s  . c o m

    Paragraph p = new Paragraph(
            java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("GUITAR TABS"),
            FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16));
    document.add(p);

    for (Paragraph p2 : guitarTabs) {
        document.add(p2);
    }

}

From source file:gov.medicaid.services.impl.ExportServiceBean.java

License:Apache License

/**
 * Adds a centered cell to the given table.
 * // w  w  w . jav a2 s .co  m
 * @param table
 *            the table to add the cell to
 * @param value
 *            the value text
 */
private static void addCenterCell(PdfPTable table, String value) {
    PdfPCell val = new PdfPCell(
            new Phrase(Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7)));
    val.setBorder(Rectangle.NO_BORDER);
    val.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    table.addCell(val);
}

From source file:gov.medicaid.services.util.PDFHelper.java

License:Apache License

/**
 * Adds a label to the given table.//from w  w w. jav  a  2  s  .c o m
 *
 * @param table the table to add to
 * @param label the label text
 */
public static void addLabel(PdfPTable table, String label) {
    PdfPCell key = new PdfPCell(
            new Phrase(Util.defaultString(label), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8)));
    key.setBorder(Rectangle.NO_BORDER);
    table.addCell(key);
}

From source file:gov.medicaid.services.util.PDFHelper.java

License:Apache License

/**
 * Adds a cell to the given table.//from   www . j a v  a 2s  .c  o  m
 *
 * @param table the table to add the cell to
 * @param value the value text
 */
public static void addCell(PdfPTable table, String value) {
    PdfPCell val = new PdfPCell(
            new Phrase(": " + Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7)));
    val.setBorder(Rectangle.NO_BORDER);
    val.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    table.addCell(val);
}

From source file:gov.medicaid.services.util.PDFHelper.java

License:Apache License

/**
 * Adds a centered cell to the given table.
 *
 * @param table the table to add the cell to
 * @param value the value text//from   w  ww.j  ava2 s  .  c o  m
 */
public static void addCenterCell(PdfPTable table, String value) {
    PdfPCell val = new PdfPCell(
            new Phrase(Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7)));
    val.setBorder(Rectangle.NO_BORDER);
    val.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    val.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
    table.addCell(val);
}

From source file:optika.sql.java

public PdfPCell getCellWhite(String text, int alignment, int bottom) {
    PdfPCell cell = new PdfPCell();
    FontSelector selector = new FontSelector();
    com.lowagie.text.Font f1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12);
    f1.setColor(Color.white);/*from  w ww . j  a  va  2s .co m*/
    selector.addFont(f1);
    cell.addElement(selector.process(text));
    cell.setPadding(0);
    cell.setHorizontalAlignment(alignment);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setPaddingBottom(bottom);
    return cell;
}

From source file:org.displaytag.render.ItextTableWriter.java

License:Artistic License

/**
 * Obtain the footer font; Meant to be overriden if a different style is desired.
 * @return The footer font./*from  w  w  w . j a v a2 s  . c  om*/
 */
protected Font getFooterFont() {
    return FontFactory.getFont(FontFactory.HELVETICA, 10);
}