Search in sources :

Example 16 with TextAttribute

use of java.awt.font.TextAttribute 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 17 with TextAttribute

use of java.awt.font.TextAttribute in project jdk8u_jdk by JetBrains.

the class ExtendedTextSourceLabel method finishInit.

private void finishInit() {
    font = source.getFont();
    Map<TextAttribute, ?> atts = font.getAttributes();
    baseTX = AttributeValues.getBaselineTransform(atts);
    if (baseTX == null) {
        cm = source.getCoreMetrics();
    } else {
        AffineTransform charTX = AttributeValues.getCharTransform(atts);
        if (charTX == null) {
            charTX = new AffineTransform();
        }
        font = font.deriveFont(charTX);
        LineMetrics lm = font.getLineMetrics(source.getChars(), source.getStart(), source.getStart() + source.getLength(), source.getFRC());
        cm = CoreMetrics.get(lm);
    }
}
Also used : TextAttribute(java.awt.font.TextAttribute) AffineTransform(java.awt.geom.AffineTransform) LineMetrics(java.awt.font.LineMetrics)

Example 18 with TextAttribute

use of java.awt.font.TextAttribute in project megameklab by MegaMek.

the class ImageHelper method printC3mbName.

public static void printC3mbName(Graphics2D g2d, float lineStart, float linePoint, Font font, boolean isArmored, boolean mixed) {
    Font c3Font = font.deriveFont(font.getStyle(), font.getSize2D());
    HashMap<TextAttribute, Integer> attrMap = new HashMap<TextAttribute, Integer>();
    attrMap.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER);
    int stringWidth;
    if (isArmored) {
        g2d.drawString("O C   Boosted Master" + (mixed ? " (IS)" : ""), lineStart, linePoint);
        stringWidth = ImageHelper.getStringWidth(g2d, "O C", c3Font);
    } else {
        g2d.drawString("C   Boosted Master" + (mixed ? " (IS)" : ""), lineStart, linePoint);
        stringWidth = ImageHelper.getStringWidth(g2d, "C", c3Font);
    }
    c3Font = font.deriveFont(attrMap);
    g2d.setFont(c3Font);
    g2d.drawString("3", lineStart + stringWidth, linePoint);
    g2d.setFont(font);
}
Also used : HashMap(java.util.HashMap) TextAttribute(java.awt.font.TextAttribute) Font(java.awt.Font)

Example 19 with TextAttribute

use of java.awt.font.TextAttribute in project megameklab by MegaMek.

the class ImageHelper method printC3mName.

public static void printC3mName(Graphics2D g2d, float lineStart, float linePoint, Font font, boolean isArmored, boolean mixed) {
    Font c3Font = font.deriveFont(font.getStyle(), font.getSize2D());
    HashMap<TextAttribute, Integer> attrMap = new HashMap<TextAttribute, Integer>();
    attrMap.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER);
    int stringWidth;
    if (isArmored) {
        g2d.drawString("O C   Master" + (mixed ? " (IS)" : ""), lineStart, linePoint);
        stringWidth = ImageHelper.getStringWidth(g2d, "O C", c3Font);
    } else {
        g2d.drawString("C   Master" + (mixed ? " (IS)" : ""), lineStart, linePoint);
        stringWidth = ImageHelper.getStringWidth(g2d, "C", c3Font);
    }
    c3Font = font.deriveFont(attrMap);
    g2d.setFont(c3Font);
    g2d.drawString("3", lineStart + stringWidth, linePoint);
    g2d.setFont(font);
}
Also used : HashMap(java.util.HashMap) TextAttribute(java.awt.font.TextAttribute) Font(java.awt.Font)

Example 20 with TextAttribute

use of java.awt.font.TextAttribute in project megameklab by MegaMek.

the class ImageHelper method printC3sbName.

public static void printC3sbName(Graphics2D g2d, float lineStart, float linePoint, Font font, boolean isArmored, boolean mixed) {
    Font c3Font = font.deriveFont(font.getStyle(), font.getSize2D());
    HashMap<TextAttribute, Integer> attrMap = new HashMap<TextAttribute, Integer>();
    attrMap.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER);
    int stringWidth;
    if (isArmored) {
        g2d.drawString("O C   Boosted Slave" + (mixed ? " (IS)" : ""), lineStart, linePoint);
        stringWidth = ImageHelper.getStringWidth(g2d, "O C", c3Font);
    } else {
        g2d.drawString("C   Boosted Slave" + (mixed ? " (IS)" : ""), lineStart, linePoint);
        stringWidth = ImageHelper.getStringWidth(g2d, "C", c3Font);
    }
    c3Font = font.deriveFont(attrMap);
    g2d.setFont(c3Font);
    g2d.drawString("3", lineStart + stringWidth, linePoint);
    g2d.setFont(font);
}
Also used : HashMap(java.util.HashMap) TextAttribute(java.awt.font.TextAttribute) Font(java.awt.Font)

Aggregations

TextAttribute (java.awt.font.TextAttribute)31 Font (java.awt.Font)22 HashMap (java.util.HashMap)22 Configuration (com.haulmont.cuba.core.global.Configuration)2 DesktopConfig (com.haulmont.cuba.desktop.DesktopConfig)2 FontMetrics (java.awt.FontMetrics)2 Paint (java.awt.Paint)2 MouseEvent (java.awt.event.MouseEvent)2 AffineTransform (java.awt.geom.AffineTransform)2 Hashtable (java.util.Hashtable)2 DesktopResources (com.haulmont.cuba.desktop.DesktopResources)1 CollapsiblePanel (com.haulmont.cuba.desktop.sys.vcl.CollapsiblePanel)1 WebColors (com.revolsys.awt.WebColors)1 Geometry (com.revolsys.geometry.model.Geometry)1 SwingUtil (com.revolsys.swing.SwingUtil)1 ClipboardUtil (com.revolsys.swing.dnd.ClipboardUtil)1 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)1 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)1 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)1 RecordLayerTableModel (com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel)1