本文整理汇总了Java中javax.microedition.lcdui.Graphics.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.setColor方法的具体用法?Java Graphics.setColor怎么用?Java Graphics.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.lcdui.Graphics
的用法示例。
在下文中一共展示了Graphics.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* ���������ʼ��
* @param score ����
* @throws IOException
*/
public void init(int score) throws IOException
{
/*��Ϸ����:42,23
gameover:42,38
������:38,58
����ͼƬ:45,107*/
gameovertip=Image.createImage("/gameovertip.GIF");
endtip=Image.createImage("/endtip.GIF");
scorebg=Image.createImage("/scorebg.GIF");
gameoverbg=Image.createImage("/gameoverbg.GIF");
Graphics gra=super.getGraphics();
gra.setColor(255, 255, 255);
gra.fillRect(0, 0, sw, sh);
gra.drawImage(endtip, 42, 23,Graphics.LEFT|Graphics.TOP);
gra.drawImage(gameovertip, 42, 38,Graphics.LEFT|Graphics.TOP);
gra.drawImage(scorebg, 38, 58,Graphics.LEFT|Graphics.TOP);
gra.drawImage(gameoverbg, 45, 107,Graphics.LEFT|Graphics.TOP);
flushGraphics();
repaint();
super.ShowScore(score);
System.out.println("��������������");
}
示例2: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
int y = 0;
String loginStatus = "";
if (session.isLoggedIn()) {
loginStatus = "Logged in as " + session.getUsername();
}
else {
loginStatus = "Not logged in";
}
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_TEXT);
g.drawString(loginStatus, w - H_SPACE * 2, y, Graphics.TOP
| Graphics.RIGHT);
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
if (separatorImage != null) {
y = height - separatorImage.getHeight() - V_SPACE;
g.drawImage(separatorImage, 0, y, Graphics.TOP | Graphics.LEFT);
}
}
示例3: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* @see CommentItem#drawContent(javax.microedition.lcdui.Graphics, int, int)
*/
public void paint(final Graphics g, final int w, final int h) {
int x = H_SPACE + xIndent;
int y = V_SPACE;
g.setColor(VisualStyles.COLOR_HIGHLIGHTED_FOREGROUND);
g.drawLine(xIndent, 0, xIndent, h);
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_AUTHOR);
final int fontHeight = FONT_AUTHOR.getHeight();
for (int i = 0; i < bodyLines.size(); i++) {
g.drawString((String) bodyLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += fontHeight;
}
}
示例4: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Paints the Scrollbar. This method should be called from CanvasTextBox
* paint method.
*/
public void paint(Graphics gfx, int x, int y) {
int height = this.owner.getHeight();
gfx.setColor(this.backgroundColor);
gfx.fillRoundRect(
x + this.margin, y,
Scrollbar.width - 2 * this.margin, height,
this.cornersDiameter, this.cornersDiameter);
this.updateThumb();
gfx.setColor(this.thumbColor);
gfx.fillRoundRect(
x + this.margin + 1, y + this.thumbY + 1,
Scrollbar.width - 2 * this.margin - 2, this.thumbHeight - 2,
this.cornersDiameter, this.cornersDiameter);
}
示例5: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Paints the label, currentState and scrollbar.
*/
public void paint(Graphics gfx) {
if (BlogWriter.isAshaPlatform()) {
gfx.setColor(0x8D8C8C);
gfx.fillRect(0, 0, getWidth(), getHeight());
}
gfx.setColor(this.currentState.labelColor);
gfx.drawString(this.label, this.margin, this.margin, Graphics.TOP | Graphics.LEFT);
int textEditorY = this.labelFont.getHeight() + 2 * this.margin;
this.currentState.paint(gfx,(this.controlWidth - this.currentState.width) / 2, textEditorY);
if (this.scrollbar != null) {
this.scrollbar.paint(gfx, this.textEditor.getWidth()
+ this.textEditorMargin, textEditorY
+ this.textEditorBorderMargin);
}
if (this.controls != null && this.isFocused()) {
this.controls.paint(gfx, (this.controlWidth - this.currentState.width) / 2 + this.currentState.width, textEditorY-1);
}
}
示例6: drawImage
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
private void drawImage(Graphics g, int x, int y, int offX, int offY) throws IOException {
Image img = TileCacheManager.loadImage(zoom, x, y, mapSource, null);
if (img != null) {
g.drawImage(img, offX, offY, Graphics.TOP | Graphics.LEFT);
} else {
// If img IS null, then a repaint() is later called
g.setColor(0, 0, 0);
g.drawString("Loading...", offX, offY, Graphics.TOP | Graphics.LEFT);
TileCacheManager.loadImage(zoom, x, y, mapSource, this);
}
}
示例7: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();
// Draw a green border around the VideoControl.
g.setColor(0x00ff00);
g.drawRect(0, 0, width - 1, height - 1);
g.drawRect(1, 1, width - 3, height - 3);
}
示例8: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(final Graphics g, final int w, final int h) {
final String dateStr = DatePrettyPrinter.prettyPrint(link.getCreated());
final String numCommentsStr = "" + link.getNumComments() + " comments";
final int ncHeight = FONT_SEPARATOR.getHeight() + SEPARATOR_V_SPACE;
int x = H_SPACE;
int y = V_SPACE;
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_TEXT);
g.drawString("by " + link.getAuthor(), x, y, Graphics.TOP
| Graphics.LEFT);
g.drawString(dateStr, w - H_SPACE * 2, y, Graphics.TOP
| Graphics.RIGHT);
// Draw left and right part of the separator, then the score in the middle
y = height - ncHeight - V_SPACE / 2;
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
if (separatorImage != null) {
g.drawImage(separatorImage, w / 2, y + ncHeight / 2, Graphics.TOP
| Graphics.HCENTER);
}
g.setFont(FONT_SEPARATOR);
g.drawString(numCommentsStr, w / 2, y - 4, Graphics.TOP
| Graphics.HCENTER);
}
示例9: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draws the item.
*
* @param g Graphics context.
* @param viewX Top-left x-coordinate of the current view area (grid coordinates, not screen)
* @param viewY Top-left y-coordinate of the current view area (grid coordinates, not screen)
*/
public void paint(Graphics g, int viewX, int viewY){
if (Log.TEST) Log.note("[GridItem#paint]-->");
// Calculate actual drawing coordinates from the view coordinates
int translatedX = x - viewX;
int translatedY = y - viewY;
// First draw the underlying rectangle, and get color for text drawing
if (selected) {
g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND));
// Draw highlighted background
g.fillRect(translatedX, translatedY, width, height);
g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BORDER));
// Draw border
g.drawRect(translatedX, translatedY, width, height);
// Set color for text drawing
g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
} else {
//g.setColor(display.getColor(Display.COLOR_BORDER));
//g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
g.setColor(~display.getColor(Display.COLOR_BACKGROUND));
// Draw border
g.drawRect(translatedX, translatedY, width, height);
// Set color for text drawing
g.setColor(display.getColor(Display.COLOR_FOREGROUND));
}
drawContents(g, translatedX + V_PAD, translatedY + H_PAD,
width - 2 * H_PAD, height - 2 * V_PAD);
}
示例10: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item.
*/
protected void paint(Graphics g, int w, int h) {
int x = VisualStyles.COMMENT_H_SPACE;
int y = VisualStyles.COMMENT_V_SPACE;
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(font);
for (int i = 0, len = textLines.size(); i < len; i++) {
g.drawString((String) textLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += font.getHeight();
}
}
示例11: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Paint the state. Should be called from Button's paint method.
*/
public void paint(Graphics gfx, String text) {
gfx.drawImage(
background,
owner.getWidth() / 2, owner.getHeight() / 2,
Graphics.VCENTER | Graphics.HCENTER);
gfx.setColor(0x000000);
gfx.drawRect(0, 0, owner.getWidth() - 1, owner.getHeight() - 1);
gfx.setColor(this.labelColor);
gfx.drawString(
text,
owner.getWidth() / 2, (owner.getHeight() / 3) * 2,
Graphics.BASELINE | Graphics.HCENTER);
}
示例12: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
public void paint(Graphics g) {
if (pressed) {
g.setColor(backgroundColorPressed);
} else {
g.setColor(backgroundColor);
}
g.fillRoundRect(left, top, width, height, cornersDiameter, cornersDiameter);
g.setColor(color);
g.drawRoundRect(left, top, width, height, cornersDiameter, cornersDiameter);
g.drawString(text, left + width / 2, top + (height - g.getFont().getHeight()) / 2, Graphics.HCENTER | Graphics.TOP);
}
示例13: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
g.setColor(0x00FFFFFF);
g.fillRect(0, 0, getWidth(), getHeight());
synchronized (paintedLock) {
painted = true;
paintedLock.notify();
}
}
示例14: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint( Graphics g ){
g.setColor(0, 0, 0);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage( iImage, x , y, Graphics.TOP | Graphics.LEFT );
if( x + iImageWidth - getWidth() < 0 )
g.drawImage( iImage, x + iImageWidth, y, Graphics.TOP | Graphics.LEFT );
}
示例15: drawGPSDot
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
private void drawGPSDot(Graphics g, int x, int y) {
if (this.gpsPos.hasLocationProvider()) {
for (int n = 2; n < zoom * 8 / this.gpsPos.getSatellites(); n += 6) {
g.setColor(0, 25, 255);
g.drawArc(x - (n >> 1), y - (n >> 1), n, n, 0, 360);
}
}
}