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


Java Graphics.getFont方法代码示例

本文整理汇总了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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:BlackBerryImplementation.java

示例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;
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:22,代码来源:EditSnap.java

示例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);
}
 
开发者ID:google,项目名称:google-authenticator,代码行数:26,代码来源:PinListFieldCallback.java

示例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);
}
 
开发者ID:yanex,项目名称:vika,代码行数:13,代码来源:TextDrawHelper.java

示例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;
}
 
开发者ID:yanex,项目名称:vika,代码行数:12,代码来源:TextDrawHelper.java


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