org.tbee.swing
Class CarouselLayout

java.lang.Object
  extended by org.tbee.swing.CarouselLayout
All Implemented Interfaces:
ActionListener, LayoutManager, EventListener

public class CarouselLayout
extends Object
implements LayoutManager, ActionListener

Author:
bug

Nested Class Summary
protected  class CarouselLayout.CarouselPosition
           
 
Field Summary
protected  Hashtable<Component,CarouselLayout.CarouselPosition> iAdditionalData
           
protected  LinkedList<Component> iComponents
           
protected  int iNumberOfItems
           
protected  double iRotationalOffset
           
protected  double iTargetOffset
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
CarouselLayout(Container container)
           
 
Method Summary
 void actionPerformed(ActionEvent actionEvent)
          Manages timer actions, terminating the timer if any event is fully achieved
 void addLayoutComponent(String name, Component comp)
          Name is ignored
 void finalizeLayoutImmediately()
          Moves everything to their "target" positions, without animating anything
 double getAngle()
          Returns the current rotational angle
 Component getFrontMostComponent()
           
 Component getNextAntiClockwise()
           
 Component getNextClockwise()
           
protected  CarouselLayout.CarouselPosition getPosition(Component comp)
          Gets the additional data stored by the layout manager for a given component
protected  boolean isAnimating()
          Determines if an animation is currently playing
 void layoutContainer(Container target)
          Lays out all of the components on the carousel.
 Dimension minimumLayoutSize(Container parent)
          Cheats and bases it's size on the prefered sizes of each component
 Dimension preferredLayoutSize(Container parent)
          Determine the widest and tallest dimensions, then return the height as 1.5 * the highest, and 3 * the widest
protected  void recalculateCarousel()
           
protected  int recalculateVisibleItems()
           
 void removeLayoutComponent(Component comp)
          Remove the component
 void setAngle(double d)
          Sets the current rotational angle.
 void setFrontMostComponent(Component component)
          Moves the specified component to the front
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iNumberOfItems

protected int iNumberOfItems

iComponents

protected LinkedList<Component> iComponents

iAdditionalData

protected Hashtable<Component,CarouselLayout.CarouselPosition> iAdditionalData

iRotationalOffset

protected double iRotationalOffset

iTargetOffset

protected double iTargetOffset
Constructor Detail

CarouselLayout

public CarouselLayout(Container container)
Parameters:
container -
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Name is ignored

Specified by:
addLayoutComponent in interface LayoutManager

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Remove the component

Specified by:
removeLayoutComponent in interface LayoutManager

getPosition

protected CarouselLayout.CarouselPosition getPosition(Component comp)
Gets the additional data stored by the layout manager for a given component

Parameters:
comp - The component you wish retreive the data for
Returns:
A position, which is added if it does not already exist. Never null unless you run out of memory!

recalculateVisibleItems

protected int recalculateVisibleItems()
Returns:

recalculateCarousel

protected void recalculateCarousel()

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Cheats and bases it's size on the prefered sizes of each component

Specified by:
minimumLayoutSize in interface LayoutManager

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Determine the widest and tallest dimensions, then return the height as 1.5 * the highest, and 3 * the widest

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - The container for the layout

layoutContainer

public void layoutContainer(Container target)
Lays out all of the components on the carousel. Using the preferred width and height to base scaling on

Specified by:
layoutContainer in interface LayoutManager

getAngle

public double getAngle()
Returns the current rotational angle

Returns:
The current rotated angle in radians

setAngle

public void setAngle(double d)
Sets the current rotational angle. Will not cause an animation to start

Parameters:
d - The desired angle in radians

isAnimating

protected boolean isAnimating()
Determines if an animation is currently playing

Returns:
true if it is animating, false if it isn't

actionPerformed

public void actionPerformed(ActionEvent actionEvent)
Manages timer actions, terminating the timer if any event is fully achieved

Specified by:
actionPerformed in interface ActionListener
Parameters:
actionEvent - the action event, although this will always be the timer

finalizeLayoutImmediately

public void finalizeLayoutImmediately()
Moves everything to their "target" positions, without animating anything


setFrontMostComponent

public void setFrontMostComponent(Component component)
Moves the specified component to the front

Parameters:
component - The component move to the front

getFrontMostComponent

public Component getFrontMostComponent()

getNextClockwise

public Component getNextClockwise()
Returns:

getNextAntiClockwise

public Component getNextAntiClockwise()
Returns:


Copyright © 2011 KnowledgePlaza. All Rights Reserved.