本文整理汇总了Java中net.rim.device.api.ui.Graphics.getGlobalAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.getGlobalAlpha方法的具体用法?Java Graphics.getGlobalAlpha怎么用?Java Graphics.getGlobalAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.rim.device.api.ui.Graphics
的用法示例。
在下文中一共展示了Graphics.getGlobalAlpha方法的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: 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);
}
}
示例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);
}
}
示例4: createMutableImage
import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public Object createMutableImage(int width, int height, int fillColor) {
Bitmap b = new Bitmap(width, height);
Graphics g = new Graphics(b);
if ((fillColor & 0xff000000) != 0xff000000) {
g.setColor(fillColor & 0xffffff);
int oldAlpha = g.getGlobalAlpha();
g.setGlobalAlpha((fillColor >> 24) & 0xff);
g.clear();
g.setGlobalAlpha(oldAlpha);
} else {
g.setColor(fillColor & 0xffffff);
g.fillRect(0, 0, width, height);
}
return b;
}
示例5: 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);
}
}