站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ScrollingTabLayoutModel (Tab Control) - NetBeans API Javadoc (Current Development Version)

org.netbeans.swing.tabcontrol 1.8

org.netbeans.swing.tabcontrol.plaf
Class ScrollingTabLayoutModel

java.lang.Object
  extended by org.netbeans.swing.tabcontrol.plaf.ScrollingTabLayoutModel
All Implemented Interfaces:
TabLayoutModel

public final class ScrollingTabLayoutModel
extends Object
implements TabLayoutModel

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.


Constructor Summary
ScrollingTabLayoutModel(TabLayoutModel wrapped, SingleSelectionModel sel, TabDataModel mdl)
          Creates a new instance of ScrollingTabLayoutModel
ScrollingTabLayoutModel(TabLayoutModel wrapped, SingleSelectionModel sel, TabDataModel mdl, int minimumXposition)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScrollingTabLayoutModel

public ScrollingTabLayoutModel(TabLayoutModel wrapped,
                               SingleSelectionModel sel,
                               TabDataModel mdl)
Creates a new instance of ScrollingTabLayoutModel


ScrollingTabLayoutModel

public ScrollingTabLayoutModel(TabLayoutModel wrapped,
                               SingleSelectionModel sel,
                               TabDataModel mdl,
                               int minimumXposition)
Method Detail

setMinimumXposition

public void setMinimumXposition(int x)

setPixelsToAddToSelection

public void setPixelsToAddToSelection(int i)
Some UIs will want to make the selected tab a little wider than the rest.

Parameters:
i -

clearCachedData

public void clearCachedData()
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.


getOffset

public int getOffset()
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()
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.


isLastTabClipped

public boolean isLastTabClipped()
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)
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.


setWidth

public void setWidth(int width)
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


setOffset

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. If set to 0, tab 0 still shows but is clipped, and so forth.


getFirstVisibleTab

public int getFirstVisibleTab(int width)
Returns the index of the first tab that is visible (may be clipped - if it == getOffset() then it is


countVisibleTabs

public int countVisibleTabs(int width)
Return the number of tabs currently visible


getLastVisibleTab

public int getLastVisibleTab(int width)
Returns the last visible tab, which may or may not be clipped


dropIndexOfPoint

public int dropIndexOfPoint(int x,
                            int y)
Description copied from interface: TabLayoutModel
Gets the index of possibly dropped component (as a new tab).

Specified by:
dropIndexOfPoint in interface TabLayoutModel

setPadding

public void setPadding(Dimension d)
Specified by:
setPadding in interface TabLayoutModel

getH

public int getH(int index)
Description copied from interface: TabLayoutModel
Get the height of the tab rectangle for the tab at index index in the data model.

Specified by:
getH in interface TabLayoutModel
Parameters:
index - The tab index
Returns:
The height

getW

public int getW(int index)
Returns a cached width, after checking the changed flag and calling change() if recalculation is needed

Specified by:
getW in interface TabLayoutModel
Parameters:
index - The tab index
Returns:
The width

getX

public int getX(int index)
Description copied from interface: TabLayoutModel
Get the x coordinate of the tab rectangle for the tab at index index in the data model.

Specified by:
getX in interface TabLayoutModel
Parameters:
index - The tab index
Returns:
The coordinate

getY

public int getY(int index)
Description copied from interface: TabLayoutModel
Get the y coordinate of the tab rectangle for the tab at index index in the data model.

Specified by:
getY in interface TabLayoutModel
Parameters:
index - The tab index
Returns:
The coordinate

indexOfPoint

public int indexOfPoint(int x,
                        int y)
Description copied from interface: TabLayoutModel
Get the index of the tab in the data model for the supplied point.

Specified by:
indexOfPoint in interface TabLayoutModel
Parameters:
x - X coordinate of a point representing a set of pixel coordinate in the space modeled by this layout model
y - Y coordinate
Returns:
The index into the data model of the tab displayed at the passed point or -1

getForwardAction

public Action getForwardAction()
Returns an Action that the control buttons can call to scroll forward


getBackwardAction

public Action getBackwardAction()
Returns an Action that the control buttons can call to scroll backward


org.netbeans.swing.tabcontrol 1.8

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.