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

📄 dtedlayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// **********************************************************************// // <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/DTEDLayer.java,v $// $RCSfile: DTEDLayer.java,v $// $Revision: 1.6.2.6 $// $Date: 2005/09/13 14:34:01 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.dted;/*  Java Core  */import java.awt.event.*;import java.io.*;import javax.swing.Box;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JSlider;import javax.swing.event.ChangeListener;import javax.swing.event.ChangeEvent;/*  OpenMap  */import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.Layer;import com.bbn.openmap.event.InfoDisplayEvent;import com.bbn.openmap.event.LayerStatusEvent;import com.bbn.openmap.event.MapMouseListener;import com.bbn.openmap.event.ProjectionEvent;import com.bbn.openmap.event.SelectMouseMode;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;import com.bbn.openmap.util.SwingWorker;/** * The DTEDLayer fills the screen with DTED data. To view the DTED * iamges, the projection has to be set in a Equal ARC projection, * which OpenMap calls the CADRG projection or the LLXY projection. In * Gesture mode, clicking on the map will cause the DTEDLayer 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 DTEDLayer uses the DTEDCacheManager to get the images it needs. * The DTEDLayer receives projection change events, and then asks the * cache manager for the images it needs based on the new projection. *  * The DTEDLayer 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 DTEDLayer 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.util.wanderer.ChangeCase * class to make modifications if necessary. * <P> *  * <pre> *  *   *    *     *     #------------------------------ *     # Properties for DTEDLayer *     #------------------------------ *     # This property should reflect the paths to the dted level 0, 1 and newer 2 (file extension .dt2) data directories, separated by a semicolon. *     dted.paths=/usr/local/matt/data/dted;/cdrom/cdrom0/dted *      *     # This property should reflect the paths to old dted level 2 data directories (file extension .dt1) *     dted.level2.paths=/usr/local/matt/data/dted_level2 *      *     # Number between 0-255: 0 is transparent, 255 is opaque *     dted.opaque=255 *      *     # Number of colors to use on the maps - 16, 32, 216 *     dted.number.colors=216 *      *     # Level of DTED data to use 0, 1, 2 *     dted.level=0 *      *     # Type of display for the data *     # 0 = no shading at all *     # 1 = greyscale slope shading *     # 2 = band shading, in meters *     # 3 = band shading, in feet *     # 4 = subframe testing *     # 5 = elevation, colored *     dted.view.type=5 *      *     # Contrast setting, 1-5 *     dted.contrast=3 *      *     # 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 *     # Number of frames to hold in the cache. The default is  *     # DTEDFrameCache.FRAME_CACHE_SIZE, which is 15 to help smaller systems.  Better *     # caching happens, the larger the number. *     dted.cacheSize=40 *     #------------------------------------- *     # End of properties for DTEDLayer *     #------------------------------------- *      *     *    *   * </pre> *  * @see com.bbn.openmap.layer.rpf.ChangeCase */public class DTEDLayer extends Layer implements ActionListener,        MapMouseListener, Serializable {    /** The cache manager. */    protected transient DTEDCacheManager cache = null;    /** The graphics list used for display. */    protected OMGraphicList omGraphics;    /**     * Set when the projection has changed while a swing worker is     * gathering graphics, and we want him to stop early.     */    protected boolean cancelled = false;    /**     * The paths to the DTED Level 0, 1 directories, telling where the     * data is. Newer level 2 data, with the .dt2 file extensions,     * should be set in this path property.     */    protected String[] paths;    /**     * Because older DTED Level 2 data has the same name extension as     * Level 1 data, a separate array of pathnames is available for     * that old data. Level 0 and 1 data should be lumped together, or     * listed in the same array of paths. Newer level 2 data with the     * .dt2 extension should be listed in the regular dted path     * property with the level 0 and 1 data.     */    protected String[] paths2;    /**     * The level of DTED to use. Level 0 is 1km post spacing, Level 1     * is 100m post spacing. Level 2 is 30m post spacing     */    protected int dtedLevel = DTEDFrameSubframe.LEVEL_0;    /**     * The display type for the dted images. Slope shading is     * greyscale terrain modeling with highlights and shading, with     * the 'sun' being in the NorthWest. Colored Elevation shading is     * the same thing, except colors are added to indicate the     * elevation. Band shading colors the pixels according to a range     * of elevations.     */    protected int viewType = DTEDFrameSubframe.NOSHADING;    /** The elevation range to use for each color in band shading. */    protected int bandHeight = 25;    /** A contrast adjustment, for slope shading (1-5). */    protected int slopeAdjust = DTEDFrameSubframe.DEFAULT_SLOPE_ADJUST;    protected int numColors = DTEDFrameColorTable.DTED_COLORS;    protected int opaqueness = DTEDFrameColorTable.DEFAULT_OPAQUENESS;    /** Flag to delete the cache if the layer is removed from the map. */    protected boolean killCache = true;    /** The number of frames held by the cache objects. */    protected int cacheSize = DTEDCacheHandler.FRAME_CACHE_SIZE;    public static final String DTEDPathsProperty = "paths";    public static final String DTED2PathsProperty = "level2.paths";    public static final String OpaquenessProperty = "opaque";    public static final String NumColorsProperty = "number.colors";    public static final String DTEDLevelProperty = "level";    public static final String DTEDViewTypeProperty = "view.type";    public static final String DTEDSlopeAdjustProperty = "contrast";    public static final String DTEDBandHeightProperty = "band.height";    public static final String DTEDMinScaleProperty = "min.scale";    public static final String DTEDKillCacheProperty = "kill.cache";    public static final String DTEDFrameCacheSizeProperty = "cacheSize";    private String level0Command = "setLevelTo0";    private String level1Command = "setLevelTo1";    private String level2Command = "setLevelTo2";    /** The thread worker used to create the DTED images. */    DTEDWorker currentWorker;    /** 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);        }    }    class DTEDWorker extends SwingWorker {        /** Constructor used to create a worker thread. */        public DTEDWorker() {            super();        }        /**         * Compute the value to be returned by the <code>get</code>         * method.         */        public Object construct() {            Debug.message("dted", getName() + "|DTEDWorker.construct()");            fireStatusUpdate(LayerStatusEvent.START_WORKING);            try {                return prepare();            } catch (OutOfMemoryError e) {                String msg = getName() + "|DTEDLayer.DTEDWorker.construct(): "                        + e;                Debug.error(msg);                fireRequestMessage(new InfoDisplayEvent(this, msg));                fireStatusUpdate(LayerStatusEvent.FINISH_WORKING);                cache = null;                return null;            }        }        /**         * Called on the event dispatching thread (not on the worker         * thread) after the <code>construct</code> method has         * returned.         */        public void finished() {            workerComplete(this);            fireStatusUpdate(LayerStatusEvent.FINISH_WORKING);        }    }    /**     * The default constructor for the Layer. All of the attributes     * are set to their default values.     */    public DTEDLayer() {        this(null, null);    }    /**     * The default constructor for the Layer. All of the attributes     * are set to their default values.     *      * @param pathsToDTEDDirs paths to the DTED directories that hold     *        level 0 and 1 data.     */    public DTEDLayer(String[] pathsToDTEDDirs) {        this(pathsToDTEDDirs, null);    }    /**     * The default constructor for the Layer. All of the attributes     * are set to their default values.     *      * @param pathsToDTEDDirs paths to the DTED directories that hold     *        level 0 and 1 data.     * @param pathsToDTED2Dirs paths to the DTED directories that hold     *        level 2 data.     */    public DTEDLayer(String[] pathsToDTEDDirs, String[] pathsToDTED2Dirs) {        setName("DTED");        setDefaultValues();        paths = pathsToDTEDDirs;        paths2 = pathsToDTED2Dirs;    }    /**     * Set the paths to the DTED directories. The DTED2 directories     * are for DTED Level 2 data files that end in .dt1. If NIMA     * changes the level 2 appendix, then the regular path will be     * changed back to look there for .dt2 files.     */    public void setPaths(String[] pathsToDTEDDirs, String[] pathsToDTED2Dirs) {        paths = pathsToDTEDDirs;        paths2 = pathsToDTED2Dirs;        if (cache != null)            cache.setDtedDirPaths(pathsToDTEDDirs, pathsToDTED2Dirs);    }    /**     * Get the paths to the DTED directories.     */    public String[] getPaths() {        return paths;    }    /**     * Get the paths to the Level 2 DTED directories. This is a     * workaround for dted level 2 data that ends in .dt1. If NIMA     * changes the level 2 data to have the .dt2 appendix, then the     * level 2 data will be able to be listed in the regular dted     * path.     */

⌨️ 快捷键说明

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