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

📄 surfacesector.java

📁 world wind java sdk 源码
💻 JAVA
字号:
/* Copyright (C) 2001, 2009 United States Government as represented bythe Administrator of the National Aeronautics and Space Administration.All Rights Reserved.*/package gov.nasa.worldwind.render;import gov.nasa.worldwind.avlist.AVKey;import gov.nasa.worldwind.geom.*;import gov.nasa.worldwind.globes.Globe;import gov.nasa.worldwind.util.*;/** * @author dcollins * @version $Id: SurfaceSector.java 10634 2009-04-29 03:52:29Z dcollins $ */public class SurfaceSector extends SurfaceConcaveShape{    protected static final String SECTOR_DEFAULT_PATH_TYPE = AVKey.GREAT_CIRCLE;    protected Sector sector;    public SurfaceSector(ShapeAttributes attributes, Sector sector)    {        super(attributes);        if (sector == null)        {            String message = Logging.getMessage("nullValue.SectorIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.sector = sector;        this.setPathType(SECTOR_DEFAULT_PATH_TYPE);    }    public SurfaceSector(ShapeAttributes attributes)    {        this(attributes, Sector.EMPTY_SECTOR);    }    public SurfaceSector(Sector sector)    {        this(new BasicShapeAttributes(), sector);    }    public SurfaceSector()    {        this(new BasicShapeAttributes());    }    public Sector getSector()    {        return this.sector;    }    public void setSector(Sector sector)    {        if (sector == null)        {            String message = Logging.getMessage("nullValue.SectorIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        this.sector = sector;        this.onShapeChanged();    }    public Position getReferencePosition()    {        return new Position(this.sector.getCentroid(), 0);    }    protected void computeLocations(Globe globe, java.util.List<LatLon> locations)    {        if (globe == null)        {            String message = Logging.getMessage("nullValue.GlobeIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (locations == null)        {            String message = Logging.getMessage("nullValue.LocationsListIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        locations.addAll(this.sector.asList());        getSurfaceShapeSupport().makeClosedPath(locations);    }    protected void computeDrawLocations(Globe globe, double edgeIntervalsPerDegree, java.util.List<LatLon> locations)    {        if (globe == null)        {            String message = Logging.getMessage("nullValue.GlobeIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (locations == null)        {            String message = Logging.getMessage("nullValue.LocationsListIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        getSurfaceShapeSupport().generateIntermediateLocations(this.sector, this.pathType,            edgeIntervalsPerDegree, this.minEdgeIntervals, this.maxEdgeIntervals, true, locations);    }    protected void doMoveTo(Position oldReferencePosition, Position newReferencePosition)    {        LatLon[] locations = new LatLon[]        {            new LatLon(this.sector.getMinLatitude(), this.sector.getMinLongitude()),            new LatLon(this.sector.getMaxLatitude(), this.sector.getMaxLongitude())        };        LatLon[] newLocations = new LatLon[2];        for (int i = 0; i < 2; i++)        {            Angle heading = LatLon.greatCircleAzimuth(oldReferencePosition, locations[i]);            Angle pathLength = LatLon.greatCircleDistance(oldReferencePosition, locations[i]);            newLocations[i] = LatLon.greatCircleEndPosition(newReferencePosition, heading, pathLength);        }        this.setSector(new Sector(            newLocations[0].getLatitude(), newLocations[1].getLatitude(),            newLocations[0].getLongitude(), newLocations[1].getLongitude()));    }    //**************************************************************//    //******************** Restorable State  ***********************//    //**************************************************************//    protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)    {        super.doGetRestorableState(rs, context);        rs.addStateValueAsSector(context, "sector", this.getSector());    }    protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)    {        super.doRestoreState(rs, context);        Sector sector = rs.getStateValueAsSector(context, "sector");        if (sector != null)            this.setSector(sector);    }    protected void legacyRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)    {        super.legacyRestoreState(rs, context);        // Previous versions of SurfaceSector would have stored the locations produced by treating the sector as a list        // of polygon locations. To restore an shape saved from the previous version, we compute the bounding sector of        // those locations to define a sector.        java.util.ArrayList<LatLon> locations = rs.getStateValueAsLatLonList(context, "locations");        if (locations != null)            this.setSector(Sector.boundingSector(locations));    }}

⌨️ 快捷键说明

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