📄 basicmappanel.java
字号:
*/ public JMenuBar getMapMenuBar() { if (menuList != null) { return menuList.getMenuBar(); } else { return null; } } /** * MapPanel method. Get a JMenu containing sub-menus created from * properties. */ public JMenu getMapMenu() { if (menuList != null) { return menuList.getMenu(); } else { return null; } } //Map Component Methods: //////////////////////// /** * Adds a component to the map bean context. This makes the * <code>mapComponent</code> available to the map layers and * other components. * * @param mapComponent a component to be added to the map bean * context * @throws MultipleSoloMapComponentException if mapComponent is a * SoloMapComponent and another instance already exists * and the policy is a reject policy. */ public void addMapComponent(Object mapComponent) { if (mapComponent != null) { getMapHandler().add(mapComponent); } } /** * Remove a component from the map bean context. * * @param mapComponent a component to be removed to the map bean * context * @return true if the mapComponent was removed. */ public boolean removeMapComponent(Object mapComponent) { if (mapComponent != null) { return getMapHandler().remove(mapComponent); } return true; } /** * Given a Class, find the object in the MapHandler. If the class * is not a SoloMapComponent and there are more than one of them * in the MapHandler, you will get the first one found. */ public Object getMapComponentByType(Class c) { return getMapHandler().get(c); } /** * Get all of the mapComponents that are of the given class type. */ public Collection getMapComponentsByType(Class c) { return getMapHandler().getAll(c); } /** * Find the object with the given prefix by looking it up in the * prefix librarian in the MapHandler. */ public Object getMapComponent(String prefix) { return getPropertyHandler().get(prefix); } /** * The BasicMapPanel looks for MapPanelChild components, finds out * from them where they prefer to be placed, and adds them. */ public void findAndInit(Object someObj) { if (someObj instanceof MapPanelChild && someObj instanceof Component) { if (Debug.debugging("basic")) { Debug.output("MapPanel: adding " + someObj.getClass().getName()); } MapPanelChild mpc = (MapPanelChild) someObj; addMapPanelChild(mpc); invalidate(); } if (someObj instanceof MenuList) { menuList = (MenuList) someObj; } } /** * Add a child to the MapPanel. */ protected void addMapPanelChild(MapPanelChild mpc) { add((Component) mpc, mpc.getPreferredLocation()); } /** * The MapPanel looks for MapPanelChild components and removes * them from iteself. */ public void findAndUndo(Object someObj) { if (someObj instanceof MapPanelChild && someObj instanceof Component) { if (Debug.debugging("basic")) { Debug.output("MapPanel: removing " + someObj.getClass().getName()); } remove((Component) someObj); invalidate(); } if (someObj instanceof MenuList && menuList == someObj) { menuList = null; } } //MapBean Methods: ////////////////// /** * A static method that creates a MapBean with it's projection set * to the values set in the Environment. Also creates a * BevelBorder.LOWERED border for the MapBean. */ public static MapBean createMapBean() { int envWidth = Environment.getInteger(Environment.Width, MapBean.DEFAULT_WIDTH); int envHeight = Environment.getInteger(Environment.Height, MapBean.DEFAULT_HEIGHT); if (envWidth <= 0 || envHeight <= 0) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if (envWidth <= 0) { envWidth = (int) d.getWidth(); } if (envHeight <= 0) { envHeight = (int) d.getHeight(); } } Projection proj = ProjectionFactory.getDefaultProjectionFromEnvironment(); if (Debug.debugging("mappanel")) { Debug.output("MapPanel: creating MapBean with initial projection " + proj); } return createMapBean(proj, new BevelBorder(BevelBorder.LOWERED)); } /** * A static method that creates a MapBean and sets its projection * and border to the values given. */ public static MapBean createMapBean(Projection proj, Border border) { MapBean mapBeano = new BufferedLayerMapBean(); mapBeano.setBorder(border); mapBeano.setProjection(proj); mapBeano.setPreferredSize(new Dimension(proj.getWidth(), proj.getHeight())); return mapBeano; } //Property Functions: ///////////////////// /** * Get the current properties. */ public Properties getProperties() { return getPropertyHandler().getProperties(); } /** * Remove an existing property if it exists. * * @return true if a property was actually removed. */ public boolean removeProperty(String property) { return getPropertyHandler().removeProperty(property); } /** * Add (or overwrite) a property to the current properties */ public void addProperty(String property, String value) { getPropertyHandler().addProperty(property, value); } /** * Add in the properties from the given URL. Any existing * properties will be overwritten except for openmap.components, * openmap.layers and openmap.startUpLayers which will be * appended. */ public void addProperties(URL urlToProperties) { getPropertyHandler().addProperties(urlToProperties); } /** * Add in the properties from the given source, which can be a * resorce, file or URL. Any existing properties will be * overwritten except for openmap.components, openmap.layers and * openmap.startUpLayers which will be appended. * * @throws MalformedURLException if propFile doesn't resolve * properly. */ public void addProperties(String propFile) throws java.net.MalformedURLException { getPropertyHandler().addProperties(propFile); } /** * remove a marker from a space delimated set of properties. */ public void removeMarker(String property, String marker) { getPropertyHandler().removeMarker(property, marker); } /** * Add in the properties from the given Properties object. Any * existing properties will be overwritten except for * openmap.components, openmap.layers and openmap.startUpLayers * which will be appended. */ public void addProperties(Properties p) { getPropertyHandler().addProperties(p); } /** * Append the given property into the current properties */ public void appendProperty(String property, Properties src) { getPropertyHandler().appendProperty(property, src); } /** * Append the given property into the current properties */ public void appendProperty(String property, String value) { getPropertyHandler().appendProperty(property, value); } /** * Prepend the given property into the current properties */ public void prependProperty(String property, Properties src) { getPropertyHandler().prependProperty(property, src); } /** * Prepend the given property into the current properties */ public void prependProperty(String property, String value) { getPropertyHandler().prependProperty(property, value); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -