| java.lang.Object org.netbeans.swing.tabcontrol.plaf.ScrollingTabLayoutModel
ScrollingTabLayoutModel | final public class ScrollingTabLayoutModel implements TabLayoutModel(Code) | | Layout model which manages an offset into a set of scrollable tabs, and
recalculates its layout on a change. Also handles adding extra pixels to the
selected tab if necessary. Basics of how it works:
Wrapppers a DefaultTabLayoutModel, which can simply calculate tab widths and
0 based positions. Listens to the data model for changes, and sets a flag
when a change happens to mark the cached widths and positions as dirty. On
any call to fetch sizes, first checks if the cached values are good,
recalculates if needed, and returns the result.
author: Tim Boudreau |
Method Summary | |
public void | clearCachedData() External operations on the selection or data model can invalidate cached
widths. | public int | countVisibleTabs(int width) | public int | dropIndexOfPoint(int x, int y) | boolean | ensureAvailableSpaceUsed(boolean useCached) | public Action | getBackwardAction() | int | getCachedFirstVisibleTab() Used when components are deleted, so that if the user scrolls to close
some tabs, and the selection is offscreen, we don't infuriatingly
re-scroll away from the end tabs. | int | getCachedLastVisibleTab() Used when components are deleted, so that if the user scrolls to close
some tabs, and the selection is offscreen, we don't infuriatingly
re-scroll away from the end tabs. | public int | getFirstVisibleTab(int width) | public Action | getForwardAction() | public int | getH(int index) | public int | getLastVisibleTab(int width) | int | getMinimumLeftClippedWidth() Probably these should be made into constructor arguments. | int | getMinimumRightClippedWidth() Probably these should be made into constructor arguments. | public int | getOffset() Get the offset - the number of tabs that are scrolled over. | public int | getPixelsToAddToSelection() Some look and feel specs require that the selected tab be wider. | public int | getW(int index) | public int | getX(int index) | public int | getY(int index) | public int | indexOfPoint(int x, int y) | public boolean | isLastTabClipped() | public boolean | makeVisible(int index, int width) Make a tab visible, according to the rules of the spec. | public void | setMinimumXposition(int x) | public int | setOffset(int i) Set the offset - the number of tabs that should be hidden to the left.
The default is -1 - tab 0 is showing. | public void | setPadding(Dimension d) | public void | setPixelsToAddToSelection(int i) Some UIs will want to make the selected tab a little wider than the
rest. | public void | setWidth(int width) Sets the current cached width the model thinks it has for displaying
tabs. |
pixelsToAddToSelection | int pixelsToAddToSelection(Code) | | Integer count of pixels that should be added to the width of the selected
tab. They will be subtracted from the surrounding tabs
|
sel | SingleSelectionModel sel(Code) | | The selection model we will get the current selection from when we need
to ensure it is visible
|
clearCachedData | public void clearCachedData()(Code) | | External operations on the selection or data model can invalidate cached
widths. The UI will listen for such changes and call this method if the
data we have cached is probably no good anymore.
|
countVisibleTabs | public int countVisibleTabs(int width)(Code) | | Return the number of tabs currently visible
|
dropIndexOfPoint | public int dropIndexOfPoint(int x, int y)(Code) | | |
ensureAvailableSpaceUsed | boolean ensureAvailableSpaceUsed(boolean useCached)(Code) | | |
getBackwardAction | public Action getBackwardAction()(Code) | | Returns an Action that the control buttons can call to scroll backward
|
getCachedFirstVisibleTab | int getCachedFirstVisibleTab()(Code) | | Used when components are deleted, so that if the user scrolls to close
some tabs, and the selection is offscreen, we don't infuriatingly
re-scroll away from the end tabs.
|
getCachedLastVisibleTab | int getCachedLastVisibleTab()(Code) | | Used when components are deleted, so that if the user scrolls to close
some tabs, and the selection is offscreen, we don't infuriatingly
re-scroll away from the end tabs.
|
getFirstVisibleTab | public int getFirstVisibleTab(int width)(Code) | | Returns the index of the first tab that is visible (may be clipped - if
it == getOffset() then it is
|
getForwardAction | public Action getForwardAction()(Code) | | Returns an Action that the control buttons can call to scroll forward
|
getH | public int getH(int index)(Code) | | |
getLastVisibleTab | public int getLastVisibleTab(int width)(Code) | | Returns the last visible tab, which may or may not be clipped
|
getMinimumLeftClippedWidth | int getMinimumLeftClippedWidth()(Code) | | Probably these should be made into constructor arguments. The minimum
space to be used for a left-clipped tab
|
getMinimumRightClippedWidth | int getMinimumRightClippedWidth()(Code) | | Probably these should be made into constructor arguments. The minimum
space to be used for a right-clipped tab
|
getOffset | public int getOffset()(Code) | | Get the offset - the number of tabs that are scrolled over. The default
value is -1, which means no tabs are scrolled off to the left. 0 means
the first tab is visible but clipped...and so forth
|
getPixelsToAddToSelection | public int getPixelsToAddToSelection()(Code) | | Some look and feel specs require that the selected tab be wider. This
method sets the number of pixels to add to its width. It is important
that the underlying layout model's padX property include enough padding
that 1-2 pixels may be stolen without causing overlap problems. The
default is 0.
|
getW | public int getW(int index)(Code) | | Returns a cached width, after checking the changed flag and calling
change() if recalculation is needed
|
getX | public int getX(int index)(Code) | | |
getY | public int getY(int index)(Code) | | |
indexOfPoint | public int indexOfPoint(int x, int y)(Code) | | |
isLastTabClipped | public boolean isLastTabClipped()(Code) | | Returns true if the last tab displayed is clipped and should therefore be
painted as a clipped tab
|
makeVisible | public boolean makeVisible(int index, int width)(Code) | | Make a tab visible, according to the rules of the spec. Returns whether
or not a repaint of the entire control is required. The width of the tab
view is passed to this method, so that it can tell if the width has
changed (in which case it needs to recalculate tab bounds), or if it can
use the existing cached values.
This method will not trigger a repaint - it just adjusts the cached withs
and positions of tabs so that the next repaint will paint correctly. It
may be called as part of a more complex operation which would not want to
trigger spurious repaints - but the return value should be noted, and if
the return value is true, the caller should repaint the tab displayer
whenever it is done doing what it is doing.
|
setMinimumXposition | public void setMinimumXposition(int x)(Code) | | |
setOffset | public int setOffset(int i)(Code) | | Set the offset - the number of tabs that should be hidden to the left.
The default is -1 - tab 0 is showing. If set to 0, tab 0 still shows but
is clipped, and so forth.
|
setPixelsToAddToSelection | public void setPixelsToAddToSelection(int i)(Code) | | Some UIs will want to make the selected tab a little wider than the
rest.
Parameters: i - |
setWidth | public void setWidth(int width)(Code) | | Sets the current cached width the model thinks it has for displaying
tabs. This is used to trigger a recalculation if it differs from the
previously passed value
|
|
|