Package hec.ui
Class TristateDecorator
java.lang.Object
hec.ui.TristateDecorator
- All Implemented Interfaces:
ItemSelectable
,ButtonModel
- Direct Known Subclasses:
TristateCheckBoxRenderer
Author: Dr. Heinz M. Kabutz
Changed some by Shannon Larson
Restricted feature added by Mike Perryman
Exactly which Design Pattern is this? Is it an Adapter,
a Proxy or a Decorator? In this case, my vote lies with the
Decorator, because we are extending functionality and
"decorating" the original model with a more powerful model.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
int
Object[]
getState()
The current state is embedded in the selection / armed state of the model.boolean
isArmed()
All these methods simply delegate to the "other" model that is being decorated.boolean
boolean
boolean
boolean
void
We rotate between NOT_SELECTED, SELECTED and SEMI_SELECTED.void
nextState
(boolean restricted) We rotate between NOT_SELECTED, SELECTED and SEMI_SELECTED.void
void
void
void
void
setArmed
(boolean b) Filter: No one may change the armed status except us.void
setEnabled
(boolean b) We disable focusing on the component when it is not enabled.void
setGroup
(ButtonGroup group) void
setMnemonic
(int key) void
setPressed
(boolean b) void
setRollover
(boolean b) void
setSelected
(boolean b) void
setState
(TristateCheckBox.State state) Sets the state.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.ButtonModel
getGroup
-
Constructor Details
-
TristateDecorator
Instantiates a new tristate decorator.- Parameters:
other
- the other
-
-
Method Details
-
setState
Sets the state.- Parameters:
state
- the new state
-
getState
The current state is embedded in the selection / armed state of the model. We return the SELECTED state when the check box is selected but not armed, SEMI_SELECTED state when the check box is selected and armed (grey) and NOT_SELECTED when the check box is de-selected.- Returns:
- the state
-
nextState
public void nextState()We rotate between NOT_SELECTED, SELECTED and SEMI_SELECTED. -
nextState
public void nextState(boolean restricted) We rotate between NOT_SELECTED, SELECTED and SEMI_SELECTED. -
setArmed
public void setArmed(boolean b) Filter: No one may change the armed status except us.- Specified by:
setArmed
in interfaceButtonModel
- Parameters:
b
- the new armed
-
setEnabled
public void setEnabled(boolean b) We disable focusing on the component when it is not enabled.- Specified by:
setEnabled
in interfaceButtonModel
- Parameters:
b
- the new enabled
-
isArmed
public boolean isArmed()All these methods simply delegate to the "other" model that is being decorated.- Specified by:
isArmed
in interfaceButtonModel
- Returns:
- true, if is armed
-
isSelected
public boolean isSelected()- Specified by:
isSelected
in interfaceButtonModel
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceButtonModel
-
isPressed
public boolean isPressed()- Specified by:
isPressed
in interfaceButtonModel
-
isRollover
public boolean isRollover()- Specified by:
isRollover
in interfaceButtonModel
-
setSelected
public void setSelected(boolean b) - Specified by:
setSelected
in interfaceButtonModel
-
setPressed
public void setPressed(boolean b) - Specified by:
setPressed
in interfaceButtonModel
-
setRollover
public void setRollover(boolean b) - Specified by:
setRollover
in interfaceButtonModel
-
setMnemonic
public void setMnemonic(int key) - Specified by:
setMnemonic
in interfaceButtonModel
-
getMnemonic
public int getMnemonic()- Specified by:
getMnemonic
in interfaceButtonModel
-
setActionCommand
- Specified by:
setActionCommand
in interfaceButtonModel
-
getActionCommand
- Specified by:
getActionCommand
in interfaceButtonModel
-
setGroup
- Specified by:
setGroup
in interfaceButtonModel
-
addActionListener
- Specified by:
addActionListener
in interfaceButtonModel
-
removeActionListener
- Specified by:
removeActionListener
in interfaceButtonModel
-
addItemListener
- Specified by:
addItemListener
in interfaceButtonModel
- Specified by:
addItemListener
in interfaceItemSelectable
-
removeItemListener
- Specified by:
removeItemListener
in interfaceButtonModel
- Specified by:
removeItemListener
in interfaceItemSelectable
-
addChangeListener
- Specified by:
addChangeListener
in interfaceButtonModel
-
removeChangeListener
- Specified by:
removeChangeListener
in interfaceButtonModel
-
getSelectedObjects
- Specified by:
getSelectedObjects
in interfaceItemSelectable
-