edu.cmu.sun.folds
Class LayoutComponent

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

public class LayoutComponent
extends java.lang.Object

A portion of a folded scroll interface. This Component does not do drawing, but instead simply represents the state of the component, and points to underlying models that the component will draw from and modify. A Component will typically represent only a portion of a ListModel. The exact portion of the list is determined by the range field. LayoutComponents can be either, TOP_FOLD, FOLD (middle), BOTTOM_FOLD. Additionally, folds can be of "UNSPECIFIED" type, but this shouldn't ever happen for long.

Author:
kowitz

Nested Class Summary
static class LayoutComponent.Type
           
 
Field Summary
(package private)  LayoutComponent matchedWithComponent
          During the animation steps, components need to be matched with other components they will be transitioning into.
(package private)  ListModel model
          The model that underlies this component.
(package private)  IndexRange nextRange
          This field is used to animate transitions.
(package private)  Layout parentLayout
          The layout object that contains this component.
(package private)  IndexRange range
          The range of the ListModel that this component is to represent.
(package private)  LayoutComponent.Type type
          The type of LayoutComponent: TOP_FOLD, FOLD, BOTTOM_FOLD, LIST, UNSPECIFIED
 
Constructor Summary
LayoutComponent(LayoutComponent comp)
          Create a copy of a Layout Component.
LayoutComponent(ListModel model, IndexRange range)
          Create a new LayoutComponent that is backed by a model, and represents a range.
LayoutComponent(ListModel model, IndexRange range, LayoutComponent.Type type)
          Create a new LayoutComponent that is backed by a model, and represents a range.
 
Method Summary
static float getFoldComponentHeight(int items)
          This method returns the height of a fold component.
 float getHeight()
          Gets the heigth of this component (in meters) as it would be displayed in the scenegraph.
 java.util.List<ItemModel> getIncludedItemModels()
          Since this component only represents a portion of the items in a model, sometimes we will want to have acess to just the list Items that this component is responsible for.
static float getListComponentHeight(int items)
          This method returns the height of a list component.
 LayoutComponent getMatchedWithComponent()
          The matchedWithComponent field is used during the animation process.
 ListModel getModel()
           
 IndexRange getNextRange()
          Returns the range that this compoennt will represent in the model after a call to updateToNextRange().
 LayoutComponent getNextSibling()
           
 Layout getParentLayout()
          Returns the Layout that contains this component.
 LayoutComponent getPreviousSibling()
           
 IndexRange getRange()
          The range that this component represnts in the model.
 LayoutComponent.Type getType()
           
 boolean isMatchedWith(LayoutComponent match)
          Checks to see if this component currently matched with another
 boolean isMatchedWithComponent()
           
 void setMatchedWithComponent(LayoutComponent match)
          The matchedWithComponent field is used during the animation process.
 void setNextRange(IndexRange nextRange)
          Sets the nextRange field.
 void setParentLayout(Layout parentLayout)
          Sets the layout that contains this component.
 void setRange(IndexRange range)
          Seths the range that this component represents in the underlying model.
 void setType(LayoutComponent.Type type)
          Change the type of this component (For instance, to a top fold)
 java.lang.String toString()
          Simply used for debugging.
 void updateToNextRange()
          Changes the current range for this component to the value stored in nextRange.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parentLayout

Layout parentLayout
The layout object that contains this component.


range

IndexRange range
The range of the ListModel that this component is to represent.


nextRange

IndexRange nextRange
This field is used to animate transitions. Layouts components understand what their next range should be after a transition. In this way, they store the state of an animation plan.


model

ListModel model
The model that underlies this component. The component will display Items from this model that match the range field.


type

LayoutComponent.Type type
The type of LayoutComponent: TOP_FOLD, FOLD, BOTTOM_FOLD, LIST, UNSPECIFIED


matchedWithComponent

LayoutComponent matchedWithComponent
During the animation steps, components need to be matched with other components they will be transitioning into. This field holds a pointer to another LayoutComponent that is matched to transition with this component.

Constructor Detail

LayoutComponent

public LayoutComponent(ListModel model,
                       IndexRange range)
Create a new LayoutComponent that is backed by a model, and represents a range. Initially this creates a component of type UNSPECIFIED;

Parameters:
model - The ListModel that this component is based upon.
range - The range of the list model that this component represents.

LayoutComponent

public LayoutComponent(ListModel model,
                       IndexRange range,
                       LayoutComponent.Type type)
Create a new LayoutComponent that is backed by a model, and represents a range.

Parameters:
model - The ListModel that this component is based upon.
range - The range of the list model that this component represents.
type - The initial Type for the component. (kind of component)

LayoutComponent

public LayoutComponent(LayoutComponent comp)
Create a copy of a Layout Component. The new layout will have a pointer to the same underlying model. It will also share a pointer to the matched if it is set All other objects are copied.

Parameters:
comp -
Method Detail

getRange

public IndexRange getRange()
The range that this component represnts in the model.


getNextRange

public IndexRange getNextRange()
Returns the range that this compoennt will represent in the model after a call to updateToNextRange().


setRange

public void setRange(IndexRange range)
Seths the range that this component represents in the underlying model.


getType

public LayoutComponent.Type getType()
Returns:
the type of this component. (Whether a type of fold, or a list)

setType

public void setType(LayoutComponent.Type type)
Change the type of this component (For instance, to a top fold)

Parameters:
type -

getHeight

public float getHeight()
Gets the heigth of this component (in meters) as it would be displayed in the scenegraph. Because so much of the layout model depends on size, we deal in these meter coordinates here.


getModel

public ListModel getModel()
Returns:
The underlying model that this component represents.

getIncludedItemModels

public java.util.List<ItemModel> getIncludedItemModels()
Since this component only represents a portion of the items in a model, sometimes we will want to have acess to just the list Items that this component is responsible for. This function returns just the items that the layout component is meant to represent.

Returns:

updateToNextRange

public void updateToNextRange()
Changes the current range for this component to the value stored in nextRange. If nextRange has not been set, this does nothing. Components should always have a non-null range. We enforce that here.


setNextRange

public void setNextRange(IndexRange nextRange)
Sets the nextRange field. When updateToNextRange() is called, the current range is set to this field.

Parameters:
nextRange -

getMatchedWithComponent

public LayoutComponent getMatchedWithComponent()
The matchedWithComponent field is used during the animation process.

See Also:
LayoutMatcher

setMatchedWithComponent

public void setMatchedWithComponent(LayoutComponent match)
The matchedWithComponent field is used during the animation process.

See Also:
LayoutMatcher

isMatchedWithComponent

public boolean isMatchedWithComponent()
Returns:
True if this component is matched with another for transitioning.
See Also:
LayoutMatcher

isMatchedWith

public boolean isMatchedWith(LayoutComponent match)
Checks to see if this component currently matched with another

Parameters:
match - Component to test against matched field
Returns:
True if this component is currently matched to the provided component.
See Also:
LayoutMatcher

toString

public java.lang.String toString()
Simply used for debugging.

Overrides:
toString in class java.lang.Object

getParentLayout

public Layout getParentLayout()
Returns the Layout that contains this component.


setParentLayout

public void setParentLayout(Layout parentLayout)
Sets the layout that contains this component. When a component is added to a Layout, the layout calls this method to link the two together.

Parameters:
parentLayout -

getPreviousSibling

public LayoutComponent getPreviousSibling()
Returns:
the previous sibling component in this layout, or null if none if previous component cannot be found.

getNextSibling

public LayoutComponent getNextSibling()
Returns:
the next sibling component in this layout, or null if none if next component cannot be found.

getFoldComponentHeight

public static float getFoldComponentHeight(int items)
This method returns the height of a fold component. (A LayoutComponent of type TOP_FOLD, FOLD, or BOTTOM_FOLD) The architecture is a bit strange at this point because components in the Model, Folds, and View packages all need to know how tall the each type of component will be.

Parameters:
items - number of items the component needs to represent
Returns:
height of the component in meters

getListComponentHeight

public static float getListComponentHeight(int items)
This method returns the height of a list component. (A LayoutComponent of type LIST) The architecture is a bit strange at this point because components in the Model, Folds, and View packages all need to know how tall the each type of component will be.

Parameters:
items - number of items the component needs to represent
Returns:
height of the component in meters