mapview.java~43~
来自「一个很有特点的地图平台,可以以动画方试展现电子地图,有拉近,拉远,滑动功能,最主」· JAVA~43~ 代码 · 共 68 行
JAVA~43~
68 行
package mapcenter.visualmap;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import com.mapinfo.beans.vmapj.*;
import mapcenter.service.*;
import mapcenter.weihu.*;
public class MapView extends JComponent implements MouseListener, MouseMotionListener {
private Log log = LogFactory.getLog("WebGIS");
private HashMap mapTools = new HashMap();
private MapTool currTool = null;
public MapView() {
super();
this.addMouseListener(this);
this.addMouseMotionListener(this);
}
public void renderMap(){
try{
Image image = MapHandle.getInstance().render();
this.getGraphics().drawImage(image,0,0,null);
}catch(Exception e){log.error(e);}
}
public void setCurrentTool(String toolName)throws Exception{
Iterator toolIter = mapTools.entrySet().iterator();
while(toolIter.hasNext()){
MapTool mapTool = (MapTool)toolIter.next();
mapTool.putValue(mapTool.SMALL_ICON,mapTool.originalIcon);
}
MapTool mapTool = (MapTool)mapTools.get(toolName);
if(mapTool == null)throw new Exception("HashMap Key no find:"+toolName);
this.currTool = mapTool;
}
public void paint(Graphics g){
currTool.paintOnMap(g);
}
//============= MouseListener接口实现 =============
public void mouseEntered(MouseEvent e) {
currTool.mouseEntered(new MapMouseEvent(e));
}
public void mouseExited(MouseEvent e) {
currTool.mouseExited(new MapMouseEvent(e));
}
public void mousePressed(MouseEvent e) {
currTool.mousePressed(new MapMouseEvent(e));
}
public void mouseReleased(MouseEvent e) {
currTool.mouseReleased(new MapMouseEvent(e));
}
public void mouseDragged(MouseEvent e) {
currTool.mouseDragged(new MapMouseEvent(e));
}
public void mouseMoved(MouseEvent e) {
currTool.mouseMoved(new MapMouseEvent(e));
}
public void mouseClicked(MouseEvent e) {
currTool.mouseClicked(new MapMouseEvent(e));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?