本文整理汇总了Java中javax.microedition.lcdui.Graphics.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.setFont方法的具体用法?Java Graphics.setFont怎么用?Java Graphics.setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.lcdui.Graphics
的用法示例。
在下文中一共展示了Graphics.setFont方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* @see CommentItem#drawContent(javax.microedition.lcdui.Graphics, int, int)
*/
public void paint(final Graphics g, final int w, final int h) {
int x = H_SPACE + xIndent;
int y = V_SPACE;
g.setColor(VisualStyles.COLOR_HIGHLIGHTED_FOREGROUND);
g.drawLine(xIndent, 0, xIndent, h);
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_AUTHOR);
final int fontHeight = FONT_AUTHOR.getHeight();
for (int i = 0; i < bodyLines.size(); i++) {
g.drawString((String) bodyLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += fontHeight;
}
}
示例2: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
int y = 0;
String loginStatus = "";
if (session.isLoggedIn()) {
loginStatus = "Logged in as " + session.getUsername();
}
else {
loginStatus = "Not logged in";
}
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_TEXT);
g.drawString(loginStatus, w - H_SPACE * 2, y, Graphics.TOP
| Graphics.RIGHT);
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
if (separatorImage != null) {
y = height - separatorImage.getHeight() - V_SPACE;
g.drawImage(separatorImage, 0, y, Graphics.TOP | Graphics.LEFT);
}
}
示例3: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
g.setFont(FONT);
final int y = V_SPACE * 2;
final int fontOffset = FONT.getHeight() / 2;
final int vote = item.getVote();
final int leftX = H_SPACE * 2;
final int rightX = w - 2 * H_SPACE;
g.drawImage(vote == -1 ? voteDownActiveImage : voteDownImage, leftX, y,
Graphics.TOP | Graphics.LEFT);
g.drawImage(vote == 1 ? voteUpActiveImage : voteUpImage, rightX, y,
Graphics.TOP | Graphics.RIGHT);
g.drawString("Vote down", leftX + voteImageWidth + H_SPACE, y
+ fontOffset, Graphics.TOP | Graphics.LEFT);
g.drawString("Vote up", rightX - voteImageWidth - H_SPACE, y
+ fontOffset, Graphics.TOP | Graphics.RIGHT);
}
示例4: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
final String displayCategory =
category != null ? category : DEFAULT_CATEGORY_NAME;
g.setFont(selected ? FONT_SELECTED : FONT);
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.drawString(displayCategory, H_SPACE, V_SPACE, Graphics.TOP | Graphics.LEFT);
}
示例5: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
final String dateStr = DatePrettyPrinter.prettyPrint(link.getCreated());
final String numCommentsStr = "" + link.getNumComments() + " comments";
final int ncHeight = FONT_SEPARATOR.getHeight() + SEPARATOR_V_SPACE;
int x = H_SPACE;
int y = V_SPACE;
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_TEXT);
g.drawString("by " + link.getAuthor(), x, y, Graphics.TOP
| Graphics.LEFT);
g.drawString(dateStr, w - H_SPACE * 2, y, Graphics.TOP
| Graphics.RIGHT);
// Draw left and right part of the separator, then the score in the middle
y = height - ncHeight - V_SPACE / 2;
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
if (separatorImage != null) {
g.drawImage(separatorImage, w / 2, y + ncHeight / 2, Graphics.TOP
| Graphics.HCENTER);
}
g.setFont(FONT_SEPARATOR);
g.drawString(numCommentsStr, w / 2, y - 4, Graphics.TOP
| Graphics.HCENTER);
}
示例6: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(Graphics g, int w, int h) {
int x = VisualStyles.COMMENT_H_SPACE;
int y = VisualStyles.COMMENT_V_SPACE;
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(font);
for (int i = 0, len = textLines.size(); i < len; i++) {
g.drawString((String) textLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += font.getHeight();
}
}
示例7: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item. Subclasses should override this.
*/
protected void paint(final Graphics g, final int w, final int h) {
int x = H_SPACE + xIndent;
int y = V_SPACE;
g.setColor(VisualStyles.COLOR_HIGHLIGHTED_FOREGROUND);
g.drawLine(xIndent, V_SPACE, xIndent, h - V_SPACE);
g.setColor(VisualStyles.COLOR_FOREGROUND);
if (comment.getAuthor() != null) {
g.setFont(FONT_AUTHOR);
g.drawString(comment.getAuthor(), x, y, Graphics.TOP | Graphics.LEFT);
y += H_FONT_AUTHOR;
}
g.setFont(FONT_META);
g.drawString(metaText, x, y, Graphics.TOP | Graphics.LEFT);
y += H_FONT_META + V_SPACE * 1.5;
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
g.setFont(FONT_BODY);
for (int i = 0; i < bodyLines.size(); i++) {
g.drawString((String) bodyLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += H_FONT_BODY;
}
}
示例8: JecpGraphics
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected JecpGraphics(Graphics g) {
this.g = g;
g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
}
示例9: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the friendly item.
*/
protected void paint(final Graphics g, final int w, final int h) {
int x = H_SPACE;
int y = V_SPACE_HALF;
g.setFont(FONT_TITLE);
g.setColor(VisualStyles.COLOR_FOREGROUND);
for (int i = 0; i < titleLines.size(); i++) {
g.drawString((String) titleLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += H_FONT_TITLE;
}
// Details text
y += V_SPACE_HALF;
g.setFont(FONT_DETAILS);
for (int i = 0; i < detailsLines.size(); i++) {
g.drawString((String) detailsLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += H_FONT_DETAILS;
}
// Draw left and right part of the separator, then the score in the middle
final String scoreStr = (link.getScore() > 0 ? "+" : "")
+ link.getScore();
final int scoreHeight = H_FONT_SCORE + SEPARATOR_V_SPACE;
y = height - scoreHeight - V_SPACE_HALF;
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
if (separatorImage != null) {
g.drawImage(separatorImage, width / 2, y + scoreHeight / 2,
Graphics.TOP
| Graphics.HCENTER);
}
g.setFont(FONT_SCORE);
g.drawString(scoreStr, width / 2, y - V_SPACE_HALF, Graphics.TOP
| Graphics.HCENTER);
// Draw thumbnail image
if (showImage && link.getImage() != null) {
g.drawImage(link.getImage(), width - H_SPACE, V_SPACE_HALF,
Graphics.TOP | Graphics.RIGHT);
}
}
示例10: paintContent
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* @see de.enough.polish.ui.CustomItem#paint(javax.microedition.lcdui.Graphics, int, int)
*/
// protected void paint(Graphics g, int w, int h) {
protected void paintContent( int x, int y, int leftBorder, int rightBorder, Graphics g ) {
final int c = y + contentHeight / 2;
g.setColor(0x949494);
g.setFont(this.font);
if (displayString == null || displayString.length() == 0) {
g.drawLine(leftBorder, c, rightBorder, c);
return;
}
int totalStringWidth = this.font.stringWidth(displayString) + this.linePadding;
if (this.isLayoutCenter) {
totalStringWidth += this.linePadding;
}
int lineLen = rightBorder - leftBorder - totalStringWidth;
if (this.isLayoutCenter) {
lineLen /= 2;
}
if (this.isLayoutCenter || this.isLayoutRight) {
g.drawLine(leftBorder, c, leftBorder + lineLen, c);
} else {
g.drawLine(leftBorder + totalStringWidth, c, leftBorder + totalStringWidth + lineLen, c);
}
g.setColor(this.fontColor);
if (this.isLayoutCenter) {
g.drawString(displayString, leftBorder + lineLen + this.linePadding, y, Graphics.LEFT | Graphics.TOP);
} else if (this.isLayoutRight) {
g.drawString(displayString, rightBorder, y, Graphics.RIGHT | Graphics.TOP);
} else {
g.drawString(displayString, leftBorder, y, Graphics.LEFT | Graphics.TOP);
}
if (this.isLayoutCenter) {
g.setColor(0x949494);
g.drawLine(leftBorder + lineLen + totalStringWidth, c, rightBorder, c);
}
}
示例11: drawStringCenteredAndTruncated
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draws the given string to the given rectangular area, truncates text if needed.
*
* @param g Graphics context.
* @param str String to draw.
* @param font Font to use for drawing.
* @param x X-coordinate.
* @param y Y-coordinate.
* @param width Width of the drawable area.
* @param height Height of the drawable area.
* @param anchor Anchor point.
*/
public static void drawStringCenteredAndTruncated(Graphics g, String str, Font font, int x, int y,
int width,int height, int anchor){
if (Log.TEST) Log.note("[ListItem#drawStringCenteredAndTruncated]-->");
String truncatedText = truncateText(str, width, font);
g.setFont(font);
int fontHeight = font.getHeight();
g.drawString(truncatedText, x, y + ((height - fontHeight) / 2), anchor);
}