org.jvnet.substance
Class SubstanceTabbedPaneUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TabbedPaneUI
          extended by javax.swing.plaf.basic.BasicTabbedPaneUI
              extended by org.jvnet.substance.SubstanceTabbedPaneUI
All Implemented Interfaces:
javax.swing.SwingConstants

public class SubstanceTabbedPaneUI
extends javax.swing.plaf.basic.BasicTabbedPaneUI

UI for tabbed panes in Substance look and feel.

Author:
Kirill Grouchnikov

Nested Class Summary
protected  class SubstanceTabbedPaneUI.MouseRolloverHandler
          Listener for rollover animation effects.
protected  class SubstanceTabbedPaneUI.TabbedContainerListener
          Tracks changes to the tabbed pane contents.
 class SubstanceTabbedPaneUI.TabbedPaneLayout
          Layout for the tabbed pane.
protected  class SubstanceTabbedPaneUI.TabRepaintCallback
          Implementation of the fade tracker callback that repaints a single tab.
protected  class SubstanceTabbedPaneUI.TabSelectionHandler
          Handler for tab selection.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
javax.swing.plaf.basic.BasicTabbedPaneUI.FocusHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.MouseHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.PropertyChangeHandler
 
Field Summary
protected  SubstanceTabbedPaneUI.TabbedContainerListener substanceContainerListener
          Tracks changes to the tabbed pane contents.
protected  java.awt.Point substanceMouseLocation
          Current mouse location.
protected  SubstanceTabbedPaneUI.MouseRolloverHandler substanceRolloverHandler
          Mouse handler for rollover effects.
protected  javax.swing.event.ChangeListener substanceSelectionListener
          Listener for animation effects on tab selection.
 
Fields inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
calcRect, contentBorderInsets, darkShadow, downKey, focus, focusListener, highlight, leftKey, lightHighlight, maxTabHeight, maxTabWidth, mouseListener, propertyChangeListener, rects, rightKey, runCount, selectedRun, selectedTabPadInsets, shadow, tabAreaInsets, tabChangeListener, tabInsets, tabPane, tabRunOverlay, tabRuns, textIconGap, upKey
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
SubstanceTabbedPaneUI()
          Creates the new UI delegate.
 
Method Summary
protected  int calculateMaxTabHeight(int tabPlacement)
           
protected  int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
           
protected  int calculateTabWidth(int tabPlacement, int tabIndex, java.awt.FontMetrics metrics)
           
protected  javax.swing.event.ChangeListener createChangeListener()
           
protected  java.awt.LayoutManager createLayoutManager()
           
protected  javax.swing.JButton createScrollButton(int direction)
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent tabPane)
           
protected  void ensureCurrentLayout()
          Ensures the current layout.
 org.jvnet.lafwidget.animation.FadeTrackerCallback getCallback(int tabIndex)
          Returns the repaint callback for the specified tab index.
protected  java.awt.Rectangle getCloseButtonRectangleForDraw(int tabIndex, int x, int y, int width, int height)
          Retrieves the close button rectangle for drawing purposes.
protected  java.awt.Rectangle getCloseButtonRectangleForEvents(int tabIndex, int x, int y, int w, int h)
          Retrieves the close button rectangle for event handling.
protected  java.awt.Insets getContentBorderInsets(int tabPlacement)
           
protected  javax.swing.Icon getIconForTab(int tabIndex)
           
static java.lang.String getMemoryUsage()
          Returns the memory usage string.
protected  ComponentState getPrevTabState(int tabIndex)
          Returns the previous state for the specified tab.
 int getRolloverTabIndex()
          Returns the index of the tab currently being rolled-over.
 java.awt.Insets getTabAreaInsets()
          Returns tab area insets.
protected  java.awt.Insets getTabAreaInsets(int tabPlacement)
           
 java.awt.Rectangle getTabBounds(javax.swing.JTabbedPane pane, int i)
           
protected  int getTabExtraWidth(int tabPlacement, int tabIndex)
          Returns extra width for the specified tab.
protected  java.awt.Insets getTabInsets(int tabPlacement, int tabIndex)
           
protected  int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
           
protected  int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
           
 java.awt.Rectangle getTabRectangle(int tabIndex)
          Returns the tab rectangle for the specified tab.
protected  int getTabRunOverlay(int tabPlacement)
           
protected  ComponentState getTabState(int tabIndex)
          Returns the current state for the specified tab.
protected  int getTextAlignment(int tabPlacement)
          Returns the text alignment for the specified tab placement.
protected  void installDefaults()
           
protected  void installListeners()
           
protected  void layoutLabel(int tabPlacement, java.awt.FontMetrics metrics, int tabIndex, java.lang.String title, javax.swing.Icon icon, java.awt.Rectangle tabRect, java.awt.Rectangle iconRect, java.awt.Rectangle textRect, boolean isSelected)
           
protected  void paintContentBorderBottomEdge(java.awt.Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
           
protected  void paintContentBorderLeftEdge(java.awt.Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
           
protected  void paintContentBorderRightEdge(java.awt.Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
           
protected  void paintContentBorderTopEdge(java.awt.Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
           
protected  void paintFocusIndicator(java.awt.Graphics g, int tabPlacement, java.awt.Rectangle[] rects, int tabIndex, java.awt.Rectangle iconRect, java.awt.Rectangle textRect, boolean isSelected)
           
protected  void paintTab(java.awt.Graphics g, int tabPlacement, java.awt.Rectangle[] rects, int tabIndex, java.awt.Rectangle iconRect, java.awt.Rectangle textRect)
           
protected  void paintTabArea(java.awt.Graphics g, int tabPlacement, int selectedIndex)
           
protected  void paintTabBackground(java.awt.Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
           
protected  void paintTabBorder(java.awt.Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
           
protected  void paintText(java.awt.Graphics g, int tabPlacement, java.awt.Font font, java.awt.FontMetrics metrics, int tabIndex, java.lang.String title, java.awt.Rectangle textRect, boolean isSelected)
           
static void reset()
          Resets image maps (used when setting new theme).
 void setTabAreaInsets(java.awt.Insets insets)
          Sets new value for tab area insets.
protected  boolean shouldPadTabRun(int tabPlacement, int run)
           
protected  void tryCloseTab(int tabIndex)
          Tries closing a single tab.
protected  void tryCloseTabs(int tabIndex, SubstanceConstants.TabCloseKind tabCloseKind)
          Tries closing tabs based on the specified tab index and tab close kind.
protected  void tryCloseTabs(java.util.Set<java.lang.Integer> tabIndexes)
          Tries closing the specified tabs.
protected  void uninstallDefaults()
           
protected  void uninstallListeners()
           
 
Methods inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
assureRectsCreated, calculateMaxTabWidth, calculateTabAreaHeight, calculateTabAreaWidth, createFocusListener, createMouseListener, createPropertyChangeListener, expandTabRunsArray, getBaseline, getBaseline, getBaselineOffset, getBaselineResizeBehavior, getFocusIndex, getFontMetrics, getMaximumSize, getMinimumSize, getNextTabIndex, getNextTabIndexInRun, getNextTabRun, getPreviousTabIndex, getPreviousTabIndexInRun, getPreviousTabRun, getRolloverTab, getRunForTab, getSelectedTabPadInsets, getTabBounds, getTabRunCount, getTabRunIndent, getTabRunOffset, getTextViewForTab, getVisibleComponent, installComponents, installKeyboardActions, installUI, lastTabInRun, navigateSelectedTab, paint, paintContentBorder, paintIcon, rotateInsets, selectAdjacentRunTab, selectNextTab, selectNextTabInRun, selectPreviousTab, selectPreviousTabInRun, setRolloverTab, setVisibleComponent, shouldRotateTabRuns, tabForCoordinate, uninstallComponents, uninstallKeyboardActions, uninstallUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getPreferredSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

substanceMouseLocation

protected java.awt.Point substanceMouseLocation
Current mouse location.


substanceRolloverHandler

protected SubstanceTabbedPaneUI.MouseRolloverHandler substanceRolloverHandler
Mouse handler for rollover effects.


substanceContainerListener

protected SubstanceTabbedPaneUI.TabbedContainerListener substanceContainerListener
Tracks changes to the tabbed pane contents. Each tab component is tracked for changes on the SubstanceLookAndFeel.WINDOW_MODIFIED property.


substanceSelectionListener

protected javax.swing.event.ChangeListener substanceSelectionListener
Listener for animation effects on tab selection.

Constructor Detail

SubstanceTabbedPaneUI

public SubstanceTabbedPaneUI()
Creates the new UI delegate.

Method Detail

reset

public static void reset()
Resets image maps (used when setting new theme).

See Also:
SubstanceLookAndFeel.setCurrentTheme(String), SubstanceLookAndFeel.setCurrentTheme(SubstanceTheme)

createUI

public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent tabPane)

installListeners

protected void installListeners()
Overrides:
installListeners in class javax.swing.plaf.basic.BasicTabbedPaneUI

uninstallListeners

protected void uninstallListeners()
Overrides:
uninstallListeners in class javax.swing.plaf.basic.BasicTabbedPaneUI

installDefaults

protected void installDefaults()
Overrides:
installDefaults in class javax.swing.plaf.basic.BasicTabbedPaneUI

uninstallDefaults

protected void uninstallDefaults()
Overrides:
uninstallDefaults in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintTabBackground

protected void paintTabBackground(java.awt.Graphics g,
                                  int tabPlacement,
                                  int tabIndex,
                                  int x,
                                  int y,
                                  int w,
                                  int h,
                                  boolean isSelected)
Overrides:
paintTabBackground in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintFocusIndicator

protected void paintFocusIndicator(java.awt.Graphics g,
                                   int tabPlacement,
                                   java.awt.Rectangle[] rects,
                                   int tabIndex,
                                   java.awt.Rectangle iconRect,
                                   java.awt.Rectangle textRect,
                                   boolean isSelected)
Overrides:
paintFocusIndicator in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintTabBorder

protected void paintTabBorder(java.awt.Graphics g,
                              int tabPlacement,
                              int tabIndex,
                              int x,
                              int y,
                              int w,
                              int h,
                              boolean isSelected)
Overrides:
paintTabBorder in class javax.swing.plaf.basic.BasicTabbedPaneUI

createScrollButton

protected javax.swing.JButton createScrollButton(int direction)
Overrides:
createScrollButton in class javax.swing.plaf.basic.BasicTabbedPaneUI

createChangeListener

protected javax.swing.event.ChangeListener createChangeListener()
Overrides:
createChangeListener in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTabAreaInsets

protected java.awt.Insets getTabAreaInsets(int tabPlacement)
Overrides:
getTabAreaInsets in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTabInsets

protected java.awt.Insets getTabInsets(int tabPlacement,
                                       int tabIndex)
Overrides:
getTabInsets in class javax.swing.plaf.basic.BasicTabbedPaneUI

calculateTabHeight

protected int calculateTabHeight(int tabPlacement,
                                 int tabIndex,
                                 int fontHeight)
Overrides:
calculateTabHeight in class javax.swing.plaf.basic.BasicTabbedPaneUI

calculateTabWidth

protected int calculateTabWidth(int tabPlacement,
                                int tabIndex,
                                java.awt.FontMetrics metrics)
Overrides:
calculateTabWidth in class javax.swing.plaf.basic.BasicTabbedPaneUI

calculateMaxTabHeight

protected int calculateMaxTabHeight(int tabPlacement)
Overrides:
calculateMaxTabHeight in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTabRunOverlay

protected int getTabRunOverlay(int tabPlacement)
Overrides:
getTabRunOverlay in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintTab

protected void paintTab(java.awt.Graphics g,
                        int tabPlacement,
                        java.awt.Rectangle[] rects,
                        int tabIndex,
                        java.awt.Rectangle iconRect,
                        java.awt.Rectangle textRect)
Overrides:
paintTab in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintTabArea

protected void paintTabArea(java.awt.Graphics g,
                            int tabPlacement,
                            int selectedIndex)
Overrides:
paintTabArea in class javax.swing.plaf.basic.BasicTabbedPaneUI

getIconForTab

protected javax.swing.Icon getIconForTab(int tabIndex)
Overrides:
getIconForTab in class javax.swing.plaf.basic.BasicTabbedPaneUI

getCloseButtonRectangleForDraw

protected java.awt.Rectangle getCloseButtonRectangleForDraw(int tabIndex,
                                                            int x,
                                                            int y,
                                                            int width,
                                                            int height)
Retrieves the close button rectangle for drawing purposes.

Parameters:
tabIndex - Tab index.
x - X coordinate of the tab.
y - Y coordinate of the tab.
width - The tab width.
height - The tab height.
Returns:
The close button rectangle.

getCloseButtonRectangleForEvents

protected java.awt.Rectangle getCloseButtonRectangleForEvents(int tabIndex,
                                                              int x,
                                                              int y,
                                                              int w,
                                                              int h)
Retrieves the close button rectangle for event handling.

Parameters:
tabIndex - Tab index.
x - X coordinate of the tab.
y - Y coordinate of the tab.
w - The tab width.
h - The tab height.
Returns:
The close button rectangle.

ensureCurrentLayout

protected void ensureCurrentLayout()
Ensures the current layout.


getCallback

public org.jvnet.lafwidget.animation.FadeTrackerCallback getCallback(int tabIndex)
Returns the repaint callback for the specified tab index.

Parameters:
tabIndex - Tab index.
Returns:
Repaint callback for the specified tab index.

tryCloseTabs

protected void tryCloseTabs(int tabIndex,
                            SubstanceConstants.TabCloseKind tabCloseKind)
Tries closing tabs based on the specified tab index and tab close kind.

Parameters:
tabIndex - Tab index.
tabCloseKind - Tab close kind.

tryCloseTab

protected void tryCloseTab(int tabIndex)
Tries closing a single tab.

Parameters:
tabIndex - Tab index.

tryCloseTabs

protected void tryCloseTabs(java.util.Set<java.lang.Integer> tabIndexes)
Tries closing the specified tabs.

Parameters:
tabIndexes - Tab indexes.

layoutLabel

protected void layoutLabel(int tabPlacement,
                           java.awt.FontMetrics metrics,
                           int tabIndex,
                           java.lang.String title,
                           javax.swing.Icon icon,
                           java.awt.Rectangle tabRect,
                           java.awt.Rectangle iconRect,
                           java.awt.Rectangle textRect,
                           boolean isSelected)
Overrides:
layoutLabel in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTextAlignment

protected int getTextAlignment(int tabPlacement)
Returns the text alignment for the specified tab placement.

Parameters:
tabPlacement - Tab placement.
Returns:
Tab text alignment.

getTabLabelShiftX

protected int getTabLabelShiftX(int tabPlacement,
                                int tabIndex,
                                boolean isSelected)
Overrides:
getTabLabelShiftX in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTabLabelShiftY

protected int getTabLabelShiftY(int tabPlacement,
                                int tabIndex,
                                boolean isSelected)
Overrides:
getTabLabelShiftY in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTabExtraWidth

protected int getTabExtraWidth(int tabPlacement,
                               int tabIndex)
Returns extra width for the specified tab.

Parameters:
tabPlacement - Tab placement.
tabIndex - Tab index.
Returns:
Extra width for the specified tab.

getRolloverTabIndex

public int getRolloverTabIndex()
Returns the index of the tab currently being rolled-over.

Returns:
Index of the tab currently being rolled-over.

setTabAreaInsets

public void setTabAreaInsets(java.awt.Insets insets)
Sets new value for tab area insets.

Parameters:
insets - Tab area insets.

getTabAreaInsets

public java.awt.Insets getTabAreaInsets()
Returns tab area insets.

Returns:
Tab area insets.

getTabRectangle

public java.awt.Rectangle getTabRectangle(int tabIndex)
Returns the tab rectangle for the specified tab.

Parameters:
tabIndex - Index of a tab.
Returns:
The tab rectangle for the specified parameters.

getMemoryUsage

public static java.lang.String getMemoryUsage()
Returns the memory usage string.

Returns:
The memory usage string.

shouldPadTabRun

protected boolean shouldPadTabRun(int tabPlacement,
                                  int run)
Overrides:
shouldPadTabRun in class javax.swing.plaf.basic.BasicTabbedPaneUI

createLayoutManager

protected java.awt.LayoutManager createLayoutManager()
Overrides:
createLayoutManager in class javax.swing.plaf.basic.BasicTabbedPaneUI

getContentBorderInsets

protected java.awt.Insets getContentBorderInsets(int tabPlacement)
Overrides:
getContentBorderInsets in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintContentBorderBottomEdge

protected void paintContentBorderBottomEdge(java.awt.Graphics g,
                                            int tabPlacement,
                                            int selectedIndex,
                                            int x,
                                            int y,
                                            int w,
                                            int h)
Overrides:
paintContentBorderBottomEdge in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintContentBorderLeftEdge

protected void paintContentBorderLeftEdge(java.awt.Graphics g,
                                          int tabPlacement,
                                          int selectedIndex,
                                          int x,
                                          int y,
                                          int w,
                                          int h)
Overrides:
paintContentBorderLeftEdge in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintContentBorderRightEdge

protected void paintContentBorderRightEdge(java.awt.Graphics g,
                                           int tabPlacement,
                                           int selectedIndex,
                                           int x,
                                           int y,
                                           int w,
                                           int h)
Overrides:
paintContentBorderRightEdge in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintContentBorderTopEdge

protected void paintContentBorderTopEdge(java.awt.Graphics g,
                                         int tabPlacement,
                                         int selectedIndex,
                                         int x,
                                         int y,
                                         int w,
                                         int h)
Overrides:
paintContentBorderTopEdge in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTabBounds

public java.awt.Rectangle getTabBounds(javax.swing.JTabbedPane pane,
                                       int i)
Overrides:
getTabBounds in class javax.swing.plaf.basic.BasicTabbedPaneUI

getPrevTabState

protected ComponentState getPrevTabState(int tabIndex)
Returns the previous state for the specified tab.

Parameters:
tabIndex - Tab index.
Returns:
The previous state for the specified tab.

getTabState

protected ComponentState getTabState(int tabIndex)
Returns the current state for the specified tab.

Parameters:
tabIndex - Tab index.
Returns:
The current state for the specified tab.

paintText

protected void paintText(java.awt.Graphics g,
                         int tabPlacement,
                         java.awt.Font font,
                         java.awt.FontMetrics metrics,
                         int tabIndex,
                         java.lang.String title,
                         java.awt.Rectangle textRect,
                         boolean isSelected)
Overrides:
paintText in class javax.swing.plaf.basic.BasicTabbedPaneUI