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;
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations