Example usage for com.lowagie.text Font color

List of usage examples for com.lowagie.text Font color

Introduction

In this page you can find the example usage for com.lowagie.text Font color.

Prototype

Color color

To view the source code for com.lowagie.text Font color.

Click Source Link

Document

the value of the color.

Usage

From source file:ambit.data.qmrf.Qmrf_Xml_Pdf.java

License:Open Source License

protected int getText(org.w3c.dom.Node node, Phrase phrase, Font currentFont, ScriptMode scriptMode,
        boolean trim, int paragraphs) {

    if (node.getNodeType() == node.ELEMENT_NODE) {
        if ("head".equals(node.getNodeName()))
            return paragraphs;
        if ("html".equals(node.getNodeName()))
            trim = true;// w  w w . j  a  va 2  s  .  co  m
        else if ("body".equals(node.getNodeName()))
            trim = true;
        else if ("p".equals(node.getNodeName()))
            trim = true;
        else
            trim = false;
        //if ("p".equals(node.getNodeName())) trim=true;
        //           System.out.println(node.getNodeName() + ' ' + trim);   
        //System.out.println(paragraphs);   
        Font f = currentFont;
        int fweight = currentFont.style();
        float fsize = currentFont.size();
        Color clr = currentFont.color();
        boolean modify = false;
        if ("b".equals(node.getNodeName())) {
            if ((currentFont.style() == Font.ITALIC) || (currentFont.style() == Font.BOLDITALIC))
                fweight = Font.BOLDITALIC;
            else
                fweight = Font.BOLD;
            modify = true;
        }
        if ("i".equals(node.getNodeName())) {
            if ((currentFont.style() == Font.BOLD) || (currentFont.style() == Font.BOLDITALIC))
                fweight = Font.BOLDITALIC;
            else
                fweight = Font.ITALIC;
            modify = true;
        }
        if ("sub".equals(node.getNodeName())) {
            scriptMode = ScriptMode.subscript;
        }
        if ("sup".equals(node.getNodeName())) {
            scriptMode = ScriptMode.superscript;
        }
        if ("font".equals(node.getNodeName())) {
            String r = ((org.w3c.dom.Element) node).getAttribute("color");
            if (r != null)
                try {
                    clr = Hex2Color(r.substring(1));
                    modify = true;
                } catch (Exception x) {
                    clr = currentFont.color();
                }
            String z = ((org.w3c.dom.Element) node).getAttribute("size");
            if (z != null) {
                try {
                    fsize = Integer.parseInt(z);
                    modify = true;
                } catch (Exception x) {
                    fsize = currentFont.size();
                }
            }
        }
        if (modify) {
            f = FontFactory.getFont(currentFont.getFamilyname(), fsize, fweight, clr);
        }
        if ("p".equals(node.getNodeName())) {
            if (paragraphs > 0)
                phrase.add(new Chunk('\n', f));
            paragraphs++;

        }

        //f = FontFactory.getFont(currentFont.getFamilyname(),curr)
        NodeList nodes = node.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++)
            paragraphs += getText(nodes.item(i), phrase, f, scriptMode, trim, paragraphs);

    } else if (node.getNodeType() == node.TEXT_NODE) {

        String value = node.getNodeValue();
        if (trim)
            value = replaceNewLine(value);
        if ("".equals(value))
            return paragraphs;
        //System.out.println(value);
        Chunk chunk = new Chunk(value, currentFont);
        HyphenationAuto autoEN = new HyphenationAuto("en", "GB", 2, 2);
        chunk.setHyphenation(autoEN);
        switch (scriptMode) {
        case superscript:
            chunk.setTextRise(currentFont.size() * 0.3f);
            break;
        case subscript:
            chunk.setTextRise(-currentFont.size() * 0.3f);
            break;

        default:
            break;
        }
        phrase.add(chunk);
    }
    return paragraphs;
}

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

private String encodeFont(Font font) {
    StringBuffer fontBuffer = new StringBuffer();
    fontBuffer.append(font.getFamilyname()).append("-");
    fontBuffer.append(font.size()).append("-");
    fontBuffer.append(encodeFontStyle(font)).append("-");
    if (font.color() != null) {
        fontBuffer.append(IWColor.getHexColorString(font.color()));
    }//w w  w  .j a v a2  s  .  c  o m
    return fontBuffer.toString();
}

From source file:org.apache.maven.doxia.module.itext.ITextFont.java

License:Apache License

/**
 * Return the font color blue//from   w  w  w  .j  a  v  a  2 s  . c o  m
 *
 * @return the font color blue
 */
public String getFontColorBlue() {
    Font font = getCurrentFont();

    return String.valueOf(font.color().getBlue());
}

From source file:org.apache.maven.doxia.module.itext.ITextFont.java

License:Apache License

/**
 * Return the font color green//from w w  w.j  av  a2s  .  c o m
 *
 * @return the font color green
 */
public String getFontColorGreen() {
    Font font = getCurrentFont();

    return String.valueOf(font.color().getGreen());
}

From source file:org.apache.maven.doxia.module.itext.ITextFont.java

License:Apache License

/**
 * Return the font color red/*from   w  w  w.  j a  va2s .  co  m*/
 *
 * @return the font color red
 */
public String getFontColorRed() {
    Font font = getCurrentFont();

    return String.valueOf(font.color().getRed());
}