本文整理汇总了Java中java.awt.Font.isItalic方法的典型用法代码示例。如果您正苦于以下问题:Java Font.isItalic方法的具体用法?Java Font.isItalic怎么用?Java Font.isItalic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Font
的用法示例。
在下文中一共展示了Font.isItalic方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import java.awt.Font; //导入方法依赖的package包/类
@Override
public void init(GameContainer container) throws SlickException {
this.container = container;
this.map = new TiledMap("/home/enzo/newmap.tmx");
SpriteSheet spriteSheet = new SpriteSheet("/home/enzo/SpriteSheetAnim.png", 64, 64);
this.animations[0] = loadAnimation(spriteSheet, 0, 1, 0);
this.animations[1] = loadAnimation(spriteSheet, 0, 1, 1);
this.animations[2] = loadAnimation(spriteSheet, 0, 1, 2);
this.animations[3] = loadAnimation(spriteSheet, 0, 1, 3);
this.animations[4] = loadAnimation(spriteSheet, 1, 9, 0);
this.animations[5] = loadAnimation(spriteSheet, 1, 9, 1);
this.animations[6] = loadAnimation(spriteSheet, 1, 9, 2);
this.animations[7] = loadAnimation(spriteSheet, 1, 9, 3);
Font font = new Font("Verdana", Font.BOLD, 20);
UnicodeFont uFont = new UnicodeFont(font, font.getSize(), font.isBold(), font.isItalic());
nameInput = new TextField(container, uFont, 150,20,500,35, new ComponentListener()
{
public void componentActivated(AbstractComponent source) {
message = "Entered1: "+nameInput.getText();
nameInput.setFocus(true);
}
});
// ComponentListener listener = new ComponentListener();
// TextField nameInput = new TextField(arg0, truetypefont, 150,20,500,35, listener);
//
// {
// public void componentActivated(AbstractComponent source) {
// System.out.println("Entered1: "+nameInput.getText());
// }
// });
}
示例2: getString
import java.awt.Font; //导入方法依赖的package包/类
private String getString(Font font) {
String style = ""; // NOI18N
if (font.isBold()) {
style += "bold"; // NOI18N
}
if (font.isItalic()) {
style += " italic"; // NOI18N
}
else {
style += " plain"; // NOI18N
}
return "[" + font.getName() + ", " + style + ", " + font.getSize() + "]"; // NOI18N
}
示例3: put
import java.awt.Font; //导入方法依赖的package包/类
/**
* Converts the value to string using {@link Strings#toString(Object)}
* method and then stores it.
* There is get methods for values that are a String, an Integer, a Boolean,
* a Font, a List of String and a Map of String*String.
*/
@Override
public Object put(Object key, Object value) {
if(value instanceof Font){
Font font = (Font)value;
String family = font.getFamily();
int size = font.getSize();
boolean italic = font.isItalic();
boolean bold = font.isBold();
value = family + "#" + size + "#" + italic + "#" + bold;
}
return super.put(key.toString(), Strings.toString(value));
}
示例4: fontToString
import java.awt.Font; //导入方法依赖的package包/类
public String fontToString(Font font) {
StringBuffer sb = new StringBuffer();
sb.append(font.getName());
sb.append(" ");
sb.append(font.getSize());
if (font.isBold()) {
sb.append(" bold");
}
if (font.isItalic()) {
sb.append(" italic");
}
return sb.toString();
}
示例5: getWidth
import java.awt.Font; //导入方法依赖的package包/类
/**
* Compute a most appropriate width of the given text layout.
*/
public static float getWidth(TextLayout textLayout, String textLayoutText, Font font) {
// For italic fonts the textLayout.getAdvance() includes some extra horizontal space.
// On the other hand index2X() for TL.getCharacterCount() is width along baseline
// so when TL ends with e.g. 'd' char the end of 'd' char is cut off.
float width;
int tlLen = textLayoutText.length();
if (!font.isItalic() ||
tlLen == 0 ||
Character.isWhitespace(textLayoutText.charAt(tlLen - 1)) ||
Bidi.requiresBidi(textLayoutText.toCharArray(), 0, textLayoutText.length()))
{
width = textLayout.getAdvance();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("TLUtils.getWidth(\"" + CharSequenceUtilities.debugText(textLayoutText) + // NOI18N
"\"): Using TL.getAdvance()=" + width + // NOI18N
// textLayoutDump(textLayout) +
'\n');
}
} else {
// Compute pixel bounds (with frc being null - means use textLayout's frc; and with default bounds)
Rectangle pixelBounds = textLayout.getPixelBounds(null, 0, 0);
width = (float) pixelBounds.getMaxX();
// On Mac OS X with retina displays the TL.getPixelBounds() give incorrect results. Luckily
// TL.getAdvance() gives a correct result in that case.
// Therefore use a minimum of both values (on all platforms).
float tlAdvance = textLayout.getAdvance();
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("TLUtils.getWidth(\"" + CharSequenceUtilities.debugText(textLayoutText) + // NOI18N
"\"): Using minimum of TL.getPixelBounds().getMaxX()=" + width + // NOI18N
" or TL.getAdvance()=" + tlAdvance +
textLayoutDump(textLayout) +
'\n');
}
width = Math.min(width, tlAdvance);
}
// For RTL text the hit-info of the first char is above the hit-info of ending char.
// However textLayout.isLeftToRight() returns true in case of mixture of LTR and RTL text
// in a single textLayout.
// Ceil the width to avoid rendering artifacts.
width = (float) Math.ceil(width);
return width;
}
示例6: createStyle
import java.awt.Font; //导入方法依赖的package包/类
private String createStyle (String element, String selector, Font font, Color fg, Color bg, boolean useDefaults) {
StringBuffer sb = new StringBuffer();
if (element != null) {
sb.append (element);
sb.append (WS);
}
if (selector != null) {
sb.append (DOT);
sb.append (selector);
sb.append (WS);
}
sb.append (ST_BEGIN);
boolean first = true;
if ((!useDefaults || !fg.equals(getDefaultColor())) && fg != null) {
sb.append (ST_COLOR);
sb.append (getHtmlColor(fg));
first = false;
}
if ((!useDefaults || !bg.equals (getDefaultBackgroundColor())) && bg != null) {
if (!first) {
sb.append (ST_SEPARATOR);
}
sb.append (ST_BGCOLOR);
sb.append (getHtmlColor(bg));
first = false;
}
if ((!useDefaults || !font.equals (getDefaultFont())) && font != null) {
if (!first) {
sb.append (ST_SEPARATOR);
}
sb.append (ST_FONT_FAMILY);
sb.append (font.getFamily()); //TODO: Locale should go here
if (font.isBold()) {
sb.append (ST_SEPARATOR);
sb.append (ST_BOLD);
}
if (font.isItalic()) {
sb.append (ST_SEPARATOR);
sb.append (ST_ITALIC);
}
Font df = getDefaultFont();
if (df != null && df.getSize() != font.getSize()) {
sb.append (ST_SEPARATOR);
sb.append (ST_SIZE);
sb.append (String.valueOf(font.getSize()));
}
}
sb.append (ST_END);
return sb.toString();
}
示例7: appendHTMLRepresentation
import java.awt.Font; //导入方法依赖的package包/类
@Override
public StringBuilder appendHTMLRepresentation(StringBuilder sb,
RSyntaxTextArea textArea, boolean fontFamily,
boolean tabsToSpaces) {
SyntaxScheme colorScheme = textArea.getSyntaxScheme();
Style scheme = colorScheme.getStyle(getType());
Font font = textArea.getFontForTokenType(getType());//scheme.font;
if (font.isBold()) {
sb.append("<b>");
}
if (font.isItalic()) {
sb.append("<em>");
}
if (scheme.underline || isHyperlink()) {
sb.append("<u>");
}
boolean needsFontTag = fontFamily || !isWhitespace();
if (needsFontTag) {
sb.append("<font");
if (fontFamily) {
sb.append(" face=\"").append(font.getFamily()).append('"');
}
if (!isWhitespace()) {
sb.append(" color=\"").append(
getHTMLFormatForColor(scheme.foreground)).append('"');
}
sb.append('>');
}
// NOTE: Don't use getLexeme().trim() because whitespace tokens will
// be turned into NOTHING.
appendHtmlLexeme(textArea, sb, tabsToSpaces);
if (needsFontTag) {
sb.append("</font>");
}
if (scheme.underline || isHyperlink()) {
sb.append("</u>");
}
if (font.isItalic()) {
sb.append("</em>");
}
if (font.isBold()) {
sb.append("</b>");
}
return sb;
}