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

📄 testlayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            setList(generateGraphics());            repaint();        }        protected void setSegs(JTextField jtf) {            try {                nsegs = Integer.parseInt(jtf.getText().trim());            } catch (NumberFormatException ex) {                return;            }        }        protected void makeFillCheckBox(JComponent parent) {            JPanel pal = PaletteHelper.createCheckbox(null,                    new String[] { "Filled" },                    new boolean[] { isFilled },                    new ActionListener() {                        public void actionPerformed(ActionEvent e) {                            isFilled = !isFilled;                            setList(generateGraphics());                            repaint();                        }                    });            parent.add(pal);        }        protected void makeColorBox(JComponent parent, String title,                                    final boolean isFill) {            JPanel pal = PaletteHelper.createVerticalPanel(title);            final JComboBox jcb = new JComboBox();            for (int i = 0; i < NCOLORS; i++) {                jcb.addItem(colorNames[i]);            }            jcb.setSelectedIndex(isFill ? fillColor : lineColor);            jcb.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent e) {                    if (isFill)                        fillColor = jcb.getSelectedIndex();                    else                        lineColor = jcb.getSelectedIndex();                    setList(generateGraphics());                    repaint();                }            });            pal.add(jcb);            parent.add(pal);        }        // get an OK button which refreshes the display.        protected JButton getOKButton() {            // add reset button            JButton jb = new JButton("OK");            jb.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent e) {                    setList(generateGraphics());                    repaint();                }            });            return jb;        }    }    protected class Line extends GraphicBase {        protected int arrowtype = -1;        protected boolean arrowhead = false;        public Line() {            llpts[0] = 45f;            llpts[1] = -90f;            llpts[2] = 0f;            llpts[3] = -180f;            xypts[0] = 45;            xypts[1] = 90;            xypts[2] = 0;            xypts[3] = 180;            lineColor = 5;        }        // makes arrow head selection        protected void makeArrowHeadGUI(JComponent parent) {            JPanel pal;            pal = PaletteHelper.createVerticalPanel(null);            final JComboBox jcb = new JComboBox();            jcb.addItem("None");            jcb.addItem("Arrow Forward");            jcb.addItem("Arrow Back");            jcb.addItem("Arrow Both");            jcb.setSelectedIndex(arrowtype + 1);            jcb.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent e) {                    switch (jcb.getSelectedIndex()) {                    case 0:                        System.out.println("TestLayer: no arrows");                        omline.addArrowHead(false);                        arrowhead = false;                        arrowtype = -1;                        break;                    case 1:                        System.out.println("TestLayer: arrows forward");                        arrowhead = true;                        arrowtype = OMArrowHead.ARROWHEAD_DIRECTION_FORWARD;                        break;                    case 2:                        System.out.println("TestLayer: arrows backward");                        arrowhead = true;                        arrowtype = OMArrowHead.ARROWHEAD_DIRECTION_BACKWARD;                        break;                    case 3:                        System.out.println("TestLayer: arrows both");                        arrowhead = true;                        arrowtype = OMArrowHead.ARROWHEAD_DIRECTION_BOTH;                        break;                    }                    setList(generateGraphics());                    repaint();                }            });            pal.add(jcb);            parent.add(pal);        }        public JPanel getGUI() {            // request focus            requestFocus();            JTextField tf;            JPanel pal;            final JPanel pop;            pop = PaletteHelper.createVerticalPanel(null);            // add arrowheads            if (!(this instanceof Rect))                makeArrowHeadGUI(pop);            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());                    }                });            }            if (rt != OMGraphic.RENDERTYPE_XY) {                tf = PaletteHelper.createTextEntry("lat1", "" + llpts[0], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setLLCoordinate((JTextField) e.getSource(), 0);                    }                });                tf = PaletteHelper.createTextEntry("lon1", "" + 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("lat2", "" + llpts[2], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setLLCoordinate((JTextField) e.getSource(), 2);                    }                });                tf = PaletteHelper.createTextEntry("lon2", "" + llpts[3], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setLLCoordinate((JTextField) e.getSource(), 3);                    }                });            } else {                tf = PaletteHelper.createTextEntry("x1", "" + xypts[0], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 0);                    }                });                tf = PaletteHelper.createTextEntry("y1", "" + xypts[1], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 1);                    }                });                tf = PaletteHelper.createTextEntry("x2", "" + xypts[2], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 2);                    }                });                tf = PaletteHelper.createTextEntry("y2", "" + xypts[3], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 3);                    }                });            }            // line color            makeColorBox(pop, "line", false);            // fill color            if (this instanceof Rect)                makeColorBox(pop, "fill", true);            // filled?            if (this instanceof Rect)                makeFillCheckBox(pop);            // add ok button            pop.add(getOKButton());            return pop;        }    }    protected class Rect extends Line {        public Rect() {            llpts[0] = -80f;            llpts[1] = 0f;            llpts[2] = 10f;            llpts[3] = 45f;            xypts[0] = 250;            xypts[1] = 100;            xypts[2] = 150;            xypts[3] = 380;            lineColor = 0;            fillColor = 9;            type = OMGraphic.LINETYPE_RHUMB;        }    }    protected class Circle extends GraphicBase {        public Circle() {            xypts[0] = 10;            xypts[1] = 20;            width = 10;            height = 20;            fillColor = 0;        }        public JPanel getGUI() {            // request focus            requestFocus();            final JPanel pop;            JTextField tf;            pop = PaletteHelper.createVerticalPanel(null);            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);                    }                });            } else {                tf = PaletteHelper.createTextEntry("x", "" + xypts[0], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 0);                    }                });                tf = PaletteHelper.createTextEntry("y", "" + xypts[1], pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        setXYCoordinate((JTextField) e.getSource(), 1);                    }                });            }            if (rt == OMGraphic.RENDERTYPE_OFFSET) {                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);                    }                });            } else if (rt == OMGraphic.RENDERTYPE_LATLON) {                tf = PaletteHelper.createTextEntry("R (km)", "" + radius, pop);                tf.addFocusListener(new FocusAdapter() {                    public void focusLost(FocusEvent e) {                        JTextField jtf = (JTextField) e.getSource();                        float f = radius;                        try {                            f = Float.valueOf(jtf.getText().trim())                                    .floatValue();                        } catch (NumberFormatException ex) {                            return;                        }                        radius = f;                        System.out.println("TestLayer: radius=" + radius);

⌨️ 快捷键说明

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