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

📄 dtedframecachelayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    protected boolean firstProjectionWarningSent = false;    /**     * Prepares the graphics for the layer. This is where the     * getRectangle() method call is made on the dted.     * <p>     * Occasionally it is necessary to abort a prepare call. When this     * happens, the map will set the cancel bit in the LayerThread,     * (the thread that is running the prepare). If this Layer needs     * to do any cleanups during the abort, it should do so, but     * return out of the prepare asap.     *       */    public synchronized OMGraphicList prepare() {        if (isCancelled()) {            Debug.message("dted", getName()                    + "|DTEDFrameCacheLayer.prepare(): aborted.");            return null;        }        if (cache == null) {            Debug.message("dted",                    getName()                            + "|DTEDFrameCacheLayer can't add anything to map because the DTEDFrameCache has not been set.");        }        Projection projection = getProjection();        if (projection == null) {            Debug.output("DTED Layer needs to be added to the MapBean before it can draw images!");            return new OMGraphicList();        }        // Check to make sure the projection is EqualArc        if (!(projection instanceof EqualArc)) {            if (!firstProjectionWarningSent) {                fireRequestInfoLine("  DTED requires an Equal Arc projection (CADRG/LLXY) to view images.");                Debug.output("DTEDFrameCacheLayer: DTED requires an Equal Arc projection (CADRG/LLXY) to view images.");                firstProjectionWarningSent = true;            }            return new OMGraphicList();        }        Debug.message("basic", getName()                + "|DTEDFrameCacheLayer.prepare(): doing it");        // Setting the OMGraphicsList for this layer. Remember, the        // OMGraphicList is made up of OMGraphics, which are generated        // (projected) when the graphics are added to the list. So,        // after this call, the list is ready for painting.        // call getRectangle();        if (Debug.debugging("dted")) {            Debug.output(getName() + "|DTEDFrameCacheLayer.prepare(): "                    + "calling getRectangle " + " with projection: "                    + projection + " ul = " + projection.getUpperLeft()                    + " lr = " + projection.getLowerRight());        }        OMGraphicList omGraphicList;        if (projection.getScale() < maxScale) {            omGraphicList = cache.getRectangle((EqualArc) projection);        } else {            fireRequestInfoLine("  The scale is too small for DTED viewing.");            Debug.error("DTEDFrameCacheLayer: scale (1:" + projection.getScale()                    + ") is smaller than minimum (1:" + maxScale + ") allowed.");            omGraphicList = new OMGraphicList();        }        /////////////////////        // safe quit        int size = 0;        if (omGraphicList != null) {            size = omGraphicList.size();            Debug.message("basic", getName()                    + "|DTEDFrameCacheLayer.prepare(): finished with " + size                    + " graphics");            // Don't forget to project them. Since they are only            // being recalled if the projection hase changed, then we            // need to force a reprojection of all of them because the            // screen position has changed.            omGraphicList.project(projection, true);        } else {            Debug.message("basic",                    getName()                            + "|DTEDFrameCacheLayer.prepare(): finished with null graphics list");        }        return omGraphicList;    }    /**     * Paints the layer.     *      * @param g the Graphics context for painting     */    public void paint(java.awt.Graphics g) {        super.paint(g);        if (location != null)            location.render(g);        location = null;    }    /**     * Get the value set for which DTED level is being used, 0-2.     */    public int getDtedLevel() {        if (cache != null) {            return cache.getDtedLevel();        } else            return LEVEL_0;    }    public void setDtedLevel(int level) {        if (cache != null) {            cache.setDtedLevel(level);        }    }    /**     * Get whether the cache will be killed when the layer is removed     * from the map.     */    public boolean getKillCache() {        return killCache;    }    public void setKillCache(boolean kc) {        killCache = kc;    }    //----------------------------------------------------------------------    // GUI    //----------------------------------------------------------------------    /** The user interface palette for the DTED layer. */    protected Box palette = null;    /** Creates the interface palette. */    public Component getGUI() {        if (palette == null) {            if (Debug.debugging("dted"))                Debug.output("DTEDFrameCacheLayer: creating DTED Palette.");            palette = Box.createVerticalBox();            Box subbox1 = Box.createHorizontalBox();            Box subbox3 = Box.createHorizontalBox();            // The DTED Level selector            JPanel levelPanel = PaletteHelper.createPaletteJPanel("DTED Level");            ButtonGroup levels = new ButtonGroup();            ActionListener al = new ActionListener() {                public void actionPerformed(ActionEvent e) {                    if (cache != null) {                        String ac = e.getActionCommand();                        int newLevel;                        if (ac.equalsIgnoreCase(level2Command))                            newLevel = LEVEL_2;                        else if (ac.equalsIgnoreCase(level1Command))                            newLevel = LEVEL_1;                        else                            newLevel = LEVEL_0;                        setDtedLevel(newLevel);                    }                }            };            JRadioButton level0 = new JRadioButton("Level 0");            level0.addActionListener(al);            level0.setActionCommand(level0Command);            JRadioButton level1 = new JRadioButton("Level 1");            level1.addActionListener(al);            level1.setActionCommand(level1Command);            JRadioButton level2 = new JRadioButton("Level 2");            level2.addActionListener(al);            level2.setActionCommand(level2Command);            levels.add(level0);            levels.add(level1);            levels.add(level2);            switch (getDtedLevel()) {            case 2:                level2.setSelected(true);                break;            case 1:                level1.setSelected(true);                break;            case 0:            default:                level0.setSelected(true);            }            levelPanel.add(level0);            levelPanel.add(level1);            levelPanel.add(level2);            // The DTED view selector from DTEDFrameCacheHandler            JPanel viewPanel = PaletteHelper.createPaletteJPanel("View Type");            viewPanel.add(cache.getGUI());            JButton redraw = new JButton("Redraw DTED Layer");            redraw.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent ae) {                    doPrepare();                }            });            subbox1.add(levelPanel);            subbox1.add(viewPanel);            palette.add(subbox1);            subbox3.add(redraw);            palette.add(subbox3);        }        return palette;    }    //----------------------------------------------------------------------    // MapMouseListener interface implementation. This will be    // replaced with a subclass of StandardMouseModeInterpreter that    // only receives the map mouse click.    //----------------------------------------------------------------------    public synchronized MapMouseListener getMapMouseListener() {        return this;    }    public String[] getMouseModeServiceList() {        String[] services = { SelectMouseMode.modeID };        return services;    }    public boolean mousePressed(MouseEvent e) {        return false;    }    public boolean mouseReleased(MouseEvent e) {        Projection projection = getProjection();        LatLonPoint ll = projection.inverse(e.getX(), e.getY());        location = new DTEDLocation(e.getX(), e.getY());        location.setElevation(cache.getElevation(ll.getLatitude(),                ll.getLongitude()));        location.generate(projection);        repaint();        return true;    }    public boolean mouseClicked(MouseEvent e) {        return false;    }    public void mouseEntered(MouseEvent e) {}    public void mouseExited(MouseEvent e) {}    public boolean mouseDragged(MouseEvent e) {        return false;    }    public boolean mouseMoved(MouseEvent e) {        return false;    }    public void mouseMoved() {}}

⌨️ 快捷键说明

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