Пример #1
0
        /**
         * Create an animator to animate heading, pitch, and roll.
         *
         * @param view         View to animate
         * @param beginHeading staring heading
         * @param endHeading   final heading
         * @param beginPitch   starting pitch
         * @param endPitch     final pitch
         * @param beginRoll    starting roll
         * @param endRoll      final roll
         *
         * @return A CompoundAnimator to animate heading, pitch, and roll.
         */
        public static CompoundAnimator createHeadingPitchRollAnimator(View view, Angle beginHeading, Angle endHeading,
                                                                      Angle beginPitch, Angle endPitch, Angle beginRoll, Angle endRoll)
        {
            if (beginHeading == null || endHeading == null || beginPitch == null || endPitch == null || beginRoll == null ||
                endRoll == null)
            {
                String message = Logging.getMessage("nullValue.AngleIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            const long MIN_LENGTH_MILLIS   = 500;
            const long MAX_LENGTH_MILLIS   = 3000;
            long       headingLengthMillis = AnimationSupport.getScaledTimeMillisecs(
                beginHeading, endHeading, Angle.POS180,
                MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS);
            long pitchLengthMillis = AnimationSupport.getScaledTimeMillisecs(
                beginPitch, endPitch, Angle.POS90,
                MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS / 2L);
            long rollLengthMillis = AnimationSupport.getScaledTimeMillisecs(
                beginRoll, endRoll, Angle.POS90,
                MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS / 2L);
            long lengthMillis = headingLengthMillis + pitchLengthMillis + rollLengthMillis;

            AngleAnimator headingAnimator = createHeadingAnimator(view, beginHeading, endHeading);
            AngleAnimator pitchAnimator   = createPitchAnimator(view, beginPitch, endPitch);
            AngleAnimator rollAnimator    = createRollAnimator(view, beginRoll, endRoll);

            CompoundAnimator headingPitchAnimator = new CompoundAnimator(new ScheduledInterpolator(lengthMillis),
                                                                         headingAnimator, pitchAnimator, rollAnimator);

            return(headingPitchAnimator);
        }
Пример #2
0
        /**
         * Create an animator to animate heading.
         *
         * @param view  View to animate
         * @param begin starting heading
         * @param end   final heading
         *
         * @return An Animator to animate heading.
         */
        public static AngleAnimator createHeadingAnimator(View view, Angle begin, Angle end)
        {
            if (begin == null || end == null)
            {
                String message = Logging.getMessage("nullValue.AngleIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            const long MIN_LENGTH_MILLIS = 500;
            const long MAX_LENGTH_MILLIS = 3000;
            long       lengthMillis      = AnimationSupport.getScaledTimeMillisecs(
                begin, end, Angle.POS180,
                MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS);

            return(new AngleAnimator(new ScheduledInterpolator(lengthMillis),
                                     begin, end, new ViewPropertyAccessor.HeadingAccessor(view)));
        }