Class StateModel
java.lang.Object
org.netbeans.api.visual.model.StateModel
This class represents a model with a single state which can be boolean or non-negative integer value.
It supports stateChanged event listening.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
The listener for listening on state changed event on a state model. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a boolean (2-states) model.StateModel
(int maxStates) Creates a model with a specified maximal states. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(StateModel.Listener listener) Adds a listener of a state value changed.void
decrease()
Decreases the state value.boolean
Returns a boolean representation of a state.int
Returns a maximal states.int
getState()
Returns a integer representation of the state.void
increase()
Increases the state value.void
removeListener
(StateModel.Listener listener) Removes a listener of a state value changed.void
setBooleanState
(boolean state) Sets a boolean state.void
setState
(int state) Sets a new state value.void
Toggles boolean state.
-
Constructor Details
-
StateModel
public StateModel()Creates a boolean (2-states) model. -
StateModel
public StateModel(int maxStates) Creates a model with a specified maximal states.- Parameters:
maxStates
- the maximal states
-
-
Method Details
-
getBooleanState
public boolean getBooleanState()Returns a boolean representation of a state.- Returns:
- the boolean value (true for non-zero value, false for zero value)
-
setBooleanState
public void setBooleanState(boolean state) Sets a boolean state.- Parameters:
state
- the boolean state; if true, then 1 value is used; if false, then 0 value is used
-
toggleBooleanState
public void toggleBooleanState()Toggles boolean state. -
getState
public int getState()Returns a integer representation of the state.- Returns:
- the integer value of the state.
-
decrease
public void decrease()Decreases the state value. If new value would have to be negative, then the maxStates-1 value is used instead. -
increase
public void increase()Increases the state value. If new value would have to be maxStates or higher, then the 0 value is used instead. -
setState
public void setState(int state) Sets a new state value.- Parameters:
state
- the new state value
-
getMaxStates
public int getMaxStates()Returns a maximal states.- Returns:
- the maximal states; 2 for boolean model
-
addListener
Adds a listener of a state value changed.- Parameters:
listener
- the listener
-
removeListener
Removes a listener of a state value changed.- Parameters:
listener
- the listener
-