Example usage for java.awt.font TextAttribute STRIKETHROUGH_ON

List of usage examples for java.awt.font TextAttribute STRIKETHROUGH_ON

Introduction

In this page you can find the example usage for java.awt.font TextAttribute STRIKETHROUGH_ON.

Prototype

Boolean STRIKETHROUGH_ON

To view the source code for java.awt.font TextAttribute STRIKETHROUGH_ON.

Click Source Link

Document

A single strikethrough.

Usage

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    final JFormattedTextField textField1 = new JFormattedTextField(new Float(10.01));
    textField1.setFormatterFactory(new AbstractFormatterFactory() {
        @Override//from   w w w.j a v a 2  s  .co  m
        public AbstractFormatter getFormatter(JFormattedTextField tf) {
            NumberFormat format = DecimalFormat.getInstance();
            format.setMinimumFractionDigits(2);
            format.setMaximumFractionDigits(2);
            format.setRoundingMode(RoundingMode.HALF_UP);
            InternationalFormatter formatter = new InternationalFormatter(format);
            formatter.setAllowsInvalid(false);
            formatter.setMinimum(0.0);
            formatter.setMaximum(1000.00);
            return formatter;
        }
    });
    Map attributes = (new Font("Serif", Font.BOLD, 16)).getAttributes();
    attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
    final JFormattedTextField textField2 = new JFormattedTextField(new Float(10.01));
    textField2.setFormatterFactory(new AbstractFormatterFactory() {

        @Override
        public AbstractFormatter getFormatter(JFormattedTextField tf) {
            NumberFormat format = DecimalFormat.getInstance();
            format.setMinimumFractionDigits(2);
            format.setMaximumFractionDigits(2);
            format.setRoundingMode(RoundingMode.HALF_UP);
            InternationalFormatter formatter = new InternationalFormatter(format);
            formatter.setAllowsInvalid(false);
            formatter.setMinimum(0.0);
            formatter.setMaximum(1000.00);
            return formatter;
        }
    });
    textField2.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            printIt(documentEvent);
        }

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            printIt(documentEvent);
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            printIt(documentEvent);
        }

        private void printIt(DocumentEvent documentEvent) {
            DocumentEvent.EventType type = documentEvent.getType();
            double t1a1 = (((Number) textField2.getValue()).doubleValue());
            if (t1a1 > 100) {
                textField2.setFont(new Font(attributes));
                textField2.setForeground(Color.red);
            } else {
                textField2.setFont(new Font("Serif", Font.BOLD, 16));
                textField2.setForeground(Color.black);
            }
        }
    });
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(textField1, BorderLayout.NORTH);
    frame.add(textField2, BorderLayout.SOUTH);
    frame.setVisible(true);
    frame.pack();
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    AttributedString as1 = new AttributedString("1234567890");
    as1.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 2, 8);
    g2d.drawString(as1.getIterator(), 15, 60);
}

From source file:IteratorUnderStrike.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    String s = "\"www.java2s.com\" is great.";

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Font plainFont = new Font("Times New Roman", Font.PLAIN, 24);

    AttributedString as = new AttributedString(s);
    as.addAttribute(TextAttribute.FONT, plainFont);
    as.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 1, 15);
    as.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 18, 25);

    g2.drawString(as.getIterator(), 24, 70);
}

From source file:MainClass.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    String s = "\"www.java2s.com,\" www.java2s.com";

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Font plainFont = new Font("Times New Roman", Font.PLAIN, 24);

    AttributedString as = new AttributedString(s);
    as.addAttribute(TextAttribute.FONT, plainFont);
    as.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 18, 22);
    g2.drawString(as.getIterator(), 24, 70);

}

From source file:net.sf.jasperreports.engine.util.JRFontUtil.java

/**
 *
 *//*  w ww.  j a v a  2  s  .co  m*/
public static Map<Attribute, Object> getAttributesWithoutAwtFont(Map<Attribute, Object> attributes,
        JRFont font) {
    attributes.put(TextAttribute.FAMILY, font.getFontName());

    attributes.put(TextAttribute.SIZE, new Float(font.getFontSize()));

    if (font.isBold()) {
        attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
    }
    if (font.isItalic()) {
        attributes.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
    }
    if (font.isUnderline()) {
        attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    }
    if (font.isStrikeThrough()) {
        attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
    }

    attributes.put(JRTextAttribute.PDF_FONT_NAME, font.getPdfFontName());
    attributes.put(JRTextAttribute.PDF_ENCODING, font.getPdfEncoding());

    if (font.isPdfEmbedded()) {
        attributes.put(JRTextAttribute.IS_PDF_EMBEDDED, Boolean.TRUE);
    }

    return attributes;
}

From source file:net.sf.jasperreports.engine.fonts.FontUtil.java

/**
 *
 *///w  ww .j av a  2  s.  c  om
public Map<Attribute, Object> getAttributesWithoutAwtFont(Map<Attribute, Object> attributes, JRFont font) {
    attributes.put(TextAttribute.FAMILY, font.getFontName());

    attributes.put(TextAttribute.SIZE, font.getFontsize());

    if (font.isBold()) {
        attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
    }
    if (font.isItalic()) {
        attributes.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
    }
    if (font.isUnderline()) {
        attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    }
    if (font.isStrikeThrough()) {
        attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
    }

    attributes.put(JRTextAttribute.PDF_FONT_NAME, font.getPdfFontName());
    attributes.put(JRTextAttribute.PDF_ENCODING, font.getPdfEncoding());

    if (font.isPdfEmbedded()) {
        attributes.put(JRTextAttribute.IS_PDF_EMBEDDED, Boolean.TRUE);
    }

    return attributes;
}

From source file:net.sf.jasperreports.engine.util.JRFontUtil.java

/**
 * Returns a java.awt.Font instance by converting a JRFont instance.
 * Mostly used in combination with third-party visualization packages such as JFreeChart (for chart themes).
 * Unless the font parameter is null, this method always returns a non-null AWT font, regardless whether it was
 * found in the font extensions or not. This is because we do need a font to draw with and there is no point
 * in raising a font missing exception here, as it is not JasperReports who does the drawing. 
 *//*from  w ww . j ava  2s.c o m*/
public static Font getAwtFont(JRFont font, Locale locale) {
    if (font == null) {
        return null;
    }

    // ignoring missing font as explained in the Javadoc
    Font awtFont = getAwtFontFromBundles(font.getFontName(),
            ((font.isBold() ? Font.BOLD : Font.PLAIN) | (font.isItalic() ? Font.ITALIC : Font.PLAIN)),
            font.getFontSize(), locale, true);

    if (awtFont == null) {
        awtFont = new Font(getAttributesWithoutAwtFont(new HashMap<Attribute, Object>(), font));
    } else {
        // add underline and strikethrough attributes since these are set at
        // style/font level
        Map<Attribute, Object> attributes = new HashMap<Attribute, Object>();
        if (font.isUnderline()) {
            attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        }
        if (font.isStrikeThrough()) {
            attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
        }

        if (!attributes.isEmpty()) {
            awtFont = awtFont.deriveFont(attributes);
        }
    }

    return awtFont;
}

From source file:net.sf.jasperreports.engine.util.JEditorPaneHtmlMarkupProcessor.java

@Override
protected Map<Attribute, Object> getAttributes(AttributeSet attrSet) {
    Map<Attribute, Object> attrMap = new HashMap<Attribute, Object>();
    if (attrSet.isDefined(StyleConstants.FontFamily)) {
        attrMap.put(TextAttribute.FAMILY, StyleConstants.getFontFamily(attrSet));
    }/*w  w w .j  av a2 s .com*/

    if (attrSet.isDefined(StyleConstants.Bold)) {
        attrMap.put(TextAttribute.WEIGHT,
                StyleConstants.isBold(attrSet) ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR);
    }

    if (attrSet.isDefined(StyleConstants.Italic)) {
        attrMap.put(TextAttribute.POSTURE, StyleConstants.isItalic(attrSet) ? TextAttribute.POSTURE_OBLIQUE
                : TextAttribute.POSTURE_REGULAR);
    }

    if (attrSet.isDefined(StyleConstants.Underline)) {
        attrMap.put(TextAttribute.UNDERLINE,
                StyleConstants.isUnderline(attrSet) ? TextAttribute.UNDERLINE_ON : null);
    }

    if (attrSet.isDefined(StyleConstants.StrikeThrough)) {
        attrMap.put(TextAttribute.STRIKETHROUGH,
                StyleConstants.isStrikeThrough(attrSet) ? TextAttribute.STRIKETHROUGH_ON : null);
    }

    if (attrSet.isDefined(StyleConstants.FontSize)) {
        attrMap.put(TextAttribute.SIZE, StyleConstants.getFontSize(attrSet));
    }

    if (attrSet.isDefined(StyleConstants.Foreground)) {
        attrMap.put(TextAttribute.FOREGROUND, StyleConstants.getForeground(attrSet));
    }

    if (attrSet.isDefined(StyleConstants.Background)) {
        attrMap.put(TextAttribute.BACKGROUND, StyleConstants.getBackground(attrSet));
    }

    //FIXME: why StyleConstants.isSuperscript(attrSet) does return false
    if (attrSet.isDefined(StyleConstants.Superscript) && !StyleConstants.isSubscript(attrSet)) {
        attrMap.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER);
    }

    if (attrSet.isDefined(StyleConstants.Subscript) && StyleConstants.isSubscript(attrSet)) {
        attrMap.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB);
    }

    return attrMap;
}

From source file:net.sf.jasperreports.engine.util.JRStyledTextParser.java

/**
 *
 *//* w  w  w  . j  a  va2  s .co m*/
private void parseStyle(JRStyledText styledText, Node parentNode) throws SAXException {
    NodeList nodeList = parentNode.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node.getNodeType() == Node.TEXT_NODE) {
            styledText.append(node.getNodeValue());
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_style.equals(node.getNodeName())) {
            NamedNodeMap nodeAttrs = node.getAttributes();

            Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();

            if (nodeAttrs.getNamedItem(ATTRIBUTE_fontName) != null) {
                styleAttrs.put(TextAttribute.FAMILY, nodeAttrs.getNamedItem(ATTRIBUTE_fontName).getNodeValue());
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_isBold) != null) {
                styleAttrs.put(TextAttribute.WEIGHT,
                        Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isBold).getNodeValue())
                                ? TextAttribute.WEIGHT_BOLD
                                : TextAttribute.WEIGHT_REGULAR);
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_isItalic) != null) {
                styleAttrs.put(TextAttribute.POSTURE,
                        Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isItalic).getNodeValue())
                                ? TextAttribute.POSTURE_OBLIQUE
                                : TextAttribute.POSTURE_REGULAR);
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_isUnderline) != null) {
                styleAttrs.put(TextAttribute.UNDERLINE,
                        Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isUnderline).getNodeValue())
                                ? TextAttribute.UNDERLINE_ON
                                : null);
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_isStrikeThrough) != null) {
                styleAttrs.put(TextAttribute.STRIKETHROUGH,
                        Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isStrikeThrough).getNodeValue())
                                ? TextAttribute.STRIKETHROUGH_ON
                                : null);
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_size) != null) {
                styleAttrs.put(TextAttribute.SIZE,
                        Float.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_size).getNodeValue()));
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_pdfFontName) != null) {
                styleAttrs.put(JRTextAttribute.PDF_FONT_NAME,
                        nodeAttrs.getNamedItem(ATTRIBUTE_pdfFontName).getNodeValue());
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_pdfEncoding) != null) {
                styleAttrs.put(JRTextAttribute.PDF_ENCODING,
                        nodeAttrs.getNamedItem(ATTRIBUTE_pdfEncoding).getNodeValue());
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_isPdfEmbedded) != null) {
                styleAttrs.put(JRTextAttribute.IS_PDF_EMBEDDED,
                        Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isPdfEmbedded).getNodeValue()));
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_forecolor) != null) {
                Color color = JRColorUtil.getColor(nodeAttrs.getNamedItem(ATTRIBUTE_forecolor).getNodeValue(),
                        Color.black);
                styleAttrs.put(TextAttribute.FOREGROUND, color);
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_backcolor) != null) {
                Color color = JRColorUtil.getColor(nodeAttrs.getNamedItem(ATTRIBUTE_backcolor).getNodeValue(),
                        Color.black);
                styleAttrs.put(TextAttribute.BACKGROUND, color);
            }

            int startIndex = styledText.length();

            parseStyle(styledText, node);

            styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_bold.equalsIgnoreCase(node.getNodeName())) {
            Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();
            styleAttrs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);

            int startIndex = styledText.length();

            parseStyle(styledText, node);

            styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
        } else if (node.getNodeType() == Node.ELEMENT_NODE
                && NODE_italic.equalsIgnoreCase(node.getNodeName())) {
            Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();
            styleAttrs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);

            int startIndex = styledText.length();

            parseStyle(styledText, node);

            styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
        } else if (node.getNodeType() == Node.ELEMENT_NODE
                && NODE_underline.equalsIgnoreCase(node.getNodeName())) {
            Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();
            styleAttrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);

            int startIndex = styledText.length();

            parseStyle(styledText, node);

            styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_sup.equalsIgnoreCase(node.getNodeName())) {
            Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();
            styleAttrs.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER);

            int startIndex = styledText.length();

            parseStyle(styledText, node);

            styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_sub.equalsIgnoreCase(node.getNodeName())) {
            Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();
            styleAttrs.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB);

            int startIndex = styledText.length();

            parseStyle(styledText, node);

            styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_font.equalsIgnoreCase(node.getNodeName())) {
            NamedNodeMap nodeAttrs = node.getAttributes();

            Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();

            if (nodeAttrs.getNamedItem(ATTRIBUTE_size) != null) {
                styleAttrs.put(TextAttribute.SIZE,
                        Float.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_size).getNodeValue()));
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_color) != null) {
                Color color = JRColorUtil.getColor(nodeAttrs.getNamedItem(ATTRIBUTE_color).getNodeValue(),
                        Color.black);
                styleAttrs.put(TextAttribute.FOREGROUND, color);
            }

            if (nodeAttrs.getNamedItem(ATTRIBUTE_fontFace) != null) {
                String fontFaces = nodeAttrs.getNamedItem(ATTRIBUTE_fontFace).getNodeValue();

                StringTokenizer t = new StringTokenizer(fontFaces, ",");
                while (t.hasMoreTokens()) {
                    String face = t.nextToken().trim();
                    if (AVAILABLE_FONT_FACE_NAMES.contains(face)) {
                        styleAttrs.put(TextAttribute.FAMILY, face);
                        break;
                    }
                }
            }

            int startIndex = styledText.length();

            parseStyle(styledText, node);

            styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));

        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_br.equalsIgnoreCase(node.getNodeName())) {
            styledText.append("\n");

            int startIndex = styledText.length();
            resizeRuns(styledText.getRuns(), startIndex, 1);

            parseStyle(styledText, node);
            styledText.addRun(
                    new JRStyledText.Run(new HashMap<Attribute, Object>(), startIndex, styledText.length()));

            if (startIndex < styledText.length()) {
                styledText.append("\n");
                resizeRuns(styledText.getRuns(), startIndex, 1);
            }
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_li.equalsIgnoreCase(node.getNodeName())) {
            String tmpText = styledText.getText();
            if (tmpText.length() > 0 && !tmpText.endsWith("\n")) {
                styledText.append("\n");
            }
            styledText.append(" \u2022 ");

            int startIndex = styledText.length();
            resizeRuns(styledText.getRuns(), startIndex, 1);
            parseStyle(styledText, node);
            styledText.addRun(
                    new JRStyledText.Run(new HashMap<Attribute, Object>(), startIndex, styledText.length()));

            // if the text in the next node does not start with a '\n', or 
            // if the next node is not a <li /> one, we have to append a new line
            Node nextNode = node.getNextSibling();
            String textContent = getFirstTextOccurence(nextNode);
            if (nextNode != null && !((nextNode.getNodeType() == Node.ELEMENT_NODE
                    && NODE_li.equalsIgnoreCase(nextNode.getNodeName())
                    || (textContent != null && textContent.startsWith("\n"))))) {
                styledText.append("\n");
                resizeRuns(styledText.getRuns(), startIndex, 1);
            }
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_a.equalsIgnoreCase(node.getNodeName())) {
            if (hyperlink == null) {
                NamedNodeMap nodeAttrs = node.getAttributes();

                Map<Attribute, Object> styleAttrs = new HashMap<Attribute, Object>();

                hyperlink = new JRBasePrintHyperlink();
                hyperlink.setHyperlinkType(HyperlinkTypeEnum.REFERENCE);
                styleAttrs.put(JRTextAttribute.HYPERLINK, hyperlink);

                if (nodeAttrs.getNamedItem(ATTRIBUTE_href) != null) {
                    hyperlink.setHyperlinkReference(nodeAttrs.getNamedItem(ATTRIBUTE_href).getNodeValue());
                }

                if (nodeAttrs.getNamedItem(ATTRIBUTE_type) != null) {
                    hyperlink.setLinkType(nodeAttrs.getNamedItem(ATTRIBUTE_type).getNodeValue());
                }

                if (nodeAttrs.getNamedItem(ATTRIBUTE_target) != null) {
                    hyperlink.setLinkTarget(nodeAttrs.getNamedItem(ATTRIBUTE_target).getNodeValue());
                }

                int startIndex = styledText.length();

                parseStyle(styledText, node);

                styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));

                hyperlink = null;
            } else {
                throw new SAXException("Hyperlink <a> tags cannot be nested.");
            }
        } else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_param.equalsIgnoreCase(node.getNodeName())) {
            if (hyperlink == null) {
                throw new SAXException("Hyperlink <param> tags must appear inside an <a> tag only.");
            } else {
                NamedNodeMap nodeAttrs = node.getAttributes();

                JRPrintHyperlinkParameter parameter = new JRPrintHyperlinkParameter();

                if (nodeAttrs.getNamedItem(ATTRIBUTE_name) != null) {
                    parameter.setName(nodeAttrs.getNamedItem(ATTRIBUTE_name).getNodeValue());
                }

                if (nodeAttrs.getNamedItem(ATTRIBUTE_valueClass) != null) {
                    parameter.setValueClass(nodeAttrs.getNamedItem(ATTRIBUTE_valueClass).getNodeValue());
                }

                String strValue = node.getTextContent();
                if (strValue != null) {
                    Object value = JRValueStringUtils.deserialize(parameter.getValueClass(), strValue);
                    parameter.setValue(value);
                }

                hyperlink.addHyperlinkParameter(parameter);
            }
        } else if (node.getNodeType() == Node.ELEMENT_NODE) {
            String nodeName = "<" + node.getNodeName() + ">";
            throw new SAXException("Tag " + nodeName + " is not a valid styled text tag.");
        }
    }
}

From source file:net.sf.jasperreports.engine.fonts.FontUtil.java

/**
 * Returns a java.awt.Font instance by converting a JRFont instance.
 * Mostly used in combination with third-party visualization packages such as JFreeChart (for chart themes).
 * Unless the font parameter is null, this method always returns a non-null AWT font, regardless whether it was
 * found in the font extensions or not. This is because we do need a font to draw with and there is no point
 * in raising a font missing exception here, as it is not JasperReports who does the drawing. 
 *///from w w w.  ja  va 2  s . c o  m
public Font getAwtFont(JRFont font, Locale locale) {
    if (font == null) {
        return null;
    }

    // ignoring missing font as explained in the Javadoc
    Font awtFont = getAwtFontFromBundles(font.getFontName(),
            ((font.isBold() ? Font.BOLD : Font.PLAIN) | (font.isItalic() ? Font.ITALIC : Font.PLAIN)),
            font.getFontsize(), locale, true);

    if (awtFont == null) {
        awtFont = new Font(getAttributesWithoutAwtFont(new HashMap<Attribute, Object>(), font));
    } else {
        // add underline and strikethrough attributes since these are set at
        // style/font level
        Map<Attribute, Object> attributes = new HashMap<Attribute, Object>();
        if (font.isUnderline()) {
            attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        }
        if (font.isStrikeThrough()) {
            attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
        }

        if (!attributes.isEmpty()) {
            awtFont = awtFont.deriveFont(attributes);
        }
    }

    return awtFont;
}