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


Java Graphics.setFont方法代码示例

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


在下文中一共展示了Graphics.setFont方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g, XYRect rect) {
    int oldColor = g.getColor(), dy = (rect.height - FONT.getHeight()) / 2, color = (isActive() || isFocused()) ?
            getTheme().getSecondaryFontColor()
            : getTheme().getPrimaryColor();
    try {
        g.setFont(FONT);
        g.setColor(color);
        TextDrawHelper.drawEllipsizedString(text, g, rect.x, rect.y + dy, rect.width);
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:13,代码来源:SongItem.java

示例5: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    if (status == null || status.length() == 0) {
        g.setFont(VkConversationUserField.fName);
        g.setColor(0xFFFFFF);
        g.drawText(name, 0, (getContentHeight() - nameHeight) / 2);
    } else {
        if (nameWidth + VkConversationUserField.INTERVAL + statusWidth > getContentWidth()) { // 2
            // lines
            g.setFont(VkConversationUserField.fName);
            g.setColor(0xFFFFFF);
            g.drawText(name, 0, 0);

            g.setFont(VkConversationUserField.fStatus);
            g.setColor(0x666666);
            g.drawText(status, 0, getContentHeight() - statusHeight);
        } else { // 1 line
            g.setFont(VkConversationUserField.fName);
            g.setColor(0xFFFFFF);
            g.drawText(name, 0, (getContentHeight() - nameHeight) / 2);

            g.setFont(VkConversationUserField.fStatus);
            g.setColor(0x666666);
            g.drawText(status, nameWidth + VkConversationUserField.INTERVAL, (getContentHeight() - 2
                    * statusHeight + nameHeight) / 2);
        }
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:28,代码来源:VkConversationUserField.java

示例6: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g, XYRect rect) {
    int y = (getContentHeight() - FONT.getHeight()) / 2;
    g.setFont(FONT);
    g.setColor(SeparatorItem.THEME.getPrimaryColor());
    g.drawText(text, DP1, y);
}
 
开发者ID:yanex,项目名称:vika,代码行数:7,代码来源:SeparatorItem.java

示例7: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    int oldAlpha = g.getGlobalAlpha();

    int height = getContentHeight(), width = getContentWidth();

    int color = getTheme().getPrimaryColor();
    if (isFocused() || isActive()) {
        color = getTheme().getSecondaryFontColor();
    }

    try {
        Font f = PaneCaptionField.font;

        int y = (height - f.getHeight()) / 2;

        int centerX = width / 2 - dx;

        g.setGlobalAlpha(255);
        g.setFont(f);
        g.setColor(color);

        int curX = centerX;
        for (int i = 0; i < titles.size(); ++i) {
            String t = (String) titles.elementAt(i);
            int x = curX - f.getAdvance(t) / 2;

            if (i < current) {
                TextDrawHelper.drawAlphaGradientString(t, g, x, y, true);
            } else if (i > current) {
                TextDrawHelper.drawAlphaGradientString(t, g, x, y, false);
            } else {
                g.drawText(t, x, y);
            }
            curX += width / 2;
            if (curX > width) {
                break;
            }
        }
    } finally {
        g.setColor(oldColor);
        g.setGlobalAlpha(oldAlpha);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:45,代码来源:PaneCaptionField.java


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