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

📄 linkraster.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        properties.write(dos);    }    /**     * Write an image, X/Y placement with an ImageIcon.     *      * @param x1 window location of the left side of the image.     * @param y1 window location of the top of the image.     * @param url URL to download the image from.     * @param properties description of drawing attributes. Not used,     *        but included to be consistant with the protocol graphics     *        format.     * @param dos DataOutputStream     * @throws IOException     */    public static void write(int x1, int y1, String url,                             LinkProperties properties, DataOutputStream dos)            throws IOException {        dos.write(Link.RASTER_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_RASTER);        dos.writeInt(RENDERTYPE_XY);        dos.writeInt(COLORMODEL_URL);        dos.writeInt(x1);        dos.writeInt(y1);        properties.setProperty(LPC_LINKRASTERIMAGEURL, url);        properties.write(dos);    }    /**     * Write an image, Lat/Lon with X/Y placement with an ImageIcon.     *      * @param lt latitude of the top of the image, before the offset.     * @param ln longitude of the left side of the image, before the     *        offset.     * @param offset_x1 number of pixels to move image to the right.     * @param offset_y1 number of pixels to move image down.     * @param url URL to download the image from.     * @param properties description of drawing attributes. Not used,     *        but included to be consistant with the protocol graphics     *        format.     * @param dos DataOutputStream     * @throws IOException     */    public static void write(float lt, float ln, int offset_x1, int offset_y1,                             String url, LinkProperties properties,                             DataOutputStream dos) throws IOException {        dos.write(Link.RASTER_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_RASTER);        dos.writeInt(RENDERTYPE_OFFSET);        dos.writeInt(COLORMODEL_URL);        dos.writeFloat(lt);        dos.writeFloat(ln);        dos.writeInt(offset_x1);        dos.writeInt(offset_y1);        properties.setProperty(LPC_LINKRASTERIMAGEURL, url);        properties.write(dos);    }    ////////////////////////////////////// BYTE PIXELS with    // COLORTABLE    /**     * Lat/Lon placement with a indexed colormodel, which is using a     * colortable and a byte array to contruct the int[] pixels.     *      * @param lt latitude of the top of the image.     * @param ln longitude of the left side of the image.     * @param w width of the image, in pixels.     * @param h height of the image, in pixels.     * @param bytes colortable index values for the pixels.     * @param colorTable color array corresponding to bytes     * @param trans transparency of image.     * @param properties description of drawing attributes. Not used,     *        but included to be consistant with the protocol graphics     *        format.     * @param dos DataOutputStream     * @throws IOException     */    public static void write(float lt, float ln, int w, int h, byte[] bytes,                             Color[] colorTable, int trans,                             LinkProperties properties, DataOutputStream dos)            throws IOException {        dos.write(Link.RASTER_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_RASTER);        dos.writeInt(RENDERTYPE_LATLON);        dos.writeInt(COLORMODEL_INDEXED);        dos.writeFloat(lt);        dos.writeFloat(ln);        dos.writeInt(w);        dos.writeInt(h);        dos.writeInt(bytes.length);        dos.write(bytes, 0, bytes.length);        dos.writeInt(colorTable.length);        int i;        for (i = 0; i < colorTable.length; i++) {            dos.writeInt(colorTable[i].getRGB());        }        dos.writeInt(trans);        properties.write(dos);    }    /**     * XY placement with a indexed colormodel, which is using a     * colortable and a byte array to contruct the int[] pixels.     *      * @param x1 window location of the left side of the image.     * @param y1 window location of the top of the image.     * @param w width of the image, in pixels.     * @param h height of the image, in pixels.     * @param bytes colortable index values for the pixels.     * @param colorTable color array corresponding to bytes     * @param trans transparency of image.     * @param properties description of drawing attributes. Not used,     *        but included to be consistant with the protocol graphics     *        format.     * @param dos DataOutputStream     * @throws IOException     */    public static void write(int x1, int y1, int w, int h, byte[] bytes,                             Color[] colorTable, int trans,                             LinkProperties properties, DataOutputStream dos)            throws IOException {        dos.write(Link.RASTER_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_RASTER);        dos.writeInt(RENDERTYPE_XY);        dos.writeInt(COLORMODEL_INDEXED);        dos.writeInt(x1);        dos.writeInt(y1);        dos.writeInt(w);        dos.writeInt(h);        dos.writeInt(bytes.length);        dos.write(bytes, 0, bytes.length);        dos.writeInt(colorTable.length);        int i;        for (i = 0; i < colorTable.length; i++) {            dos.writeInt(colorTable[i].getRGB());        }        dos.writeInt(trans);        properties.write(dos);    }    /**     * Lat/lon placement with XY offset with a indexed colormodel,     * which is using a colortable and a byte array to construct the     * int[] pixels.     *      * @param lt latitude of the top of the image, before the offset.     * @param ln longitude of the left side of the image, before the     *        offset.     * @param offset_x1 number of pixels to move image to the right.     * @param offset_y1 number of pixels to move image down.     * @param w width of the image, in pixels.     * @param h height of the image, in pixels.     * @param bytes colortable index values for the pixels.     * @param colorTable color array corresponding to bytes     * @param trans transparency of image.     * @param properties description of drawing attributes. Not used,     *        but included to be consistant with the protocol graphics     *        format.     * @param dos DataOutputStream     * @throws IOException     */    public static void write(float lt, float ln, int offset_x1, int offset_y1,                             int w, int h, byte[] bytes, Color[] colorTable,                             int trans, LinkProperties properties,                             DataOutputStream dos) throws IOException {        dos.write(Link.RASTER_HEADER.getBytes());        dos.writeInt(GRAPHICTYPE_RASTER);        dos.writeInt(RENDERTYPE_OFFSET);        dos.writeInt(COLORMODEL_INDEXED);        dos.writeFloat(lt);        dos.writeFloat(ln);        dos.writeInt(offset_x1);        dos.writeInt(offset_y1);        dos.writeInt(w);        dos.writeInt(h);        dos.writeInt(bytes.length);        dos.write(bytes, 0, bytes.length);        dos.writeInt(colorTable.length);        int i;        for (i = 0; i < colorTable.length; i++) {            dos.writeInt(colorTable[i].getRGB());        }        dos.writeInt(trans);        properties.write(dos);    }    /**     * Write a raster to the link.     */    public static void write(OMRaster raster, Link link, LinkProperties props)            throws IOException {        switch (raster.getRenderType()) {        case OMRaster.RENDERTYPE_LATLON:        case OMRaster.RENDERTYPE_XY:        case OMRaster.RENDERTYPE_OFFSET:        default:            Debug.error("LinkRaster.write: raster not implemented.");        }    }    /**     * Read the DataInputStream, and create an OMRaster. Assumes that     * the LinkRaster header has been read from the link.     *      * @param dis DataInputStream     * @return OMRaster     * @throws IOException     * @see com.bbn.openmap.omGraphics.OMRaster     */    public static OMRaster read(DataInputStream dis) throws IOException {        OMRaster raster = null;        float lat = 0;        float lon = 0;        int x = 0;        int y = 0;        int w = 0;        int h = 0;        int length, i;        String url;        Debug.message("link", "LinkRaster | Reading Raster graphic");        int renderType = dis.readInt();        int colorModel = dis.readInt();        if (Debug.debugging("link")) {            System.out.println("LinkRaster | Rendertype = " + renderType                    + ", colorModel = " + colorModel);        }        switch (renderType) {        case RENDERTYPE_OFFSET:            lat = dis.readFloat();            lon = dis.readFloat();        // Fall through...        case RENDERTYPE_XY:            x = dis.readInt();            y = dis.readInt();            break;        case RENDERTYPE_LATLON:        default:            lat = dis.readFloat();            lon = dis.readFloat();            if (Debug.debugging("link")) {                System.out.println("LinkRaster | Location: lat = " + lat                        + ", lon = " + lon);            }        }        // Now act differently depending on the colormodel        if (colorModel != COLORMODEL_URL) {            w = dis.readInt();            h = dis.readInt();            if (Debug.debugging("link")) {                System.out.println("LinkRaster | Size: width = " + w                        + ", height = " + h);            }            if (colorModel == COLORMODEL_INDEXED) {                length = dis.readInt();                byte[] bytes = new byte[length];                if (Debug.debugging("link")) {                    System.out.println("LinkRaster | Reading " + length                            + " bytes.");                }                dis.readFully(bytes);                if (Debug.debugging("link")) {                    System.out.println("LinkRaster | read bytes.");                }                length = dis.readInt();                if (Debug.debugging("link")) {                    System.out.println("LinkRaster | " + length + " Colors.");                }                Color[] colorTable = new Color[length];                for (i = 0; i < length; i++) {                    int colorvalue = dis.readInt();                    colorTable[i] = ColorFactory.createColor(colorvalue, true);                    if (Debug.debugging("linkdetail")) {                        System.out.println("LinkRaster | Color " + i + " =  "                                + colorTable[i] + " from "                                + Integer.toHexString(colorvalue));                    }                }                int trans = dis.readInt();                if (Debug.debugging("link")) {                    System.out.println("LinkRaster | Transparency =  " + trans);                }                switch (renderType) {                case RENDERTYPE_OFFSET:                    raster = new OMRaster(lat, lon, x, y, w, h, bytes, colorTable, trans);                    break;                case RENDERTYPE_XY:                    raster = new OMRaster(x, y, w, h, bytes, colorTable, trans);                    break;                case RENDERTYPE_LATLON:                default:                    raster = new OMRaster(lat, lon, w, h, bytes, colorTable, trans);                }            } else { // must be COLORMODEL_DIRECT                length = dis.readInt();                int[] pix = new int[length];                if (Debug.debugging("link")) {                    System.out.println("LinkRaster | Reading " + length                            + " pixels.");                }                for (i = 0; i < length; i++) {                    pix[i] = dis.readInt();                }                switch (renderType) {                case RENDERTYPE_OFFSET:                    raster = new OMRaster(lat, lon, x, y, w, h, pix);                    break;                case RENDERTYPE_XY:                    raster = new OMRaster(x, y, w, h, pix);                    break;                case RENDERTYPE_LATLON:                default:                    raster = new OMRaster(lat, lon, w, h, pix);                }            }        }        LinkProperties properties = new LinkProperties(dis);        if (colorModel == COLORMODEL_URL) {            url = properties.getProperty(LPC_LINKRASTERIMAGEURL);            if (url != null) {                switch (renderType) {                case RENDERTYPE_OFFSET:                    raster = new OMRaster(lat, lon, x, y, new ImageIcon(url));                    break;                case RENDERTYPE_XY:                    raster = new OMRaster(x, y, new ImageIcon(url));                    break;                case RENDERTYPE_LATLON:                default:                    raster = new OMRaster(lat, lon, new ImageIcon(url));                }            }        }        if (raster != null) {            raster.setAppObject(properties);            raster.setRotationAngle((double) ProjMath.degToRad(PropUtils.floatFromProperties(properties,                    LPC_LINKROTATION,                    0.0f)));        }        return raster;    }}

⌨️ 快捷键说明

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