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


Java Graphics.drawText方法代码示例

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


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

示例1: drawAlphaGradientString

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public static void drawAlphaGradientString(
        String text, Graphics g, int x, int y, boolean toRight) {
    int oldAlpha = g.getGlobalAlpha();
    try {
        int dx = 0, currentAlpha = toRight ? 255 : 55;
        int step = (toRight ? -1 : 1) * 200 / text.length();
        for (int i = 0; i < text.length(); ++i) {
            char c = text.charAt(i);
            g.setGlobalAlpha(currentAlpha);
            g.drawText("" + c, x + dx, y);
            dx += g.getFont().getAdvance(c);
            currentAlpha += step;
        }
    } finally {
        g.setGlobalAlpha(oldAlpha);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:18,代码来源:TextDrawHelper.java

示例2: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    try {
        if (isFocused() || isActive()) {
            g.setColor(getTheme().getSecondaryFontColor());
        } else {
            g.setColor(getTheme().getPrimaryColor());
        }

        int dy = (getContentHeight() - g.getFont().getHeight()) / 2;
        int dx = (getContentWidth() - g.getFont().getAdvance(text)) / 2;
        g.drawText(text, dx, dy, DrawStyle.TOP | DrawStyle.LEFT, Integer.MAX_VALUE);
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:17,代码来源:ButtonField.java

示例3: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    if (bitmap != null) {
        bitmap.draw(g, 0, 0, getContentWidth(), getContentHeight());
    } else if (defaultBitmap != null) {
        defaultBitmap.draw(g, 0, 0, getContentWidth(), getContentHeight());
    }
    if (text != null) {
        int h = R.px(10);

        int oldAlpha = g.getGlobalAlpha();
        int oldColor = g.getColor();

        g.setGlobalAlpha(150);
        g.fillRect(0, getContentHeight() - h, getContentWidth(), h);
        g.setGlobalAlpha(200);
        g.setColor(0xEEEEEE);
        g.drawText(text, getContentWidth() / 2, getContentHeight() - h / 2, DrawStyle.HCENTER);

        g.setGlobalAlpha(oldAlpha);
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:23,代码来源:ImageField.java

示例4: paint

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

    try {
        int x = getContentLeft() + getContentWidth() - image.getWidth() - VkCompactTitleField.px(1);
        int y = (getContentHeight() - image.getHeight()) / 2;

        if (animationLaunched) {
            g.drawBitmap(x, y, image.getWidth(), image.getHeight(),
                    image.getBitmap(currentFrame), 0, 0);
        }

        if (text != null) {
            g.setColor(0xffffff);
            g.drawText(text, getContentLeft(), (getContentHeight() - g.getFont().getHeight()) / 2);
        }
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:21,代码来源:VkCompactTitleField.java

示例5: run

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void run() {
	synchronized (UiApplication.getEventLock()) {
		if (_time > 0) {
			Bitmap _bmp = new Bitmap(Display.getWidth(),
					Display.getHeight());
			Graphics g = new Graphics(_bmp);
			g.setColor(Color.BLACK);
			g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
			g.drawBitmap(
					((_bmp.getWidth() / 2) - (_img.getWidth() / 2)), 0,
					_img.getWidth(), _img.getHeight(), _img, 0, 0);
			g.setColor(Color.WHITE);
			g.drawText(_time + "s", Display.getWidth() - 60,
					Display.getHeight() - 50);
			bmp.setBitmap(_bmp);
			_time--;				
		} else {
			t.cancel();
			quit();			
		}
	}
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:23,代码来源:DisplayStory.java

示例6: run

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void run() {
	synchronized (UiApplication.getEventLock()) {
		if (_time > 0) {
			Bitmap _bmp = new Bitmap(Display.getWidth(),
					Display.getHeight());
			Graphics g = new Graphics(_bmp);
			g.setColor(Color.BLACK);
			g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
			g.drawBitmap(
					((_bmp.getWidth() / 2) - (_img.getWidth() / 2)), 0,
					_img.getWidth(), _img.getHeight(), _img, 0, 0);
			g.setColor(Color.WHITE);
			g.drawText(_time + "s", Display.getWidth() - 60,
					Display.getHeight() - 50);
			bmp.setBitmap(_bmp);
			_time--;				
		} else {
			t.cancel();
			quit();
						
		}
	}
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:24,代码来源:DisplaySnap.java

示例7: 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

示例8: 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

示例9: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void paint(Graphics g) {
    int f = getFieldCount();
    if(f > 0) {
        g.drawBitmap(0, 0, getWidth(), getHeight(), screen, 0, 0);

        Form currentForm = Display.getInstance().getCurrent();
        for(int iter = 0 ; iter < f ; iter++) {
            Field fld = getField(iter);
            int pops = 0;
            if(currentForm != null) {
                PeerComponent p = findPeer(currentForm.getContentPane(), fld);
                if(p != null) {
                    pops = clipOnLWUITBounds(p, g);
                } else {
                    Component cmp = currentForm.getFocused();

                    // we are now editing an edit field
                    if(cmp != null && cmp instanceof TextArea && cmp.hasFocus() && fld instanceof EditField) {
                        pops = clipOnLWUITBounds(cmp, g);
                        int x = fld.getLeft();
                        int y = fld.getTop();
                        g.clear(x, y, Math.max(cmp.getWidth(), fld.getWidth()),
                                Math.max(cmp.getHeight(), fld.getHeight()));
                    }
                }
            }
            paintChild(g, fld);
            while(pops > 0) {
                g.popContext();
                pops--;
            }
        }
    } else {
        g.drawBitmap(0, 0, getWidth(), getHeight(), screen, 0, 0);
    }
    g.setColor(0);
    g.drawText(debug, 0, 0);
    painted = true;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:40,代码来源:BlackBerryCanvas.java

示例10: 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

示例11: paint

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

    if (displayingHint) {
        g.setColor(theme.getSecondaryFontColor());
        g.drawText(hint, 0, 0);
    } else {
        g.setColor(theme.getPrimaryColor());
        super.paint(g);
    }

    g.setColor(oldColor);
}
 
开发者ID:yanex,项目名称:vika,代码行数:14,代码来源:CustomPasswordEditField.java

示例12: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    try {
        int maxWidth = getContentWidth() - bmp.getWidth() - ImageTextButtonField.INTERVAL;
        String cutted = TextDrawHelper.calcEllipsize(text, g, maxWidth);

        int y = (getContentHeight() - bmp.getHeight()) / 2;
        int x = (getContentWidth() - bmp.getWidth() - ImageTextButtonField.INTERVAL - getFont()
                .getAdvance(cutted)) / 2;

        g.drawBitmap(x, y, bmp.getWidth(), bmp.getHeight(), bmp, 0, 0);

        if (isFocused() || isActive()) {
            g.setColor(getTheme().getSecondaryFontColor());
        } else {
            g.setColor(getTheme().getPrimaryColor());
        }

        if (g.getFont().getAdvance(text) > maxWidth) {
            TextDrawHelper.drawEllipsizedString(text, g,
                    x + bmp.getWidth() + ImageTextButtonField.INTERVAL,
                    (getContentHeight() - g.getFont().getHeight()) / 2, maxWidth);
        } else {
            g.drawText(text, x + bmp.getWidth() + ImageTextButtonField.INTERVAL,
                    getContentHeight() / 2,
                    DrawStyle.VCENTER, getContentWidth());
        }
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:32,代码来源:ImageTextButtonField.java

示例13: 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

示例14: 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

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