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

📄 omarc.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************//// <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/OMArc.java,v $// $RCSfile: OMArc.java,v $// $Revision: 1.5.2.3 $// $Date: 2005/01/10 16:59:43 $// $Author: dietrick $//// **********************************************************************package com.bbn.openmap.omGraphics;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Point;import java.awt.Shape;import java.awt.geom.AffineTransform;import java.awt.geom.Arc2D;import java.awt.geom.GeneralPath;import java.awt.geom.PathIterator;import java.io.Serializable;import java.util.ArrayList;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.proj.Cylindrical;import com.bbn.openmap.proj.Length;import com.bbn.openmap.proj.ProjMath;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;/** * Graphic object that represents an arc. * <p> * <h3>NOTE:</h3> * See the <a * href="com.bbn.openmap.proj.Projection.html#poly_restrictions"> * RESTRICTIONS </a> on Lat/Lon polygons/polylines which apply to arcs * as well. Not following the guidelines listed may result in * ambiguous/undefined shapes! Similar assumptions apply to the other * vector graphics that we define: polys, rects, lines. * <p> * These assumptions are virtually the same as those on the more * generic OMPoly graphic type. * <p> *  * @see OMPoly */public class OMArc extends OMGraphic implements Serializable {    /** Horizontal pixel location of the center. */    protected int x1 = 0;    /** Vertical pixel location of the center. */    protected int y1 = 0;    /** Horizontal pixel offset. */    protected int off_x = 0;    /** Vertical pixel offset. */    protected int off_y = 0;    /**     * Center point.     */    protected LatLonPoint center;    /**     * Radius of arc in radians. For LATLON arc. Note that the methods     * for this class use Decimal Degrees, or ask for a Length object     * to use for units. The radius is converted to radians for     * internal use.     */    protected float radius = 0.0f;    /**     * The pixel horizontal diameter of the arc. For XY and OFFSET     * arcs.     */    protected int width = 0;    /**     * The pixel vertical diameter of the arc. For XY and OFFSET arcs.     */    protected int height = 0;    /**     * The starting angle of the arc in decimal degrees. This is     * defined in decimal degrees because the java.awt.geom.Arc object     * wants it in decimal degrees. 0 is North?     */    protected float start = 0.0f;    /**     * The angular extent of the arc in decimal degrees.     */    protected float extent = 360.0f;    /**     * For Arcs, how the arc should be closed when rendered.     * Arc2D.OPEN is the default, Arc2D.PIE and Arc2D.CHORD are     * options.     *      * @see java.awt.geom.Arc2D     */    protected int arcType = Arc2D.OPEN;    /**     * Used to render arc in Cylindrical projections when the arc     * encompases a pole.     */    private GeneralPath polarShapeLine = null;    /**     * Indicates that the polarShapeLine should be used for rendering.     */    private boolean correctFill = false;    /** Force the correct polar hack. */    private boolean correctPolar = false;    /**     * Number of vertices to draw for lat/lon poly-arcs.     */    protected int nverts;    /**     * The angle by which the circle/ellipse is to be rotated, in     * radians     */    protected double rotationAngle = DEFAULT_ROTATIONANGLE;    /**     * The simplest constructor for an OMArc, and it expects that all     * fields will be filled in later. Rendertype is     * RENDERTYPE_UNKNOWN.     */    public OMArc() {        super(RENDERTYPE_UNKNOWN, LINETYPE_UNKNOWN, DECLUTTERTYPE_NONE);    }    /**     * Create an OMArc, positioned with a lat-lon center and x-y axis.     * Rendertype is RENDERTYPE_OFFSET.     *      * @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     */    public OMArc(float latPoint, float lonPoint, int w, int h, float s, float e) {        this(latPoint, lonPoint, 0, 0, w, h, s, e);    }    /**     * Create a OMArc, positioned with a x-y center with x-y axis.     * Rendertype is RENDERTYPE_XY.     *      * @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. For XY     *        rendertype arcs, positive extents go in the     *        counter-clockwise direction, matching the     *        java.awt.geom.Arc2D convention.     */    public OMArc(int x1, int y1, int w, int h, float s, float e) {        super(RENDERTYPE_XY, LINETYPE_UNKNOWN, DECLUTTERTYPE_NONE);        this.x1 = x1;        this.y1 = y1;        width = w;        height = h;        start = s;        extent = e;    }    /**     * Create a OMArc, positioned at a Lat-lon location, x-y offset,     * x-y axis. Rendertype is RENDERTYPE_OFFSET.     *      * @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. For Offset     *        rendertype arcs, positive extents go in the     *        counter-clockwise direction, matching the     *        java.awt.geom.Arc2D convention.     */    public OMArc(float latPoint, float lonPoint, int offset_x1, int offset_y1,            int w, int h, float s, float e) {        super(RENDERTYPE_OFFSET, LINETYPE_UNKNOWN, DECLUTTERTYPE_NONE);        center = new LatLonPoint(latPoint, lonPoint);        off_x = offset_x1;        off_y = offset_y1;        width = w;        height = h;        start = s;        extent = e;    }    /**     * Creates an OMArc with a Lat-lon center and a lat-lon axis.     * Rendertype is RENDERTYPE_LATLON.     *      * @param latPoint latitude of center point, decimal degrees     * @param lonPoint longitude of center point, decimal degrees     * @param radius distance in decimal degrees (converted to radians     *        internally).     * @param s starting angle of arc, decimal degrees     * @param e angular extent of arc, decimal degrees. For LATLON     *        rendertype arcs, positive extents go in the clockwise     *        direction, matching the OpenMap convention in coordinate     *        space.     */    public OMArc(float latPoint, float lonPoint, float radius, float s, float e) {        this(new LatLonPoint(latPoint, lonPoint),             radius,             Length.DECIMAL_DEGREE,             -1,             s,             e);    }    /**     * Create an OMArc with a lat/lon center and a physical distance     * radius. Rendertype is RENDERTYPE_LATLON.     *      * @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 com.bbn.openmap.proj.Length object.     * @param s starting angle of arc, decimal degrees.     * @param e angular extent of arc, decimal degrees. For LATLON     *        rendertype arcs, positive extents go in the clockwise     *        direction, matching the OpenMap convention in coordinate     *        space.     */    public OMArc(float latPoint, float lonPoint, float radius, Length units,            float s, float e) {        this(new LatLonPoint(latPoint, lonPoint), radius, units, -1, s, e);    }    /**     * Create an OMArc with a lat/lon center and a physical distance     * radius. Rendertype is RENDERTYPE_LATLON.     *      * @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 com.bbn.openmap.proj.Length object specifying     *        units.     * @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. For LATLON     *        rendertype arcs, positive extents go in the clockwise     *        direction, matching the OpenMap convention in coordinate     *        space.     */    public OMArc(float latPoint, float lonPoint, float radius, Length units,            int nverts, float s, float e) {        this(new LatLonPoint(latPoint, lonPoint), radius, units, nverts, s, e);    }    /**     * Create an OMArc with a lat/lon center and a physical distance     * radius. Rendertype is RENDERTYPE_LATLON.     *      * @param center LatLon center of arc     * @param radius distance     * @param units com.bbn.openmap.proj.Length object specifying     *        units for distance.     * @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. For LATLON     *        rendertype arcs, positive extents go in the clockwise     *        direction, matching the OpenMap convention in coordinate     *        space.     */    public OMArc(LatLonPoint center, float radius, Length units, int nverts,            float s, float e) {        super(RENDERTYPE_LATLON, LINETYPE_UNKNOWN, DECLUTTERTYPE_NONE);        this.radius = units.toRadians(radius);        this.center = center;        this.nverts = nverts;        this.start = s;        this.extent = e;    }    /**     * Get the x position of the center. This is always meaningful     * only if the render type is RENDERTYPE_XY or RENDERTYPE_OFFSET,     * and meaningful after generation if the RENDERTYPE_LATLON.     *      * @return x position of center.     */    public int getX() {        return x1;    }    /**     * Get the y position of the center. This is always meaningful     * only if the render type is RENDERTYPE_XY or RENDERTYPE_OFFSET,     * and meaningful after generation if the RENDERTYPE_LATLON.     *      * @return y position of center.     */    public int getY() {        return y1;    }    /**     * Get the x offset from the center. This is meaningful only if     * the render type is RENDERTYPE_OFFSET.     *      * @return x offset from center.     */    public int getOffX() {        return off_x;    }    /**     * Get the y position of the center. This is meaningful only if     * the render type is RENDERTYPE_OFFSET.     *      * @return y offset from center.     */    public int getOffY() {        return off_y;    }    /**     * Get the center LatLonPoint. This is meaningful only if the     * rendertype is RENDERTYPE_LATLON or RENDERTYPE_OFFSET.     *      * @return LatLonPoint position of center.     */    public LatLonPoint getLatLon() {        return center;    }    /**     * Get the radius. This is meaningful only if the render type is     * RENDERTYPE_LATLON.     *      * @return float radius in decimal degrees     */    public float getRadius() {        return Length.DECIMAL_DEGREE.fromRadians(radius);    }    /**     * Get the horizontal pixel diameter of the arc. This is     * meaningful only if the render type is RENDERTYPE_XY or     * RENDERTYPE_OFFSET.     *      * @return the horizontal pixel diameter of the arc.     */    public int getWidth() {        return width;    }    /**     * Get the vertical pixel diameter of the arc. This is meaningful     * only if the render type is RENDERTYPE_XY or RENDERTYPE_OFFSET.     *      * @return the vertical pixel diameter of the arc.     */    public int getHeight() {        return height;    }    /**     * Get the starting angle of the arc.     *      * @return the starting angle of the arc in decimal degrees.     */    public float getStartAngle() {        return start;    }    /**     * Get the extent angle of the arc.     *      * @return the angular extent of the arc in decimal degrees. For     *         LATLON rendertype arcs, positive extents go in the     *         clockwise direction, matching the OpenMap convention in     *         coordinate space. For XY and OFFSET rendertype arcs,     *         positive extents go in the clockwise direction,     *         matching the java.awt.geom.Arc2D convention.     */    public float getExtentAngle() {        return extent;    }    /**     * Get the number of vertices of the lat/lon arc. This will be     * meaningful only if the render type is RENDERTYPE_XY or     * RENDERTYPE_OFFSET and for LINETYPE_GREATARC or LINETYPE_RHUMB     * line types.     *      * @return int number of segment points     */    public int getNumVerts() {        return nverts;    }    /**     * Set the x position of the center. This will be meaningful only     * if the render type is RENDERTYPE_XY.     *      * @param value the x position of center.     */    public void setX(int value) {        if (x1 == value)            return;        x1 = value;        setNeedToRegenerate(true);    }    /**     * Set the y position of the center. This will be meaningful only     * if the render type is RENDERTYPE_XY.     *      * @param value the y position of center.     */    public void setY(int value) {        if (y1 == value)            return;        y1 = value;        setNeedToRegenerate(true);    }    /**     * Set the x offset from the center. This will be meaningful only     * if the render type is RENDERTYPE_OFFSET.     *      * @param value the x position of center.     */    public void setOffX(int value) {        if (off_x == value)

⌨️ 快捷键说明

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