📄 linkraster.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/LinkRaster.java,v $// $RCSfile: LinkRaster.java,v $// $Revision: 1.3.2.1 $// $Date: 2004/10/14 18:27:08 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.link;import com.bbn.openmap.omGraphics.OMRaster;import com.bbn.openmap.proj.ProjMath;import com.bbn.openmap.util.ColorFactory;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PropUtils;import java.awt.Color;import java.awt.Image;import java.awt.image.PixelGrabber;import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.IOException;import javax.swing.ImageIcon;/** * Read and write a Link protocol versions of a raster. */public class LinkRaster implements LinkGraphicConstants, LinkPropertiesConstants { /** * Writes an image, Lat/Lon placement with a direct colormodel. * * @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 pix color values for the pixels. * @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, int[] pix, LinkProperties properties, DataOutputStream dos) throws IOException { dos.write(Link.RASTER_HEADER.getBytes()); dos.writeInt(GRAPHICTYPE_RASTER); dos.writeInt(RENDERTYPE_LATLON); dos.writeInt(COLORMODEL_DIRECT); dos.writeFloat(lt); dos.writeFloat(ln); dos.writeInt(w); dos.writeInt(h); dos.writeInt(pix.length); for (int i = 0; i < pix.length; i++) { dos.writeInt(pix[i]); } properties.write(dos); } /** * Write an image, XY placement with a direct colormodel. * * @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 pix color values for the pixels. * @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, int[] pix, LinkProperties properties, DataOutputStream dos) throws IOException { dos.write(Link.RASTER_HEADER.getBytes()); dos.writeInt(GRAPHICTYPE_RASTER); dos.writeInt(RENDERTYPE_XY); dos.writeInt(COLORMODEL_DIRECT); dos.writeInt(x1); dos.writeInt(y1); dos.writeInt(w); dos.writeInt(h); dos.writeInt(pix.length); for (int i = 0; i < pix.length; i++) { dos.writeInt(pix[i]); } properties.write(dos); } /** * Write an image, Lat/lon placement with XY offset with a direct * colormodel. * * @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 pix color values for the pixels. * @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, int[] pix, LinkProperties properties, DataOutputStream dos) throws IOException { dos.write(Link.RASTER_HEADER.getBytes()); dos.writeInt(GRAPHICTYPE_RASTER); dos.writeInt(RENDERTYPE_OFFSET); dos.writeInt(COLORMODEL_DIRECT); dos.writeFloat(lt); dos.writeFloat(ln); dos.writeInt(offset_x1); dos.writeInt(offset_y1); dos.writeInt(w); dos.writeInt(h); dos.writeInt(pix.length); for (int i = 0; i < pix.length; i++) { dos.writeInt(pix[i]); } properties.write(dos); } /** * Write an image, Lat/Lon placement with an ImageIcon. * * @param lt latitude of the top of the image. * @param ln longitude of the left side of the image. * @param image java.awt.Image to use for image. * @param image_width width of image in pixels. * @param image_height height of image in pixels. * @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, Image image, int image_width, int image_height, LinkProperties properties, DataOutputStream dos) throws IOException, InterruptedException { int[] pixels = new int[image_width * image_height]; PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, image_width, image_height, pixels, 0, image_width); pixelgrabber.grabPixels(); LinkRaster.write(lt, ln, image_width, image_height, pixels, properties, 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 image java.awt.Image to use for image. * @param image_width width of image in pixels. * @param image_height height of image in pixels. * @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, Image image, int image_width, int image_height, LinkProperties properties, DataOutputStream dos) throws IOException, InterruptedException { int[] pixels = new int[image_width * image_height]; PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, image_width, image_height, pixels, 0, image_width); pixelgrabber.grabPixels(); LinkRaster.write(x1, y1, image_width, image_height, pixels, properties, 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 image java.awt.Image to use for image. * @param image_width width of image in pixels. * @param image_height height of image in pixels. * @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, Image image, int image_width, int image_height, LinkProperties properties, DataOutputStream dos) throws IOException, InterruptedException { int[] pixels = new int[image_width * image_height]; PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, image_width, image_height, pixels, 0, image_width); pixelgrabber.grabPixels(); LinkRaster.write(lt, ln, offset_x1, offset_y1, image_width, image_height, pixels, properties, dos); } /** * Write an image, Lat/Lon placement with an ImageIcon. * * @param lt latitude of the top of the image. * @param ln longitude of the left side of the image. * @param ii ImageIcon to use for 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, ImageIcon ii, LinkProperties properties, DataOutputStream dos) throws IOException, InterruptedException { int image_width, image_height; Image image; image_width = ii.getIconWidth(); image_height = ii.getIconHeight(); image = ii.getImage(); LinkRaster.write(lt, ln, image, image_width, image_height, properties, 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 ii ImageIcon to use for 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, ImageIcon ii, LinkProperties properties, DataOutputStream dos) throws IOException, InterruptedException { int image_width, image_height; Image image; image_width = ii.getIconWidth(); image_height = ii.getIconHeight(); image = ii.getImage(); LinkRaster.write(x1, y1, image, image_width, image_height, properties, 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 ii ImageIcon to use for 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, ImageIcon ii, LinkProperties properties, DataOutputStream dos) throws IOException, InterruptedException { int image_width, image_height; Image image; image_width = ii.getIconWidth(); image_height = ii.getIconHeight(); image = ii.getImage(); LinkRaster.write(lt, ln, offset_x1, offset_y1, image, image_width, image_height, properties, dos); } ////////////////////////////////////// IMAGEICON LOADED FROM AN // URL /** * Write an image, Lat/Lon placement with an ImageIcon. * * @param lt latitude of the top of the image. * @param ln longitude of the left side 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(float lt, float ln, String url, LinkProperties properties, DataOutputStream dos) throws IOException { dos.write(Link.RASTER_HEADER.getBytes()); dos.writeInt(GRAPHICTYPE_RASTER); dos.writeInt(RENDERTYPE_LATLON); dos.writeInt(COLORMODEL_URL); dos.writeFloat(lt); dos.writeFloat(ln); properties.setProperty(LPC_LINKRASTERIMAGEURL, url);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -