com.miginfocom.util.states
Interface StateObservable

All Known Subinterfaces:
Activity
All Known Implementing Classes:
AbstractActivity, DefaultActivity

public interface StateObservable

Interface to implement if the class can handle states. (such as mouse over and selection). It can then be handled by a StateHandler.

See Also:
StateHandler

Field Summary
static int GROUP_TOGGLE
          A group where normally just one can have this state.
static int SPRING
          A type like a normal JButton.
static int TOGGLE
          Like a toggle button.
 
Method Summary
 java.lang.Object getGroupToggleContext(int state)
          Return a context that is used to define a GROUP_TOGGLE pool.
 int getHandledStates()
          Returns the states that are legal for this object.
 int getSettableStates(int states)
          Returns which of the suggested states is actually settable.
 StatesI getStates()
          Returns the current States object.
 int getStateType(int state)
          What type of state that state is.
 boolean isHandlingStates(int states)
          Return if all the states is handled.
 boolean isMultiState(int state)
          Returns if more than one object in the same toggle group context can have this state.
 void setGroupToggleContext(int state, java.lang.Object context)
          Sets the context for the icon to toggle within.
 

Field Detail

SPRING

static final int SPRING
A type like a normal JButton. Also used for mouse over. The sate is cleared when the reson for the state cease to be true.

See Also:
Constant Field Values

TOGGLE

static final int TOGGLE
Like a toggle button. JCheckBox is a good example.

See Also:
Constant Field Values

GROUP_TOGGLE

static final int GROUP_TOGGLE
A group where normally just one can have this state. If isMultiState() returns true, more than one object can have this state in that group. E.g. select many activities with shift held down. The state will not be unset if it is set again (like a toggle), notmally it gets unset as a responce to sonething else, like someone else in the same group (context) get set.

See Also:
Constant Field Values
Method Detail

getStates

StatesI getStates()
Returns the current States object. State changes should be made though this object, or preferrably though the StateHander class, which also manages state interactions between StateObservable objects and state change notification coalescing.

Returns:
The current state object

getHandledStates

int getHandledStates()
Returns the states that are legal for this object. Or:ed together.

Returns:
The states that are legal for this object. Or:ed together.
See Also:
isHandlingStates(int)

isHandlingStates

boolean isHandlingStates(int states)
Return if all the states is handled.

Parameters:
states - The state(s) to check
Returns:
true is it is handled
See Also:
getHandledStates()

getStateType

int getStateType(int state)
What type of state that state is. I.e. how the state is set and unset.

Parameters:
state - The state. Should not be more than one (not or:ed)
Returns:
What type state is. E.g. SPRING

getGroupToggleContext

java.lang.Object getGroupToggleContext(int state)
Return a context that is used to define a GROUP_TOGGLE pool. For instance the mouse over state is globally exclusive, only one "object" kan normally have the state GenericStates.MOUSE_OVER_BIT. Therefore all objects implementing this interface normally should return the same (or rather an object that .equals() OR ==) context for all concrete implementations of this interface (null normally) for the GenericStates.MOUSE_OVER_BIT state.
The returned context is normally interpreted by a StateHandler that may, or may not care about it.
Note! This method is only used for states that has the type GROUP_TOGGLE.

Parameters:
state - The state. Should not be more than one (not or:ed)
Returns:
The context. May be null.
See Also:
getStateType(int), isMultiState(int)

setGroupToggleContext

void setGroupToggleContext(int state,
                           java.lang.Object context)
Sets the context for the icon to toggle within. Approximately same as a button group for JRadioButtons. Normally this value is returned by getGroupToggleContext(int), but that depends on the concrete implementation that may, for instance, want to enforce a certain behaviour.

Parameters:
state - The state to set the context for. Should only be one state, not or:ed.
context - The context to set. Can be any object, including null, but should have a correct implementation of .equals() if non-null.
See Also:
States.getStateArray(), getGroupToggleContext(int)

isMultiState

boolean isMultiState(int state)
Returns if more than one object in the same toggle group context can have this state. Multiple states are normally set with a modifier. E.g. select many activities with shift held down.

Parameters:
state - The state. Should not be more than one (not or:ed)
Returns:
If more than one object in the same toggle group context can have this state
See Also:
getGroupToggleContext(int)

getSettableStates

int getSettableStates(int states)
Returns which of the suggested states is actually settable. Note that a state may be supported but not currently possible to set, for instance if the object is disabled it can't be selected.

Parameters:
states - The states or:ed together
Returns:
The states allowed to set


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.