orbit.java

来自「world wind java sdk 源码」· Java 代码 · 共 827 行 · 第 1/3 页

JAVA
827
字号
/*Copyright (C) 2001, 2008 United States Governmentas represented by the Administrator of theNational Aeronautics and Space Administration.All Rights Reserved.*/package gov.nasa.worldwind.render.airspaces;import gov.nasa.worldwind.geom.*;import gov.nasa.worldwind.globes.Globe;import gov.nasa.worldwind.render.DrawContext;import gov.nasa.worldwind.util.GeometryBuilder;import gov.nasa.worldwind.util.Logging;import gov.nasa.worldwind.util.RestorableSupport;import javax.media.opengl.GL;import java.util.ArrayList;import java.util.List;/** * @author tag * @version $Id: Orbit.java 9232 2009-03-06 05:52:06Z dcollins $ */public class Orbit extends AbstractAirspace{    public interface OrbitType    {        public static final String LEFT = "Left";        public static final String CENTER = "Center";        public static final String RIGHT = "Right";    }    protected static final int DEFAULT_ARC_SLICES = 16;    protected static final int DEFAULT_LENGTH_SLICES = 32;    protected static final int DEFAULT_STACKS = 1;    protected static final int DEFAULT_LOOPS = 4;        private LatLon location1 = LatLon.ZERO;    private LatLon location2 = LatLon.ZERO;    private String orbitType = OrbitType.CENTER;    private double width = 1.0;    private boolean enableCaps = true;    // Geometry.    private int arcSlices = DEFAULT_ARC_SLICES;    private int lengthSlices = DEFAULT_LENGTH_SLICES;    private int stacks = DEFAULT_STACKS;    private int loops = DEFAULT_LOOPS;    public Orbit(LatLon location1, LatLon location2, String orbitType, double width)    {        if (location1 == null)        {            String message = "nullValue.Location1IsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (location2 == null)        {            String message = "nullValue.Location2IsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (orbitType == null)        {            String message = "nullValue.OrbitTypeIsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (width < 0.0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", "width=" + width);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }                this.location1 = location1;        this.location2 = location2;        this.orbitType = orbitType;        this.width = width;        this.makeDefaultDetailLevels();    }    public Orbit(AirspaceAttributes attributes)    {        super(attributes);        this.makeDefaultDetailLevels();    }    public Orbit()    {        this.makeDefaultDetailLevels();    }    private void makeDefaultDetailLevels()    {        List<DetailLevel> levels = new ArrayList<DetailLevel>();        double[] ramp = ScreenSizeDetailLevel.computeDefaultScreenSizeRamp(5);        DetailLevel level;        level = new ScreenSizeDetailLevel(ramp[0], "Detail-Level-0");        level.setValue(ARC_SLICES,    16);        level.setValue(LENGTH_SLICES, 32);        level.setValue(STACKS,        1);        level.setValue(LOOPS,         4);        level.setValue(DISABLE_TERRAIN_CONFORMANCE, false);        levels.add(level);        level = new ScreenSizeDetailLevel(ramp[1], "Detail-Level-1");        level.setValue(ARC_SLICES,    13);        level.setValue(LENGTH_SLICES, 25);        level.setValue(STACKS,        1);        level.setValue(LOOPS,         3);        level.setValue(DISABLE_TERRAIN_CONFORMANCE, false);        levels.add(level);        level = new ScreenSizeDetailLevel(ramp[2], "Detail-Level-2");        level.setValue(ARC_SLICES,    10);        level.setValue(LENGTH_SLICES, 18);        level.setValue(STACKS,        1);        level.setValue(LOOPS,         2);        level.setValue(DISABLE_TERRAIN_CONFORMANCE, false);        levels.add(level);        level = new ScreenSizeDetailLevel(ramp[3], "Detail-Level-3");        level.setValue(ARC_SLICES,    7);        level.setValue(LENGTH_SLICES, 11);        level.setValue(STACKS,        1);        level.setValue(LOOPS,         1);        level.setValue(DISABLE_TERRAIN_CONFORMANCE, false);        levels.add(level);        level = new ScreenSizeDetailLevel(ramp[4], "Detail-Level-4");        level.setValue(ARC_SLICES,    4);        level.setValue(LENGTH_SLICES, 4);        level.setValue(STACKS,        1);        level.setValue(LOOPS,         1);        level.setValue(DISABLE_TERRAIN_CONFORMANCE, true);        levels.add(level);        this.setDetailLevels(levels);    }    public LatLon[] getLocations()    {        LatLon[] array = new LatLon[2];        array[0] = this.location1;        array[1] = this.location2;        return array;    }    public void setLocations(LatLon location1, LatLon location2)    {        if (location1 == null)        {            String message = "nullValue.Location1IsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (location2 == null)        {            String message = "nullValue.Location2IsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.location1 = location1;        this.location2 = location2;        this.setExtentOutOfDate();    }    public String getOrbitType()    {        return this.orbitType;    }    public void setOrbitType(String orbitType)    {        if (orbitType == null)        {            String message = "nullValue.OrbitTypeIsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.orbitType = orbitType;        this.setExtentOutOfDate();    }    public double getWidth()    {        return this.width;    }    public void setWidth(double width)    {        if (width < 0.0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", "width=" + width);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.width = width;        this.setExtentOutOfDate();    }    public boolean isEnableCaps()    {        return this.enableCaps;    }    public void setEnableCaps(boolean enable)    {        this.enableCaps = enable;    }    public Position getReferencePosition()    {        double[] altitudes = this.getAltitudes();        return new Position(this.location1, altitudes[0]);    }    protected void doMoveTo(Position oldRef, Position newRef)    {        if (oldRef == null)        {            String message = "nullValue.OldRefIsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (newRef == null)        {            String message = "nullValue.NewRefIsNull";            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        super.doMoveTo(oldRef, newRef);        LatLon[] locations = this.getLocations();        int count = locations.length;        for (int i = 0; i < count; i++)        {            double distance = LatLon.greatCircleDistance(oldRef, locations[i]).radians;            double azimuth = LatLon.greatCircleAzimuth(oldRef, locations[i]).radians;            locations[i] = LatLon.greatCircleEndPosition(newRef, azimuth, distance);        }        this.setLocations(locations[0], locations[1]);    }    protected int getArcSlices()    {        return this.arcSlices;    }    protected void setArcSlices(int arcSlices)    {        if (arcSlices < 0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", "arcSlices=" + arcSlices);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.arcSlices = arcSlices;    }    protected int getLengthSlices()    {        return this.lengthSlices;    }    protected void setLengthSlices(int lengthSlices)    {        if (lengthSlices < 0)

⌨️ 快捷键说明

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