sk.baka.ambient.activity.main
Class ControllerGroup

java.lang.Object
  extended by sk.baka.ambient.activity.main.ControllerGroup

public final class ControllerGroup
extends Object

Groups given controllers together and allows group operations over them.

Author:
Martin Vysny

Constructor Summary
ControllerGroup()
          Creates new group controller.
 
Method Summary
 void add(AbstractController controller, ActionsEnum action)
          Registers a controller to this group.
 void destroy()
          Destroys all controllers.
 void flipVisibility(AbstractController controller, Boolean visibility)
          Hides all other controllers and flips the visibility of given controller.
 AbstractController get(int index)
          Returns controller present at given index.
 ActionsEnum getActionForController(AbstractController controller)
          Returns action which triggers visibility of this controller.
<T extends AbstractController>
T
getController(Class<T> clazz)
          Returns first controller with given class (or subclass of given class).
 AbstractController getVisibleController()
          Returns the visible controller.
 int getVisibleControllerIndex()
          Returns the visible controller.
 void registerAndUpdate(SimpleBus bus)
          Registers all controllers from given bus.
 void unregister(SimpleBus bus)
          Unregisters all controllers from given bus.
 void zoom(boolean zoom)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerGroup

public ControllerGroup()
Creates new group controller.

Method Detail

add

public void add(AbstractController controller,
                ActionsEnum action)
Registers a controller to this group.

Parameters:
controller - the controller to register.
action - action which triggers visibility of this controller.

destroy

public void destroy()
Destroys all controllers. Exceptions are catched and logged.


flipVisibility

public void flipVisibility(AbstractController controller,
                           Boolean visibility)
Hides all other controllers and flips the visibility of given controller.

Parameters:
controller - the controller to show/hide. If null then all controllers are hidden.
visibility - set this visibility for the controller. If null then the visibility is flipped.

getVisibleControllerIndex

public int getVisibleControllerIndex()
Returns the visible controller.

Returns:
index of the visible controller or -1 if no such controller exists.

getVisibleController

public AbstractController getVisibleController()
Returns the visible controller.

Returns:
index of the visible controller or -1 if no such controller exists.

getActionForController

public ActionsEnum getActionForController(AbstractController controller)
Returns action which triggers visibility of this controller.

Parameters:
controller - the controller, may be null.
Returns:
the action or null if no such controller exists or it has no action attached.

unregister

public void unregister(SimpleBus bus)
Unregisters all controllers from given bus.

Parameters:
bus - the bus to unregister controllers from.

registerAndUpdate

public void registerAndUpdate(SimpleBus bus)
Registers all controllers from given bus. Invokes AbstractController.update(sk.baka.ambient.commons.Interval) on all controllers.

Parameters:
bus - the bus to unregister controllers from.

get

public AbstractController get(int index)
Returns controller present at given index. Returns null if the index is invalid.

Parameters:
index - the index
Returns:
controller instance or null.

getController

public <T extends AbstractController> T getController(Class<T> clazz)
Returns first controller with given class (or subclass of given class).

Type Parameters:
T - the controller type
Parameters:
clazz - the controller class
Returns:
non-null controller instance.
Throws:
IllegalArgumentException - if no such controller exists.

zoom

public void zoom(boolean zoom)


Copyright © 2007-2008. All Rights Reserved.