当前位置: 首页>>代码示例>>Java>>正文


Java Font.getFont方法代码示例

本文整理汇总了Java中javax.microedition.lcdui.Font.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java Font.getFont方法的具体用法?Java Font.getFont怎么用?Java Font.getFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.lcdui.Font的用法示例。


在下文中一共展示了Font.getFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawTopRow

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
/**
 * Draws the top row.
 * 
 * @param g Graphics context.
 * @param rect Rectangle to draw in.
 * @param useWholeArea if true then top row will occupy the whole rect.
 * @return Height used for top row.
 */
protected int drawTopRow(Graphics g, int[] rect, boolean useWholeArea){
	if (Log.TEST) Log.note("[ListItem#drawTopRow]-->");
	int x = rect[0];
	int y = rect[1];
	int width = rect[2];
	int height = rect[3];
	Font font = null;
	if((itemType & TYPE_ONE_ROW) > 0){
		font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE);
	} else if ((itemType & TYPE_TWO_ROW) > 0){
		font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
	}
	if(!useWholeArea){
		height = font.getHeight() + V_PAD * 2;
	}
	// Draw the text to the middle of the top row
	Util.drawStringCenteredAndTruncated(g, text1, font, x, y + V_PAD, width, height, Graphics.TOP | Graphics.LEFT );
	return height;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:28,代码来源:ListItem.java

示例2: RatingItem

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param imageProvider For image retrieval.
 * @param width Width of the item.
 * @param rating Initial rating.
 * @throws FavouriteArtistsException
 */
protected RatingItem(ImageProvider imageProvider, int width, short rating) throws FavouriteArtistsException {
	super(null);
	
	this.width = width;
	this.rating = rating;
	
	// Create images
	starImgFilled = imageProvider.getImage(BIG_STAR_FILLED_IMG_FILE);
	starImgEmpty = imageProvider.getImage(BIG_STAR_EMPTY_IMG_FILE);
	
	// Get font
	font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
	
	// Calculate height
	height += V_PAD * 2;
	height += font.getHeight();
	height += GESTURE_ZONE_HEIGHT;
	
	// Create GIZ for each star icon
	zones = new GestureInteractiveZone[STAR_COUNT];
	int starX = 0; 
	int starY = font.getHeight() + V_PAD;
	for(int i = 0; i < STAR_COUNT; i++){
		GestureInteractiveZone zone =
			new GestureInteractiveZone(GestureInteractiveZone.GESTURE_TAP);
		// Set dimensions of the GIZ in relation to the Displayable
		zone.setRectangle(starX, starY, GESTURE_ZONE_WIDTH, GESTURE_ZONE_HEIGHT);
		// Register the GIZ
		if(GestureRegistrationManager.register(this, zone) != true){
        	throw new FavouriteArtistsException("GestureRegistrationManager.register() failed!");
        }
        // Add a listener for gesture events.
        GestureRegistrationManager.setListener(this, this);
		zones[i] = zone;
		starX += starImgFilled.getWidth() + H_PAD;
	}
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:46,代码来源:RatingItem.java

示例3: drawContents

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
/**
   * Draw item contents.
   * 
   * @param g Graphics context
   * @param x X-coordinate.
   * @param y Y-coordinate.
   * @param width Width of the drawable area.
   * @param height Height of the drawable area.
   */
  protected void drawContents(Graphics g, int x, int y, int width, int height){
  	if (Log.TEST) Log.note("[GridItem#drawContents]-->");
  	// Divide item vertically to three parts: icon+name, rating and comment
  	int topRowHeight = height / 3;
  	int middleRowY = y + topRowHeight;
  	int middleRowHeight = topRowHeight;
  	int bottomRowY = middleRowY + middleRowHeight;
  	int bottomRowHeight = y + height - bottomRowY;
  	
  	// Draw icon  to the top left area
  	Util.drawImageCentered(g, icon, x, y, ICON_MAX_W, ICON_MAX_H);
  	// Draw artist name next to icon
  	Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
  	Util.drawStringCenteredAndTruncated(g, favData.getName(), font, x + ICON_MAX_H + ICON_TEXT_MARGIN, y,
  			width - ICON_MAX_H - ICON_TEXT_MARGIN, topRowHeight,
  			Graphics.TOP | Graphics.LEFT );
  	// Draw rating in the middle part
  	int starImgX = x + STAR_IMG_H_PAD;
for(int i = 1; i <= favData.getRating(); i++) {
                  
                  Util.drawImageCentered(g, starImg, starImgX, middleRowY, starImg.getWidth()+ STAR_IMG_H_PAD * 2, middleRowHeight);
                  starImgX += STAR_IMG_H_PAD + starImg.getWidth();
}
// Draw comment in the bottom part
font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
Util.drawStringCenteredAndTruncated(g, favData.getComment(), font, x, bottomRowY,
  			width, bottomRowHeight,
  			Graphics.TOP | Graphics.LEFT );
  }
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:39,代码来源:GridItem.java

示例4: drawBottomRow

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
/**
 * Draws the bottom row.
 * 
 * @param g Graphics context.
 * @param rect Rectangle to draw in.
 */
protected void drawBottomRow(Graphics g, int[] rect){
	if (Log.TEST) Log.note("[ListItem#drawBottomRow]-->");
	int x = rect[0];
	int y = rect[1];
	int width = rect[2];
	int height = rect[3];
	Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
	height = font.getHeight() + V_PAD * 2;
	// Draw the text to the middle of the bottom row
	Util.drawStringCenteredAndTruncated(g, text2, font, x, y + V_PAD, width, height, Graphics.TOP | Graphics.LEFT );
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:ListItem.java

示例5: CanvasTextBox

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
public CanvasTextBox(Canvas parent, String label, int type, int textLimit,
		boolean multiline) {
	super(1, 1);
	this.setParent(parent);
	this.label = label;
	this.textLimit = textLimit;
	this.multiline = multiline;

	this.labelFont = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
			Font.SIZE_LARGE);
	this.initializeTextEditor(parent, type);
	this.createStates();              
	this.setAutomaticSize();
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:15,代码来源:CanvasTextBox.java

示例6: getFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private static Font getFont(String face, String style, String size) {
	int meFace = 0;
	if (face.equalsIgnoreCase("system")) {
		meFace |= Font.FACE_SYSTEM;
	} else if (face.equalsIgnoreCase("monospace")) {
		meFace |= Font.FACE_MONOSPACE;
	} else if (face.equalsIgnoreCase("proportional")) {
		meFace |= Font.FACE_PROPORTIONAL;
	}

	int meStyle = 0;
	String testStyle = style.toLowerCase();
	if (testStyle.indexOf("plain") != -1) {
		meStyle |= Font.STYLE_PLAIN;
	}
	if (testStyle.indexOf("bold") != -1) {
		meStyle |= Font.STYLE_BOLD;
	}
	if (testStyle.indexOf("italic") != -1) {
		meStyle |= Font.STYLE_ITALIC;
	}
	if (testStyle.indexOf("underlined") != -1) {
		meStyle |= Font.STYLE_UNDERLINED;
	}

	int meSize = 0;
	if (size.equalsIgnoreCase("small")) {
		meSize |= Font.SIZE_SMALL;
	} else if (size.equalsIgnoreCase("medium")) {
		meSize |= Font.SIZE_MEDIUM;
	} else if (size.equalsIgnoreCase("large")) {
		meSize |= Font.SIZE_LARGE;
	}

	return Font.getFont(meFace, meStyle, meSize);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:37,代码来源:DeviceImpl.java

示例7: init

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
public void init(Graphics g) {
    boldFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL);
    boldHeight = boldFont.getHeight();
    
    //normalFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);

    initiated = true;
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:9,代码来源:MenuContainer.java

示例8: setFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
public void setFont(int arg1, int arg2, int arg3) {
    Font f = Font.getFont(arg1, arg2, arg3);
    graphics.setFont(f);
}
 
开发者ID:NeiroNext,项目名称:JccAPV,代码行数:5,代码来源:Graphics.java

示例9: setDesiredFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private void setDesiredFont() {
    Font font = Font.getFont(0, 0, 0);
    g.setFont(font);
}
 
开发者ID:queader,项目名称:Comcraft,代码行数:5,代码来源:Comcraft.java

示例10: getSmallFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private static Font getSmallFont() {
    if (small==null) small=Font.getFont(face, plain, smallSize);
    return small;
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:5,代码来源:FontCache.java

示例11: getSmallBoldFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private static Font getSmallBoldFont() {
    if (smallBold==null) smallBold=Font.getFont(face, bold, smallSize);
    return smallBold;
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:5,代码来源:FontCache.java

示例12: getMiddleFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private static Font getMiddleFont() {
    if (middle==null) middle=Font.getFont(face, plain, middleSize);
    return middle;
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:5,代码来源:FontCache.java

示例13: getMiddleBoldFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private static Font getMiddleBoldFont() {
    if (middleBold==null) middleBold=Font.getFont(face, bold, middleSize);
    return middleBold;
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:5,代码来源:FontCache.java

示例14: getBigFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private static Font getBigFont() {
    if (big==null) big=Font.getFont(face, plain, bigSize);
    return big;
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:5,代码来源:FontCache.java

示例15: getBigBoldFont

import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private static Font getBigBoldFont() {
    if (bigBold==null) bigBold=Font.getFont(face, bold, bigSize);
    return bigBold;
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:5,代码来源:FontCache.java


注:本文中的javax.microedition.lcdui.Font.getFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。