本文整理汇总了Java中javax.microedition.lcdui.Font.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Font.getHeight方法的具体用法?Java Font.getHeight怎么用?Java Font.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.lcdui.Font
的用法示例。
在下文中一共展示了Font.getHeight方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: paintTextRow
import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
/**
* Renders a text row to Canvas.
*/
private int paintTextRow(Graphics g, String text, int x, int y) {
int w = getWidth();
Font font = g.getFont();
for (int j = 0; j < text.length(); j++) {
char c = text.charAt(j);
int cw = font.charWidth(c);
if (x + cw > w) {
x = 0;
y += font.getHeight();
}
g.drawChar(c, x, y, Graphics.TOP | Graphics.LEFT);
x += cw;
}
if (touch || nHD_portrait) {
y += (2 * font.getHeight());
} else {
y += font.getHeight();
}
return y;
}
示例3: 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 );
}
示例4: getPrefContentHeight
import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
public int getPrefContentHeight(int h)
{
Font f = Font.getDefaultFont();
return 8 * f.getHeight() + 6;
}
示例5: drawDateBox
import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
private void drawDateBox(int xPos, int yPos)
{
int prevColor = gObj.getColor();
Font font = Font.getDefaultFont();
int boxWidth = font.stringWidth("30") + 5;
int boxHeight = font.getHeight() - 2;
String monthStr = (new Integer(currMonth+1)).toString() + " ";
String dayStr = (new Integer(currDay)).toString() + " ";
String yearStr = (new Integer(currYear)).toString();
//Clear the previous rectangle on the date field
if(prevSelectionMode != -1)
{
gObj.setColor(0x00FFFFFF);
if(prevSelectionMode == MONTH)
{
boxWidth = font.stringWidth(monthStr);
gObj.fillRect(xPos, yPos, boxWidth, boxHeight);
}
else if(prevSelectionMode == DAY)
{
boxWidth = font.stringWidth(dayStr);
gObj.fillRect(xPos + font.stringWidth(monthStr), yPos, boxWidth, boxHeight);
}
else if(prevSelectionMode == YEAR)
{
boxWidth = font.stringWidth(yearStr);
gObj.fillRect(xPos + font.stringWidth(monthStr) + font.stringWidth(dayStr), yPos, boxWidth, boxHeight);
}
else if(prevSelectionMode == NONE)
{
boxWidth = font.stringWidth(NO_DATE_STR) + 5;
gObj.fillRect(xPos + font.stringWidth(monthStr) + font.stringWidth(dayStr) + font.stringWidth(yearStr) + font.stringWidth(" "), yPos, boxWidth, boxHeight);
}
}
gObj.setColor(0x0000FF0A);
if(selectionMode == MONTH)
{
boxWidth = font.stringWidth(monthStr);
gObj.fillRect(xPos, yPos, boxWidth, boxHeight);
}
else if(selectionMode == DAY)
{
boxWidth = font.stringWidth(dayStr);
gObj.fillRect(xPos + font.stringWidth(monthStr), yPos, boxWidth, boxHeight);
}
else if(selectionMode == YEAR)
{
boxWidth = font.stringWidth(yearStr);
gObj.fillRect(xPos + font.stringWidth(monthStr) + font.stringWidth(dayStr), yPos, boxWidth, boxHeight);
}
else if(selectionMode == NONE)
{
boxWidth = font.stringWidth(NO_DATE_STR);
gObj.fillRect(xPos + font.stringWidth(monthStr) + font.stringWidth(dayStr) + font.stringWidth(yearStr) + font.stringWidth(" ") , yPos, boxWidth, boxHeight);
}
gObj.setColor(prevColor);
}
示例6: paintContent
import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
if(player != null) {
//center stuff
width = rightBorder - leftBorder;
int offsetX = (width - cw) / 2;
vc.setDisplayLocation(x + offsetX, y);
if(!playing) {
vc.setVisible(false);
Font f = g.getFont();
int fnth = f.getHeight();
//Calculate margins and locations
int mx = x + offsetX;
int my = y;
int mw = vc.getDisplayWidth();
int mh = vc.getDisplayHeight();
int hi = Math.max((int)Math.floor(.2 * mh), fnth);
int fh = mh - hi * 2;
//int fw = mw - wi * 2;
//int wi = (int)Math.floor(.2 * mw);
int fw = (int)Math.floor(.9 * fh);
int wi = (mw - fw)/2;
int wu = (int)Math.floor(fw / 5.0);
int hu = (int)Math.floor(fh / 7.0);
if(hashKeyImage == null) {
hashKeyImage = ImageUtils.getImage(imageLocation);
if(hashKeyImage != null){
//scale
int[] newDimension = ImageUtils.getNewDimensions(hashKeyImage, fw,fh);
if(newDimension[0] != height || newDimension[1] != width) {
hashKeyImage = ImageUtils.resizeImage(hashKeyImage, newDimension[1], newDimension[0]);
}
}
}
if(hashKeyImage != null) {
g.drawImage(hashKeyImage, mx + wi + fw / 2, my + hi + fh / 2, Graphics.HCENTER | Graphics.VCENTER);
} else {
//Draw us a big 'ol hash
g.setColor(0, 0, 0);
g.fillRect(mx + wi + wu, my + hi, wu, fh);
g.fillRect(mx + wi + 3 * wu, my + hi, wu, fh);
g.fillRect(mx + wi, my + hi + 2 * hu, fw, hu);
g.fillRect(mx + wi, my + hi + 4 * hu, fw, hu);
}
int tw = f.stringWidth(top);
int bw = f.stringWidth(bottom);
int tx = (mw - tw)/2 + mx;
int tyo = (hi - fnth) /2;
int ty = my + tyo;
g.drawString(top, tx, ty, Graphics.TOP | Graphics.LEFT);
int bx = (mw - bw)/2 + mx;
int by = (my + mh - hi) + tyo;
g.drawString(bottom, bx, by, Graphics.TOP | Graphics.LEFT);
}
}
}
示例7: paint
import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();
g.setGrayScale(255);
g.fillRect(0, 0, width, height);
g.setColor(0x5691F0);
g.drawRect(0, 0, width - 1, height - 1);
g.setGrayScale(0);
g.drawRect(2, 2, width - 5, height - 5);
int pos = posX;
while (pos < width - 5) {
g.drawLine(3 + pos, 3, 3 + pos, height - 4);
pos += POSNUMBER;
}
pos = posY;
while (pos < height - 5) {
g.drawLine(3, 3 + pos, width - 4, 3 + pos);
pos += POSNUMBER;
}
// Paint canvas info in the middle
String text = width + " x " + height;
Font f = g.getFont();
int w = f.stringWidth(text) + 4;
int h = 2 * f.getHeight() + 4;
int arcWidth = w;
int arcHeight = h;
g.setColor(0xFFCC11);
g.drawRoundRect((width - w)/2, (height - h)/2, w, h, arcWidth, arcHeight);
g.setColor(0xFFEE99);
g.fillRoundRect((width - w)/2, (height - h)/2, w, h, arcWidth, arcHeight);
g.setColor(0xBB5500);
g.drawString(text, width/2, (height - f.getHeight())/2, Graphics.HCENTER | Graphics.TOP);
// Pint Ball
g.setColor(ballColor);
g.fillRoundRect(ballPosX - 4, ballPosY - 4, 8, 8, 8, 8);
ballPosX += ballMoveX;
ballPosY += ballMoveY;
boolean changeColor = false;
if ((ballPosX < 4) || (ballPosX > width - 4)) {
ballMoveX = -ballMoveX;
changeColor = true;
}
if ((ballPosY < 4) || (ballPosY > height - 4)) {
ballMoveY = -ballMoveY;
changeColor = true;
}
if (changeColor) {
ballColor = ballRandom.nextInt(0xFF) + (ballRandom.nextInt(0xFF) << 8) + (ballRandom.nextInt(0xFF) << 16);
}
}
示例8: drawStringCenteredAndTruncated
import javax.microedition.lcdui.Font; //导入方法依赖的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);
}
示例9: paintContent
import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
if(player != null) {
//center stuff
width = rightBorder - leftBorder;
int offsetX = (width - cw) / 2;
vc.setDisplayLocation(x + offsetX, y);
if(!playing) {
vc.setVisible(false);
Font f = g.getFont();
int fnth = f.getHeight();
//Calculate margins and locations
int mx = x + offsetX;
int my = y;
int mw = vc.getDisplayWidth();
int mh = vc.getDisplayHeight();
int hi = Math.max((int)Math.floor(.2 * mh), fnth);
int fh = mh - hi * 2;
//int fw = mw - wi * 2;
//int wi = (int)Math.floor(.2 * mw);
int fw = (int)Math.floor(.9 * fh);
int wi = (mw - fw)/2;
int wu = (int)Math.floor(fw / 5.0);
int hu = (int)Math.floor(fh / 7.0);
//Draw us a big 'ol hash
g.setColor(0, 0, 0);
g.fillRect(mx + wi + wu, my + hi, wu, fh);
g.fillRect(mx + wi + 3 * wu, my + hi, wu, fh);
g.fillRect(mx + wi, my + hi + 2 * hu, fw, hu);
g.fillRect(mx + wi, my + hi + 4 * hu, fw, hu);
String top = Localization.get("video.playback.top");
//String top = "lw: " + vc.getSourceWidth() + " lh: " + vc.getSourceHeight();
String bottom = Localization.get("video.playback.bottom");
//String bottom = "cw: " + cw + " ch: " + ch;
int tw = f.stringWidth(top);
int bw = f.stringWidth(bottom);
int tx = (mw - tw)/2 + mx;
int tyo = (hi - fnth) /2;
int ty = my + tyo;
g.drawString(top, tx, ty, Graphics.TOP | Graphics.LEFT);
int bx = (mw - bw)/2 + mx;
int by = (my + mh - hi) + tyo;
g.drawString(bottom, bx, by, Graphics.TOP | Graphics.LEFT);
}
}
}
示例10: getPrefContentHeight
import javax.microedition.lcdui.Font; //导入方法依赖的package包/类
public int getPrefContentHeight(int h) { Font f = Font.getDefaultFont(); return 8 * f.getHeight() + 6; }