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

📄 testlayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    }                });                tf = PaletteHelper.createTextEntry("nverts", "" + nsegs, pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setSegs((JTextField) e.getSource());                    }                });            }            if (rt != OMGraphic.RENDERTYPE_LATLON) {                tf = PaletteHelper.createTextEntry("width", "" + width, pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        JTextField jtf = (JTextField) e.getSource();                        try {                            width = Integer.parseInt(jtf.getText().trim());                        } catch (NumberFormatException ex) {                            return;                        }                    }                });                tf = PaletteHelper.createTextEntry("height", "" + height, pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        JTextField jtf = (JTextField) e.getSource();                        try {                            height = Integer.parseInt(jtf.getText().trim());                        } catch (NumberFormatException ex) {                            return;                        }                    }                });            }            // line color            makeColorBox(pop, "line", false);            // fill color            makeColorBox(pop, "fill", true);            // filled?            makeFillCheckBox(pop);            // add ok button            pop.add(getOKButton());            return pop;        }    }    protected class Poly extends GraphicBase {        protected float lat = 0f;        protected float lon = 0f;        protected int cMode = OMPoly.COORDMODE_ORIGIN;        public Poly() {            llpts = new float[8];            xypts = new int[6];            llpts[0] = 10f;            llpts[1] = -20f;            llpts[2] = 45f;            llpts[3] = -70f;            llpts[4] = 0f;            llpts[5] = -90f;            llpts[6] = -15f;            llpts[7] = -40f;            xypts[0] = 145;            xypts[1] = 190;            xypts[2] = 160;            xypts[3] = 210;            xypts[2] = 135;            xypts[3] = 215;            lineColor = 4;            fillColor = 9;            type = OMGraphic.LINETYPE_GREATCIRCLE;        }        // set latlon vertices        protected void setVertices(String verts) {            try {                String str;                StringTokenizer tok = new StringTokenizer(verts, "\n\r");                // clean out comments                verts = "";                while (tok.hasMoreTokens()) {                    str = tok.nextToken().trim();                    if (str.charAt(0) != '#') {                        verts = verts + str + " ";                    }                }                // extract vertices                tok = new StringTokenizer(verts);                int size = tok.countTokens();                System.out.println("ll size=" + size);                llpts = new float[size];                for (int i = 0; i < size; i += 2) {                    str = tok.nextToken();                    System.out.print("lat=" + str);                    llpts[i] = Float.valueOf(str).floatValue();                    str = tok.nextToken();                    System.out.println(" lon=" + str);                    llpts[i + 1] = Float.valueOf(str).floatValue();                }            } catch (NumberFormatException ex) {                return;            }        }        protected void setXY(JTextArea jta) {            try {                if (false)                    throw new NumberFormatException("foo");            } catch (NumberFormatException ex) {                return;            }        }        protected void setLL(JTextArea jta) {            setVertices(jta.getText().trim());        }        protected void setLLCoordinate(JTextField jtf, int i) {            try {                if (i == 0)                    lat = Float.valueOf(jtf.getText().trim()).floatValue();                else                    lon = Float.valueOf(jtf.getText().trim()).floatValue();            } catch (NumberFormatException ex) {                return;            }        }        public JPanel getGUI() {            // request focus            requestFocus();            final JPanel pop;            JPanel pal;            JTextField tf;            JTextArea ta;            pop = PaletteHelper.createVerticalPanel(null);            if (rt == OMGraphic.RENDERTYPE_LATLON) {                pal = PaletteHelper.createVerticalPanel(null);                JComboBox jcb = new JComboBox();                jcb.addItem("Straight");// indices correspond to                                        // LineType.java                jcb.addItem("Rhumb");                jcb.addItem("Great Circle");                jcb.setSelectedIndex(type - 1);                jcb.addActionListener(new ActionListener() {                    public void actionPerformed(ActionEvent e) {                        setType((JComboBox) e.getSource());                    }                });                pal.add(jcb);                pop.add(pal);                tf = PaletteHelper.createTextEntry("nsegs", "" + nsegs, pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setSegs((JTextField) e.getSource());                    }                });                String entry = "";                for (int i = 0; i < llpts.length; i += 2) {                    entry = entry + llpts[i] + " " + llpts[i + 1] + "\n";                }                ta = PaletteHelper.createTextArea("llpts", entry, pop, 5, 8);                ta.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setLL((JTextArea) e.getSource());                    }                });            } else {                if (rt == OMGraphic.RENDERTYPE_OFFSET) {                    tf = PaletteHelper.createTextEntry("lat",                            "" + llpts[0],                            pop);                    tf.addFocusListener(new FocusAdapter() {                        public void focusLost(FocusEvent e) {                            setLLCoordinate((JTextField) e.getSource(), 0);                        }                    });                    tf = PaletteHelper.createTextEntry("lon",                            "" + llpts[1],                            pop);                    tf.addFocusListener(new FocusAdapter() {                        public void focusLost(FocusEvent e) {                            setLLCoordinate((JTextField) e.getSource(), 1);                        }                    });                }                String entry = "";                for (int i = 0; i < xypts.length; i += 2) {                    entry = entry + xypts[i] + " " + xypts[i + 1] + "\n";                }                ta = PaletteHelper.createTextArea("xypts", entry, pop, 0, 0);                ta.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXY((JTextArea) e.getSource());                    }                });            }            // line color            makeColorBox(pop, "line", false);            // fill color            makeColorBox(pop, "fill", true);            // filled?            makeFillCheckBox(pop);            // add ok button            pop.add(getOKButton());            return pop;        }    }    protected class Text extends GraphicBase {        protected String data;        protected String font = "SansSerif-Bold-18";        protected int just = OMText.JUSTIFY_CENTER;        public Text() {            llpts[0] = 42.35f;            llpts[1] = -70.5f;            xypts[0] = 20;            xypts[1] = 10;            lineColor = 10;            data = "Boston";        }        public JPanel getGUI() {            // request focus            requestFocus();            final JPanel pop;            JPanel pal;            JTextField tf;            final JComboBox jcb;            pop = PaletteHelper.createVerticalPanel(null);            tf = PaletteHelper.createTextEntry("text", data, pop);            tf.addFocusListener(new FocusAdapter() {                public void focusLost(FocusEvent e) {                    data = ((JTextField) (e.getSource())).getText().trim();                }            });            tf = PaletteHelper.createTextEntry("font", font, pop);            tf.addFocusListener(new FocusAdapter() {                public void focusLost(FocusEvent e) {                    font = ((JTextField) (e.getSource())).getText().trim();                }            });            pal = PaletteHelper.createVerticalPanel(null);            jcb = new JComboBox();            jcb.addItem("right");// indices correspond to values in                                 // OMText            jcb.addItem("center");            jcb.addItem("left");            jcb.setSelectedIndex(just);            jcb.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent e) {                    just = jcb.getSelectedIndex();                    setList(generateGraphics());                    repaint();                }            });            pal.add(jcb);            pop.add(pal);            if (rt != OMGraphic.RENDERTYPE_XY) {                tf = PaletteHelper.createTextEntry("lat", "" + llpts[0], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setLLCoordinate((JTextField) e.getSource(), 0);                    }                });                tf = PaletteHelper.createTextEntry("lon", "" + llpts[1], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setLLCoordinate((JTextField) e.getSource(), 1);                    }                });            }            if (rt != OMGraphic.RENDERTYPE_LATLON) {                tf = PaletteHelper.createTextEntry("off_x", "" + xypts[0], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 0);                    }                });                tf = PaletteHelper.createTextEntry("off_y", "" + xypts[1], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 1);                    }                });            }            // line color            makeColorBox(pop, "text", false);            // add ok button            pop.add(getOKButton());            return pop;        }    }}

⌨️ 快捷键说明

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