|
org.netbeans.swing.tabcontrol 1.8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.swing.tabcontrol.plaf.TabState
public abstract class TabState
Used by BasicTabDisplayerUI and its subclasses. Tracks and manages the state of tabs, mainly which one currently contains the mouse, if the mouse is in the close button, if the tab is adjacent to a selected tab, if it is leftmost, rightmost, active, etc. This class hides most of the complexity of deciding what mouse events should trigger a repaint of what areas in an optimized way. It provides setters which a mouse listener can call to indicate that the mouse has, say, moved into a tab, or from one tab to another, or the selection has changed, etc.
Essentially, this class is fed indices of tabs that have various states (selected, contains mouse, etc.), figures out if this affects one tab, two tabs (a different tab had the state, such as the mouse moving from one tab to another) or all tabs (activated). It determines a change type, and consults a repaint policy (an integer bitmask) to decide if one, both, all or no tabs should be repainted.
The typical use case is to implement a subclass, and override getState() to mix in bitmasks for things like whether a tab is clipped, etc. - things the base implementation can't know about.
Subclasses implement the repaintTab()
method to do the actual
repainting, and implement getRepaintPolicy()
. The repainting will be
called if an event happens that changes the state in a way that the repaint policy
bitmask indicates should cause a repaint.
BasicTabDisplayerUI implements a mouse listener which will call the appropriate methods when the mouse enters/exits tabs, etc.
State is composed as an integer bitmask which covers all of the supported
states of a tab that may affect the way they paint. These are also the values that
are passed to the methods of a TabCellRenderer
to tell it how to
paint itself. Two other integer
bitmasks are used: The changeType
, which indicates whether a
change was from one tab to another tab, one tab to no tab (i.e. selection set
to -1), one tab to the same tab (i.e. the mouse moved out of the tab control,
and so the tab with the mouse in it is now no tab). RepaintPolicy is an integer
bitmask composed of conditions under which the control should repaint one or all
tabs, and determines what types of changes actually trigger repaints.
Subclasses are expected to override getState()
to provide
information about non-mouse-or-focus related states, such as clipping of
scrollable tabs. Predefined states for tabs are: CLIP_RIGHT, CLIP_LEFT,
ARMED, PRESSED, SELECTED, ACTIVE, NOT_ONSCREEN, LEFTMOST, RIGHTMOST,
CLOSE_BUTTON_ARMED, BEFORE_SELECTED, AFTER_SELECTED, MOUSE_IN_TABS_AREA,
MOUSE_PRESSED_IN_CLOSE_BUTTON. Subclasses must handle returning the following
states if they wish to, which are not handled directly in TabState: LEFTMOST,
RIGHTMOST, CLIP_LEFT, CLIP_RIGHT, NOT_ONSCREEN.
Most of the states are fairly self-explanatory; NOT_ONSCREEN is useful as an optimization so that no work is done for events that would try to produce a repaint for something not visible; CLIP_* refers to the case in scrollable tab UIs, in which a tab may only be partially visible; MOUSE_PRESSED_IN_CLOSE_BUTTON is distinct because the CLOSE_BUTTON_ARMED state will be reset if the mouse moves out of the close button area, but UIs should perform a close action if the mouse was pressed over the close button, moved away from the close button and then back to it, so this state preserves the information that the originating location of a mouse press was in the close button.
Field Summary | |
---|---|
static int |
ACTIVE
Bitmask indicating the tab is activated |
static int |
AFTER_SELECTED
Bitmask indicating that the tab's index is that of the selected index plus one |
static int |
ALL_TABS
Change type indicating one of the boolean state changes, such as STATE_ACTIVE |
static int |
ARMED
Bitmask indicating the tab contains the mouse |
static int |
ATTENTION
Bitmask indicating that the tab is in "attention" mode - blinking or flashing to get the user's attention. |
static int |
BEFORE_ARMED
Bitmask indicating that the tab's index is that of the armed index less one |
static int |
BEFORE_SELECTED
Bitmask indicating that the tab's index is that of the selected index less one |
static int |
CHANGE_NONE_TO_TAB
Change type indicating that a state was added that no tab previously had |
static int |
CHANGE_TAB_TO_NONE
Change type indicating a change happened (such as the mouse leaving a tab) such that now no tab has the state previously held by the affected tab |
static int |
CHANGE_TAB_TO_SELF
|
static int |
CHANGE_TAB_TO_TAB
Change type indicating a change of state for two tabs |
static int |
CLIP_LEFT
Bitmask for state of tabs clipped on the right side - that is, partially displayed |
static int |
CLIP_RIGHT
Bitmask for state of tabs clipped on the right side - that is, partially displayed |
static int |
CLOSE_BUTTON_ARMED
Bitmask indicating that the tab contains the mouse and the mouse is in the close button |
static int |
LEFTMOST
Bitmask indicating the tab is at the extreme left and not clipped |
static int |
MOUSE_IN_TABS_AREA
Bitmask indicating that the mouse is in the tabs area |
static int |
MOUSE_PRESSED_IN_CLOSE_BUTTON
Bitmask indicating that the mouse is inside the close button and has been pressed. |
static int |
NO_CHANGE
Change type indicating no change happened (i.e. |
static int |
NOT_ONSCREEN
State bitmask indicating a tab is not displayed at all and shouldn't be painted. |
static int |
PRESSED
Bitmask indicating the tab contains the mouse and the mouse button has been pressed |
static int |
REPAINT_ALL_ON_MOUSE_ENTER_TABS_AREA
Repaint policy bitmask indicating that all tabs should be repainted whenever the mouse enters or leaves the area in which tabs are painted |
static int |
REPAINT_ALL_TABS_ON_ACTIVATION_CHANGE
Repaint policy bitmask indicating that all tabs should be repainted when the activated state changes |
static int |
REPAINT_ALL_TABS_ON_SELECTION_CHANGE
Repaint policy bitmask indicating that all tabs should be repainted whenever the selection changes |
static int |
REPAINT_ON_CLOSE_BUTTON_PRESSED
Repaint policy bitmask indicating that the tab should be repainted when the close button is pressed |
static int |
REPAINT_ON_MOUSE_ENTER_CLOSE_BUTTON
Repaint policy bitmask indicating that the tab should be repainted when the mouse enters or exits the close button region |
static int |
REPAINT_ON_MOUSE_ENTER_TAB
Repaint policy bitmask indicating that a tab should be repainted whenever the mouse enters or exits it |
static int |
REPAINT_ON_MOUSE_PRESSED
Repaint policy bitmask indicating that the tab should be repainted on mouse pressed events |
static int |
REPAINT_ON_SELECTION_CHANGE
Repaint policy bitmask indicating that a tab should be repainted when it becomes selected/unselected |
static int |
REPAINT_SELECTION_ON_ACTIVATION_CHANGE
Repaint policy bitmask indicating that the selected tab should be repainted when the activated state changes |
static int |
RIGHTMOST
Bitmask indicating the tab is at the extreme right and not clipped |
static int |
SELECTED
Bitmask indicating the tab is selected |
static int |
STATE_LAST
Indicates the last constant defined - renderers that wish to add their own bitmasks should use multiples of this number |
Constructor Summary | |
---|---|
TabState()
|
Method Summary | |
---|---|
void |
addAlarmTab(int alarmTab)
Add a tab to the list of those which should "flash" or otherwise give some notification to the user to get their attention |
protected void |
change(int lastTab,
int currTab,
int type,
int changeType)
Called when a setter for a tab index has produced a change in a state-affecting property, such as which tab contains the mouse. |
void |
clearTransientStates()
Clear all mouse position related state information. |
abstract int |
getRepaintPolicy(int tab)
Get the repaint policy that will be used to determine what tabs to repaint, based on state changes. |
int |
getState(int tab)
Get the state of a given tab. |
protected void |
maybeRepaint(int tab,
int type)
|
protected void |
possibleChange(boolean prevVal,
boolean currVal,
int type)
|
protected void |
possibleChange(int lastTab,
int currTab,
int type)
|
void |
removeAlarmTab(int alarmTab)
Remove a tab to the list of those which should "flash" or otherwise give some notification to the user to get their attention |
protected abstract void |
repaintAllTabs()
|
protected abstract void |
repaintTab(int tab)
|
boolean |
setActive(boolean b)
Set the condition for all tabs of the component being activated. |
int |
setCloseButtonContainsMouse(int i)
Set the index of the tab whose close button contains the mouse cursor. |
int |
setContainsMouse(int i)
Set the index of the tab which currently contains the mouse cursor. |
boolean |
setMouseInTabsArea(boolean b)
Set the condition for all tabs of the mouse being in the tabs area. |
int |
setMousePressedInCloseButton(int i)
Set the index of the tab in which the mouse button has been pressed in the close button. |
int |
setPressed(int i)
Set the index of the tab over which a mouse button has been pressed. |
int |
setSelected(int i)
Set the index of the tab which is currently selected. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int CLIP_RIGHT
public static final int CLIP_LEFT
public static final int ARMED
public static final int PRESSED
public static final int SELECTED
public static final int ACTIVE
public static final int NOT_ONSCREEN
public static final int LEFTMOST
public static final int RIGHTMOST
public static final int CLOSE_BUTTON_ARMED
public static final int BEFORE_SELECTED
public static final int AFTER_SELECTED
public static final int MOUSE_IN_TABS_AREA
public static final int MOUSE_PRESSED_IN_CLOSE_BUTTON
public static final int ATTENTION
public static final int BEFORE_ARMED
public static int STATE_LAST
public static final int REPAINT_ON_MOUSE_ENTER_TAB
public static final int REPAINT_ALL_ON_MOUSE_ENTER_TABS_AREA
public static final int REPAINT_ON_MOUSE_ENTER_CLOSE_BUTTON
public static final int REPAINT_ON_MOUSE_PRESSED
public static final int REPAINT_SELECTION_ON_ACTIVATION_CHANGE
public static final int REPAINT_ALL_TABS_ON_ACTIVATION_CHANGE
public static final int REPAINT_ON_SELECTION_CHANGE
public static final int REPAINT_ALL_TABS_ON_SELECTION_CHANGE
public static final int REPAINT_ON_CLOSE_BUTTON_PRESSED
public static final int NO_CHANGE
public static final int CHANGE_TAB_TO_TAB
public static final int CHANGE_TAB_TO_NONE
public static final int CHANGE_NONE_TO_TAB
public static final int CHANGE_TAB_TO_SELF
public static final int ALL_TABS
Constructor Detail |
---|
public TabState()
Method Detail |
---|
public int getState(int tab)
tab
- The index of the tab
public void clearTransientStates()
public final int setPressed(int i)
i
- The tab which is pressed, or -1 to clear PRESSED from the state
of the previously pressed tab
public final int setContainsMouse(int i)
i
- The tab which contains the mouse cursor, or -1 to clear ARMED
from the state of the tab
public final int setCloseButtonContainsMouse(int i)
i
- The index of the tab whose close button contains the mouse
cursor, or -1 to clear CLOSE_BUTTON_CONTAINS_MOUSE from the
state of the tab which previously had it
public final int setMousePressedInCloseButton(int i)
i
- The tab in which the mouse was pressed while over the close
button
public final int setSelected(int i)
i
- The tab index which is selected
public final boolean setMouseInTabsArea(boolean b)
b
- Whether the mouse is in the tabs area or not
public final boolean setActive(boolean b)
b
- Whether or not the component is activated
public final void addAlarmTab(int alarmTab)
public final void removeAlarmTab(int alarmTab)
protected void possibleChange(boolean prevVal, boolean currVal, int type)
protected void possibleChange(int lastTab, int currTab, int type)
public String toString()
protected void change(int lastTab, int currTab, int type, int changeType)
lastTab
- The tab previously holding the state which has changed,
or -1currTab
- The tab currently holding the state which has changed,
or -1type
- The thing that changed. This will be one of the state
constants.changeType
- This is one of the defined change types such as
ALL_TABS, TAB_TO_TAB, etc.protected void maybeRepaint(int tab, int type)
protected abstract void repaintTab(int tab)
protected abstract void repaintAllTabs()
public abstract int getRepaintPolicy(int tab)
BasicTabDisplayerUI.createRepaintPolicy()
tab
- Index of tab in question
|
org.netbeans.swing.tabcontrol 1.8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |