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

📄 dblocationhandler.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    public Properties getPropertyInfo(Properties list) {        list = super.getPropertyInfo(list);        list.put("class" + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.NonEditablePropertyEditor");        list.put(jdbcStringProperty, "JDBC login string");        list.put(jdbcDriverProperty, "JDBC driver class name");        list.put(userNameProperty, "User name");        list.put(userPasswordProperty, "User password");        list.put(locationQueryStringProperty,                "Select statement that the data object needs.");        list.put(RawDataRecordSet.tableNameProperty,                "The name of the table in the database that holds the images.");        list.put(RawDataRecordSet.rawDataColumnNameProperty,                "The name of the column in the table in the database that holds the name (key) of the image.");        list.put(RawDataRecordSet.rawDataKeyColumnNameProperty,                "The name of the column in the table in the database that holds the raw image bytes.");        return list;    }    public void reloadData() {        quadtree = createData();    }    /**     * Look in the database and create the QuadTree holding all the     * Locations.     */    protected QuadTree createData() {        QuadTree qt = new QuadTree(90.0f, -180.0f, -90.0f, 180.0f, 100, 50f);        ByteRasterLocation loc;        byte bytearr[];        if (locationQueryString == null) {            return qt;        }        // Code for reading from DB and pushing it into QuadTree.        try {            if (jdbcDriver != null) {                Class.forName(getJdbcDriver());            }            Connection connection = DriverManager.getConnection(getJdbcString(),                    getUserName(),                    getUserPassword());            RawDataRecordSet gifdataRS = new RawDataRecordSet(connection, getPropertyPrefix(), props);            RecordSet locationdataRS = new RecordSet(connection, locationQueryString);            while (locationdataRS.next()) {                LocationData ld = new LocationData(locationdataRS);                if (Debug.debugging("location")) {                    Debug.output("DBLocationHandler:  location information:\n"                            + ld);                }                bytearr = gifdataRS.getRawData(ld.getGraphicName());                float lat = ld.getLatitude();                float lon = ld.getLongitude();                loc = new ByteRasterLocation(lat, lon, ld.getCityName(), bytearr);                loc.setLocationHandler(this);                // let the layer handler default set these                // initially...                loc.setShowName(isShowNames());                loc.setShowLocation(isShowLocations());                loc.setLocationPaint(getLocationColor());                loc.getLabel().setLinePaint(getNameColor());                loc.setDetails(ld.getCityName() + " is at lat: " + lat                        + ", lon: " + lon);                qt.put(lat, lon, loc);            }            locationdataRS.close();            connection.close();        } catch (SQLException sqlE) {            Debug.error("DBLocationHandler:SQL Exception: " + sqlE.getMessage());            sqlE.printStackTrace();        } catch (ClassNotFoundException cnfE) {            Debug.error("DBLocationHandler: Class not found Exception: " + cnfE);        }        return qt;    }    public String getJdbcString() {        return jdbcString;    }    public String getJdbcDriver() {        return jdbcDriver;    }    public String getUserName() {        return userName;    }    public String getUserPassword() {        return userPassword;    }    public Properties getLocationProperties() {        return props;    }    /**     * Prepares the graphics for the layer. This is where the     * getRectangle() method call is made on the location.     * <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 Vector get(float nwLat, float nwLon, float seLat, float seLon,                      Vector graphicList) {        // IF the quadtree has not been set up yet, do it!        if (quadtree == null) {            Debug.output("DBLocationHandler: Figuring out the locations and names! (This is a one-time operation!)");            quadtree = createData();        }        if (quadtree != null) {            if (Debug.debugging("location")) {                Debug.output("DBLocationHandler|DBLocationHandler.get() ul.lon = "                        + nwLon                        + " lr.lon = "                        + seLon                        + " delta = "                        + (seLon - nwLon));            }            quadtree.get(nwLat, nwLon, seLat, seLon, graphicList);        }        return graphicList;    }    public void fillLocationPopUpMenu(LocationPopupMenu locMenu) {        LocationCBMenuItem lcbi = new LocationCBMenuItem(LocationHandler.showname, locMenu, getLayer());        lcbi.setState(locMenu.getLoc().isShowName());        locMenu.add(lcbi);        locMenu.add(new LocationMenuItem(showdetails, locMenu, getLayer()));    }    /** Box used for constructing the palette widgets */    protected Box box = null;    /**     * Provides the palette widgets to control the options of showing     * maps, or attribute text.     *      * @return Component object representing the palette widgets.     */    public Component getGUI() {        if (box == null) {            JCheckBox showDBLocationCheck, showNameCheck;            JButton rereadFilesButton;            showDBLocationCheck = new JCheckBox("Show Locations", isShowLocations());            showDBLocationCheck.setActionCommand(showLocationsCommand);            showDBLocationCheck.addActionListener(this);            showNameCheck = new JCheckBox("Show Location Names", isShowNames());            showNameCheck.setActionCommand(showNamesCommand);            showNameCheck.addActionListener(this);            rereadFilesButton = new JButton("Reload Data From Source");            rereadFilesButton.setActionCommand(readDataCommand);            rereadFilesButton.addActionListener(this);            box = Box.createVerticalBox();            box.add(showDBLocationCheck);            box.add(showNameCheck);            box.add(rereadFilesButton);        }        return box;    }    //----------------------------------------------------------------------    // ActionListener interface implementation    //----------------------------------------------------------------------    /**     * The Action Listener method, that reacts to the palette widgets     * actions.     */    public void actionPerformed(ActionEvent e) {        String cmd = e.getActionCommand();        if (cmd == showLocationsCommand) {            JCheckBox locationCheck = (JCheckBox) e.getSource();            setShowLocations(locationCheck.isSelected());            if (Debug.debugging("location")) {                Debug.output("DBLocationHandler::actionPerformed showLocations is "                        + isShowLocations());            }            getLayer().repaint();        } else if (cmd == showNamesCommand) {            JCheckBox namesCheck = (JCheckBox) e.getSource();            setShowNames(namesCheck.isSelected());            if (Debug.debugging("location")) {                Debug.output("DBLocationHandler::actionPerformed showNames is "                        + isShowNames());            }            getLayer().repaint();        } else if (cmd == readDataCommand) {            Debug.output("DBLocationHandler: Re-reading Locations file");            quadtree = null;            getLayer().doPrepare();        } else {            Debug.error("DBLocationHandler: Unknown action command \"" + cmd                    + "\" in actionPerformed().");        }    }}

⌨️ 快捷键说明

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