Class StateModel

java.lang.Object
org.netbeans.api.visual.model.StateModel

public final class StateModel extends Object
This class represents a model with a single state which can be boolean or non-negative integer value. It supports stateChanged event listening.
  • 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

      public void addListener(StateModel.Listener listener)
      Adds a listener of a state value changed.
      Parameters:
      listener - the listener
    • removeListener

      public void removeListener(StateModel.Listener listener)
      Removes a listener of a state value changed.
      Parameters:
      listener - the listener