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

📄 gotomenu.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }        props.put(prefix + ViewListProperty, viewList.toString());        return props;    }    /** PropertyConsumer interface method. */    public Properties getPropertyInfo(Properties props) {        props = super.getPropertyInfo(props);        props.put(ViewListProperty,                "Space-separated marker list of different views");        props.put(AddDefaultListProperty,                "Flag to add default views (true/false).");        props.put(AddDefaultListProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor");        props.put(AddDataViewsProperty,                "Flag to add views from some data components.");        props.put(AddDataViewsProperty + ScopedEditorProperty,                "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor");        props.put(NameProperty, "The formal name of the view for the user.");        props.put(LatProperty, "The latitude of the center of the view.");        props.put(LonProperty, "The longitude of the center of the view.");        props.put(ScaleProperty, "The scale of the view.");        props.put(ProjectionTypeProperty, "The projection name of the view");        return props;    }    /** Add the default views to the menu. */    public void addDefaultLocations() {        add(new GoToButton(i18n.get(this, "world", "World"), 0, 0, Float.MAX_VALUE, Mercator.MercatorName));    }    Vector customViews = new Vector();    /**     * Parse and add the view from properties.     */    public void addLocationItem(String prefix, Properties props) {        prefix = PropUtils.getScopedPropertyPrefix(prefix);        String locationName = props.getProperty(prefix + NameProperty);        String latString = props.getProperty(prefix + LatProperty);        String lonString = props.getProperty(prefix + LonProperty);        String scaleString = props.getProperty(prefix + ScaleProperty);        String projID = props.getProperty(prefix + ProjectionTypeProperty);        if (Debug.debugging("goto")) {            Debug.output("GoToMenu: adding view - " + locationName + ", "                    + latString + ", " + lonString + ", " + scaleString + ", "                    + projID);        }        try {            float lat = new Float(latString).floatValue();            float lon = new Float(lonString).floatValue();            float scale = new Float(scaleString).floatValue();            GoToButton gtb = new GoToButton(locationName, lat, lon, scale, projID);            customViews.add(gtb);            add(gtb);        } catch (NumberFormatException nfe) {            return;        } catch (Exception e) {            return;        }    }    public void addDataBoundsProvider(DataBoundsProvider provider) {        DataBoundsViewMenuItem dbvmi = new DataBoundsViewMenuItem(provider);        dataBoundsProviders.put(provider, dbvmi);        dbvmi.findAndInit(getBeanContext());        dataBoundsMenu.add(dbvmi);    }    public void removeDataBoundsProvider(DataBoundsProvider provider) {        JMenuItem item = (DataBoundsViewMenuItem) dataBoundsProviders.get(provider);        if (item != null) {            dataBoundsMenu.remove(item);        }    }    /**     * Add a button to the menu that will set the map to a particular view.     */    public void addView(GoToButton newOne) {        customViews.add(newOne);        add(newOne);        revalidate();    }    /**     * This is the button that will bring up the dialog to actually name a new     * view being added. The new view will be the current projection of the map.     */    public class AddNewViewButton extends JMenuItem implements ActionListener {        public AddNewViewButton(String title) {            super(title);            this.addActionListener(this);        }        public void actionPerformed(ActionEvent ae) {            if (map != null) {                Projection proj = map.getProjection();                LatLonPoint llp = proj.getCenter();                new GoToButton(llp.getLatitude(), llp.getLongitude(), proj.getScale(), proj.getName());            }        }    }    /**     * This button contains the trigger for a saved view.     */    public class GoToButton extends JMenuItem implements ActionListener {        public float latitude;        public float longitude;        public float scale;        public String projectionID;        GoToMenu menu;        public GoToButton(String title, float lat, float lon, float s,                String projID) {            super(title);            init(lat, lon, s, projID);        }        public GoToButton(float lat, float lon, float s, String projID) {            init(lat, lon, s, projID);            NameFetcher nf = new NameFetcher(this);            if (map != null) {                Point p = map.getLocationOnScreen();                int x = (int)p.getX();                int y = (int)p.getY();                int w = map.getWidth();                int h = map.getHeight();                nf.setLocation(x + (w-nf.getWidth())/2, y + (h - nf.getHeight())/2);            }            nf.show();        }        public void init(float lat, float lon, float s, String projID) {            latitude = lat;            longitude = lon;            scale = s;            projectionID = projID;            this.addActionListener(this);        }        /**         * Gets called when the NameFetcher sucessfully retrieves a name for the view.         * @param name new name for the button.         */        public void setNameAndAdd(String name) {            this.setText(name);            GoToMenu.this.addView(this);        }        public void actionPerformed(ActionEvent ae) {            if (map != null) {                Projection oldProj = map.getProjection();                Class projClass = ProjectionFactory.getProjClassForName(projectionID);                if (projClass == null) {                    projClass = com.bbn.openmap.proj.Mercator.class;                }                Projection newProj = ProjectionFactory.makeProjection(projClass,                        latitude,                        longitude,                        scale,                        oldProj.getWidth(),                        oldProj.getHeight());                map.setProjection(newProj);            }        }    }    /**     * Brings up a GUI to name a new view.     */    public class NameFetcher extends JDialog implements ActionListener {        JTextField nameField;        JLabel label;        JButton closebutton, applybutton;        GoToButton notifyThis;        public NameFetcher(GoToButton buttonToName) {            notifyThis = buttonToName;            setTitle(i18n.get(GoToMenu.class, "addViewTitle", "Add View"));            JPanel palette = new JPanel();            palette.setLayout(new BoxLayout(palette, BoxLayout.Y_AXIS));            JPanel namePanel = new JPanel();            namePanel.setLayout(new FlowLayout());            label = new JLabel(i18n.get(GoToMenu.class, "nameOfView", "Name of View: "));            nameField = new JTextField("", 20);            namePanel.add(label);            namePanel.add(nameField);            palette.add(namePanel);            JPanel buttonPanel = new JPanel();            GridBagLayout gridbag = new GridBagLayout();            GridBagConstraints c = new GridBagConstraints();            buttonPanel.setLayout(gridbag);            applybutton = new JButton(i18n.get(GoToMenu.class, "addView", "Add View"));            applybutton.addActionListener(this);            gridbag.setConstraints(applybutton, c);            closebutton = new JButton(i18n.get(GoToMenu.class, "close", "Close"));            closebutton.addActionListener(this);            c.gridx = GridBagConstraints.RELATIVE;            gridbag.setConstraints(closebutton, c);            buttonPanel.add(applybutton);            buttonPanel.add(closebutton);            palette.add(buttonPanel);            this.getContentPane().add(palette);            this.pack();        }        public void actionPerformed(ActionEvent event) {            if (event.getSource() == applybutton) {                String newName = nameField.getText();                if (newName != null && !(newName.equals(""))) {                    notifyThis.setNameAndAdd(newName);                }            }            this.setVisible(false);        }    }}

⌨️ 快捷键说明

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