bibliothek.gui.dock.station.stack.tab.layouting
Class AbstractTabsLayoutBlock

java.lang.Object
  extended by bibliothek.gui.dock.station.stack.tab.layouting.AbstractTabsLayoutBlock
All Implemented Interfaces:
LayoutBlock, TabsLayoutBlock
Direct Known Subclasses:
LineTabsLayoutBlock

public abstract class AbstractTabsLayoutBlock
extends Object
implements TabsLayoutBlock


Nested Class Summary
protected  class AbstractTabsLayoutBlock.TabsSize
          This Size contains an array of Tabs which are required to get this size.
 
Constructor Summary
AbstractTabsLayoutBlock()
           
 
Method Summary
 void addTab(Tab tab)
          Adds a tab to this block at its end.
 void checkExistence()
          This method compares the tabs of this block with the tabs known to the owning TabPane.
abstract  void doLayout()
          Updates the layout of this block.
 Rectangle getBounds()
          Gets the boundaries of this block.
 Tab[] getDockableTabMap()
          Gets an array that has the same size as TabPane.getDockables(), the tab at location x has the same Dockable as in the array returned by getDockables.
 TabPlacement getOrientation()
          Gets the alignment of the tabs.
 int[] getOriginalTabLocations()
          This method maps each Tab of this LayoutBlock to the location its Dockable has in the owning TabPane.
 TabPane getPane()
          Gets the producer of new tabs.
 Tab getSelectedTab()
          Searches the tab that is currently selected.
 Tab[] getTabs()
          Gets an array containing all the tabs of this block.
 int getTabsCount()
          Returns the number of tabs currently on this block.
 Tab[] getTabsOrderedByImportance()
          Gets all tabs that could, in theory, be displayed on this block.
 int indexOfTab(Tab tab)
          Tells the index at which tab appears on this block.
 void insertTab(Tab tab)
          Inserts tab somewhere in this block.
 void insertTab(Tab tab, int index)
          Adds tab at index in the list of tabs.
 boolean isVisible()
           
 void removeAllTabs()
          Removes all tabs of this block.
 Tab removeTab(int index)
          Removes the tab of location index.
 boolean removeTab(Tab tab)
          Removes tab from this block.
 void setBounds(int x, int y, int width, int height)
          Sets the boundaries of this block.
 void setLayout(Size size)
          Sets the layout of this block, the exact meaning of size depends on this block.
 void setOrientation(TabPlacement side)
          Tells this LayoutBlock at which side of the tabs it is shown.
 void setPane(TabPane pane)
          Sets the producer of new tabs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.station.stack.tab.layouting.TabsLayoutBlock
getTabs, getTabsCount, isAllTabs
 
Methods inherited from interface bibliothek.gui.dock.station.stack.tab.layouting.LayoutBlock
getSizes
 

Constructor Detail

AbstractTabsLayoutBlock

public AbstractTabsLayoutBlock()
Method Detail

setPane

public void setPane(TabPane pane)
Sets the producer of new tabs.

Parameters:
pane - the produced, might be null

getPane

public TabPane getPane()
Gets the producer of new tabs.

Returns:
the produced, may be null

getOrientation

public TabPlacement getOrientation()
Gets the alignment of the tabs.

Returns:
the alignment

setOrientation

public void setOrientation(TabPlacement side)
Description copied from interface: LayoutBlock
Tells this LayoutBlock at which side of the tabs it is shown.

Specified by:
setOrientation in interface LayoutBlock
Parameters:
side - the placement, not null

getSelectedTab

public Tab getSelectedTab()
Searches the tab that is currently selected. Only tabs that are part of this block are searched, a tab that exists but is not known is not reported.

Returns:
the selected tab or null if no tab is selected

checkExistence

public void checkExistence()
This method compares the tabs of this block with the tabs known to the owning TabPane. Any tab not found in the TabPane is removed from this block.


getTabs

public Tab[] getTabs()
Gets an array containing all the tabs of this block. Notice that this array may include Tabs whose Dockable is no longer part of the owning TabPane.

Returns:
the tabs

getTabsCount

public int getTabsCount()
Returns the number of tabs currently on this block.

Returns:
the nubmer of Tabs

addTab

public void addTab(Tab tab)
Adds a tab to this block at its end.

Parameters:
tab - the new tab, not null

insertTab

public void insertTab(Tab tab)
Inserts tab somewhere in this block. In general this method tries to add tab at a location such that the order of tabs equals the order of Dockables of the underlying TabPane.

Parameters:
tab - the tab to insert
Throws:
IllegalStateException - if no TabPane is available
IllegalArgumentException - if the Dockable of tab is not a child of this blocks TabPane

indexOfTab

public int indexOfTab(Tab tab)
Tells the index at which tab appears on this block.

Parameters:
tab - some tab
Returns:
its location or -1 if not found

getTabsOrderedByImportance

public Tab[] getTabsOrderedByImportance()
Gets all tabs that could, in theory, be displayed on this block. The tabs are ordered by importance, the most important tabs come first. In the default implementation the fist tab is always getSelectedTab(), then all the currently displayed tabs follow, only after them the invisible tabs follow. Tabs whose Dockable is no longer registered at the owning TabPane are ignored.

Returns:
all tabs, ordered by importance
Throws:
IllegalStateException - if getPane() returns null

getOriginalTabLocations

public int[] getOriginalTabLocations()
This method maps each Tab of this LayoutBlock to the location its Dockable has in the owning TabPane.

Returns:
the location of the original elements, may contain values of -1 to indicate that a tab is still present on this block but should have been removed.
Throws:
IllegalStateException - if there is no TabPane present

getDockableTabMap

public Tab[] getDockableTabMap()
Gets an array that has the same size as TabPane.getDockables(), the tab at location x has the same Dockable as in the array returned by getDockables. This includes the possibility to have no tab at some locations.

Returns:
the tabs, may contain null values
Throws:
IllegalStateException - if there is no TabPane known to this block.

insertTab

public void insertTab(Tab tab,
                      int index)
Adds tab at index in the list of tabs.

Parameters:
tab - a new tab, not null
index - the index of the new tab

removeTab

public boolean removeTab(Tab tab)
Removes tab from this block.

Parameters:
tab - the tab to remove
Returns:
true if tab was removed, false otherwise

removeTab

public Tab removeTab(int index)
Removes the tab of location index.

Parameters:
index - the index of the tab
Returns:
the tab that was removed

removeAllTabs

public void removeAllTabs()
Removes all tabs of this block.


doLayout

public abstract void doLayout()
Updates the layout of this block. The layout includes the location and size of all the Tabs managed by this block. This method must not add or remove tabs from the block.


setLayout

public void setLayout(Size size)
Description copied from interface: LayoutBlock
Sets the layout of this block, the exact meaning of size depends on this block. In general keys returned by the last call of LayoutBlock.getSizes() must be accepted, for any other key the behavior is unspecified.

Specified by:
setLayout in interface LayoutBlock
Parameters:
size - the new layout

isVisible

public boolean isVisible()

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Description copied from interface: LayoutBlock
Sets the boundaries of this block. The component(s) represented by this block must somehow fit into the rectangle.

Specified by:
setBounds in interface LayoutBlock
Parameters:
x - the x coordinate
y - the y coordinate
width - the width in pixel
height - the height in pixel

getBounds

public Rectangle getBounds()
Gets the boundaries of this block.

Returns:
the boundaries