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

📄 editableompoint.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        assertGrabPoints();        OMPoint point = (OMPoint) graphic;        boolean ntr = point.getNeedToRegenerate();        int renderType = point.getRenderType();        LatLonPoint llp;        int latoffset = 0;        int lonoffset = 0;        boolean doStraight = true;        if (ntr == false) {            if (renderType == OMGraphic.RENDERTYPE_LATLON                    || renderType == OMGraphic.RENDERTYPE_OFFSET) {                if (projection != null) {                    float lon = point.getLon();                    float lat = point.getLat();                    llp = new LatLonPoint(lat, lon);                    java.awt.Point p = projection.forward(llp);                    if (renderType == OMGraphic.RENDERTYPE_LATLON) {                        doStraight = false;                        gpc.set((int) p.getX(), (int) p.getY());                    } else {                        latoffset = (int) p.getY();                        lonoffset = (int) p.getX();                        gpo.set(lonoffset, latoffset);                    }                }            }            if (doStraight) {                gpc.set(lonoffset + point.getX(), latoffset + point.getY());            }            if (renderType == OMGraphic.RENDERTYPE_OFFSET) {                gpo.updateOffsets();            }        } else {            Debug.message("eomg",                    "EditableOMPoint.setGrabPoints: graphic needs to be regenerated");        }    }    /**     * Take the current location of the GrabPoints, and modify the     * location parameters of the OMPoint with them. Called when you     * want the graphic to change according to the grab points.     */    public void setGrabPoints() {        int renderType = point.getRenderType();        LatLonPoint llp1;        Debug.message("eomg", "EditableOMPoint.setGrabPoints()");        // Do center point for lat/lon or offset points        if (renderType == OMGraphic.RENDERTYPE_LATLON) {            if (projection != null) {                //movingPoint == gpc                llp1 = projection.inverse(gpc.getX(), gpc.getY());                point.set(llp1.getLatitude(), llp1.getLongitude());                // point.setNeedToRegenerate set            }        }        boolean settingOffset = getStateMachine().getState() instanceof GraphicSetOffsetState                && movingPoint == gpo;        // If the center point is moving, the offset distance changes        if (renderType == OMGraphic.RENDERTYPE_OFFSET) {            llp1 = projection.inverse(gpo.getX(), gpo.getY());            point.setLat(llp1.getLatitude());            point.setLon(llp1.getLongitude());            if (settingOffset || movingPoint == gpc) {                // Don't call point.setLocation because we only want                // to                // setNeedToRegenerate if !settingOffset.                point.setX(gpc.getX() - gpo.getX());                point.setY(gpc.getY() - gpo.getY());            }            if (!settingOffset) {                Debug.message("eomg", "EditableOMPoint: updating offset point");                point.set(gpc.getX() - gpo.getX(), gpc.getY() - gpo.getY());            }            // Set Location has reset the rendertype, but provides            // the convenience of setting the max and min values            // for us.            point.setRenderType(OMGraphic.RENDERTYPE_OFFSET);        }        // Do the point height and width for XY and OFFSET render        // types.        if (renderType == OMGraphic.RENDERTYPE_XY) {            Debug.message("eomg", "EditableOMPoint: updating x/y point");            if (movingPoint == gpc) {                point.set(gpc.getX(), gpc.getY());            }        }        if (projection != null) {            regenerate(projection);        }    }    /**     * Get whether a graphic can be manipulated by its edges, rather     * than just by its grab points.     */    public boolean getCanGrabGraphic() {        return false;    }    /**     * Called to set the OffsetGrabPoint to the current mouse     * location, and update the OffsetGrabPoint with all the other     * GrabPoint locations, so everything can shift smoothly. Should     * also set the OffsetGrabPoint to the movingPoint. Should be     * called only once at the beginning of the general movement, in     * order to set the movingPoint. After that, redraw(e) should just     * be called, and the movingPoint will make the adjustments to the     * graphic that are needed.     */    public void move(java.awt.event.MouseEvent e) {}    /**     * Use the current projection to place the graphics on the screen.     * Has to be called to at least assure the graphics that they are     * ready for rendering. Called when the graphic position changes.     *      * @param proj com.bbn.openmap.proj.Projection     * @return true     */    public boolean generate(Projection proj) {        Debug.message("eomgdetail", "EditableOMPoint.generate()");        if (point != null)            point.regenerate(proj);        for (int i = 0; i < gPoints.length; i++) {            GrabPoint gp = gPoints[i];            if (gp != null) {                gp.generate(proj);            }        }        return true;    }    /**     * Given a new projection, the grab points may need to be     * repositioned off the current position of the graphic. Called     * when the projection changes.     */    public void regenerate(Projection proj) {        Debug.message("eomg", "EditableOMPoint.regenerate()");        if (point != null)            point.regenerate(proj);        setGrabPoints(point);        generate(proj);    }    /**     * Draw the EditableOMPoint parts into the java.awt.Graphics     * object. The grab points are only rendered if the point machine     * state is PointSelectedState.POINT_SELECTED.     *      * @param graphics java.awt.Graphics.     */    public void render(java.awt.Graphics graphics) {        Debug.message("eomgdetail", "EditableOMPoint.render()");        State state = getStateMachine().getState();        if (!(state instanceof GraphicUndefinedState)) {            if (point != null) {                point.setVisible(true);                point.render(graphics);                point.setVisible(false);            } else {                Debug.message("eomg", "EditableOMPoint.render: null point.");            }            int renderType = point.getRenderType();            if (state instanceof GraphicSelectedState                    || state instanceof GraphicEditState) {                for (int i = 0; i < gPoints.length; i++) {                    GrabPoint gp = gPoints[i];                    if (gp != null) {                        if ((i == OFFSET_POINT_INDEX                                && renderType == OMGraphic.RENDERTYPE_OFFSET && movingPoint == gpo)                                ||                                (state instanceof GraphicSelectedState && ((i != OFFSET_POINT_INDEX && renderType != OMGraphic.RENDERTYPE_OFFSET) || (renderType == OMGraphic.RENDERTYPE_OFFSET)))                        ) {                            gp.setVisible(true);                            gp.render(graphics);                            gp.setVisible(false);                        }                    }                }            }        }    }    /**     * Modifies the gui to not include line type adjustments, and adds     * widgets to control point settings.     *      * @param graphicAttributes the GraphicAttributes to use to get     *        the GUI widget from to control those parameters for this     *        EOMG.     * @return java.awt.Component to use to control parameters for     *         this EOMG.     */    public Component getGUI(GraphicAttributes graphicAttributes) {        Debug.message("eomg", "EditableOMPoint.getGUI");        if (graphicAttributes != null) {            JPanel panel = graphicAttributes.getColorAndLineGUI();            panel.add(getPointGUI());            return panel;        } else {            return getPointGUI();        }    }    protected JToolBar pToolBar = null;    protected JToolBar getPointGUI() {        if (pToolBar == null) {            pToolBar = new GridBagToolBar();            // Add buttons to toggle oval/rect, radius of point.        }        return pToolBar;    }}

⌨️ 快捷键说明

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