Search in sources :

Example 1 with EAttribute

use of sun.font.EAttribute in project jdk8u_jdk by JetBrains.

the class AttributeValues method merge.

public AttributeValues merge(AttributeValues src, int mask) {
    int m = mask & src.defined;
    for (EAttribute ea : EAttribute.atts) {
        if (m == 0) {
            break;
        }
        if ((m & ea.mask) != 0) {
            m &= ~ea.mask;
            i_set(ea, src);
            update(ea);
        }
    }
    return this;
}
Also used : EAttribute(sun.font.EAttribute) Paint(java.awt.Paint)

Example 2 with EAttribute

use of sun.font.EAttribute in project jdk8u_jdk by JetBrains.

the class AttributeValues method toMap.

public Map<TextAttribute, Object> toMap(Map<TextAttribute, Object> fill) {
    if (fill == null) {
        fill = new HashMap<TextAttribute, Object>();
    }
    for (int m = defined, i = 0; m != 0; ++i) {
        EAttribute ea = EAttribute.atts[i];
        if ((m & ea.mask) != 0) {
            m &= ~ea.mask;
            fill.put(ea.att, get(ea));
        }
    }
    return fill;
}
Also used : EAttribute(sun.font.EAttribute) TextAttribute(java.awt.font.TextAttribute) Paint(java.awt.Paint)

Example 3 with EAttribute

use of sun.font.EAttribute in project jdk8u_jdk by JetBrains.

the class AttributeValues method toSerializableHashtable.

public Hashtable<Object, Object> toSerializableHashtable() {
    Hashtable ht = new Hashtable();
    int hashkey = defined;
    for (int m = defined, i = 0; m != 0; ++i) {
        EAttribute ea = EAttribute.atts[i];
        if ((m & ea.mask) != 0) {
            m &= ~ea.mask;
            Object o = get(ea);
            if (o == null) {
            // hashkey will handle it
            } else if (o instanceof Serializable) {
                // check all...
                ht.put(ea.att, o);
            } else {
                hashkey &= ~ea.mask;
            }
        }
    }
    ht.put(DEFINED_KEY, Integer.valueOf(hashkey));
    return ht;
}
Also used : EAttribute(sun.font.EAttribute) Serializable(java.io.Serializable) Hashtable(java.util.Hashtable) Paint(java.awt.Paint)

Example 4 with EAttribute

use of sun.font.EAttribute in project jdk8u_jdk by JetBrains.

the class AttributeValues method toString.

public String toString() {
    StringBuilder b = new StringBuilder();
    b.append('{');
    for (int m = defined, i = 0; m != 0; ++i) {
        EAttribute ea = EAttribute.atts[i];
        if ((m & ea.mask) != 0) {
            m &= ~ea.mask;
            if (b.length() > 1) {
                b.append(", ");
            }
            b.append(ea);
            b.append('=');
            switch(ea) {
                case EFAMILY:
                    b.append('"');
                    b.append(family);
                    b.append('"');
                    break;
                case EWEIGHT:
                    b.append(weight);
                    break;
                case EWIDTH:
                    b.append(width);
                    break;
                case EPOSTURE:
                    b.append(posture);
                    break;
                case ESIZE:
                    b.append(size);
                    break;
                case ETRANSFORM:
                    b.append(transform);
                    break;
                case ESUPERSCRIPT:
                    b.append(superscript);
                    break;
                case EFONT:
                    b.append(font);
                    break;
                case ECHAR_REPLACEMENT:
                    b.append(charReplacement);
                    break;
                case EFOREGROUND:
                    b.append(foreground);
                    break;
                case EBACKGROUND:
                    b.append(background);
                    break;
                case EUNDERLINE:
                    b.append(underline);
                    break;
                case ESTRIKETHROUGH:
                    b.append(strikethrough);
                    break;
                case ERUN_DIRECTION:
                    b.append(runDirection);
                    break;
                case EBIDI_EMBEDDING:
                    b.append(bidiEmbedding);
                    break;
                case EJUSTIFICATION:
                    b.append(justification);
                    break;
                case EINPUT_METHOD_HIGHLIGHT:
                    b.append(imHighlight);
                    break;
                case EINPUT_METHOD_UNDERLINE:
                    b.append(imUnderline);
                    break;
                case ESWAP_COLORS:
                    b.append(swapColors);
                    break;
                case ENUMERIC_SHAPING:
                    b.append(numericShaping);
                    break;
                case EKERNING:
                    b.append(kerning);
                    break;
                case ELIGATURES:
                    b.append(ligatures);
                    break;
                case ETRACKING:
                    b.append(tracking);
                    break;
                default:
                    throw new InternalError();
            }
            if ((nondefault & ea.mask) == 0) {
                b.append('*');
            }
        }
    }
    b.append("[btx=" + baselineTransform + ", ctx=" + charTransform + "]");
    b.append('}');
    return b.toString();
}
Also used : EAttribute(sun.font.EAttribute) Paint(java.awt.Paint)

Example 5 with EAttribute

use of sun.font.EAttribute in project jdk8u_jdk by JetBrains.

the class AttributeValues method fromSerializableHashtable.

public static AttributeValues fromSerializableHashtable(Hashtable<Object, Object> ht) {
    AttributeValues result = new AttributeValues();
    if (ht != null && !ht.isEmpty()) {
        for (Map.Entry<Object, Object> e : ht.entrySet()) {
            Object key = e.getKey();
            Object val = e.getValue();
            if (key.equals(DEFINED_KEY)) {
                result.defineAll(((Integer) val).intValue());
            } else {
                try {
                    EAttribute ea = EAttribute.forAttribute((Attribute) key);
                    if (ea != null) {
                        result.set(ea, val);
                    }
                } catch (ClassCastException ex) {
                }
            }
        }
    }
    return result;
}
Also used : EAttribute(sun.font.EAttribute) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

EAttribute (sun.font.EAttribute)5 Paint (java.awt.Paint)4 TextAttribute (java.awt.font.TextAttribute)1 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 Map (java.util.Map)1