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

📄 testlayer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    case 0:                        line.visible = !line.visible;                        omline.setVisible(line.visible);                        repaint();                        break;                    case 1:                        circle.visible = !circle.visible;                        omcircle.setVisible(circle.visible);                        repaint();                        break;                    case 2:                        rect.visible = !rect.visible;                        omrect.setVisible(rect.visible);                        repaint();                        break;                    case 3:                        text.visible = !text.visible;                        omtext.setVisible(text.visible);                        repaint();                        break;                    case 4:                        poly.visible = !poly.visible;                        ompoly.setVisible(poly.visible);                        repaint();                        break;                    default:                        System.out.println("TestLayer: Unimplemented...");                    }                }            };            pal = PaletteHelper.createCheckbox("Graphics", new String[] {                    "Line", "Circle", "Rect", "Text", "Poly" }, new boolean[] {                    line.visible, circle.visible, rect.visible, text.visible,                    poly.visible }, al);            gridbag.setConstraints(pal, constraints);            gui.add(pal);            // line controls            pal = getGraphicPalette(line, "Line");            gridbag.setConstraints(pal, constraints);            gui.add(pal);            // circle controls            pal = getGraphicPalette(circle, "Circle");            gridbag.setConstraints(pal, constraints);            gui.add(pal);            // rect controls            pal = getGraphicPalette(rect, "Rect");            gridbag.setConstraints(pal, constraints);            gui.add(pal);            // text controls            pal = getGraphicPalette(text, "Text");            gridbag.setConstraints(pal, constraints);            gui.add(pal);            // poly controls            pal = getGraphicPalette(poly, "Poly");            gridbag.setConstraints(pal, constraints);            gui.add(pal);        }        return gui;    }    /**     * Create the sub-palette for a particular graphic type.     *      * @param obj GraphicObj     * @param title panel title     * @return JPanel sub-palette     */    protected JPanel getGraphicPalette(final GraphicBase obj, final String title) {        final JComboBox jcb;        final JFrame jframe;        final JRootPane main;        final JPanel parent;        parent = PaletteHelper.createVerticalPanel(title);        jframe = new JFrame();        main = jframe.getRootPane();        // different controls for different render types        jcb = new JComboBox();        jcb.addItem("LatLon");// indices correspond to LineType.java        jcb.addItem("XY");        jcb.addItem("Offset");        jcb.setSelectedIndex(obj.rt - 1);        jcb.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                obj.setRender(jcb);                switch (obj.rt) {                case OMGraphic.RENDERTYPE_LATLON:                    jframe.setTitle(title + " - LatLon");                    main.getContentPane().removeAll();                    main.getContentPane().add(obj.getGUI());                    jframe.pack();                    jframe.setVisible(true);                    break;                case OMGraphic.RENDERTYPE_XY:                    jframe.setTitle(title + " - XY");                    main.getContentPane().removeAll();                    main.getContentPane().add(obj.getGUI());                    jframe.pack();                    jframe.setVisible(true);                    break;                case OMGraphic.RENDERTYPE_OFFSET:                    jframe.setTitle(title + " - XY Offset");                    main.getContentPane().removeAll();                    main.getContentPane().add(obj.getGUI());                    jframe.pack();                    jframe.setVisible(true);                    break;                default:                    System.err.println("ARRRR!");                    break;                }            }        });        parent.add(jcb);        return parent;    }    /**     * Returns self as the <code>MapMouseListener</code> in order to     * receive <code>MapMouseEvent</code>s. If the implementation     * would prefer to delegate <code>MapMouseEvent</code>s, it     * could return the delegate from this method instead.     *      * @return MapMouseListener this     */    public MapMouseListener getMapMouseListener() {        return this;    }    /**     * Return a list of the modes that are interesting to the     * MapMouseListener. The source MouseEvents will only get sent to     * the MapMouseListener if the mode is set to one that the     * listener is interested in. Layers interested in receiving     * events should register for receiving events in "select" mode.     * <code>     * <pre>     * return new String[1] { SelectMouseMode.modeID };     * </pre>     * <code>     * @see NavMouseMode#modeID     * @see SelectMouseMode#modeID     * @see NullMouseMode#modeID     */    public String[] getMouseModeServiceList() {        return new String[] { SelectMouseMode.modeID };    }    /**     * Invoked when a mouse button has been pressed on a component.     *      * @param e MouseEvent     * @return true if the listener was able to process the event.     */    public boolean mousePressed(MouseEvent e) {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mousePressed()");        }        return true;    }    /**     * Invoked when a mouse button has been released on a component.     *      * @param e MouseEvent     * @return true if the listener was able to process the event.     */    public boolean mouseReleased(MouseEvent e) {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mouseReleased()");        }        return true;    }    /**     * Invoked when the mouse has been clicked on a component. The     * listener will receive this event if it successfully processed     * <code>mousePressed()</code>, or if no other listener     * processes the event. If the listener successfully processes     * mouseClicked(), then it will receive the next mouseClicked()     * notifications that have a click count greater than one.     *      * @param e MouseListener MouseEvent to handle.     * @return true if the listener was able to process the event.     */    public boolean mouseClicked(MouseEvent e) {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mouseClicked()");        }        return true;    }    /**     * Invoked when the mouse enters a component.     *      * @param e MouseListener MouseEvent to handle.     */    public void mouseEntered(MouseEvent e) {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mouseEntered()");        }    }    /**     * Invoked when the mouse exits a component.     *      * @param e MouseListener MouseEvent to handle.     */    public void mouseExited(MouseEvent e) {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mouseExited()");        }    }    // Mouse Motion Listener events    ///////////////////////////////    /**     * Invoked when a mouse button is pressed on a component and then     * dragged. The listener will receive these events if it     * successfully processes mousePressed(), or if no other listener     * processes the event.     *      * @param e MouseMotionListener MouseEvent to handle.     * @return true if the listener was able to process the event.     */    public boolean mouseDragged(MouseEvent e) {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mouseDragged()");        }        return true;    }    /**     * Invoked when the mouse button has been moved on a component     * (with no buttons no down).     *      * @param e MouseListener MouseEvent to handle.     * @return true if the listener was able to process the event.     */    public boolean mouseMoved(MouseEvent e) {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mouseMoved()");        }        return true;    }    /**     * Handle a mouse cursor moving without the button being pressed.     * This event is intended to tell the listener that there was a     * mouse movement, but that the event was consumed by another     * layer. This will allow a mouse listener to clean up actions     * that might have happened because of another motion event     * response.     */    public void mouseMoved() {        if (Debug.debugging("TestLayer")) {            System.out.println("TestLayer.mouseMoved()[alt]");        }    }    //////////////////////////////////////////////////////////////////    /*     * The GUI code is implemented here.     */    protected abstract class GraphicBase {        // ll data        protected float[] llpts = new float[4];        protected float radius = 4000f;        protected int type = OMGraphic.LINETYPE_GREATCIRCLE;        protected int nsegs = 360;        // xy data        protected int[] xypts = new int[4];        protected int width, height;        // generic        protected int lineColor = NCOLORS - 2;        protected int fillColor = NCOLORS - 1;        protected boolean visible = true;        protected boolean isFilled = false;        protected int rt = OMGraphic.RENDERTYPE_LATLON;        // GUI code        protected abstract JPanel getGUI();        protected void setXYCoordinate(JTextField jtf, int i) {            try {                xypts[i] = Integer.parseInt(jtf.getText().trim());            } catch (NumberFormatException ex) {                return;            }        }        protected void setLLCoordinate(JTextField jtf, int i) {            try {                llpts[i] = Float.valueOf(jtf.getText().trim()).floatValue();            } catch (NumberFormatException ex) {                return;            }        }        protected void setType(JComboBox jcb) {            type = jcb.getSelectedIndex() + 1;            setList(generateGraphics());            repaint();        }        protected void setRender(JComboBox jcb) {            rt = jcb.getSelectedIndex() + 1;

⌨️ 快捷键说明

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