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

📄 shapelayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        list.put(initPropertiesProperty, shapeFileProperty + " "                + spatialIndexProperty + " " + pointImageURLProperty + " "                + shadowXProperty + " " + shadowYProperty                + da.getInitPropertiesOrder() + " " + AddToBeanContextProperty + " "                + MinScaleProperty + " " + MaxScaleProperty);        interString = i18n.get(ShapeLayer.class,                shapeFileProperty,                I18n.TOOLTIP,                "Location of Shape file - .shp (File, URL or relative file path).");        list.put(shapeFileProperty, interString);        interString = i18n.get(ShapeLayer.class,                shapeFileProperty,                shapeFileProperty);        list.put(shapeFileProperty + LabelEditorProperty, interString);        list.put(shapeFileProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.FUPropertyEditor");        interString = i18n.get(ShapeLayer.class,                spatialIndexProperty,                I18n.TOOLTIP,                "Location of Spatial Index file - .ssx (File, URL or relative file path).");        list.put(spatialIndexProperty, interString);        interString = i18n.get(ShapeLayer.class,                spatialIndexProperty,                spatialIndexProperty);        list.put(spatialIndexProperty + LabelEditorProperty, interString);        list.put(spatialIndexProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.FUPropertyEditor");        interString = i18n.get(ShapeLayer.class,                pointImageURLProperty,                I18n.TOOLTIP,                "Image file to use for map location of point data (optional).");        list.put(pointImageURLProperty, interString);        interString = i18n.get(ShapeLayer.class,                pointImageURLProperty,                pointImageURLProperty);        list.put(pointImageURLProperty + LabelEditorProperty, interString);        list.put(pointImageURLProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.FUPropertyEditor");        interString = i18n.get(ShapeLayer.class,                shadowXProperty,                I18n.TOOLTIP,                "Horizontal pixel offset for shadow image for shapes.");        list.put(shadowXProperty, interString);        interString = i18n.get(ShapeLayer.class,                shadowXProperty,                shadowXProperty);        list.put(shadowXProperty + LabelEditorProperty, interString);        interString = i18n.get(ShapeLayer.class,                shadowYProperty,                I18n.TOOLTIP,                "Vertical pixel offset for shadow image for shapes.");        list.put(shadowYProperty, interString);        interString = i18n.get(ShapeLayer.class,                shadowYProperty,                shadowYProperty);        list.put(shadowYProperty + LabelEditorProperty, interString);        return list;    }    public void setDrawingAttributes(DrawingAttributes da) {        drawingAttributes = da;    }    public DrawingAttributes getDrawingAttributes() {        return drawingAttributes;    }    /**     * Create the OMGraphics using the shape file and SpatialIndex.     *      * @return OMGraphicList     * @deprecated use prepare() instead.     */    protected OMGraphicList computeGraphics() {        return prepare();    }    /**     * Create the OMGraphics using the shape file and SpatialIndex.     *      * @return OMGraphicList     */    public synchronized OMGraphicList prepare() {        if (spatialIndex == null) {            Debug.message("shape", "ShapeLayer: spatialIndex is null!");            return new OMGraphicList();        }        Projection projection = getProjection();        if (projection == null) {            Debug.message("basic", "ShapeLayer|" + getName()                    + ": prepare called with null projection");            return new OMGraphicList();        }        LatLonPoint ul = projection.getUpperLeft();        LatLonPoint lr = projection.getLowerRight();        float ulLat = ul.getLatitude();        float ulLon = ul.getLongitude();        float lrLat = lr.getLatitude();        float lrLon = lr.getLongitude();        OMGraphicList list = null;        // check for dateline anomaly on the screen. we check for        // ulLon >= lrLon, but we need to be careful of the check for        // equality because of floating point arguments...        if ((ulLon > lrLon)                || MoreMath.approximately_equal(ulLon, lrLon, .001f)) {            if (Debug.debugging("shape")) {                Debug.output("ShapeLayer.computeGraphics(): Dateline is on screen");            }            double ymin = (double) Math.min(ulLat, lrLat);            double ymax = (double) Math.max(ulLat, lrLat);            try {                ESRIRecord records1[] = spatialIndex.locateRecords(ulLon,                        ymin,                        180.0d,                        ymax);                ESRIRecord records2[] = spatialIndex.locateRecords(-180.0d,                        ymin,                        lrLon,                        ymax);                int nRecords1 = records1.length;                int nRecords2 = records2.length;                list = new OMGraphicList(nRecords1 + nRecords2);                for (int i = 0; i < nRecords1; i++) {                    records1[i].addOMGraphics(list, drawingAttributes);                }                for (int i = 0; i < nRecords2; i++) {                    records2[i].addOMGraphics(list, drawingAttributes);                }            } catch (InterruptedIOException iioe) {                // This means that the thread has been interrupted,                // probably due to a projection change. Not a big                // deal, just return, don't do any more work, and let                // the next thread solve all problems.                list = null;            } catch (IOException ex) {                ex.printStackTrace();            } catch (FormatException fe) {                fe.printStackTrace();            }        } else {            double xmin = (double) Math.min(ulLon, lrLon);            double xmax = (double) Math.max(ulLon, lrLon);            double ymin = (double) Math.min(ulLat, lrLat);            double ymax = (double) Math.max(ulLat, lrLat);            try {                ESRIRecord records[] = spatialIndex.locateRecords(xmin,                        ymin,                        xmax,                        ymax);                int nRecords = records.length;                list = new OMGraphicList(nRecords);                for (int i = 0; i < nRecords; i++) {                    records[i].addOMGraphics(list, drawingAttributes);                }            } catch (InterruptedIOException iioe) {                // This means that the thread has been interrupted,                // probably due to a projection change. Not a big                // deal, just return, don't do any more work, and let                // the next thread solve all problems.                list = null;            } catch (java.io.IOException ex) {                ex.printStackTrace();            } catch (FormatException fe) {                fe.printStackTrace();            }        }        if (list != null) {            list.generate(projection, true);// all new graphics        }        return list;    }    /**     * Renders the layer on the map.     *      * @param g a graphics context     */    public void paint(Graphics g) {        if (shadowX == 0 && shadowY == 0) {            // Enabling buffer...            super.paint(g);        } else {            // grab local for thread safety            OMGraphicList omg = getList();            if (omg != null) {                if (Debug.debugging("shape"))                    Debug.output("ShapeLayer.paint(): " + omg.size() + " omg"                            + " shadow=" + shadowX + "," + shadowY);                if (shadowX != 0 || shadowY != 0) {                    Graphics shadowG = g.create();                    shadowG.translate(shadowX, shadowY);                    omg.render(shadowG);                } else {                    omg.render(g);                }                if (Debug.debugging("shape")) {                    Debug.output("ShapeLayer.paint(): done");                }            }        }    }    protected transient JPanel box;    public Component getGUI() {        if (box == null) {            box = new JPanel();            box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));            box.setAlignmentX(Component.LEFT_ALIGNMENT);            JPanel stuff = new JPanel();            // stuff.setLayout(new BoxLayout(stuff,            // BoxLayout.X_AXIS));            // stuff.setAlignmentX(Component.LEFT_ALIGNMENT);            DrawingAttributes da = getDrawingAttributes();            if (da != null) {                stuff.add(da.getGUI());            }            box.add(stuff);            JPanel pal2 = new JPanel();            JButton redraw = new JButton(i18n.get(ShapeLayer.class,                    "redrawLayerButton",                    "Redraw Layer"));            redraw.setActionCommand(RedrawCmd);            redraw.addActionListener(this);            pal2.add(redraw);            box.add(pal2);        }        return box;    }    public void actionPerformed(ActionEvent e) {        super.actionPerformed(e);        String cmd = e.getActionCommand();        if (cmd == RedrawCmd) {            if (isVisible()) {                doPrepare();            }        }    }    /**     * DataBoundsInformer interface.     */    public DataBounds getDataBounds() {        DataBounds box = null;        if (spatialIndex != null) {            ESRIBoundingBox bounds = spatialIndex.getBounds();            if (bounds != null) {                box = new DataBounds(bounds.min.x, bounds.min.y, bounds.max.x, bounds.max.y);            }        }        return box;    }}

⌨️ 快捷键说明

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