?? mapoverlaytext.java.svn-base
字號:
package wFramework;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class MapOverlayText extends MapOverlay
{
private String text;
private int color;
private Font font;
private Image background;
public MapOverlayText(Map map, Point pos, String text, Object param)
{
super(map, pos, param);
this.text = text;
color = 0x000000;
this.font = Font.getFont(Font.FONT_STATIC_TEXT, Font.STYLE_PLAIN, Font.SIZE_SMALL);
background = null;
updateBounds();
}
public void setText(String text)
{
this.text = text;
updateBounds();
}
public String getText()
{
return text;
}
public int getColor()
{
return color;
}
public void setColor(int color)
{
this.color = color;
}
public void setFont(Font font)
{
if (this.font != font)
{
this.font = font;
updateBounds();
}
}
private Image makeFillImage(int width, int height)
{
int data[] = new int[width * height];
for (int i = 0; i < width * height; i++)
data[i] = 0x80ffffff;
return Image.createRGBImage(data, width, height, true);
}
public void paint(Graphics g)
{
Point px = map.worldToPixel(pos);
g.setFont(font);
//g.setColor(0xffffff);
//g.fillRoundRect(px.x + bounds.p.x - bounds.e.x, px.y + bounds.p.y - bounds.e.y, bounds.e.x * 2, bounds.e.y * 2, 8, 8);
g.drawImage(background, px.x, px.y + bounds.p.y - bounds.e.y, Graphics.HCENTER | Graphics.TOP);
g.setColor(color);
g.drawString(text, px.x, px.y + bounds.p.y - bounds.e.y, Graphics.HCENTER | Graphics.TOP);
}
private void updateBounds()
{
int w = font.stringWidth(text) + 2;
int h = font.getHeight();
int x0 = -w / 2;
int y0 = -h / 2;
bounds = new Rect(x0, y0, x0 + w, y0 + h);
background = makeFillImage(w, h);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -