sarsegmentplane.java

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

JAVA
913
字号
/* 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.applications.sar;import gov.nasa.worldwind.*;import gov.nasa.worldwind.avlist.*;import gov.nasa.worldwind.geom.*;import gov.nasa.worldwind.globes.Globe;import gov.nasa.worldwind.render.*;import gov.nasa.worldwind.terrain.SectorGeometryList;import gov.nasa.worldwind.util.*;import java.awt.*;import java.beans.PropertyChangeEvent;/** * @author dcollins * @version $Id: SARSegmentPlane.java 9630 2009-03-24 10:50:46Z dcollins $ */public class SARSegmentPlane extends WWObjectImpl{    private String angleFormat;    private String elevationUnit;    private WorldWindow wwd; // Can be null.    // Segment plane components.    private SegmentPlane segmentPlane;    private SegmentPlaneEditor segmentPlaneEditor;    private SegmentPlaneController segmentPlaneController;    private boolean modifiedSinceLastArm = false;        private boolean ignorePlaneChangeEvents = false;    public SARSegmentPlane()    {        this.segmentPlane = new SegmentPlane();        this.segmentPlaneEditor = new SegmentPlaneEditor();        this.segmentPlaneController = new SegmentPlaneController(null);        this.segmentPlane.setVisible(false);        this.segmentPlane.addPropertyChangeListener(this);        this.segmentPlaneEditor.setSegmentPlane(this.segmentPlane);        this.segmentPlaneController.setEditor(this.segmentPlaneEditor);        this.initSegmentPlane();    }    public boolean isVisible()    {        return this.segmentPlane.isVisible();    }    public void setVisible(boolean visible)    {        this.segmentPlane.setVisible(visible);    }        public boolean isArmed()    {        return this.segmentPlaneEditor.isArmed();    }    public void setArmed(boolean armed)    {        if (armed && !(this.segmentPlaneEditor.isArmed()))        {            this.modifiedSinceLastArm = false;        }        this.segmentPlaneEditor.setArmed(armed);    }    public boolean isSnapToGrid()    {        return this.segmentPlaneEditor.isSnapToGrid();    }    public void setSnapToGrid(boolean snapToGrid)    {        this.segmentPlaneEditor.setSnapToGrid(snapToGrid);    }    public double[] getGridCellDimensions()    {        return this.segmentPlane.getGridCellDimensions();    }    public void setGridCellDimensions(double width, double height)    {        this.segmentPlane.setGridCellDimensions(width, height);    }    public String getAngleFormat()    {        return this.angleFormat;    }    public void setAngleFormat(String angleFormat)    {        this.angleFormat = angleFormat;    }    public String getElevationUnit()    {        return this.elevationUnit;    }    public void setElevationUnit(String elevationUnit)    {        this.elevationUnit = elevationUnit;    }    public WorldWindow getWorldWindow()    {        return this.wwd;    }    public void setWorldWindow(WorldWindow wwd)    {        if (this.wwd == wwd)            return;        if (this.wwd != null)        {            this.wwd.removePropertyChangeListener(this);            if (this.wwd.getModel().getLayers().contains(this.segmentPlaneEditor))            {                this.wwd.getModel().getLayers().remove(this.segmentPlaneEditor);            }        }        this.wwd = wwd;        this.segmentPlaneController.setWorldWindow(wwd);        if (this.wwd != null)        {            this.wwd.addPropertyChangeListener(this);            if (!this.wwd.getModel().getLayers().contains(this.segmentPlaneEditor))            {                this.wwd.getModel().getLayers().add(this.segmentPlaneEditor);            }        }    }    @SuppressWarnings({"StringEquality"})    public void propertyChange(PropertyChangeEvent e)    {        String propertyName = e.getPropertyName();        if (e.getSource() == this.segmentPlane)        {            this.modifiedSinceLastArm = true;        }        if (propertyName == SegmentPlane.SEGMENT_BEGIN || propertyName == SegmentPlane.SEGMENT_END)        {            if (!this.ignorePlaneChangeEvents)            {                super.propertyChange(e);            }        }        else if (propertyName == SAR2.ANGLE_FORMAT)        {            if (e.getNewValue() != null)            {                this.setAngleFormat(e.getNewValue().toString());                super.propertyChange(e);            }        }        else if (propertyName == SAR2.ELEVATION_UNIT)        {            if (e.getNewValue() != null)            {                this.setElevationUnit(e.getNewValue().toString());                super.propertyChange(e);            }        }    }    public Position[] getSegmentPositions()    {        return this.segmentPlane.getSegmentPositions();    }    public void setSegmentPositions(Position position1, Position position2)    {        this.ignorePlaneChangeEvents = true;        try        {            this.segmentPlane.setSegmentPositions(position1, position2);        }        finally        {            this.ignorePlaneChangeEvents = false;        }    }    public double[] getPlaneAltitudes()    {        return this.segmentPlane.getPlaneAltitudes();    }    public void setPlaneAltitudes(double lowerAltitude, double upperAltitude)    {        this.ignorePlaneChangeEvents = true;        try        {            this.segmentPlane.setPlaneAltitudes(lowerAltitude, upperAltitude);        }        finally        {            this.ignorePlaneChangeEvents = false;        }    }    public LatLon[] getPlaneLocations()    {        return this.segmentPlane.getPlaneLocations();    }    public void setPlaneLocations(LatLon location1, LatLon location2)    {        this.ignorePlaneChangeEvents = true;        try        {            this.segmentPlane.setPlaneLocations(location1, location2);        }        finally        {            this.ignorePlaneChangeEvents = false;        }    }    public SegmentPlaneAttributes getAttributes()    {        return this.segmentPlane.getAttributes();    }    public void setAttributes(SegmentPlaneAttributes attributes)    {        this.segmentPlane.setAttributes(attributes);    }    public void setObjectVisible(String key, boolean geometryVisible, boolean labelVisible)    {        SegmentPlaneAttributes.GeometryAttributes geometryAttributes =            this.segmentPlane.getAttributes().getGeometryAttributes(key);        if (geometryAttributes != null)        {            geometryAttributes.setVisible(geometryVisible);        }        SegmentPlaneAttributes.LabelAttributes labelAttributes =            this.segmentPlane.getAttributes().getLabelAttributes(key);        if (labelAttributes != null)        {            labelAttributes.setVisible(labelVisible);        }    }    public double[] computeAltitudesToFitPositions(Iterable<? extends Position> positions)    {        if (this.wwd == null)        {            String message = Logging.getMessage("nullValue.WorldWindow");            Logging.logger().severe(message);            throw new IllegalStateException(message);        }                return computeAltitudesToFitPositions(this.wwd, this.segmentPlane, positions, this.modifiedSinceLastArm);    }    public LatLon[] computeLocationsToFitPositions(Position position1, Position position2)    {        if (this.wwd == null)        {            String message = Logging.getMessage("nullValue.WorldWindow");            Logging.logger().severe(message);            throw new IllegalStateException(message);        }        return computeLocationsToFitPositions(this.wwd, this.segmentPlane, position1, position2,            this.modifiedSinceLastArm);    }    public Position getIntersectionPosition(Line line)    {        if (line == null)        {            String message = Logging.getMessage("nullValue.LineIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (this.wwd == null)        {            String message = Logging.getMessage("nullValue.WorldWindow");            Logging.logger().severe(message);            throw new IllegalStateException(message);        }        Globe globe = this.wwd.getModel().getGlobe();                Vec4 point = this.segmentPlaneEditor.getSegmentPlaneRenderer().intersect(globe, line, this.segmentPlane);        if (point == null)

⌨️ 快捷键说明

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