Example usage for javax.swing.text StyleConstants Subscript

List of usage examples for javax.swing.text StyleConstants Subscript

Introduction

In this page you can find the example usage for javax.swing.text StyleConstants Subscript.

Prototype

Object Subscript

To view the source code for javax.swing.text StyleConstants Subscript.

Click Source Link

Document

Name of the Subscript attribute.

Usage

From source file:au.org.ala.delta.ui.rtf.RTFWriter.java

private void configureAttributeHandlers() {
    _attributeHandlers.put(StyleConstants.Bold,
            new BooleanAttributeHandler(StyleConstants.Bold, CharacterAttributeType.Bold.keyword()));
    _attributeHandlers.put(StyleConstants.Italic,
            new BooleanAttributeHandler(StyleConstants.Italic, CharacterAttributeType.Italics.keyword()));
    _attributeHandlers.put(StyleConstants.Underline,
            new BooleanAttributeHandler(StyleConstants.Underline, CharacterAttributeType.Underline.keyword()));
    _attributeHandlers.put(StyleConstants.Subscript,
            new BooleanAttributeHandler(StyleConstants.Subscript, CharacterAttributeType.Subscript.keyword(),
                    CharacterAttributeType.NoSuperscriptOrSubscript.keyword()));
    _attributeHandlers.put(StyleConstants.Superscript,
            new BooleanAttributeHandler(StyleConstants.Superscript,
                    CharacterAttributeType.Superscript.keyword(),
                    CharacterAttributeType.NoSuperscriptOrSubscript.keyword()));

    // _attributeHandlers.put(StyleConstants.FontSize, new FontSizeAttributeHandler(StyleConstants.FontSize, CharacterAttributeType.FontSize.keyword(), 11));
    // _attributeHandlers.put(StyleConstants.FontFamily, new FontFamilyAttributeHandler(StyleConstants.FontFamily, CharacterAttributeType.Font.keyword()));
}

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));
    }//from ww  w  .ja v a  2s  .  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;
}