📄 mapwindow.java
字号:
// **********************************************************************// // <copyright>// // BBN Technologies// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000// // Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/gui/MapWindow.java,v $// $RCSfile: MapWindow.java,v $// $Revision: 1.2.2.1 $// $Date: 2004/10/14 18:26:53 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.gui;import java.awt.*;import javax.swing.*;import com.bbn.openmap.*;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;/** * The MapWindow is a window with the basics - MapBean, * MouseDelegator, SelectMouseMode, LayerHandler. It can be used to * draw stuff into if you add a layer to it that handles what you want * to render. The SelectMouseMode will automatically direct mouse * events to the layer if it is set up to receive "Gestures". * <P> * * If you want to add an object that needs to set itself to a * particular location on the frame, i.e. the ToolPanel or * InformationDelegator, you have to do the layout management yourself * with the MapWindow. The OpenMapFrame has an idea of where it wants * those components to go, but the MapWindow doesn't. */public class MapWindow extends JFrame { /** The MapHandler BeanContext. */ protected MapHandler mapHandler = new MapHandler(); /** The MapBean. */ protected MapBean map; public MapWindow() { super(); } public MapWindow(String windowTitle) { super(windowTitle); try { map = new BufferedMapBean(); mapHandler.add(new MouseDelegator()); mapHandler.add(new LayerHandler()); mapHandler.add(map); getContentPane().add(map, BorderLayout.CENTER); } catch (MultipleSoloMapComponentException msmce) { } } /** Add an object to the internal MapHandler. */ public void addTo(Object obj) throws MultipleSoloMapComponentException { mapHandler.add(obj); } /** Remove an object from the internal MapHandler. */ public void removeFrom(Object obj) { mapHandler.remove(obj); } /** Get the MapHandler. */ public MapHandler getMapHandler() { return mapHandler; } /** Get the map. */ public MapBean getMap() { return map; } public void setProjection(Projection proj) { map.setProjection(proj); } public Projection getProjection() { return map.getProjection(); } public static void main(String[] argv) { Environment.init(); Debug.init(); MapBean.suppressCopyright = true; MapWindow mw = new MapWindow("OpenMap's MapWindow"); mw.setSize(500, 500); try { mw.addTo(new com.bbn.openmap.layer.shape.ShapeLayer("share/data/shape/dcwpo-browse.shp")); mw.addTo(new com.bbn.openmap.event.NavMouseMode2()); mw.addTo(new com.bbn.openmap.gui.ToolPanel()); mw.addTo(new com.bbn.openmap.gui.OMToolSet()); // If you want to add a ToolPanel, or an // InformationDelegator, or anything that needs to know // about the layout of the MapWindow frame, then you have // to do the layout management yourself. For example: // ToolPanel toolPanel = new ToolPanel(); // toolPanel.setFloatable(false); // mw.getContentPane().add(toolPanel, BorderLayout.NORTH); } catch (MultipleSoloMapComponentException memce) { } mw.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -