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

📄 omgrid.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// **********************************************************************// // <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/omGraphics/OMGrid.java,v $// $RCSfile: OMGrid.java,v $// $Revision: 1.5.2.5 $// $Date: 2005/08/11 21:03:22 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.omGraphics;import java.awt.Graphics;import java.awt.Point;import com.bbn.openmap.omGraphics.grid.GridData;import com.bbn.openmap.omGraphics.grid.OMGridData;import com.bbn.openmap.omGraphics.grid.OMGridGenerator;import com.bbn.openmap.omGraphics.grid.OMGridObjects;import com.bbn.openmap.proj.Length;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;/** * An OMGrid object is a two-dimensional container object for data. * The grid can be laid out in geographic or pixel space. There are * two different ways that the OMGrid can be used. * <P> * The data placed in the array can represent the attributes of what * you want the grid to represent - elevation values, temperatures, * etc. In order to render the data on the screen, you'll need to set * the OMGridGenerator object, and let it interpret the data to create * the desired OMGraphics for you. * <P> * The OMGrid data values can also contain integer ID keys for objects * contained in the OMGridObjects object held by the OMGrid. By using * the OMGrid in this way, the OMGrid becomes a placeholder for other * graphics, and will manage the generate() function calls to those * objects that are on the screen. * <P> * The OMGridGenerator object will take precidence over the * OMGridObjects - If the OMGridGenerator is set within the grid, the * OMGridGenerator will create the OMGraphics to be displayed for the * grid, as opposed the OMGridObjects getting a chance to generate * themselves. The OMGrid extends OMGraphicList, and the OMGraphics * that the OMGridGenerator creates are added to the OMGrid. If you * want the OMGrid to hide the OMGraphics that are created, make it * vague. */public class OMGrid extends OMGraphicList {    /**     * The orientation angle of the grid, in radians. Up/North is     * zero.     */    protected float orientation;    /**     * Number of rows in the data array. Gets set by the OMGrid     * depending on the major of the grid.     */    protected int rows;    /**     * Number of columns in the data array. Gets set by the OMGrid     * depending on the major of the grid.     */    protected int columns;    /**     * The starting latitude point of the grid. Only relevant when the     * data points are laid out in a lat/lon grid, or when an x/y grid     * is anchored to a lat/lon location. DOES NOT follow the OpenMap     * convention where area object locations are defined by the upper     * left location - the location of the grid is noted by the lower     * left corner, because grid data is usually defined by the lower     * left location. Makes it easier to deal with overlap rows and     * columns, and to calculate the locations of the rows and     * columns.     */    protected float latitude;    /**     * The starting longitude point of the grid. Only relevant when     * the data points are laid out in a lat/lon grid, or when an x/y     * grid is anchored to a lat/lon location. DOES NOT follow the     * OpenMap convention where area object locations are defined by     * the upper left location - the location of the grid is noted by     * the lower left corner, because grid data is usually defined by     * the lower left location. Makes it easier to deal with overlap     * rows and columns, and to calculate the locations of the rows     * and columns.     */    protected float longitude;    /**     * The vertical/latitude interval, the distance between row data     * points in the vertical direction. For x/y grids, this can     * server as a pixel multiplier. For lat/lon grids, it represents     * the decimal degrees between grid points.     */    protected float verticalResolution;    /**     * The horizontal/longitude interval, the distance between column     * data points in the horizontal direction. For x/y grids, this     * can server as a pixel mulitplier. For lat/lon grids, it     * represents the decimal degrees between grid points.     */    protected float horizontalResolution;    /**     * The Object holding the data for the OMGrid. The GridData     * abstracts the type of data that is held by the OMGrid. Note:     * the 0 index of the array in both directions is in the lower     * left corner of the matrix. As you increase indexes in both     * dimensions, you go up-right.     */    public GridData data;    /**     * If needed, the data array can hold numerical identifiers, which     * are keys to objects stored in this hashtable. That way, the     * grid can be used to hold an array of objects. If the objs are     * set, then the OMGrid object automatically assumes that all     * graphic operations are supposed to involve the objs.     */    protected OMGridObjects gridObjects = null;    /**     * Horizontal screen location of the upper left corner of the grid     * in pixels, before projection, of XY and OFFSET grids.     */    protected Point point = null;    /**     * Horizontal screen location of the upper left corner of the grid     * in pixels, after projection.     */    public Point point1 = null;    /**     * Horizontal screen location of the lower right corner of the     * grid in pixels, after projection.     */    public Point point2 = null;    /**     * Pixel height of grid, set after generate. For non-equidistant     * projections, this will be a bounding box height.     */    public int height = 0;    /**     * Pixel width of grid, set after generate. For non-equidistant     * projections, this will be a bounding box width.     */    public int width = 0;    /**     * Value of a bad/invalid point in the grid. Has roots in the DTED     * way of doing things.     */    public final static int GRID_NULL = -32767;    /** An object that knows how to generate graphics for the matrix. */    protected OMGridGenerator generator = null;    /**     * Means that the first dimension of the array refers to the     * column count.     */    public static final boolean COLUMN_MAJOR = true;    /**     * Means that the first dimension of the array refers to the row     * count.     */    public static final boolean ROW_MAJOR = false;    /**     * Keep track of which dimension different parts of the double     * array represent. COLUMN_MAJOR is the default, meaning that the     * first dimension of the array represents the vertical location     * in the array, and the second is the horizontal location in the     * array.     */    protected boolean major = COLUMN_MAJOR;    /**     * The units, if needed, of the values contained in the grid data     * array. Null value is default and acceptable.     */    protected Length units = null;    /** Default constructor. */    public OMGrid() {}    /**     * Create a OMGrid that covers a lat/lon area. Column major by     * default. If your data is row major, use null for the data, set     * the major direction, and then set the data.     *      * @param lat latitude of lower left corner of the grid, in     *        decimal degrees.     * @param lon longitude of lower left corner of the grid, in     *        decimal degrees.     * @param vResolution the vertical resolution of the data, as     *        decimal degrees per row.     * @param hResolution the horizontal resolution of the data, as     *        decimal degrees per column.     * @param data a double array of integers, representing the rows     *        and columns of data.     */    public OMGrid(float lat, float lon, float vResolution, float hResolution,            int[][] data) {        setRenderType(RENDERTYPE_LATLON);        set(lat, lon, 0, 0, vResolution, hResolution, data);    }    /**     * Create a OMGrid that covers a x/y screen area.Column major by     * default. If your data is row major, use null for the data, set     * the major direction, and then set the data.     *      * @param x horizontal location, in pixels, of the left side of     *        the grid from the left side of the map.     * @param y vertical location, in pixels, of the top of the grid     *        from the top side of the map.     * @param vResolution the vertical resolution of the data, as     *        pixels per row.     * @param hResolution the horizontal resolution of the data, as     *        pixels per column.     * @param data a double array of integers, representing the rows     *        and columns of data.     */    public OMGrid(int x, int y, float vResolution, float hResolution,            int[][] data) {        setRenderType(RENDERTYPE_XY);        set(0.0f, 0.0f, x, y, vResolution, hResolution, data);    }    /**     * Create a OMGrid that covers a x/y screen area, anchored to a     * lat/lon point. Column major by default. If your data is row     * major, use null for the data, set the major direction, and then     * set the data.     *      * @param lat latitude of the anchor point of the grid, in decimal     *        degrees.     * @param lon longitude of the anchor point of the grid, in     *        decimal degrees.     * @param x horizontal location, in pixels, of the left side of     *        the grid from the longitude anchor point.     * @param y vertical location, in pixels, of the top of the grid     *        from the latitude anchor point.     * @param vResolution the vertical resolution of the data, as     *        pixels per row.     * @param hResolution the horizontal resolution of the data, as     *        pixels per column.     * @param data a double array of integers, representing the rows     *        and columns of data.     */    public OMGrid(float lat, float lon, int x, int y, float vResolution,            float hResolution, int[][] data) {        setRenderType(RENDERTYPE_OFFSET);        set(lat, lon, x, y, vResolution, hResolution, data);    }    /**     * Create a OMGrid that covers a lat/lon area. Column major by     * default. If your data is row major, use null for the data, set     * the major direction, and then set the data.     *      * @param lat latitude of lower left corner of the grid, in     *        decimal degrees.     * @param lon longitude of lower left corner of the grid, in     *        decimal degrees.     * @param vResolution the vertical resolution of the data, as     *        decimal degrees per row.     * @param hResolution the horizontal resolution of the data, as     *        decimal degrees per column.     * @param data GridData object holding rows and columns of grid data.     */    public OMGrid(float lat, float lon, float vResolution, float hResolution,            GridData data) {        setRenderType(RENDERTYPE_LATLON);        set(lat, lon, 0, 0, vResolution, hResolution, data);    }    /**     * Create a OMGrid that covers a x/y screen area.Column major by     * default. If your data is row major, use null for the data, set     * the major direction, and then set the data.     *      * @param x horizontal location, in pixels, of the left side of     *        the grid from the left side of the map.     * @param y vertical location, in pixels, of the top of the grid     *        from the top side of the map.     * @param vResolution the vertical resolution of the data, as     *        pixels per row.     * @param hResolution the horizontal resolution of the data, as     *        pixels per column.     * @param data GridData object holding rows and columns of grid data.     */    public OMGrid(int x, int y, float vResolution, float hResolution,            GridData data) {        setRenderType(RENDERTYPE_XY);        set(0.0f, 0.0f, x, y, vResolution, hResolution, data);    }    /**     * Create a OMGrid that covers a x/y screen area, anchored to a     * lat/lon point. Column major by default. If your data is row     * major, use null for the data, set the major direction, and then     * set the data.     *      * @param lat latitude of the anchor point of the grid, in decimal     *        degrees.     * @param lon longitude of the anchor point of the grid, in     *        decimal degrees.     * @param x horizontal location, in pixels, of the left side of

⌨️ 快捷键说明

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