org.tbee.swing
Class CarouselLayout

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

public class CarouselLayout
extends java.lang.Object
implements java.awt.LayoutManager, java.awt.event.ActionListener

Author:
bug

Nested Class Summary
protected  class CarouselLayout.CarouselPosition
           
 
Field Summary
protected  java.util.Hashtable<java.awt.Component,CarouselLayout.CarouselPosition> iAdditionalData
           
protected  java.util.LinkedList<java.awt.Component> iComponents
           
protected  int iNumberOfItems
           
protected  double iRotationalOffset
           
protected  double iTargetOffset
           
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
CarouselLayout(java.awt.Container container)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
          Manages timer actions, terminating the timer if any event is fully achieved
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Name is ignored
 void finalizeLayoutImmediately()
          Moves everything to their "target" positions, without animating anything
 double getAngle()
          Returns the current rotational angle
 java.awt.Component getFrontMostComponent()
           
 java.awt.Component getNextAntiClockwise()
           
 java.awt.Component getNextClockwise()
           
protected  CarouselLayout.CarouselPosition getPosition(java.awt.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(java.awt.Container target)
          Lays out all of the components on the carousel.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Cheats and bases it's size on the prefered sizes of each component
 java.awt.Dimension preferredLayoutSize(java.awt.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(java.awt.Component comp)
          Remove the component
 void setAngle(double d)
          Sets the current rotational angle.
 void setFrontMostComponent(java.awt.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 java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iNumberOfItems

protected int iNumberOfItems

iComponents

protected java.util.LinkedList<java.awt.Component> iComponents

iAdditionalData

protected java.util.Hashtable<java.awt.Component,CarouselLayout.CarouselPosition> iAdditionalData

iRotationalOffset

protected double iRotationalOffset

iTargetOffset

protected double iTargetOffset
Constructor Detail

CarouselLayout

public CarouselLayout(java.awt.Container container)
Parameters:
container -
Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Name is ignored

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Remove the component

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

getPosition

protected CarouselLayout.CarouselPosition getPosition(java.awt.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 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Cheats and bases it's size on the prefered sizes of each component

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.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 java.awt.LayoutManager
Parameters:
parent - The container for the layout

layoutContainer

public void layoutContainer(java.awt.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 java.awt.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(java.awt.event.ActionEvent actionEvent)
Manages timer actions, terminating the timer if any event is fully achieved

Specified by:
actionPerformed in interface java.awt.event.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(java.awt.Component component)
Moves the specified component to the front

Parameters:
component - The component move to the front

getFrontMostComponent

public java.awt.Component getFrontMostComponent()

getNextClockwise

public java.awt.Component getNextClockwise()
Returns:

getNextAntiClockwise

public java.awt.Component getNextAntiClockwise()
Returns:


Copyright © 2010 KnowledgePlaza. All Rights Reserved.