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

📄 esrishapeexport.java

📁 OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你就能够快速构建用于访问legacy数据库的应用程序与applets。OpenMap提供了允许用户查看和操作地理空间信息的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * OMGraphics to EsriGraphics), which forces you to group shapes into like     * types (points, polylines and polygons).     */    public void export() {        OMGraphicList list = getGraphicList();        if (list == null) {            Debug.error("EsriShapeExport: no graphic list to export!");            return;        }        export(list, null, true);    }    /**     * A counter for graphics that are not RENDERTYPE_LATLON.     */    int badGraphics;    /**     * This method is intended to allow embedded OMGraphicLists to be handled.     * The record should be set if the list is an embedded list, reusing a     * record from the top level interation. Set the record to null at the top     * level iteration to cause the method to fetch the record from the     * masterDBF, if it exists.     *      * @param list the OMGraphicList to write     * @param record the record for the current list, used if the list is     *        actually a multipart geometry for the overall list. May be null     *        anyway, though.     * @deprecated use export(OMGraphicList, ArrayList, boolean) instead.     * @see #export(OMGraphicList list, ArrayList record, boolean writeFiles)     */    protected void export(OMGraphicList list, ArrayList record) {        export(list, record, true);    }    /**     * This method is intended to allow embedded OMGraphicLists to be handled.     * The record should be set if the list is an embedded list, reusing a     * record from the top level interation. Set the record to null at the top     * level iteration to cause the method to fetch the record from the     * masterDBF, if it exists. If the list is an EsriGraphicList, then the     * export for EsriGraphicLists will be called. The DbfTableModel for the     * list should be stored as an attribute in the EsriGraphicList under the     * DBF_ATTRIBUTE key.     *      * @param list the OMGraphicList to write.     * @param masterRecord the record for the current list, used if the list is     *        actually a multipart geometry for the overall list. May be null     *        anyway, though.     * @param writeFiles Flag to note when this method is being called     *        iteratively, which is when record is not null. If it is iterative,     *        then the writing of the files should not be performed on this     *        round of the method call.     */    protected void export(OMGraphicList list, ArrayList masterRecord,                          boolean writeFiles) {        badGraphics = 0;        if (list == null) {            return;        } else if (list instanceof EsriGraphicList) {            export((EsriGraphicList) list);            return;        }        int dbfIndex = 0;        // parse the graphic list and fill the individual lists with        // the appropriate shape types        Iterator it = list.iterator();        while (it.hasNext()) {            OMGraphic dtlGraphic = (OMGraphic) it.next();            // Reset the record to the master flag record, which will            // cause a new record to be read for the top level list            // contents, but duplicate the current masterRecord for            // iterative contents.            ArrayList record = masterRecord;            if (record == null) {                record = getMasterDBFRecord(dbfIndex++);            }            // If we have an OMGraphicList, interate through that one            // as well. We're not handling multi-part geometries yet.            if (dtlGraphic instanceof OMGraphicList) {                if (DEBUG)                    Debug.output("ESE: handling OMGraphicList");                export((OMGraphicList) dtlGraphic, record, false);                continue;            }            // check to be sure the graphic is rendered in LAT/LON            if (dtlGraphic.getRenderType() != RENDERTYPE_LATLON) {                badGraphics++;                continue;            }            if (dtlGraphic instanceof OMPoly) {                OMPoly omPoly = (OMPoly) dtlGraphic;                // verify that this instance of OMPoly is a polygon                if (isPolygon(omPoly)) {                    if (DEBUG)                        Debug.output("ESE: handling OMPoly polygon");                    addPolygon(dtlGraphic, record);                }                // if it is not it must be a polyline and therefore                // added to the line list                else {                    if (DEBUG)                        Debug.output("ESE: handling OMPoly line");                    addLine(dtlGraphic, record);                }            }            // (end)if (dtlGraphic instanceof OMPoly)            // add all other fully enclosed graphics to the polyList            else if (dtlGraphic instanceof OMRect) {                if (DEBUG)                    Debug.output("ESE: handling OMRect");                addPolygon((OMGraphic) EsriPolygonList.convert((OMRect) dtlGraphic),                        record);            } else if (dtlGraphic instanceof OMCircle) {                if (DEBUG)                    Debug.output("ESE: handling OMCircle");                addPolygon((OMGraphic) EsriPolygonList.convert((OMCircle) dtlGraphic,                        projection),                        record);            } else if (dtlGraphic instanceof OMRangeRings) {                if (DEBUG)                    Debug.output("ESE: handling OMRangeRings");                export(EsriPolygonList.convert((OMRangeRings) dtlGraphic,                        projection), record, false);            }            // add lines to the lineList            else if (dtlGraphic instanceof OMLine) {                if (DEBUG)                    Debug.output("ESE: handling OMLine");                addLine((OMGraphic) EsriPolylineList.convert((OMLine) dtlGraphic),                        record);            }            // add points to the pointList            else if (dtlGraphic instanceof OMPoint) {                if (DEBUG)                    Debug.output("ESE: handling OMPoint");                addPoint(dtlGraphic, record);            }        }        // (end)for (int i = 0; i < dtlGraphicList.size(); i++)        if (badGraphics > 0) {            // Information popup provider, it's OK that this gets            // dropped.            DrawingToolRenderException.notifyUserOfNonLatLonGraphics(badGraphics);        }        if (!writeFiles) {            // Punch the stack back up so that the initial call will            // write the files.            return;        }        boolean needConfirmation = false;        // call the file chooser if no path is given        if (filePath == null) {            filePath = getFilePathFromUser();            if (filePath == null) {                return; // User cancelled.            }            needConfirmation = true;        }        if (DEBUG)            Debug.output("ESE: writing files...");        boolean needTypeSuffix = false;        // (end)if (filePath == null) call the appropriate methods to        // set up the shape files of their respective types        if (polyList != null) {            eseInterfaces.add(new ESEInterface(polyList, filePath, null));            needTypeSuffix = true;        }        if (lineList != null) {            eseInterfaces.add(new ESEInterface(lineList, filePath, (needTypeSuffix ? "Lines"                    : null)));            needTypeSuffix = true;        }        if (pointList != null) {            eseInterfaces.add(new ESEInterface(pointList, filePath, (needTypeSuffix ? "Pts"                    : null)));        }        if (needConfirmation) {            showGUI();        } else {            writeFiles();        }    }    /**     * Writes out EsriGraphicLists as shape files, assumes that the     * DbfTableModel representing the attribute data for the list objects is     * stored as an attribute in the EsriGraphicList under the DBF_ATTRIBUTE     * key. This export handles multi-part geometries, because it's assumed that     * the sorting of the graphic types have been handled and that any sub-lists     * are meant to be multi-part geometries. If the filePath hasn't been set in     * the EsriShapeExport class, the user will be asked to provide it.     */    protected void export(EsriGraphicList egList) {        Object obj = egList.getAttribute(DBF_ATTRIBUTE);        // Backward compatibility        if (obj == null) {            obj = egList.getAppObject();        }        if (obj == null) {            egList.putAttribute(DBF_ATTRIBUTE, getMasterDBF());            // egList.setAppObject(getMasterDBF());        }        eseInterfaces.add(new ESEInterface(egList, filePath, null));        writeFiles();    }    /**     * The the Iterator of ESEIterators.     */    protected Iterator getInterfaces() {        return eseInterfaces.iterator();    }    /**     * Just write the files from the ESEInterfaces.     */    protected void writeFiles() {        Iterator it = getInterfaces();        while (it.hasNext()) {            ((ESEInterface) it.next()).write();        }    }    protected JFrame frame = null;    /**     * Show the GUI for saving the Shape files.     */    public void showGUI() {        if (frame == null) {            frame = new JFrame("Saving Shape Files");            frame.getContentPane().add(getGUI(), BorderLayout.CENTER);            // frame.setSize(400, 300);            frame.pack();        }        frame.setVisible(true);    }    /**     * Hide the Frame holding the GUI.     */    public void hideGUI() {        if (frame != null) {            frame.setVisible(false);        }    }    /**     * Create the GUI for managing the different ESEIterators.     */    public Component getGUI() {        JPanel panel = new JPanel();        panel.setLayout(new BorderLayout());        JPanel interfacePanel = new JPanel();        interfacePanel.setLayout(new GridLayout(0, 1));        Iterator interfaces = getInterfaces();        int count = 0;        while (interfaces.hasNext()) {            interfacePanel.add(((ESEInterface) interfaces.next()).getGUI());            count++;        }        panel.add(interfacePanel, BorderLayout.CENTER);        if (count > 1) {            JLabel notification = new JLabel("  " + count                    + " Shape file sets needed:");            panel.add(notification, BorderLayout.NORTH);        }        JButton saveButton = new JButton("Save");        saveButton.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent ae) {                writeFiles();                hideGUI();            }        });        JButton cancelButton = new JButton("Cancel");        cancelButton.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent ae) {                hideGUI();            }        });        JPanel controlPanel = new JPanel();        controlPanel.add(saveButton);        controlPanel.add(cancelButton);        panel.add(controlPanel, BorderLayout.SOUTH);        return panel;    }    /**     * Prepares and returns a 7 column DbfTableModel to accept input for columns     * of TYPE_CHARACTER. <br>     * <br>     * The default model used holds most of the DrawingAttributes of the     * OMGraphics.     *      *      * @param list the EsriGraphicList to create a DbfTableModel from.     * @return The completed DbfTableModel.     */

⌨️ 快捷键说明

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