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

📄 linkarc.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
字号:
// **********************************************************************//// <copyright>////  BBN Technologies//  10 Moulton Street//  Cambridge, MA 02138//  (617) 873-8000////  Copyright (C) BBNT Solutions LLC. All rights reserved.//// </copyright>// **********************************************************************//// $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/layer/link/LinkArc.java,v $// $RCSfile: LinkArc.java,v $// $Revision: 1.2.2.1 $// $Date: 2004/10/14 18:27:06 $// $Author: dietrick $//// **********************************************************************package com.bbn.openmap.layer.link;import com.bbn.openmap.omGraphics.OMArc;import com.bbn.openmap.proj.Length;import com.bbn.openmap.util.Debug;import com.bbn.openmap.LatLonPoint;import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.IOException;/** * Reading and writing a Link protocol version of a circle. */public class LinkArc implements LinkGraphicConstants, LinkPropertiesConstants {    /**     * Write an arc with lat/lon placement.     *      * @param latPoint latitude of center point, decimal degrees     * @param lonPoint longitude of center point, decimal degrees     * @param w horizontal diameter of arc, pixels     * @param h vertical diameter of arc, pixels     * @param s starting angle of arc, decimal degrees     * @param e angular extent of arc, decimal degrees     * @param properties attributes for the arc.     * @param dos DataOutputStream.     * @throws IOException     */    public static void write(float latPoint, float lonPoint, int w, int h,                             float s, float e, LinkProperties properties,                             DataOutputStream dos) throws IOException {        LinkArc.write(latPoint, lonPoint, 0, 0, w, h, s, e, properties, dos);    }    /**     * Write an arc with x/y placement.     *      * @param x1 window position of center point from left of window,     *        in pixels     * @param y1 window position of center point from top of window,     *        in pixels     * @param w horizontal diameter of arc, pixels     * @param h vertical diameter of arc, pixels     * @param s starting angle of arc, decimal degrees     * @param e angular extent of arc, decimal degrees     * @param properties attributes for the arc.     * @param dos DataOutputStream.     * @throws IOException     */    public static void write(int x1, int y1, int w, int h, float s, float e,                             LinkProperties properties, DataOutputStream dos)            throws IOException {        dos.write(Link.ARC_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_ARC);        dos.writeInt(RENDERTYPE_XY);        dos.writeInt(x1);        dos.writeInt(y1);        dos.writeInt(w);        dos.writeInt(h);        dos.writeFloat(s);        dos.writeFloat(e);        properties.write(dos);    }    /**     * Writing an arc at a x, y, offset to a Lat/Lon location.     *      * @param latPoint latitude of center of arc.     * @param lonPoint longitude of center of arc.     * @param offset_x1 # pixels to the right the center will be moved     *        from lonPoint.     * @param offset_y1 # pixels down that the center will be moved     *        from latPoint.     * @param w horizontal diameter of arc, pixels.     * @param h vertical diameter of arc, pixels.     * @param s starting angle of arc, decimal degrees     * @param e angular extent of arc, decimal degrees     * @param properties attributes for the arc.     * @param dos DataOutputStream.     * @throws IOException     */    public static void write(float latPoint, float lonPoint, int offset_x1,                             int offset_y1, int w, int h, float s, float e,                             LinkProperties properties, DataOutputStream dos)            throws IOException {        dos.write(Link.ARC_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_ARC);        dos.writeInt(RENDERTYPE_OFFSET);        dos.writeFloat(latPoint);        dos.writeFloat(lonPoint);        dos.writeInt(offset_x1);        dos.writeInt(offset_y1);        dos.writeInt(w);        dos.writeInt(h);        dos.writeFloat(s);        dos.writeFloat(e);        properties.write(dos);    }    /**     * Write an arc with a certain radius at a Lat/Lon location.     * Assumes the radius is in decimal degrees.     *      * @param latPoint latitude of center point, decimal degrees     * @param lonPoint longitude of center point, decimal degrees     * @param radius distance in decimal degrees     * @param s starting angle of arc, decimal degrees     * @param e angular extent of arc, decimal degrees     * @param properties attributes for the arc.     * @param dos DataOutputStream.     * @throws IOException     */    public static void write(float latPoint, float lonPoint, float radius,                             float s, float e, LinkProperties properties,                             DataOutputStream dos) throws IOException {        LinkArc.write(latPoint, lonPoint, radius, -1, -1, s, e, properties, dos);    }    /**     * Write an arc with a certain radius at a Lat/Lon location, and     * allows you to specify units of the radius.     *      * @param latPoint latitude of center of arc in decimal degrees     * @param lonPoint longitude of center of arc in decimal degrees     * @param radius distance     * @param units integer value for units for distance - KM, MILES,     *        NMILES. If &lt; 0, assume decimal degrees.     * @param s starting angle of arc, decimal degrees     * @param e angular extent of arc, decimal degrees     * @param properties attributes for the arc.     * @param dos DataOutputStream.     * @throws IOException     */    public static void write(float latPoint, float lonPoint, float radius,                             int units, float s, float e,                             LinkProperties properties, DataOutputStream dos)            throws IOException {        LinkArc.write(latPoint,                lonPoint,                radius,                units,                -1,                s,                e,                properties,                dos);    }    /**     * Write an arc with a certain radius at a Lat/Lon location, and     * allows you to specify units of the radius, as well as the     * number of verticies to use to approximate the arc.     *      * @param latPoint latitude of center of arc in decimal degrees     * @param lonPoint longitude of center of arc in decimal degrees     * @param radius distance     * @param units integer value for units for distance - OMArc.KM,     *        OMArc.MILES, OMArc.NMILES. If &lt; 0, assume decimal     *        degrees.     * @param nverts number of vertices for the poly-arc (if &lt; 3,     *        value is generated internally).     * @param s starting angle of arc, decimal degrees     * @param e angular extent of arc, decimal degrees     * @param properties attributes for the arc.     * @param dos DataOutputStream.     * @throws IOException     */    public static void write(float latPoint, float lonPoint, float radius,                             int units, int nverts, float s, float e,                             LinkProperties properties, DataOutputStream dos)            throws IOException {        // Write this out...        dos.write(Link.ARC_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_ARC);        dos.writeInt(RENDERTYPE_LATLON);        dos.writeFloat(latPoint);        dos.writeFloat(lonPoint);        dos.writeFloat(radius);        dos.writeInt(units);        dos.writeInt(nverts);        dos.writeFloat(s);        dos.writeFloat(e);        properties.write(dos);    }    public static void write(OMArc arc, Link link, LinkProperties props)            throws IOException {        LatLonPoint llp;        switch (arc.getRenderType()) {        case OMArc.RENDERTYPE_LATLON:            llp = arc.getLatLon();            LinkArc.write(llp.getLatitude(),                    llp.getLongitude(),                    arc.getRadius(),                    arc.getStartAngle(),                    arc.getExtentAngle(),                    props,                    link.dos);            break;        case OMArc.RENDERTYPE_XY:            LinkArc.write(arc.getX(),                    arc.getY(),                    arc.getWidth(),                    arc.getHeight(),                    arc.getStartAngle(),                    arc.getExtentAngle(),                    props,                    link.dos);            break;        case OMArc.RENDERTYPE_OFFSET:            llp = arc.getLatLon();            LinkArc.write(llp.getLatitude(),                    llp.getLongitude(),                    arc.getOffX(),                    arc.getOffY(),                    arc.getWidth(),                    arc.getHeight(),                    arc.getStartAngle(),                    arc.getExtentAngle(),                    props,                    link.dos);            break;        default:            Debug.error("LinkArc.write: arc rendertype unknown.");        }    }    /**     * Read the arc protocol off the data input, and return an OMArc.     * Assumes the header for the graphic has already been read.     *      * @param dis the DataInputStream     * @return OMArc     * @throws IOException     * @see com.bbn.openmap.omGraphics.OMArc     */    public static OMArc read(DataInputStream dis) throws IOException {        OMArc arc = null;        float lat, lon, radius, start, extent;        int x, y, w, h;        int renderType = dis.readInt();        switch (renderType) {        case RENDERTYPE_LATLON:            lat = dis.readFloat();            lon = dis.readFloat();            radius = dis.readFloat();            start = dis.readFloat();            extent = dis.readFloat();            int units = dis.readInt();            int nverts = dis.readInt();            Length unit = Length.DECIMAL_DEGREE;            switch (units) {            case 0:                unit = Length.KM;                break;            case 1:                unit = Length.MILE;                break;            case 2:                unit = Length.NM;                break;            default:            }            arc = new OMArc(new LatLonPoint(lat, lon), radius, unit, nverts, start, extent);            break;        case RENDERTYPE_XY:            x = dis.readInt();            y = dis.readInt();            w = dis.readInt();            h = dis.readInt();            start = dis.readFloat();            extent = dis.readFloat();            arc = new OMArc(x, y, w, h, start, extent);            break;        case RENDERTYPE_OFFSET:            lat = dis.readFloat();            lon = dis.readFloat();            x = dis.readInt();            y = dis.readInt();            w = dis.readInt();            h = dis.readInt();            start = dis.readFloat();            extent = dis.readFloat();            arc = new OMArc(lat, lon, x, y, w, h, start, extent);            break;        default:        }        LinkProperties properties = new LinkProperties(dis);        if (arc != null) {            properties.setProperties(arc);        }        return arc;    }}

⌨️ 快捷键说明

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