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

📄 segmentplane.java

📁 world wind java sdk 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2001, 2008 United States Government as represented by
the Administrator of the National Aeronautics and Space Administration.
All Rights Reserved.
*/
package gov.nasa.worldwind.render;

import gov.nasa.worldwind.WWObjectImpl;
import gov.nasa.worldwind.geom.*;
import gov.nasa.worldwind.globes.Globe;
import gov.nasa.worldwind.util.Logging;

import java.util.*;

/**
 * @author dcollins
 * @version $Id: SegmentPlane.java 9630 2009-03-24 10:50:46Z dcollins $
 */
public class SegmentPlane extends WWObjectImpl
{
    public static class ControlPoint
    {
        private Object owner;
        private Object key;
        private double uCoordinate;
        private double vCoordinate;
        private boolean relativeToSurface;

        public ControlPoint(Object owner, Object key, double uCoordinate, double vCoordinate,
            boolean relativeToSurface)
        {
            if (owner == null)
            {
                String message = Logging.getMessage("nullValue.OwnerIsNull");
                Logging.logger().severe(message);
                throw new IllegalArgumentException(message);
            }
            if (key == null)
            {
                String message = Logging.getMessage("nullValue.KeyIsNull");
                Logging.logger().severe(message);
                throw new IllegalArgumentException(message);
            }

            this.owner = owner;
            this.key = key;
            this.uCoordinate = uCoordinate;
            this.vCoordinate = vCoordinate;
            this.relativeToSurface = relativeToSurface;
        }

        public Object getOwner()
        {
            return this.owner;
        }

        public Object getKey()
        {
            return this.key;
        }

        public double[] getCoordinates()
        {
            return new double[] {this.uCoordinate, this.vCoordinate};
        }

        public boolean isRelativeToSurface()
        {
            return this.relativeToSurface;
        }
    }

    protected static class StateKey
    {
        private final SegmentPlane segmentPlane;
        private final long serialNumber;

        public StateKey(SegmentPlane segmentPlane, long serialNumber)
        {
            this.segmentPlane = segmentPlane;
            this.serialNumber = serialNumber;
        }

        public boolean equals(Object o)
        {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;

            StateKey that = (StateKey) o;
            return this.segmentPlane.equals(that.segmentPlane) && (this.serialNumber == that.serialNumber);
        }

        public int hashCode()
        {
            int result = this.segmentPlane != null ? this.segmentPlane.hashCode() : 0;
            result = 31 * result + (int) (this.serialNumber ^ (this.serialNumber >>> 32));
            return result;
        }
    }

    public static final String ALTIMETER = "SegmentPlane.Altimeter";
    public static final String CONTROL_POINT_LOWER_LEFT = "SegmentPlane.ControlPointLowerLeft";
    public static final String CONTROL_POINT_LOWER_RIGHT = "SegmentPlane.ControlPointLowerRight";
    public static final String CONTROL_POINT_UPPER_RIGHT = "SegmentPlane.ControlPointUpperRight";
    public static final String CONTROL_POINT_TOP_EDGE = "SegmentPlane.ControlPointTopEdge";
    public static final String CONTROL_POINT_LEADING_EDGE = "SegmentPlane.ControlPointLeadingEdge";
    public static final String HORIZONTAL_AXIS_LABELS = "SegmentPlane.HorizontalAxisLabels";
    public static final String PLANE_ALTITUDES = "SegmentPlane.PlaneAltitudes";
    public static final String PLANE_BACKGROUND = "SegmentPlane.PlaneBackground";
    public static final String PLANE_BORDER = "SegmentPlane.PlaneBorder";
    public static final String PLANE_GRID = "SegmentPlane.PlaneGrid";
    public static final String PLANE_GRID_DIMENSIONS = "SegmentPlane.PlaneGridDimensions";
    public static final String PLANE_LOCATIONS = "SegmentPlane.PlaneLocations";
    public static final String PLANE_OUTLINE = "SegmentPlane.PlaneOutline";
    public static final String SEGMENT_BEGIN = "SegmentPlane.SegmentBegin";
    public static final String SEGMENT_END = "SegmentPlane.SegmentEnd";
    public static final String VERTICAL_AXIS_LABELS = "SegmentPlane.VerticalAxisLabels";

    public static final int TOP = 1;
    public static final int BOTTOM = 2;
    public static final int LEFT = 4;
    public static final int RIGHT = 8;

    private boolean visible;
    private SegmentPlaneAttributes attributes;
    private double planeLowerAltitude;
    private double planeUpperAltitude;
    private LatLon planeLocation1;
    private LatLon planeLocation2;
    private double gridCellWidth;
    private double gridCellHeight;
    private int planeOutlineMask;
    private int borderMask;
    private Position segmentBeginPosition;
    private Position segmentEndPosition;
    private List<ControlPoint> controlPointList;
    protected long serialNumber = 1;

    public SegmentPlane()
    {
        this.visible = true;
        this.attributes = new SegmentPlaneAttributes();
        this.planeLowerAltitude = 0.0;
        this.planeUpperAltitude = 0.0;
        this.planeLocation1 = LatLon.ZERO;
        this.planeLocation2 = LatLon.ZERO;
        this.gridCellWidth = 1.0;
        this.gridCellHeight = 1.0;
        this.planeOutlineMask = TOP | BOTTOM | LEFT | RIGHT;
        this.borderMask = TOP | BOTTOM | LEFT | RIGHT;
        this.segmentBeginPosition = Position.ZERO;
        this.segmentEndPosition = Position.ZERO;
        this.controlPointList = new ArrayList<ControlPoint>();

        this.addDefaultAttributes(PLANE_BACKGROUND);
        this.addDefaultAttributes(PLANE_GRID);
        this.addDefaultAttributes(PLANE_OUTLINE);
        this.addDefaultAttributes(PLANE_BORDER);
        this.addDefaultAttributes(SEGMENT_BEGIN);
        this.addDefaultAttributes(SEGMENT_END);
        this.addDefaultAttributes(ALTIMETER);

        this.addDefaultControlPoint(CONTROL_POINT_LOWER_LEFT,   0.0, 0.0, true);
        this.addDefaultControlPoint(CONTROL_POINT_LOWER_RIGHT,  1.0, 0.0, true);
        this.addDefaultControlPoint(CONTROL_POINT_UPPER_RIGHT,  1.0, 1.0, false);
        this.addDefaultControlPoint(CONTROL_POINT_TOP_EDGE,     0.5, 1.0, false);
        this.addDefaultControlPoint(CONTROL_POINT_LEADING_EDGE, 1.0, 0.5, true);
    }

    protected void addDefaultAttributes(Object key)
    {
        this.getAttributes().setGeometryAttributes(key, new SegmentPlaneAttributes.GeometryAttributes());
        this.getAttributes().setLabelAttributes(key, new SegmentPlaneAttributes.LabelAttributes());
    }

    protected void addDefaultControlPoint(Object key, double u, double v, boolean relativeToSurface)
    {
        this.addControlPoint(new ControlPoint(this, key, u, v, relativeToSurface));
        this.addDefaultAttributes(key);
    }

    public boolean isVisible()
    {
        return this.visible;
    }

    public void setVisible(boolean visible)
    {
        this.visible = visible;
    }

    public SegmentPlaneAttributes getAttributes()
    {
        return attributes;
    }

    public void setAttributes(SegmentPlaneAttributes attributes)
    {
        if (attributes == null)
        {
            String message = Logging.getMessage("nullValue.AttributesIsNull");
            Logging.logger().severe(message);
            throw new IllegalArgumentException(message);
        }

        this.attributes = attributes;
    }

    public double[] getPlaneAltitudes()
    {
        return new double[] {this.planeLowerAltitude, this.planeUpperAltitude};
    }

    /**
     * Set the upper and lower altitude limits.
     *
     * @param lowerAltitude the lower altitude limit, in meters relative to mean sea level
     * @param upperAltitude the upper altitude limit, in meters relative to mean sea level
     */
    public void setPlaneAltitudes(double lowerAltitude, double upperAltitude)
    {
        double[] oldAltitudes = this.getPlaneAltitudes();

        this.planeLowerAltitude = lowerAltitude;
        this.planeUpperAltitude = upperAltitude;
        this.setStateExpired();

⌨️ 快捷键说明

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