本文整理汇总了Java中net.rim.device.api.ui.Graphics.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.getFont方法的具体用法?Java Graphics.getFont怎么用?Java Graphics.getFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.rim.device.api.ui.Graphics
的用法示例。
在下文中一共展示了Graphics.getFont方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setClip
import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void setClip(Object graphics, int x, int y, int width, int height) {
Graphics g = (net.rim.device.api.ui.Graphics) graphics;
net.rim.device.api.ui.Font oldFont = g.getFont();
int oldColor = g.getColor();
int oldAlpha = g.getGlobalAlpha();
while (g.getContextStackSize() > 1) {
g.popContext();
}
g.pushRegion(x, y, width, height, 0, 0);
g.translate(-g.getTranslateX(), -g.getTranslateY());
/**
* applying a clip will automatically
* reset some information that we need to keep track of
* manually (it seems).
*/
g.setFont(oldFont == null ? (net.rim.device.api.ui.Font) getDefaultFont() : oldFont);
g.setColor(oldColor);
g.setGlobalAlpha(oldAlpha);
}
示例2: DrawTime
import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
private void DrawTime(int X, int Y) {
Graphics gd = new Graphics(bmpd);
Graphics g = new Graphics(bmp);
Font gsavefong = g.getFont();
Font myFont = g.getFont();
g.setColor(currentcolor);
gd.setColor(currentcolor);
g.setFont(myFont.derive(Font.LATIN_SCRIPT, 15, Ui.UNITS_mm));
gd.setFont(myFont.derive(Font.LATIN_SCRIPT, 15, Ui.UNITS_mm));
Date current = new Date();
String txt = current.toString().substring(11, 17);
int size = g.getFont().getAdvance(txt);
g.drawText(txt, X - size / 2,
Y - Ui.convertSize(15, Ui.UNITS_mm, Ui.UNITS_px) / 2);
gd.drawText(txt, X - size / 2,
Y - Ui.convertSize(15, Ui.UNITS_mm, Ui.UNITS_px) / 2);
g.setFont(gsavefong);
gd.setFont(gsavefong);
actualize();
hour = false;
}
示例3: drawListRow
import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void drawListRow(ListField listField, Graphics graphics, int index,
int y, int width) {
PinInfo item = mItems[index];
int iconWidth = mIcon.getWidth();
int iconHeight = mIcon.getHeight();
int iconX = width - PADDING - iconWidth;
int iconY = y + Math.max(0, (mRowHeight - iconHeight) / 2);
graphics.drawBitmap(iconX, iconY, iconWidth, iconHeight, mIcon, 0, 0);
int textWidth = Math.max(0, width - iconWidth - PADDING * 3);
int textX = PADDING;
int textY = y + PADDING;
int flags = Graphics.ELLIPSIS;
Font savedFont = graphics.getFont();
graphics.setFont(mUserFont);
graphics.drawText(item.mUser, textX, textY, flags, textWidth);
textY += mUserFont.getHeight();
graphics.setFont(mPinFont);
graphics.drawText(item.mPin, textX, textY, flags, textWidth);
graphics.setFont(savedFont);
}
示例4: drawEllipsizedString
import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public static void drawEllipsizedString(String text, Graphics g, int x, int y, int maxWidth) {
Font f = g.getFont();
String t = text;
if (f.getAdvance(t) <= maxWidth) {
g.drawText(text, x, y);
return;
}
while (f.getAdvance(t + ELLIPSIZE) > maxWidth) {
t = t.substring(0, t.length() - 1);
}
g.drawText(t + ELLIPSIZE, x, y);
}
示例5: calcEllipsize
import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public static String calcEllipsize(String text, Graphics g, int maxWidth) {
String t = text;
Font f = g.getFont();
if (f.getAdvance(t) <= maxWidth) {
return t;
}
while (f.getAdvance(t + ELLIPSIZE) > maxWidth) {
t = t.substring(0, t.length() - 1);
}
return t + ELLIPSIZE;
}