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

📄 dtedframecachelayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************// // <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/layer/dted/DTEDFrameCacheLayer.java,v $// $RCSfile: DTEDFrameCacheLayer.java,v $// $Revision: 1.3.2.6 $// $Date: 2005/09/13 14:34:01 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.dted;/*  Java Core  */import java.awt.Component;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseEvent;import java.io.Serializable;import javax.swing.Box;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JPanel;import javax.swing.JRadioButton;/*  OpenMap  */import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.dataAccess.dted.DTEDConstants;import com.bbn.openmap.dataAccess.dted.DTEDFrameCacheHandler;import com.bbn.openmap.event.MapMouseListener;import com.bbn.openmap.event.SelectMouseMode;import com.bbn.openmap.layer.OMGraphicHandlerLayer;import com.bbn.openmap.omGraphics.OMGraphicList;import com.bbn.openmap.omGraphics.OMRect;import com.bbn.openmap.omGraphics.OMText;import com.bbn.openmap.proj.EqualArc;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PaletteHelper;import com.bbn.openmap.util.PropUtils;/** * The DTEDFrameCacheLayer fills the screen with DTED data. To view * the DTED iamges, the projection has to be set in an ARC projection, * which OpenMap calls the CADRG or LLXY projection. In Gesture mode, * clicking on the map will cause the DTEDFrameCacheLayer to place a * point on the window and show the elevation of that point. The * Gesture response is not dependent on the scale or projection of the * screen. * <P> *  * The DTEDFrameCacheLayer uses the DTEDCacheHandler to get the images * it needs. The DTEDFrameCacheLayer receives projection change * events, and then asks the cache handler for the images it needs * based on the new projection. *  * The DTEDFrameCacheLayer also relies on properties to set its * variables, such as the dted frame paths (there can be several at a * time), the opaqueness of the frame images, number of colors to use, * and some other display variables. The DTEDFrameCacheLayer * properties look something like this: * <P> *  * NOTE: Make sure your DTED file and directory names are in lower * case. You can use the com.bbn.openmap.layer.rpf.ChangeCase class to * make modifications if necessary. * <P> *  * <pre> *  *   *   #------------------------------ *   # Properties for DTEDFrameCacheLayer *   #------------------------------ *    *   # Level of DTED data to use 0, 1, 2 *   dted.level=0 *    *   # height (meters or feet) between color changes in band shading *   dted.band.height=25 *    *   # Minumum scale to display images. Larger numbers mean smaller scale,  *   # and are more zoomed out. *   dted.min.scale=20000000 *    *   # Delete the cache if the layer is removed from the map. *   dted.kill.cache=true *   *   # Need to set GeneratorLoaders for DTED rendering.  These properties get *   # forwarded on to the DTEDFrameCacheHandler. *   dted.generators=greys colors *   dted.greys.class=com.bbn.openmap.omGraphics.grid.SlopeGeneratorLoader *   dted.greys.prettyName=Slope Shading *   dted.greys.colorsClass=com.bbn.openmap.omGraphics.grid.GreyscaleSlopeColors *   dted.colors.class=com.bbn.openmap.omGraphics.grid.SlopeGeneratorLoader *   dted.colors.prettyName=Elevation Shading *   dted.colors.colorsClass=com.bbn.openmap.omGraphics.grid.ColoredShadingColors *   *   #------------------------------------- *   # End of properties for DTEDFrameCacheLayer *   #------------------------------------- *    *   * </pre> *  * @see com.bbn.openmap.layer.rpf.ChangeCase */public class DTEDFrameCacheLayer extends OMGraphicHandlerLayer implements        ActionListener, MapMouseListener, Serializable, DTEDConstants {    /** The cache handler. */    protected transient DTEDFrameCacheHandler cache = new DTEDFrameCacheHandler(null);    protected long minScale = 20000000;    /** Flag to delete the cache if the layer is removed from the map. */    protected boolean killCache = true;    public static final String DTEDLevelProperty = "level";    public static final String DTEDMinScaleProperty = "min.scale";    public static final String DTEDKillCacheProperty = "kill.cache";    private String level0Command = "setLevelTo0";    private String level1Command = "setLevelTo1";    private String level2Command = "setLevelTo2";    /** The elevation spot used in the gesture mode. */    DTEDLocation location = null;    /**     * Instances of this class are used to display elevation labels on     * the map.     */    static class DTEDLocation {        OMText text;        OMRect dot;        public DTEDLocation(int x, int y) {            text = new OMText(x + 10, y, (String) null, (java.awt.Font) null, OMText.JUSTIFY_LEFT);            dot = new OMRect(x - 1, y - 1, x + 1, y + 1);            text.setLinePaint(java.awt.Color.red);            dot.setLinePaint(java.awt.Color.red);        }        /**         * Set the text to the elevation text.         *          * @param elevation elevation of the point in meters.         */        public void setElevation(int elevation) {            // m - ft conversion            if (elevation < -100)                text.setData("No Data Here");            else {                int elevation_ft = (int) ((float) elevation * 3.280840f);                text.setData(elevation + " m / " + elevation_ft + " ft");            }        }        /** Set the x-y location of the combo in the screen */        public void setLocation(int x, int y) {            text.setX(x + 10);            text.setY(y);            dot.setLocation(x - 1, y - 1, x + 1, y + 1);        }        public void render(java.awt.Graphics g) {            text.render(g);            dot.render(g);        }        public void generate(Projection proj) {            text.generate(proj);            dot.generate(proj);        }    }    /**     * The default constructor for the Layer. All of the attributes     * are set to their default values.     */    public DTEDFrameCacheLayer() {        setProjectionChangePolicy(new com.bbn.openmap.layer.policy.ListResetPCPolicy(this));    }    /**     * The default constructor for the Layer. All of the attributes     * are set to their default values.     *      * @param dfc paths to the DTED directories that hold     *        level 0 and 1 data.     */    public DTEDFrameCacheLayer(com.bbn.openmap.dataAccess.dted.DTEDFrameCache dfc) {        this();        setFrameCache(dfc);    }    public void setFrameCache(com.bbn.openmap.dataAccess.dted.DTEDFrameCache dfc) {        if (cache != null) {            cache.setFrameCache(dfc);        }    }    public com.bbn.openmap.dataAccess.dted.DTEDFrameCache getFrameCache() {        if (cache != null) {            return cache.getFrameCache();        } else            return null;    }    protected void setDefaultValues() {        // defaults        setMaxScale(20000000);    }    /**     * Set all the DTED properties from a properties object.     */    public void setProperties(java.util.Properties properties) {        setProperties(null, properties);    }    /**     * Set all the DTED properties from a properties object.     */    public void setProperties(String prefix, java.util.Properties properties) {        super.setProperties(prefix, properties);        prefix = PropUtils.getScopedPropertyPrefix(this);        setDtedLevel(PropUtils.intFromProperties(properties, prefix                + DTEDLevelProperty, getDtedLevel()));        cache.setProperties(prefix, properties);    }    /**     * Called when the layer is no longer part of the map.     */    public void removed(java.awt.Container cont) {        OMGraphicList rasters = getList();        if (rasters != null) {            rasters.clear();        }    }    public void findAndInit(Object someObj) {        if (someObj instanceof com.bbn.openmap.dataAccess.dted.DTEDFrameCache) {            setFrameCache((com.bbn.openmap.dataAccess.dted.DTEDFrameCache) someObj);        }    }    public void findAndUndo(Object someObj) {        if (someObj == getFrameCache()) {            setFrameCache(null);        }    }    /**     * A flag to keep track of when the first time a warning was put     * up if the projection isn't EquiArc.     */

⌨️ 快捷键说明

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