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

📄 vpflayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * If the warehouse gets set as a result of this method being     * called, the properties will beed to be reset on it.     *      * @param sbf Search by features.     */    public void checkWarehouse(boolean sbf) {        if (warehouse == null) {            if (Debug.debugging("vpf")) {                Debug.output("VPFLayer.getWarehouse: creating warehouse");            }            if (lst != null && lst.getDatabaseName() != null                    && lst.getDatabaseName().equals("DCW")) {                warehouse = new VPFLayerDCWWarehouse();            } else if (sbf) {                warehouse = new VPFFeatureGraphicWarehouse();            } else {                warehouse = new VPFLayerGraphicWarehouse();            }        } else if ((sbf && warehouse instanceof VPFLayerGraphicWarehouse)                || (!sbf && warehouse instanceof VPFFeatureGraphicWarehouse)) {            warehouse = null;            checkWarehouse(sbf);        }    }    /**     * Use doPrepare() method instead. This was the old method call to     * do the same thing doPrepare is now doing, from the     * OMGraphicHandler superclass. doPrepare() launches a thread to     * do the work.     *      * @deprecated use doPrepare() instead of computeLayer();     */    public void computeLayer() {        doPrepare();    }    /**     * Use prepare instead. This was the old method call to do the     * same thing prepare() is now doing.     *      * @deprecated use prepare() instead of getRectangle();     */    public OMGraphicList getRectangle() {        return prepare();    }    /**     * Create the OMGraphicList to use on the map. OMGraphicHandler     * methods call this.     */    public synchronized OMGraphicList prepare() {        if (lst == null) {            try {                initLST();            } catch (IllegalArgumentException iae) {                Debug.error("VPFLayer.prepare: Illegal Argument Exception.\n\nPerhaps a file not found.  Check to make sure that the paths to the VPF data directories are the parents of \"lat\" or \"lat.\" files. \n\n"                        + iae);                return null;            }            if (lst == null) {                if (Debug.debugging("vpf")) {                    Debug.output("VPFLayer| " + getName()                            + " prepare(), Library Selection Table not set.");                }                return null;            }        }        if (warehouse == null) {            StringBuffer dpb = new StringBuffer();            if (dataPaths != null) {                for (int num = 0; num < dataPaths.length; num++) {                    if (num > 0) {                        dpb.append(":");                    }                    dpb.append(dataPaths[num]);                }            }            Debug.error("VPFLayer.getRectangle:  Data path probably wasn't set correctly ("                    + dpb.toString() + ").  The warehouse not initialized.");            return null;        }        Projection p = getProjection();        if (p == null) {            Debug.error("VPFLayer.getRectangle() called without a projection set in the layer. Make sure a projection is set in the layer before calling getRectangle.");            return new OMGraphicList();        }        LatLonPoint upperleft = p.getUpperLeft();        LatLonPoint lowerright = p.getLowerRight();        if (Debug.debugging("vpfdetail")) {            Debug.output("VPFLayer.getRectangle: " + coverageType /*                                                                   * + " " +                                                                   * dynamicArgs                                                                   */);        }        warehouse.clear();        //      int edgecount[] = new int[] { 0 , 0 };        //      int textcount[] = new int[] { 0 , 0 };        //      int areacount[] = new int[] { 0 , 0 };        // Check both dynamic args and palette values when        // deciding what to draw.        if (Debug.debugging("vpf")) {            Debug.output("VPFLayer.getRectangle(): "                    + "calling draw with boundaries: " + upperleft + " "                    + lowerright);        }        long start = System.currentTimeMillis();        StringTokenizer t = new StringTokenizer(coverageType);        while (t.hasMoreTokens()) {            String currentCoverage = t.nextToken();            if (searchByFeatures) {                lst.drawFeatures((int) p.getScale(),                        p.getWidth(),                        p.getHeight(),                        currentCoverage,                        (VPFFeatureWarehouse) warehouse,                        upperleft,                        lowerright);            } else {                lst.drawTile((int) p.getScale(),                        p.getWidth(),                        p.getHeight(),                        currentCoverage,                        warehouse,                        upperleft,                        lowerright);            }        }        long stop = System.currentTimeMillis();        //      if (Debug.debugging("vpfdetail")) {        //          Debug.output("Returned " + edgecount[0] +        //                       " polys with " + edgecount[1] + " points\n" +        //                       "Returned " + textcount[0] +        //                       " texts with " + textcount[1] + " points\n" +        //                       "Returned " + areacount[0] +        //                       " areas with " + areacount[1] + " points");        //      }        if (Debug.debugging("vpf")) {            Debug.output("VPFLayer.getRectangle(): read time: "                    + ((stop - start) / 1000d) + " seconds");        }        OMGraphicList omglist = warehouse.getGraphics();        // Don't forget to project.        start = System.currentTimeMillis();        omglist.project(p);        stop = System.currentTimeMillis();        if (Debug.debugging("vpf")) {            Debug.output("VPFLayer.getRectangle(): proj time: "                    + ((stop - start) / 1000d) + " seconds");        }        return omglist;    }    private transient JPanel box;    /**     * Gets the palette associated with the layer.     *      * @return Component or null     */    public Component getGUI() {        if (lst == null) {            try {                initLST();            } catch (IllegalArgumentException iie) {                Debug.error(iie.getMessage());            }        }        if (warehouse == null) {            return (new javax.swing.JLabel("VPF Layer data not loaded properly."));        }        if (box == null) {            box = new JPanel();            box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));            box.setAlignmentX(Component.LEFT_ALIGNMENT);            JPanel stuff = new JPanel();            JPanel pal = null;            ActionListener al = new ActionListener() {                public void actionPerformed(ActionEvent e) {                    int index = Integer.parseInt(e.getActionCommand(), 10);                    switch (index) {                    case 0:                        warehouse.setEdgeFeatures(!warehouse.drawEdgeFeatures());                        break;                    case 1:                        warehouse.setTextFeatures(!warehouse.drawTextFeatures());                        break;                    case 2:                        warehouse.setAreaFeatures(!warehouse.drawAreaFeatures());                        break;                    case 3:                        warehouse.setEPointFeatures(!warehouse.drawEPointFeatures());                        break;                    case 4:                        warehouse.setCPointFeatures(!warehouse.drawCPointFeatures());                        break;                    default:                        throw new RuntimeException("argh!");                    }                }            };            pal = PaletteHelper.createCheckbox("Show:", new String[] {                    VPFUtil.Edges, VPFUtil.Text, VPFUtil.Area, VPFUtil.EPoint,                    VPFUtil.CPoint }, new boolean[] {                    warehouse.drawEdgeFeatures(), warehouse.drawTextFeatures(),                    warehouse.drawAreaFeatures(),                    warehouse.drawEPointFeatures(),                    warehouse.drawCPointFeatures() }, al);            stuff.add(pal);            if (lst != null) {                Component warehouseGUI = warehouse.getGUI(lst);                if (warehouseGUI != null) {                    stuff.add(warehouseGUI);                }            }            box.add(stuff);            JPanel pal2 = new JPanel();            JButton config = new JButton("Configure Layer");            config.setActionCommand(ConfigCmd);            config.addActionListener(this);            pal2.add(config);            JButton redraw = new JButton("Redraw Layer");            redraw.setActionCommand(RedrawCmd);            redraw.addActionListener(this);            pal2.add(redraw);            box.add(pal2);        }        return box;    }    public final static String ConfigCmd = "CONFIGURE";    protected WindowSupport configWindowSupport = null;    public void actionPerformed(ActionEvent e) {        String cmd = e.getActionCommand();        if (cmd == RedrawCmd) {            setList(null);            if (isVisible()) {                doPrepare();            }        } else if (cmd == ConfigCmd) {            if (configWindowSupport == null) {                configWindowSupport = new WindowSupport(new VPFConfig(this), "Configure "                        + getName() + " Features");            } else {                configWindowSupport.setTitle(getName());            }            configWindowSupport.displayInWindow();        } else {            super.actionPerformed(e);        }    }    protected void setConfigSettings(String prefix, Properties props) {        lst = null;        setProperties(prefix, props);        if (isVisible()) {            doPrepare();        }        if (configWindowSupport != null) {            configWindowSupport.setTitle(getName());        }    }    public String getToolTipTextFor(OMGraphic omg) {        return (String) omg.getAttribute(OMGraphicConstants.TOOLTIP);    }    public String getInfoText(OMGraphic omg) {        return (String) omg.getAttribute(OMGraphicConstants.INFOLINE);    }}

⌨️ 快捷键说明

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