本文整理汇总了Java中net.rim.device.api.ui.Graphics类的典型用法代码示例。如果您正苦于以下问题:Java Graphics类的具体用法?Java Graphics怎么用?Java Graphics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Graphics类属于net.rim.device.api.ui包,在下文中一共展示了Graphics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sublayout
import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void sublayout(int w, int h) {
//super.sublayout(w, h);
// the alternative undeprecated API requires a signature
if(net.rim.device.api.ui.Graphics.getScreenWidth() != screenWidth ||
net.rim.device.api.ui.Graphics.getScreenHeight() != screenHeight) {
screenWidth = net.rim.device.api.ui.Graphics.getScreenWidth();
screenHeight = net.rim.device.api.ui.Graphics.getScreenHeight();
if(screenWidth > 0 && screenHeight > 0) {
screen = new Bitmap(screenWidth, screenHeight);
globalGraphics = new Graphics(screen);
if(impl != null) {
impl.sizeChanged(screenWidth, screenHeight);
}
}
}
super.sublayout(w, h);
}
示例2: 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);
}
示例3: draw
import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void draw(Graphics g, XYRect r) {
int x = r.x + padding.left;
int y = r.y + padding.top;
int width = r.width - padding.left - padding.right;
int height = r.height - padding.top - padding.bottom;
XYRect rect = new XYRect(x, y, width, height);
int oldColor = g.getColor();
g.setColor(color);
g.fillRoundRect(rect.x, rect.y, rect.width, rect.height, arc, arc);
if (drawBorder) {
g.setColor(borderColor);
g.drawRoundRect(rect.x, rect.y, rect.width, rect.height, arc, arc);
}
g.setColor(oldColor);
}
示例4: draw
import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void draw(Graphics g, XYRect rect) {
int[] path = {startColor, startColor, endColor, endColor};
int[] xes = {0x0, rect.width, rect.width, 0};
int[] yes = {0x0, 0x0, rect.height, rect.height};
g.translate(rect.x, rect.y);
g.drawShadedFilledPath(xes, yes, null, path, null);
g.translate(-rect.x, -rect.y);
int oldColor = g.getColor();
if (topBorderHeight > 0) {
g.setColor(topBorderColor);
g.fillRect(rect.x, rect.y, rect.width, topBorderHeight);
}
if (bottomBorderHeight > 0) {
g.setColor(bottomBorderColor);
g.fillRect(rect.x, rect.y - bottomBorderHeight, rect.width, bottomBorderHeight);
}
g.setColor(oldColor);
}
示例5: 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);
}
}
示例6: paint
import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
protected void paint(Graphics g) {
if (wrapped != g) {
wrapped = g;
graphicsWrapper = new com.nutiteq.wrappers.Graphics(g);
}
// paint on wrapper (in effect painting on native graphics)
map.paint(graphicsWrapper);
// remove pushContext() done inside library
graphicsWrapper.popAll();
if (touchOkShow) {
int x = getContentWidth() - TouchMapField.OK_BITMAP.getWidth();
int y = 0;// getContentHeight()-OK_BITMAP.getHeight();
g.drawBitmap(x, y, TouchMapField.OK_BITMAP.getWidth(),
TouchMapField.OK_BITMAP.getHeight(), TouchMapField.OK_BITMAP, 0, 0);
}
}
示例7: 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);
}
示例8: paint
import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
protected void paint(Graphics g) {
AbstractBitmapField bmp;
if (isSelected && !isActive()) {
bmp = selectedBmp;
} else if (isActive()) {
bmp = activeBmp;
} else if (isFocused()) {
bmp = focusBmp;
} else {
bmp = defaultBmp;
}
if (bmp != null) {
bmp.draw(g, 0, 0, getContentWidth(), getContentHeight());
}
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: paint
import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void paint(int lastXPoint, int lastYPoint, Graphics graphics, int currentcolor) {
TRACE_COLOR = currentcolor;
int[] paintXpoints = _xPoints;
int[] paintYpoints = _yPoints;
if (lastXPoint > 0) {
paintXpoints = new int[_xPoints.length + 1];
paintYpoints = new int[_yPoints.length + 1];
paintXpoints[0] = lastXPoint;
paintYpoints[0] = lastYPoint;
for (int i = 1; i < paintXpoints.length; i++) {
paintXpoints[i] = _xPoints[i - 1];
paintYpoints[i] = _yPoints[i - 1];
}
}
paintPath(paintXpoints, paintYpoints, graphics);
}
示例12: paint
import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void paint(int lastXPoint, int lastYPoint, Graphics graphics, int currentcolor) {
TRACE_COLOR = currentcolor;
if (_xPoint < 0) {
// Just a break....
if (lastXPoint >= 0) {
paintPoint(lastXPoint, lastYPoint, graphics);
}
} else if (lastXPoint >= 0) {
System.out.println("Painting Point on Path");
paintPath(new int[] { lastXPoint, _xPoint },
new int[] { lastYPoint, _yPoint }, graphics);
} else {
paintPoint(_xPoint, _yPoint, graphics);
}
}
示例13: 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();
}
}
}
示例14: 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();
}
}
}
示例15: 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;
}