public final class ScrollingTabLayoutModel extends Object implements TabLayoutModel
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.
Constructor and Description |
---|
ScrollingTabLayoutModel(TabLayoutModel wrapped,
SingleSelectionModel sel,
TabDataModel mdl)
Creates a new instance of ScrollingTabLayoutModel
|
ScrollingTabLayoutModel(TabLayoutModel wrapped,
SingleSelectionModel sel,
TabDataModel mdl,
int minimumXposition) |
Modifier and Type | Method and Description |
---|---|
void |
clearCachedData()
External operations on the selection or data model can invalidate cached
widths.
|
int |
countVisibleTabs(int width)
Return the number of tabs currently visible
|
int |
dropIndexOfPoint(int x,
int y)
Gets the index of possibly dropped component (as a new tab).
|
Action |
getBackwardAction()
Returns an Action that the control buttons can call to scroll backward
|
int |
getFirstVisibleTab(int width)
Returns the index of the first tab that is visible (may be clipped - if
it == getOffset() then it is
|
Action |
getForwardAction()
Returns an Action that the control buttons can call to scroll forward
|
int |
getH(int index)
Get the height of the tab rectangle for the tab at index
index in the data model. |
int |
getLastVisibleTab(int width)
Returns the last visible tab, which may or may not be clipped
|
int |
getOffset()
Get the offset - the number of tabs that are scrolled over.
|
int |
getPixelsToAddToSelection()
Some look and feel specs require that the selected tab be wider.
|
int |
getW(int index)
Returns a cached width, after checking the changed flag and calling
change() if recalculation is needed
|
int |
getX(int index)
Get the x coordinate of the tab rectangle for the tab at index
index in the data model. |
int |
getY(int index)
Get the y coordinate of the tab rectangle for the tab at index
index in the data model. |
int |
indexOfPoint(int x,
int y)
Get the index of the tab in the data model for the supplied point.
|
boolean |
isLastTabClipped()
Returns true if the last tab displayed is clipped and should therefore be
painted as a clipped tab
|
boolean |
makeVisible(int index,
int width)
Make a tab visible, according to the rules of the spec.
|
void |
setMinimumXposition(int x) |
int |
setOffset(int i)
Set the offset - the number of tabs that should be hidden to the left.
|
void |
setPadding(Dimension d) |
void |
setPixelsToAddToSelection(int i)
Some UIs will want to make the selected tab a little wider than the
rest.
|
void |
setWidth(int width)
Sets the current cached width the model thinks it has for displaying
tabs.
|
public ScrollingTabLayoutModel(TabLayoutModel wrapped, SingleSelectionModel sel, TabDataModel mdl)
public ScrollingTabLayoutModel(TabLayoutModel wrapped, SingleSelectionModel sel, TabDataModel mdl, int minimumXposition)
public void setMinimumXposition(int x)
public void setPixelsToAddToSelection(int i)
i
- public void clearCachedData()
public int getOffset()
public int getPixelsToAddToSelection()
public boolean isLastTabClipped()
public boolean makeVisible(int index, int width)
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.
public void setWidth(int width)
public int setOffset(int i)
public int getFirstVisibleTab(int width)
public int countVisibleTabs(int width)
public int getLastVisibleTab(int width)
public int dropIndexOfPoint(int x, int y)
TabLayoutModel
dropIndexOfPoint
in interface TabLayoutModel
public void setPadding(Dimension d)
setPadding
in interface TabLayoutModel
public int getH(int index)
TabLayoutModel
index
in the data model.getH
in interface TabLayoutModel
index
- The tab indexpublic int getW(int index)
getW
in interface TabLayoutModel
index
- The tab indexpublic int getX(int index)
TabLayoutModel
index
in the data model.getX
in interface TabLayoutModel
index
- The tab indexpublic int getY(int index)
TabLayoutModel
index
in the data model.getY
in interface TabLayoutModel
index
- The tab indexpublic int indexOfPoint(int x, int y)
TabLayoutModel
indexOfPoint
in interface TabLayoutModel
x
- X coordinate of a point representing a set of pixel coordinate in the space
modeled by this layout modely
- Y coordinatepublic Action getForwardAction()
public Action getBackwardAction()