Example usage for com.lowagie.text Font isBold

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

Introduction

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

Prototype

public boolean isBold() 

Source Link

Document

checks if this font is Bold.

Usage

From source file:it.businesslogic.ireport.gui.sheet.SheetProperty.java

License:Open Source License

public void updateLabel() {

    if (this.getType() != CATEGORY_LABEL) {
        try {/*  www .  j ava 2s. c o m*/
            if (getLabelComponent() != null) {

                //String bold = (value == null || this.isReadOnly() || !isShowResetButton()) ? "" : "<html><b>";

                boolean needBold = !(value == null || this.isReadOnly() || !isShowResetButton());

                java.awt.Font f = getLabelComponent().getFont();

                if (f.isBold() && !needBold) {
                    ((JLabel) getLabelComponent()).setFont(f.deriveFont(Font.NORMAL));
                } else if (!f.isBold() && needBold) {
                    ((JLabel) getLabelComponent()).setFont(f.deriveFont(Font.BOLD));
                }

                // The table is used to avoid word wrap
                //((JLabel)getLabelComponent()).setText("<html><table><tr><td nowrap>" + bold + this.getName() + "</td></tr></table></html>");
                ((JLabel) getLabelComponent()).setText(this.getName());

                if (this.isReadOnly()) {
                    getLabelComponent().setEnabled(false);
                } else {
                    getLabelComponent().setEnabled(true);
                }

                if (labelError != null) {
                    ((JLabel) getLabelComponent()).setIcon(errorIcon);
                    getLabelComponent().setForeground(errorColor);
                    getLabelComponent().setToolTipText(labelError);
                } else {
                    ((JLabel) getLabelComponent()).setIcon(null);
                    getLabelComponent().setForeground(getLabelColor());
                    getLabelComponent().setToolTipText(getName());
                }

                getLabelComponent().updateUI();
            }
        } catch (Exception ex) {

        }
    }
}

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

License:Apache License

/**
 * Return the font style/*from  www . ja  va2  s.  c  om*/
 *
 * @return the font style
 */
public String getFontStyle() {
    Font font = getCurrentFont();
    StringBuilder sb = new StringBuilder();

    if (font.isBold()) {
        sb.append(BOLD);
    }

    if (font.isItalic()) {
        if (sb.length() == 0) {
            sb.append(ITALIC);
        } else {
            sb.append(",");
            sb.append(ITALIC);
        }
    }

    if (font.isUnderlined()) {
        if (sb.length() == 0) {
            sb.append(UNDERLINE);
        } else {
            sb.append(",");
            sb.append(UNDERLINE);
        }
    }

    if (sb.length() == 0) {
        return NORMAL;
    }

    return sb.toString();
}

From source file:org.pentaho.reporting.libraries.fonts.itext.BaseFontSupport.java

License:Open Source License

/**
 * Returns a BaseFont which can be used to represent the given AWT Font
 *
 * @param font the font to be converted//w w  w. j  a  va  2s .  c o  m
 * @return a BaseFont which has similar properties to the provided Font
 */

public BaseFont awtToPdf(final Font font) {
    // this has to be defined in the element, an has to set as a default...
    final boolean embed = isEmbedFonts();
    final String encoding = getDefaultEncoding();
    try {
        return createBaseFont(font.getName(), font.isBold(), font.isItalic(), encoding, embed);
    } catch (Exception e) {
        // unable to handle font creation exceptions properly, all we can
        // do is throw a runtime exception and hope the best ..
        throw new BaseFontCreateException("Unable to create font: " + font, e);
    }
}