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

📄 dtedlayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    public String[] getLevel2Paths() {        return paths2;    }    protected void setDefaultValues() {        // defaults        paths = null;        paths2 = null;        setOpaqueness(DTEDFrameColorTable.DEFAULT_OPAQUENESS);        setDtedLevel(DTEDFrameSubframe.LEVEL_0);        setBandHeight(DTEDFrameSubframe.DEFAULT_BANDHEIGHT);        setSlopeAdjust(DTEDFrameSubframe.DEFAULT_SLOPE_ADJUST);        setViewType(DTEDFrameSubframe.COLOREDSHADING);        setMaxScale(20000000);    }    /**     * Sets the current graphics list to the given list.     *      * @param aList a list of OMGraphics     */    public synchronized void setGraphicList(OMGraphicList aList) {        omGraphics = aList;    }    /**     * Retrieves the current graphics list.     */    public synchronized OMGraphicList getGraphicList() {        return omGraphics;    }    /**     * 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);        paths = PropUtils.initPathsFromProperties(properties, prefix                + DTEDPathsProperty, paths);        paths2 = PropUtils.initPathsFromProperties(properties, prefix                + DTED2PathsProperty, paths2);        setOpaqueness(PropUtils.intFromProperties(properties, prefix                + OpaquenessProperty, getOpaqueness()));        setNumColors(PropUtils.intFromProperties(properties, prefix                + NumColorsProperty, getNumColors()));        setDtedLevel(PropUtils.intFromProperties(properties, prefix                + DTEDLevelProperty, getDtedLevel()));        setViewType(PropUtils.intFromProperties(properties, prefix                + DTEDViewTypeProperty, getViewType()));        setSlopeAdjust(PropUtils.intFromProperties(properties, prefix                + DTEDSlopeAdjustProperty, getSlopeAdjust()));        setBandHeight(PropUtils.intFromProperties(properties, prefix                + DTEDBandHeightProperty, getBandHeight()));        // The Layer maxScale is talking the place of the DTEDLayer minScale property.        setMaxScale(PropUtils.floatFromProperties(properties, prefix                + DTEDMinScaleProperty, getMaxScale()));        setCacheSize((int) PropUtils.intFromProperties(properties, prefix                + DTEDFrameCacheSizeProperty, getCacheSize()));        setKillCache(PropUtils.booleanFromProperties(properties, prefix                + DTEDKillCacheProperty, getKillCache()));    }    /**     * Called when the layer is no longer part of the map. In this     * case, we should disconnect from the server if we have a link.     */    public void removed(java.awt.Container cont) {        if (killCache) {            Debug.output("DTEDLayer: emptying cache!");            cache = null;        }    }    /**     * Used to set the cancelled flag in the layer. The swing worker     * checks this once in a while to see if the projection has     * changed since it started working. If this is set to true, the     * swing worker quits when it is safe.     */    public synchronized void setCancelled(boolean set) {        cancelled = set;    }    /** Check to see if the cancelled flag has been set. */    public synchronized boolean isCancelled() {        return cancelled;    }    /**     * Implementing the ProjectionPainter interface.     */    public synchronized void renderDataForProjection(Projection proj,                                                     java.awt.Graphics g) {        if (proj == null) {            Debug.error("DTEDLayer.renderDataForProjection: null projection!");            return;        } else if (!proj.equals(getProjection())) {            setProjection(proj.makeClone());            setGraphicList(prepare());        }        paint(g);    }    /**     * From the ProjectionListener interface.     */    public void projectionChanged(ProjectionEvent e) {        Debug.message("basic", getName() + "|DTEDLayer.projectionChanged()");        if (setProjection(e) == null) {            // Projection didn't change            repaint();            return;        }        setGraphicList(null);        doPrepare();    }    /**     * The DTEDWorker calls this method on the layer when it is done     * working. If the calling worker is not the same as the "current"     * worker, then a new worker is created.     *      * @param worker the worker that has the graphics.     */    protected synchronized void workerComplete(DTEDWorker worker) {        if (!isCancelled()) {            currentWorker = null;            setGraphicList((OMGraphicList) worker.get());            repaint();        } else {            setCancelled(false);            currentWorker = new DTEDWorker();            currentWorker.execute();        }    }    /**     * Method to trigger the layer to recreate the graphics and paint     * them.     */    public void doPrepare() {        // If there isn't a worker thread working on this already,        // create a thread that will do the real work. If there is        // a thread working on this, then set the cancelled flag        // in the layer.        if (currentWorker == null) {            currentWorker = new DTEDWorker();            currentWorker.execute();        } else            setCancelled(true);        if (currentWorker == null) {            fireStatusUpdate(LayerStatusEvent.START_WORKING);            currentWorker = new DTEDWorker();            currentWorker.execute();        } else            setCancelled(true);    }    /**     * 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() + "|DTEDLayer.prepare(): aborted.");            return null;        }        Projection projection = getProjection();        if (projection == null) {            Debug.error("DTED Layer needs to be added to the MapBean before it can draw images!");            return new OMGraphicList();        }        if (cache == null) {            Debug.output("DTEDLayer: Creating cache! (This is a one-time operation!)");            cache = new DTEDCacheManager(paths, paths2, numColors, opaqueness);            cache.setCacheSize(cacheSize);            DTEDFrameSubframeInfo dfsi = new DTEDFrameSubframeInfo(viewType, bandHeight, dtedLevel, slopeAdjust);            cache.setSubframeInfo(dfsi);        }        // Check to make sure the projection is EqualArc        if (!(projection instanceof EqualArc)) {            if (viewType != DTEDFrameSubframe.NOSHADING) {                fireRequestInfoLine("  DTED requires an Equal Arc projection (CADRG/LLXY) to view images.");                Debug.error("DTEDLayer: DTED requires an Equal Arc projection (CADRG/LLXY) to view images.");            }            return new OMGraphicList();        }        Debug.message("basic", getName() + "|DTEDLayer.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() + "|DTEDLayer.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("DTEDLayer: 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()                    + "|DTEDLayer.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()                    + "|DTEDLayer.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) {        Debug.message("dted", getName() + "|DTEDLayer.paint()");        OMGraphicList tmpGraphics = getGraphicList();        if (tmpGraphics != null) {            tmpGraphics.render(g);        }        if (location != null)            location.render(g);        location = null;    }    /**     * Get the view type set for creating images.     * <P>     *      * <pre>     *      *       *        *         *     0: DTEDFrameSubframe.NOSHADING     *     1: DTEDFrameSubframe.SLOPESHADING     *     2: DTEDFrameSubframe.COLOREDSHADING     *     3: DTEDFrameSubframe.METERSHADING     *     4: DTEDFrameSubframe.FEETSHADING     *          *         *        *       * </pre>     */    public int getViewType() {        return viewType;    }    public void setViewType(int vt) {        switch (vt) {        case DTEDFrameSubframe.NOSHADING:        case DTEDFrameSubframe.SLOPESHADING:        case DTEDFrameSubframe.COLOREDSHADING:        case DTEDFrameSubframe.METERSHADING:        case DTEDFrameSubframe.FEETSHADING:            viewType = vt;            if (cache != null) {                DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();                dfsi.viewType = viewType;            }            break;        default:        // unchanged        }    }    /**     * Get the value for the interval between band colors for meter     * and feet shading view types.     */    public int getBandHeight() {        return bandHeight;    }    public void setBandHeight(int bh) {        bandHeight = bh;        if (cache != null) {            DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();            dfsi.bandHeight = bandHeight;        }    }    /**     * Get the value for contrast adjustments, 1-5.     */    public int getSlopeAdjust() {        return slopeAdjust;    }    public void setSlopeAdjust(int sa) {        if (sa > 0 && sa <= 5) {            slopeAdjust = sa;            if (cache != null) {                DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();                dfsi.slopeAdjust = slopeAdjust;            }        } else {            Debug.output("DTEDLayer (" + getName()

⌨️ 快捷键说明

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