scheduledorbitviewstateiterator.java

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

JAVA
473
字号
        OrbitViewAnimator animator = new BasicOrbitViewAnimator.DoubleAnimator(begin, end, propertyAccessor);        return new ScheduledOrbitViewStateIterator(lengthMillis, animator, smoothed);    }    public static ScheduledOrbitViewStateIterator createCenterHeadingPitchIterator(        Position beginCenter, Position endCenter,        Angle beginHeading, Angle endHeading,        Angle beginPitch, Angle endPitch,        long lengthMillis, boolean smoothed)    {        if (beginCenter == null || endCenter == null)        {            String message = Logging.getMessage("nullValue.PositionIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (beginHeading == null || endHeading == null || beginPitch == null || endPitch == null)        {            String message = Logging.getMessage("nullValue.AngleIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (lengthMillis < 0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", lengthMillis);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        OrbitViewPropertyAccessor.PositionAccessor cPropAccessor =                OrbitViewPropertyAccessor.createCenterPositionAccessor();        OrbitViewPropertyAccessor.AngleAccessor hPropAccessor = OrbitViewPropertyAccessor.createHeadingAccessor();        OrbitViewPropertyAccessor.AngleAccessor pPropAccessor = OrbitViewPropertyAccessor.createPitchAccessor();        OrbitViewAnimator cAnimator = new BasicOrbitViewAnimator.PositionAnimator(beginCenter, endCenter, cPropAccessor);        OrbitViewAnimator hAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginHeading, endHeading, hPropAccessor);        OrbitViewAnimator pAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginPitch, endPitch, pPropAccessor);        OrbitViewAnimator animator = new BasicOrbitViewAnimator.CompoundAnimator(cAnimator, hAnimator, pAnimator);        return new ScheduledOrbitViewStateIterator(lengthMillis, animator, smoothed);    }    public static ScheduledOrbitViewStateIterator createCenterZoomIterator(        Position beginCenter, Position endCenter,        double beginZoom, double endZoom,        long lengthMillis, boolean smoothed)    {        if (beginCenter == null || endCenter == null)        {            String message = Logging.getMessage("nullValue.PositionIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (lengthMillis < 0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", lengthMillis);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        OrbitViewPropertyAccessor.PositionAccessor cPropAccessor =                OrbitViewPropertyAccessor.createCenterPositionAccessor();        OrbitViewPropertyAccessor.DoubleAccessor zPropAccessor = OrbitViewPropertyAccessor.createZoomAccessor();        OrbitViewAnimator cAnimator = new BasicOrbitViewAnimator.PositionAnimator(beginCenter, endCenter, cPropAccessor);        OrbitViewAnimator zAnimator = new BasicOrbitViewAnimator.DoubleAnimator(beginZoom, endZoom, zPropAccessor);        OrbitViewAnimator animator = new BasicOrbitViewAnimator.CompoundAnimator(cAnimator, zAnimator);        return new ScheduledOrbitViewStateIterator(lengthMillis, animator, smoothed);    }    public static ScheduledOrbitViewStateIterator createCenterHeadingPitchZoomIterator(        Position beginCenter, Position endCenter,        Angle beginHeading, Angle endHeading,        Angle beginPitch, Angle endPitch,        double beginZoom, double endZoom,        long lengthMillis, boolean smoothed)    {        if (beginCenter == null || endCenter == null)        {            String message = Logging.getMessage("nullValue.PositionIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (beginHeading == null || endHeading == null || beginPitch == null || endPitch == null)        {            String message = Logging.getMessage("nullValue.AngleIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (lengthMillis < 0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", lengthMillis);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        OrbitViewPropertyAccessor.PositionAccessor cPropAccessor =                OrbitViewPropertyAccessor.createCenterPositionAccessor();        OrbitViewPropertyAccessor.AngleAccessor hPropAccessor = OrbitViewPropertyAccessor.createHeadingAccessor();        OrbitViewPropertyAccessor.AngleAccessor pPropAccessor = OrbitViewPropertyAccessor.createPitchAccessor();        OrbitViewPropertyAccessor.DoubleAccessor zPropAccessor = OrbitViewPropertyAccessor.createZoomAccessor();        OrbitViewAnimator cAnimator = new BasicOrbitViewAnimator.PositionAnimator(beginCenter, endCenter, cPropAccessor);        OrbitViewAnimator hAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginHeading, endHeading, hPropAccessor);        OrbitViewAnimator pAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginPitch, endPitch, pPropAccessor);        OrbitViewAnimator zAnimator = new BasicOrbitViewAnimator.DoubleAnimator(beginZoom, endZoom, zPropAccessor);        OrbitViewAnimator animator = new BasicOrbitViewAnimator.CompoundAnimator(            cAnimator, hAnimator, pAnimator, zAnimator);        return new ScheduledOrbitViewStateIterator(lengthMillis, animator, smoothed);    }    public static ScheduledOrbitViewStateIterator createHeadingPitchIterator(        Angle beginHeading, Angle endHeading,        Angle beginPitch, Angle endPitch)    {        if (beginHeading == null || endHeading == null || beginPitch == null || endPitch == null)        {            String message = Logging.getMessage("nullValue.AngleIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        final long MIN_LENGTH_MILLIS = 500;        final long MAX_LENGTH_MILLIS = 3000;        long headingLengthMillis = getScaledLengthMillis(            beginHeading, endHeading, Angle.POS180,            MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS);        long pitchLengthMillis = getScaledLengthMillis(            beginPitch, endPitch, Angle.POS90,            MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS / 2L);        long lengthMillis = headingLengthMillis + pitchLengthMillis;        boolean smoothed = true;        return createHeadingPitchIterator(            beginHeading, endHeading,            beginPitch, endPitch,            lengthMillis, smoothed);    }    public static ScheduledOrbitViewStateIterator createHeadingPitchIterator(        Angle beginHeading, Angle endHeading,        Angle beginPitch, Angle endPitch,        long lengthMillis, boolean smoothed)    {        if (beginHeading == null || endHeading == null || beginPitch == null || endPitch == null)        {            String message = Logging.getMessage("nullValue.AngleIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (lengthMillis < 0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", lengthMillis);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        OrbitViewPropertyAccessor.AngleAccessor hPropAccessor = OrbitViewPropertyAccessor.createHeadingAccessor();        OrbitViewPropertyAccessor.AngleAccessor pPropAccessor = OrbitViewPropertyAccessor.createPitchAccessor();        OrbitViewAnimator hAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginHeading, endHeading, hPropAccessor);        OrbitViewAnimator pAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginPitch, endPitch, pPropAccessor);        OrbitViewAnimator animator = new BasicOrbitViewAnimator.CompoundAnimator(hAnimator, pAnimator);        return new ScheduledOrbitViewStateIterator(lengthMillis, animator, smoothed);    }    public static ScheduledOrbitViewStateIterator createHeadingPitchZoomIterator(        Angle beginHeading, Angle endHeading,        Angle beginPitch, Angle endPitch,        double beginZoom, double endZoom,        long lengthMillis, boolean smoothed)    {        if (beginHeading == null || endHeading == null || beginPitch == null || endPitch == null)        {            String message = Logging.getMessage("nullValue.AngleIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (lengthMillis < 0)        {            String message = Logging.getMessage("generic.ArgumentOutOfRange", lengthMillis);            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        OrbitViewPropertyAccessor.AngleAccessor hPropAccessor = OrbitViewPropertyAccessor.createHeadingAccessor();        OrbitViewPropertyAccessor.AngleAccessor pPropAccessor = OrbitViewPropertyAccessor.createPitchAccessor();        OrbitViewPropertyAccessor.DoubleAccessor zPropAccessor = OrbitViewPropertyAccessor.createZoomAccessor();        OrbitViewAnimator hAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginHeading, endHeading, hPropAccessor);        OrbitViewAnimator pAnimator = new BasicOrbitViewAnimator.AngleAnimator(beginPitch, endPitch, pPropAccessor);        OrbitViewAnimator zAnimator = new BasicOrbitViewAnimator.DoubleAnimator(beginZoom, endZoom, zPropAccessor);        OrbitViewAnimator animator = new BasicOrbitViewAnimator.CompoundAnimator(hAnimator, pAnimator, zAnimator);        return new ScheduledOrbitViewStateIterator(lengthMillis, animator, smoothed);    }    private static long getScaledLengthMillis(        Angle begin, Angle end, Angle max,        long minLengthMillis, long maxLengthMillis)    {        Angle angularDistance = begin.angularDistanceTo(end);        double scaleFactor = angularRatio(angularDistance, max);        return (long) mixDouble(scaleFactor, minLengthMillis, maxLengthMillis);    }    private static double angularRatio(Angle x, Angle y)    {        if (x == null || y == null)        {            String message = Logging.getMessage("nullValue.AngleIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        double unclampedRatio = x.divide(y);        return clampDouble(unclampedRatio, 0, 1);    }    private static double clampDouble(double value, double min, double max)    {        return value < min ? min : (value > max ? max : value);    }    private static double mixDouble(double amount, double value1, double value2)    {        if (amount < 0)            return value1;        else if (amount > 1)            return value2;        return value1 * (1.0 - amount) + value2 * amount;    }}

⌨️ 快捷键说明

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