public virtual void tweenObjects(SpriterAnimation  animation)
 {
     foreach (SpriterObject key in objectsToTween.Keys)
     {
         SpriterObject toTween = key;
         SpriterKeyFrame frame = animation.frames[objectsToTween[key]];
         long time = frame.getTime();
         SpriterKeyFrame currentFrame = animation.getPreviousFrameForObject
             (toTween, time);
         SpriterKeyFrame nextFrame = animation.getNextFrameFor
             (toTween, currentFrame, 1);
         if (nextFrame != currentFrame)
         {
             SpriterObject object1 = currentFrame.getObjectFor
                 (toTween);
             SpriterObject object2 = nextFrame.getObjectFor(toTween
                 );
             this.interpolateSpriterObject(toTween, object1, object2, currentFrame.getTime(),
                 nextFrame.getTime(), time);
         }
         SpriterObject[] objects = new SpriterObject
             [frame.getObjects().Length + 1];
         for (int i = 0; i < objects.Length - 1; i++)
         {
             objects[i] = frame.getObjects()[i];
         }
         objects[objects.Length - 1] = toTween;
         frame.setObjects(objects);
     }
 }
 //import Com.Brashmonkey.Spriter.converters.SpriterObjectConverter;
 //import AnimationObject;
 //final private SpriterObjectConverter objectConverter = new SpriterObjectConverter();
 public virtual SpriterAnimation buildAnimation(
     Animation animation)
 {
     MainLine mainline = animation.getMainline();
     IList<TimeLine> timeLines =
         animation.getTimeline();
     IList<Key> keyFrames = mainline
         .getKey();
     bonesToTween = new Dictionary<SpriterBone
         , int>();
     objectsToTween = new Dictionary<SpriterObject
         , int>();
     SpriterAnimation spriterAnimation = new SpriterAnimation(animation.getId(), animation.getName(), animation.getLength());
     for (int k = 0; k < keyFrames.Count; k++)
     {
         Key mainlineKey = keyFrames[k];
         IList<SpriterObject> tempObjects
              = new List<SpriterObject
             >();
         IList<SpriterBone> tempBones
              = new List<SpriterBone
             >();
         SpriterKeyFrame frame = new SpriterKeyFrame
             ();
         frame.setTime(mainlineKey.getTime());
         frame.setId(mainlineKey.getId());
         foreach (BoneRef boneRef in mainlineKey.getBoneRef())
         {
             TimeLine timeline = timeLines[boneRef.getTimeline()];
             Key timelineKey = timeline.getKey()[boneRef.getKey()];
             SpriterBone bone = boneMerger.merge(boneRef, timelineKey
                 );
             bone.setName(timeline.getName());
             if (mainlineKey.getTime() != timelineKey.getTime())
             {
                 bonesToTween.Add(bone, k);
             }
             else
             {
                 tempBones.Add(bone);
             }
         }
         //}
         foreach (AnimationObjectRef objectRef in mainlineKey.getObjectRef
             ())
         {
             TimeLine timeline = timeLines[objectRef.getTimeline()];
             Key timelineKey = timeline.getKey()[objectRef.getKey()
                 ];
             SpriterObject @object = objectMerger.merge(objectRef
                 , timelineKey);
             @object.setName(timeline.getName());
             if (mainlineKey.getTime() != timelineKey.getTime())
             {
                 objectsToTween.Add(@object, k);
             }
             else
             {
                 tempObjects.Add(@object);
             }
         }
         //}
         SpriterObject[] objArray = new SpriterObject[tempObjects.Count];
         tempObjects.CopyTo(objArray,0);
         frame.setObjects(objArray);
         SpriterBone[] boneArray = new SpriterBone[tempBones.Count];
         tempBones.CopyTo(boneArray, 0);
         frame.setBones(boneArray);
         spriterAnimation.frames.Add(frame);
     }
     this.tweenBones(spriterAnimation);
     this.tweenObjects(spriterAnimation);
     return spriterAnimation;
 }
 public virtual void tweenBones(SpriterAnimation  animation)
 {
     foreach (SpriterBone key in bonesToTween.Keys)
     {
         SpriterBone toTween = key;
         SpriterKeyFrame frame = animation.frames[bonesToTween[key]];
         long time = frame.getTime();
         SpriterKeyFrame currentFrame = animation.getPreviousFrameForBone
             (toTween, time);
         SpriterKeyFrame nextFrame = animation.getNextFrameFor
             (toTween, currentFrame, 1);
         if (nextFrame != currentFrame)
         {
             SpriterBone bone1 = currentFrame.getBoneFor(toTween
                 );
             SpriterBone bone2 = nextFrame.getBoneFor(toTween);
             this.interpolateAbstractObject(toTween, bone1, bone2, currentFrame.getTime(), nextFrame
                 .getTime(), time);
         }
         SpriterBone[] bones = new SpriterBone
             [frame.getBones().Length + 1];
         for (int i = 0; i < bones.Length - 1; i++)
         {
             bones[i] = frame.getBones()[i];
         }
         bones[bones.Length - 1] = toTween;
         frame.setBones(bones);
     }
 }