edu.cmu.sun.folds
Class LayoutTransitoner

java.lang.Object
  extended by edu.cmu.sun.folds.LayoutTransitoner

public class LayoutTransitoner
extends java.lang.Object

When the Folded Scrolling window changes, we need to make a smooth transition between scenes. In order to do this, we run the LayoutTransitioner. The transitioner takes two layouts, a current layout, and a next layout. The class creates a third layout as a return that represents the planed transition between the current layout and the next layout. The layout that is returned has components with their nextRange field set. This means that a call to updateNextRange will change the returned layout to the ranges needed to represent the next layout.

Author:
Braden Kowitz
See Also:
LayoutComponent

Field Summary
(package private)  java.util.LinkedList<LayoutComponent> activeComps
          We transition from the activeLayout to nextLayout.
(package private)  Layout activeLayout
          the current, active layout
(package private)  int activePos
          As we iterate, we build the plan slowly.
(package private)  java.util.LinkedList<LayoutComponent> nextComps
          We transition from the activeLayout to nextLayout.
(package private)  Layout nextLayout
          the next layout, the one we are transitioning to.
(package private)  int nextPos
          As we iterate, we build the plan slowly.
(package private)  Layout plan
          the layout that this object creates to transition between activeLayout and nextLayout.
 
Constructor Summary
LayoutTransitoner()
           
 
Method Summary
private  void addActiveComp(LayoutComponent lcActive)
           
private  boolean addIfMatched(LayoutComponent lcActive, LayoutComponent lcNext)
          returns true if the components have been added
private  void addNextComp(LayoutComponent lcNext)
           
private  void addNextComponentsToPlan()
           
private  void addPlanComponent(LayoutComponent.Type type, ListModel model, IndexRange range, IndexRange nextRange)
           
private  void addUnmatchedFoldsOfType(LayoutComponent.Type type)
           
private  void consolidateLayouts()
          Before we begin the transition calculation, we want to make sure there are no empty components (size zero) hanging in there, or adjacent LIST components, that could introduce matching problems.
private  LayoutComponent getFirst(java.util.LinkedList<LayoutComponent> compList)
           
private  void makeAnimationPlan()
          makes an animation plan between activeLayout and nextLayout and stores it in the plan member variable
private  void matchLayouts()
          Between the two laytous, match the components that need to animate between each other.
 Layout prepareAnimation(Layout fromActiveLayout, Layout toNextLayout)
          Creates an animation plan that visually transitions between two layouts.
private  void segmentLayouts()
          Since we must insert and remove visual elements, we must make sure that they disaper or appear at the right spot in the list, and then animate correctly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeLayout

Layout activeLayout
the current, active layout


nextLayout

Layout nextLayout
the next layout, the one we are transitioning to.


plan

Layout plan
the layout that this object creates to transition between activeLayout and nextLayout.


activePos

int activePos
As we iterate, we build the plan slowly. This holds the index of the ListModdel that we have built up-to in activeComps. This variable is useful for inserting components that have to disapear, or appear in the transition. This helps us make sure the components animate in the correct way as they disapear or appear.


nextPos

int nextPos
As we iterate, we build the plan slowly. This holds the index of the ListModel that we have built up-to in nextComps. This variable is useful for inserting components that have to disapear, or appear in the transition. This helps us make sure the components animate in the correct way as they disapear or appear.


activeComps

java.util.LinkedList<LayoutComponent> activeComps
We transition from the activeLayout to nextLayout. This field holds a currently built part of the part. It represents the components that are goign to be the FROM components in the plan. Then, once all of the components are matched and added, we create a plan from activeComps and nextComps.


nextComps

java.util.LinkedList<LayoutComponent> nextComps
We transition from the activeLayout to nextLayout. This field holds a currently built part of the part. It represents the components that are goign to be the TO components in the plan. Then, once all of the components are matched and added, we create a plan from activeComps and nextComps. (these ranges will be set as nextRanges in the LayoutComponents of the plan)

Constructor Detail

LayoutTransitoner

public LayoutTransitoner()
Method Detail

prepareAnimation

public Layout prepareAnimation(Layout fromActiveLayout,
                               Layout toNextLayout)
Creates an animation plan that visually transitions between two layouts. Note that the Layout it returns is set to visually represent the fromActiveLayout passed in. However, the layout that is returned may have been segmented or consolidated to be differnet on a logic leve. To perform the transition, the caller must replace the current layout with the returned layout, then call updateToNextRanges() on the layout, then do a smooth animation update.


matchLayouts

private void matchLayouts()
Between the two laytous, match the components that need to animate between each other. Matched layouts will be in both lists, they will not disappear or appear during the visual scene transition.


segmentLayouts

private void segmentLayouts()
Since we must insert and remove visual elements, we must make sure that they disaper or appear at the right spot in the list, and then animate correctly. We segment in both directions to make sure that there are no 2-1 or 1-2 mappings between the layouts. This makes sure we have space to instert growing components.

See Also:
Layout

consolidateLayouts

private void consolidateLayouts()
Before we begin the transition calculation, we want to make sure there are no empty components (size zero) hanging in there, or adjacent LIST components, that could introduce matching problems.


makeAnimationPlan

private void makeAnimationPlan()
makes an animation plan between activeLayout and nextLayout and stores it in the plan member variable


addUnmatchedFoldsOfType

private void addUnmatchedFoldsOfType(LayoutComponent.Type type)

addNextComponentsToPlan

private void addNextComponentsToPlan()

addNextComp

private void addNextComp(LayoutComponent lcNext)

addActiveComp

private void addActiveComp(LayoutComponent lcActive)

addIfMatched

private boolean addIfMatched(LayoutComponent lcActive,
                             LayoutComponent lcNext)
returns true if the components have been added


addPlanComponent

private void addPlanComponent(LayoutComponent.Type type,
                              ListModel model,
                              IndexRange range,
                              IndexRange nextRange)

getFirst

private LayoutComponent getFirst(java.util.LinkedList<LayoutComponent> compList)