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

📄 ompoly.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * coordinate pairs are the same. This is for RENDERTYPE_XY polys.     *      * @param xPoints int[] of x coordinates     * @param yPoints int[] of y coordinates     */    public void setLocation(int[] xPoints, int[] yPoints) {        xs = xPoints;        ys = yPoints;        setNeedToRegenerate(true);        setRenderType(RENDERTYPE_XY);    }    /**     * Set the location based on a latitude, longitude, and some xy     * points. The coordinate mode and the polygon setting are the     * same as in the constructor used. This is for RENDERTYPE_OFFSET     * polys.     *      * @param latPoint latitude in decimal degrees     * @param lonPoint longitude in decimal degrees     * @param units radians or decimal degrees. Use OMGraphic.RADIANS     *        or OMGraphic.DECIMAL_DEGREES     * @param xypoints array of x/y points, arranged x, y, x, y, etc.     */    public void setLocation(float latPoint, float lonPoint, int units,                            int[] xypoints) {        this.units = OMGraphic.RADIANS;        if (units == OMGraphic.DECIMAL_DEGREES) {            lat = ProjMath.degToRad(latPoint);            lon = ProjMath.degToRad(lonPoint);        } else {            lat = latPoint;            lon = lonPoint;        }        int end = xypoints.length >> 1;        xs = new int[end];        ys = new int[end];        for (int i = 0, j = 0; i < end; i++, j += 2) {            xs[i] = xypoints[j];            ys[i] = xypoints[j + 1];        }        setNeedToRegenerate(true);        setRenderType(RENDERTYPE_OFFSET);    }    /**     * Set the location based on a latitude, longitude, and some xy     * points. The coordinate mode and the polygon setting are the     * same as in the constructor used. This is for RENDERTYPE_OFFSET     * polys.     *      * @param latPoint latitude in decimal degrees     * @param lonPoint longitude in decimal degrees     * @param units radians or decimal degrees. Use OMGraphic.RADIANS     *        or OMGraphic.DECIMAL_DEGREES     * @param xPoints int[] of x coordinates     * @param yPoints int[] of y coordinates     */    public void setLocation(float latPoint, float lonPoint, int units,                            int[] xPoints, int[] yPoints) {        this.units = OMGraphic.RADIANS;        if (units == OMGraphic.DECIMAL_DEGREES) {            lat = ProjMath.degToRad(latPoint);            lon = ProjMath.degToRad(lonPoint);        } else {            lat = latPoint;            lon = lonPoint;        }        xs = xPoints;        ys = yPoints;        setNeedToRegenerate(true);        setRenderType(RENDERTYPE_OFFSET);    }    /**     * Return the rawllpts array. NOTE: this is an unsafe method to     * access the rawllpts array. Use with caution. These are RADIANS!     *      * @return float[] rawllpts of lat, lon, lat, lon     */    public float[] getLatLonArray() {        return rawllpts;    }    /**     * Set the latitude of the offset point, in decimal degrees. For     * RENDERTYPE_OFFSET Polygons.     */    public void setLat(float lat) {        this.lat = ProjMath.degToRad(lat);        setNeedToRegenerate(true);    }    /**     * Get the latitude of the offset point, in decimal degrees. For     * RENDERTYPE_OFFSET Polygons.     */    public float getLat() {        return ProjMath.radToDeg(lat);    }    /**     * Set the longitude of the offset point, in decimal degrees. For     * RENDERTYPE_OFFSET Polygons.     */    public void setLon(float lon) {        this.lon = ProjMath.degToRad(lon);        setNeedToRegenerate(true);    }    /**     * Get the longitude of the offset point, in decimal degrees. For     * RENDERTYPE_OFFSET Polygons.     */    public float getLon() {        return ProjMath.radToDeg(lon);    }    /**     * Set the array of x points. For RENDERTYPE_OFFSET, RENDERTYPE_XY     * polys.     */    public void setXs(int[] x) {        xs = x;        setNeedToRegenerate(true);    }    /**     * Get the array of x points. For RENDERTYPE_OFFSET, RENDERTYPE_XY     * polys.     */    public int[] getXs() {        return xs;    }    /**     * Set the array of y points. For RENDERTYPE_OFFSET, RENDERTYPE_XY     * polys.     */    public void setYs(int[] y) {        ys = y;        setNeedToRegenerate(true);    }    /**     * Get the array of y points. For RENDERTYPE_OFFSET, RENDERTYPE_XY     * polys.     */    public int[] getYs() {        return ys;    }    /**     * Set the fill Paint of the poly. If the color value is     * non-clear, then the poly is a polygon (connected and filled),     * otherwise it's a polyline (non-filled).     *      * @param paint value Color     */    public void setFillPaint(Paint paint) {        super.setFillPaint(paint);        isPolygon = !isClear(paint);    }    /**     * Check if this is a polygon or a polyline. A polygon is a     * multi-segment line that has a non-clear fill color. A polyline     * is a multi-segment line that has no fill color.     *      * @return true if polygon false if polyline     */    public boolean isPolygon() {        return isPolygon;    }    /**     * Set the Polyline/Polygon setting, if you know better. If the     * fillPaint is set after this method is called, then the     * fillPaint isPolygon rules apply. If the fillPaint is opaque,     * then it is assumed to be a Polygon and isPolygon will be set to     * true. If this is set to be false, the fillPaint will be set to     * clear.     */    public void setIsPolygon(boolean set) {        if (!set) {            // This is important for the rendering, especially if the            // shapes are being created and OMGraphic.render() will be            // used. The fillPaint being == OMColor.clear will            // prevent the filled area from being drawn.            fillPaint = OMColor.clear;        }        isPolygon = set;    }    /**     * Set the number of subsegments for each segment in the poly.     * (This is only for LINETYPE_GREATCIRCLE or LINETYPE_RHUMB line     * types, and if &lt; 1, this value is generated internally).     *      * @param nsegs number of segment points     */    public void setNumSegs(int nsegs) {        this.nsegs = nsegs;    }    /**     * Get the number of subsegments for each segment in the poly.     * (This is only for LINETYPE_GREATCIRCLE or LINETYPE_RHUMB line     * types).     *      * @return int number of segment points     */    public int getNumSegs() {        return nsegs;    }    /**     * For RENDERTYPE_OFFSET, type of offset.     *      * @see #COORDMODE_ORIGIN     * @see #COORDMODE_PREVIOUS     */    public void setCoordMode(int coordMode) {        this.coordMode = coordMode;    }    /**     * For RENDERTYPE_OFFSET, type of offset.     *      * @see #COORDMODE_ORIGIN     * @see #COORDMODE_PREVIOUS     */    public int getCoordMode() {        return coordMode;    }    public void setDoShapes(boolean set) {        doShapes = set;    }    public boolean getDoShapes() {        return doShapes;    }    /**     * Prepare the poly for rendering.     *      * @param proj Projection     * @return true if generate was successful     */    public boolean generate(Projection proj) {        int i, j, npts;        setShape(null);        setNeedToRegenerate(true);        if (proj == null) {            Debug.message("omgraphic", "OMPoly: null projection in generate!");            return false;        }        // answer the question now, saving calcuation for future        // calculations. The set method forces the calculation for        // the query.        isGeometryClosed();        switch (renderType) {        case RENDERTYPE_XY:            if (xs == null) {                Debug.message("omgraphic",                        "OMPoly x/y rendertype null coordinates");                return false;            }            // Need to keep these around for the LabeledOMPoly            xpoints = new int[1][0];            xpoints[0] = xs;            ypoints = new int[1][0];            ypoints[0] = ys;            break;        case RENDERTYPE_OFFSET:            if (xs == null) {                Debug.message("omgraphic",                        "OMPoly offset rendertype null coordinates");                return false;            }            npts = xs.length;            int[] _x = new int[npts];            int[] _y = new int[npts];            // forward project the radian point            Point origin = proj.forward(lat, lon, new Point(0, 0), true);// radians            if (coordMode == COORDMODE_ORIGIN) {                for (i = 0; i < npts; i++) {                    _x[i] = xs[i] + origin.x;                    _y[i] = ys[i] + origin.y;                }            } else { // CModePrevious offset deltas                _x[0] = xs[0] + origin.x;                _y[0] = ys[0] + origin.y;                for (i = 1; i < npts; i++) {                    _x[i] = xs[i] + _x[i - 1];                    _y[i] = ys[i] + _y[i - 1];                }            }            // Need to keep these around for the LabeledOMPoly            xpoints = new int[1][0];            xpoints[0] = _x;            ypoints = new int[1][0];            ypoints[0] = _y;            break;        case RENDERTYPE_LATLON:            // polygon/polyline project the polygon/polyline.            // Vertices should already be in radians.            ArrayList vector = proj.forwardPoly(rawllpts,                    lineType,                    nsegs,                    isPolygon);            int size = vector.size();            xpoints = new int[(int) (size / 2)][0];            ypoints = new int[xpoints.length][0];            for (i = 0, j = 0; i < size; i += 2, j++) {                xpoints[j] = (int[]) vector.get(i);                ypoints[j] = (int[]) vector.get(i + 1);            }

⌨️ 快捷键说明

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