⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapoverlayicon.java.svn-base

📁 利用J2ME编写的手机应用程序。 功能包括显示图片
💻 SVN-BASE
字号:
package wFramework;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class MapOverlayIcon extends MapOverlay 
{
	private Image icon;
	
	public MapOverlayIcon(Map map, Point pos, Object param)
	{
		super(map, pos, param);
		
		try
		{
			icon = Image.createImage("/wFramework/images/defaulticon.png");
		}
		catch (Exception e)
		{
			System.out.println("Failed to load default icon");
		}
	}
	
	public void setIcon(Image icon)
	{
		this.icon = icon;
		updateBounds();
	}
	
	public Image getIcon()
	{
		return icon;
	}

	public void paint(Graphics g)
	{
		if (icon == null) return;
		Point px = map.worldToPixel(pos);
		g.drawImage(icon, px.x, px.y, Graphics.HCENTER | Graphics.VCENTER);
	}

	private void updateBounds()
	{
		if (icon == null) return;
		
		int w = icon.getWidth();
		int h = icon.getHeight();
		int x0 = -w / 2;
		int y0 = -h / 2;
		bounds = new Rect(x0, y0, x0 + w, y0 + w);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -