Example usage for com.lowagie.text Font UNDERLINE

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

Introduction

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

Prototype

int UNDERLINE

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

Click Source Link

Document

this is a possible style.

Usage

From source file:fr.opensagres.odfdom.converter.pdf.internal.styles.StyleTextProperties.java

License:Open Source License

public int getStyleFlagComplex() {
    int style = Font.NORMAL;
    if (Boolean.TRUE.equals(fontItalicComplex)) {
        style |= Font.ITALIC;// w  w  w  . j ava 2 s. c om
    }
    if (Boolean.TRUE.equals(fontBoldComplex)) {
        style |= Font.BOLD;
    }
    if (Boolean.TRUE.equals(fontUnderline)) {
        style |= Font.UNDERLINE;
    }
    if (Boolean.TRUE.equals(fontStrikeThru)) {
        style |= Font.STRIKETHRU;
    }
    return style;
}

From source file:fr.opensagres.xdocreport.itext.extension.font.AbstractFontRegistry.java

License:Open Source License

/**
 * checks if this font is underlined.//from w ww.j  a  v a  2s . c o m
 * 
 * @return a <CODE>boolean</CODE>
 */
public boolean isUnderlined(int style) {
    if (style == Font.UNDEFINED) {
        return false;
    }
    return (style & Font.UNDERLINE) == Font.UNDERLINE;
}

From source file:mitm.common.pdf.MessagePDFBuilder.java

License:Open Source License

private Font createLinkFont() {
    /*//ww w .j  av  a2 s  . c  o m
     * Font for anchors (links)
     */
    Font linkFont = new Font();
    linkFont.setStyle(Font.UNDERLINE);
    linkFont.setColor(0, 0, 255);
    linkFont.setSize(linkFontSize);

    return linkFont;
}

From source file:net.sf.jasperreports.engine.export.JRPdfExporter.java

License:LGPL

/**
 *
 *//*from   w ww .ja  va 2s . c  om*/
protected Font getFont(Map attributes) {
    JRFont jrFont = new JRBaseFont(attributes);

    Exception initialException = null;

    Color forecolor = (Color) attributes.get(TextAttribute.FOREGROUND);

    Font font = null;
    PdfFont pdfFont = null;
    FontKey key = new FontKey(jrFont.getFontName(), jrFont.isBold(), jrFont.isItalic());

    if (fontMap != null && fontMap.containsKey(key)) {
        pdfFont = (PdfFont) fontMap.get(key);
    } else {
        pdfFont = new PdfFont(jrFont.getPdfFontName(), jrFont.getPdfEncoding(), jrFont.isPdfEmbedded());
    }

    try {
        font = FontFactory.getFont(pdfFont.getPdfFontName(), pdfFont.getPdfEncoding(), pdfFont.isPdfEmbedded(),
                jrFont.getFontSize(),
                (pdfFont.isPdfSimulatedBold() ? Font.BOLD : 0)
                        | (pdfFont.isPdfSimulatedItalic() ? Font.ITALIC : 0)
                        | (jrFont.isUnderline() ? Font.UNDERLINE : 0)
                        | (jrFont.isStrikeThrough() ? Font.STRIKETHRU : 0),
                forecolor);

        // check if FontFactory didn't find the font
        if (font.getBaseFont() == null && font.family() == Font.UNDEFINED) {
            font = null;
        }
    } catch (Exception e) {
        initialException = e;
    }

    if (font == null) {
        byte[] bytes = null;

        try {
            bytes = JRLoader.loadBytesFromLocation(pdfFont.getPdfFontName(), classLoader, urlHandlerFactory,
                    fileResolver);
        } catch (JRException e) {
            throw new JRRuntimeException("Could not load the following font : " + "\npdfFontName   : "
                    + pdfFont.getPdfFontName() + "\npdfEncoding   : " + pdfFont.getPdfEncoding()
                    + "\nisPdfEmbedded : " + pdfFont.isPdfEmbedded(), initialException);
        }

        BaseFont baseFont = null;

        try {
            baseFont = BaseFont.createFont(pdfFont.getPdfFontName(), pdfFont.getPdfEncoding(),
                    pdfFont.isPdfEmbedded(), true, bytes, null);
        } catch (DocumentException e) {
            throw new JRRuntimeException(e);
        } catch (IOException e) {
            throw new JRRuntimeException(e);
        }

        font = new Font(baseFont, jrFont.getFontSize(),
                ((pdfFont.isPdfSimulatedBold()) ? Font.BOLD : 0)
                        | ((pdfFont.isPdfSimulatedItalic()) ? Font.ITALIC : 0)
                        | (jrFont.isUnderline() ? Font.UNDERLINE : 0)
                        | (jrFont.isStrikeThrough() ? Font.STRIKETHRU : 0),
                forecolor);
    }

    return font;
}

From source file:nl.dykema.jxmlnote.report.pdf.PdfChunk.java

License:Open Source License

public void setFont(Font g) {
    Font f = new Font(g);
    int chst = 0;
    if (_bold) {/* w  ww.  ja v  a 2  s .  c  o  m*/
        chst += Font.BOLD;
    }
    if (_italic) {
        chst += Font.ITALIC;
    }
    if (_underline) {
        chst += Font.UNDERLINE;
    }
    f.setStyle(chst);
    super.setFont(f);
}

From source file:nl.dykema.jxmlnote.report.pdf.PdfParagraph.java

License:Open Source License

public Paragraph setStyle(XMLNoteParStyle style) {
    //System.out.println(super.getLeading()+","+super.getMultipliedLeading());
    _style = style;/*  w w w  . ja v  a2  s. c  om*/
    if (style == null) {
        return this;
    }

    int chst = 0;
    if (style.bold()) {
        chst += Font.BOLD;
    }
    if (style.italics()) {
        chst += Font.ITALIC;
    }
    if (style.underline()) {
        chst += Font.UNDERLINE;
    }
    Font f = getFont(style.getFont());
    f.setSize(style.pointSize());
    f.setStyle(chst);
    float indentleft;
    indentleft = (float) style.leftIndent();
    super.setIndentationLeft(indentleft);
    super.setSpacingAfter(style.bottomSkip());
    super.setSpacingBefore(style.topSkip());
    //super.setLeading(0.0f); DO DIT NIET!

    //System.out.println(super.getLeading()+","+super.getMultipliedLeading());
    int p1align = getAlign(style);
    super.setAlignment(p1align);
    super.setFont(f);
    //System.out.println(super.getLeading()+","+super.getMultipliedLeading());
    super.setLeading(0.0f, 1.2f);
    //System.out.println(super.getLeading()+","+super.getMultipliedLeading());

    return this;
}

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

License:Apache License

/**
 * Add italic style to the current style
 */
public void addUnderlined() {
    this.currentStyle += Font.UNDERLINE;
}

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

License:Apache License

/**
 * Remove italic style to the current style
 *//*w  ww  .  j a va 2s .c om*/
public void removeUnderlined() {
    this.currentStyle -= Font.UNDERLINE;
    if (this.currentStyle < 0) {
        this.currentStyle = Font.NORMAL;
    }
}

From source file:org.apache.poi.xwpf.converter.internal.itext.StyleEngineForIText.java

License:Open Source License

private FontInfos processRPR(CTRPr ctParaRPr) {

    FontInfos fontInfos = new FontInfos();
    CTFonts fonts = ctParaRPr.getRFonts();
    if (fonts != null && fonts.getAscii() != null) {

        // font familly
        fontInfos.setFontFamily(fonts.getAscii());
    }//from   w w  w . j av  a  2  s  . c o  m

    boolean bold = ctParaRPr.getB() != null && STOnOff.TRUE.equals(ctParaRPr.getB().xgetVal());
    boolean italic = ctParaRPr.getI() != null && STOnOff.TRUE.equals(ctParaRPr.getI().xgetVal());

    if (bold && italic) {
        fontInfos.setFontStyle(Font.BOLDITALIC);
    } else if (bold) {
        fontInfos.setFontStyle(Font.BOLD);
    } else if (italic) {
        fontInfos.setFontStyle(Font.ITALIC);

    }
    // font size
    CTHpsMeasure hpsMeasure = ctParaRPr.getSz();
    if (hpsMeasure != null) {

        STHpsMeasure measure = hpsMeasure.xgetVal();
        float size = measure.getBigDecimalValue().floatValue();
        // cf. http://www.schemacentral.com/sc/ooxml/t-w_ST_HpsMeasure.html
        fontInfos.setFontSize(size / 2);
    }

    CTUnderline underline = ctParaRPr.getU();

    int style = fontInfos.getFontStyle();
    if (underline != null) {

        STUnderline uu = underline.xgetVal();

        if (STUnderline.NONE != uu.enumValue()) {
            style = style | Font.UNDERLINE;
            fontInfos.setFontStyle(style);
        }
    }

    // font color...
    CTColor ctColor = ctParaRPr.getColor();
    if (ctColor != null) {

        STHexColor hexColor = ctColor.xgetVal();
        String strText = hexColor.getStringValue();

        if (!"auto".equals(strText)) {

            Color color = ColorRegistry.getInstance().getColor("0x" + strText);
            fontInfos.setFontColor(color);
        }
    }

    // font encoding
    fontInfos.setFontEncoding(options.getFontEncoding());
    return fontInfos;
}

From source file:org.areasy.common.doclet.document.Fonts.java

License:Open Source License

public static Font getFont(int faceType, int style, int size) {
    Font font = null;//from w ww.  j  a  v a2  s.  c  o  m
    String lookup = String.valueOf(faceType);
    String fontFile = fontTable.getProperty(lookup);

    int fontStyle = Font.NORMAL;
    Color color = COLOR_BLACK;

    if ((style & LINK) != 0) {
        fontStyle += Font.UNDERLINE;
        color = COLOR_LINK;
    } else if ((style & UNDERLINE) != 0)
        fontStyle += Font.UNDERLINE;

    if ((style & STRIKETHROUGH) != 0)
        fontStyle += Font.STRIKETHRU;

    if (fontFile != null) {

        File file = new File(DefaultConfiguration.getWorkDir(), fontFile);
        if (file.exists() && file.isFile()) {

            try {
                String encoding = encTable.getProperty(lookup, BaseFont.CP1252);
                BaseFont bfComic = BaseFont.createFont(file.getAbsolutePath(), encoding, BaseFont.EMBEDDED);

                if ((style & AbstractConfiguration.ITALIC) > 0) {
                    if ((style & AbstractConfiguration.BOLD) > 0)
                        fontStyle += Font.BOLDITALIC;
                    else
                        fontStyle += Font.ITALIC;
                } else if ((style & AbstractConfiguration.BOLD) > 0)
                    fontStyle += Font.BOLD;

                if (fontStyle != Font.NORMAL)
                    font = new Font(bfComic, size, fontStyle, color);
                else
                    font = new Font(bfComic, size);

                if (font == null)
                    throw new IllegalArgumentException("Font null: " + fontFile);
            } catch (Exception e) {
                e.printStackTrace();
                throw new IllegalArgumentException("Font unusable");
            }
        } else
            DocletUtility.error("Font file not found: " + fontFile);
    } else {
        // Use predefined font
        String face = "";

        if (faceType == TEXT_FONT) {
            face = FontFactory.HELVETICA;

            if ((style & AbstractConfiguration.ITALIC) > 0) {
                if ((style & AbstractConfiguration.BOLD) > 0)
                    face = FontFactory.HELVETICA_BOLDOBLIQUE;
                else
                    face = FontFactory.HELVETICA_OBLIQUE;
            } else if ((style & AbstractConfiguration.BOLD) > 0)
                face = FontFactory.HELVETICA_BOLD;
        } else {
            face = FontFactory.COURIER;
            if ((style & ITALIC) > 0) {
                if ((style & BOLD) > 0)
                    face = FontFactory.COURIER_BOLDOBLIQUE;
                else
                    face = FontFactory.COURIER_OBLIQUE;
            } else if ((style & BOLD) > 0)
                face = FontFactory.COURIER_BOLD;
        }

        if (fontStyle != Font.NORMAL)
            font = FontFactory.getFont(face, size, fontStyle, color);
        else
            font = FontFactory.getFont(face, size);
    }

    return font;
}