Quaqua 5.4.1 2009-07-14

ch.randelshofer.quaqua.panther
Class Quaqua14PantherScrollTabbedPaneUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.TabbedPaneUI
          extended by javax.swing.plaf.basic.BasicTabbedPaneUI
              extended by ch.randelshofer.quaqua.panther.Quaqua14PantherScrollTabbedPaneUI
All Implemented Interfaces:
NavigatableTabbedPaneUI, javax.swing.SwingConstants

public class Quaqua14PantherScrollTabbedPaneUI
extends javax.swing.plaf.basic.BasicTabbedPaneUI
implements NavigatableTabbedPaneUI

A replacement for Apple's AquaTabbedPaneUI for Mac OS X 10.3 Panther. All tabs are placed in one run. Tabs on the left and on the right are rotated by 90 degrees. If the tabs don't fit into one run, they are shortened. Tabs on the top and on the bottom are only shortend as at least one tab can be shown fully. If this isn't possible, a combo box is shown instead of the tabs.

Supports the following client properties on the JTabbedPane:

Supports the following client properties on the children of the JTabbedPane:

Version:
1.4 2009-04-27 Added support for client property Quaqua.TabbedPane.tabAlignment.
1.3.3 2007-02-08 Use QuaquaBeginGraphics/QuaquaEndGraphics.
1.3.2 2006-09-27 Made QuaquaTabbedPaneLayout extend from BasicTabbedPaneUI.TabbedPaneLayout in order to fix a class cast exception occuring when using Quaqua14PantherTabbedPaneUI as a proxy.
1.3.1 2006-09-21 Added fix for J2SE 1.6.
1.3 2006-09-16 Added support for HTML rendered tabs.
1.2 2006-09-04 Fixed keyboard navigation problems.
1.1 2006-04-09 TabsComboBox now inherits font from tabbed pane. Added support for client propery Quaqua.tabbedPane.shortenTabs. Choosing an item in the TabsComboBox did not always switch to the specified tab.
1.0 January 10, 2006 Created.
Author:
Werner Randelshofer

Nested Class Summary
 class Quaqua14PantherScrollTabbedPaneUI.QuaquaMouseHandler
          This inner class is marked "public" due to a compiler bug.
 class Quaqua14PantherScrollTabbedPaneUI.QuaquaPropertyHandler
          This inner class is marked "public" due to a compiler bug.
 class Quaqua14PantherScrollTabbedPaneUI.QuaquaTabbedPaneLayout
          This inner class is marked "public" due to a compiler bug.
 class Quaqua14PantherScrollTabbedPaneUI.QuaquaTabSelectionHandler
          This inner class is marked "public" due to a compiler bug.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
javax.swing.plaf.basic.BasicTabbedPaneUI.MouseHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.PropertyChangeHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.TabbedPaneLayout, javax.swing.plaf.basic.BasicTabbedPaneUI.TabSelectionHandler
 
Field Summary
 
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
Quaqua14PantherScrollTabbedPaneUI()
          Creates a new instance.
 
Method Summary
protected  void addMnemonic(int index, int mnemonic)
          Adds the specified mnemonic at the specified index.
protected  int calculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight)
           
protected  int calculateTabAreaWidth(int tabPlacement, int vertRunCount, int maxTabWidth)
           
protected  int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
           
protected  javax.swing.event.ChangeListener createChangeListener()
           
protected  java.awt.event.FocusListener createFocusListener()
           
protected  java.awt.event.ItemListener createItemListener()
           
protected  java.awt.LayoutManager createLayoutManager()
           
protected  java.awt.event.MouseListener createMouseListener()
           
protected  java.beans.PropertyChangeListener createPropertyChangeListener()
           
static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent x)
           
protected  java.awt.Insets getContentBorderInsets(int tabPlacement)
           
 java.lang.Integer getIndexForMnemonic(int mnemonic)
           
protected  java.awt.Insets getInsets()
           
protected  java.lang.String getPropertyPrefix()
           
protected  java.awt.Rectangle getTabBounds(int tabIndex, java.awt.Rectangle dest)
          Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component.
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)
           
protected  java.awt.Insets getTabVisualMargin()
           
protected  javax.swing.text.View getTextViewForTab(int tabIndex)
          Returns the text View object required to render stylized text (HTML) for the specified tab or null if no specialized text rendering is needed for this tab.
protected  java.awt.Insets getVisualMargin()
           
protected  void installComponents()
           
protected  void installDefaults()
           
protected  void installKeyboardActions()
           
protected  void installListeners()
           
protected  java.lang.String layoutTabLabel(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)
           
 void navigateSelectedTab(int direction)
          Tab Navigation methods.
 void paint(java.awt.Graphics gr, javax.swing.JComponent c)
           
protected  void paintContentBorder(java.awt.Graphics gr, int tabPlacement, int selectedIndex)
           
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 gr, int tabPlacement, java.awt.Rectangle[] rects, int tabIndex, java.awt.Rectangle iconRect, java.awt.Rectangle textRect)
           
protected  void paintTabArea(java.awt.Graphics gr, 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)
          this function draws the border around each tab note that this function does now draw the background of the tab.
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)
           
protected  void repaintTabArea()
           
 boolean requestFocusForVisibleComponent()
           
protected  void resetMnemonics()
          Resets the mnemonics bindings to an empty state.
 void setPropertyPrefix(java.lang.String newValue)
           
protected  boolean shouldRotateTabRuns(int tabPlacement)
           
 int tabForCoordinate(javax.swing.JTabbedPane pane, int x, int y)
          Returns the tab index which intersects the specified point in the JTabbedPane's coordinate space.
protected  void uninstallComponents()
           
protected  void uninstallListeners()
           
 
Methods inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
assureRectsCreated, calculateMaxTabHeight, calculateMaxTabWidth, calculateTabWidth, createScrollButton, expandTabRunsArray, getFocusIndex, getFontMetrics, getIconForTab, getMaximumSize, getMinimumSize, getNextTabIndex, getNextTabIndexInRun, getNextTabRun, getPreviousTabIndex, getPreviousTabIndexInRun, getPreviousTabRun, getRolloverTab, getRunForTab, getSelectedTabPadInsets, getTabAreaInsets, getTabBounds, getTabRunCount, getTabRunIndent, getTabRunOffset, getTabRunOverlay, getVisibleComponent, installUI, lastTabInRun, layoutLabel, paintContentBorderBottomEdge, paintContentBorderLeftEdge, paintContentBorderRightEdge, paintContentBorderTopEdge, paintIcon, rotateInsets, selectAdjacentRunTab, selectNextTab, selectNextTabInRun, selectPreviousTab, selectPreviousTabInRun, setRolloverTab, setVisibleComponent, shouldPadTabRun, uninstallDefaults, 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
 

Constructor Detail

Quaqua14PantherScrollTabbedPaneUI

public Quaqua14PantherScrollTabbedPaneUI()
Creates a new instance.

Method Detail

getIndexForMnemonic

public java.lang.Integer getIndexForMnemonic(int mnemonic)
Specified by:
getIndexForMnemonic in interface NavigatableTabbedPaneUI

getPropertyPrefix

protected java.lang.String getPropertyPrefix()

setPropertyPrefix

public void setPropertyPrefix(java.lang.String newValue)

createUI

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

createItemListener

protected java.awt.event.ItemListener createItemListener()

createLayoutManager

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

installDefaults

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

installComponents

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

uninstallComponents

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

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

createMouseListener

protected java.awt.event.MouseListener createMouseListener()
Overrides:
createMouseListener in class javax.swing.plaf.basic.BasicTabbedPaneUI

createPropertyChangeListener

protected java.beans.PropertyChangeListener createPropertyChangeListener()
Overrides:
createPropertyChangeListener in class javax.swing.plaf.basic.BasicTabbedPaneUI

createChangeListener

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

createFocusListener

protected java.awt.event.FocusListener createFocusListener()
Overrides:
createFocusListener in class javax.swing.plaf.basic.BasicTabbedPaneUI

installKeyboardActions

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

getVisualMargin

protected java.awt.Insets getVisualMargin()

getTabVisualMargin

protected java.awt.Insets getTabVisualMargin()

getInsets

protected java.awt.Insets getInsets()

getTabInsets

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

getContentBorderInsets

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

paint

public void paint(java.awt.Graphics gr,
                  javax.swing.JComponent c)
Overrides:
paint in class javax.swing.plaf.basic.BasicTabbedPaneUI

paintContentBorder

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

layoutTabLabel

protected java.lang.String layoutTabLabel(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)

paintTabArea

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

paintTab

protected void paintTab(java.awt.Graphics gr,
                        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

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

paintTabBorder

protected void paintTabBorder(java.awt.Graphics g,
                              int tabPlacement,
                              int tabIndex,
                              int x,
                              int y,
                              int w,
                              int h,
                              boolean isSelected)
this function draws the border around each tab note that this function does now draw the background of the tab. that is done elsewhere

Overrides:
paintTabBorder in class javax.swing.plaf.basic.BasicTabbedPaneUI

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

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

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

tabForCoordinate

public int tabForCoordinate(javax.swing.JTabbedPane pane,
                            int x,
                            int y)
Returns the tab index which intersects the specified point in the JTabbedPane's coordinate space.

Overrides:
tabForCoordinate in class javax.swing.plaf.basic.BasicTabbedPaneUI

getTabBounds

protected java.awt.Rectangle getTabBounds(int tabIndex,
                                          java.awt.Rectangle dest)
Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component. This is required because the tab rects are by default defined in the coordinate space of the component where they are rendered, which could be the JTabbedPane (for WRAP_TAB_LAYOUT) or a ScrollableTabPanel (SCROLL_TAB_LAYOUT). This method should be used whenever the tab rectangle must be relative to the JTabbedPane itself and the result should be placed in a designated Rectangle object (rather than instantiating and returning a new Rectangle each time). The tab index parameter must be a valid tabbed pane tab index (0 to tab count - 1, inclusive). The destination rectangle parameter must be a valid Rectangle instance. The handling of invalid parameters is unspecified.

Overrides:
getTabBounds in class javax.swing.plaf.basic.BasicTabbedPaneUI
Parameters:
tabIndex - the index of the tab
dest - the rectangle where the result should be placed
Returns:
the resulting rectangle
Since:
1.4

resetMnemonics

protected void resetMnemonics()
Resets the mnemonics bindings to an empty state.


addMnemonic

protected void addMnemonic(int index,
                           int mnemonic)
Adds the specified mnemonic at the specified index.


getTextViewForTab

protected javax.swing.text.View getTextViewForTab(int tabIndex)
Returns the text View object required to render stylized text (HTML) for the specified tab or null if no specialized text rendering is needed for this tab. This is provided to support html rendering inside tabs.

Overrides:
getTextViewForTab in class javax.swing.plaf.basic.BasicTabbedPaneUI
Parameters:
tabIndex - the index of the tab
Returns:
the text view to render the tab's text or null if no specialized rendering is required
Since:
1.4

calculateTabHeight

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

calculateTabAreaHeight

protected int calculateTabAreaHeight(int tabPlacement,
                                     int horizRunCount,
                                     int maxTabHeight)
Overrides:
calculateTabAreaHeight in class javax.swing.plaf.basic.BasicTabbedPaneUI

calculateTabAreaWidth

protected int calculateTabAreaWidth(int tabPlacement,
                                    int vertRunCount,
                                    int maxTabWidth)
Overrides:
calculateTabAreaWidth in class javax.swing.plaf.basic.BasicTabbedPaneUI

repaintTabArea

protected void repaintTabArea()

shouldRotateTabRuns

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

requestFocusForVisibleComponent

public boolean requestFocusForVisibleComponent()
Specified by:
requestFocusForVisibleComponent in interface NavigatableTabbedPaneUI

navigateSelectedTab

public void navigateSelectedTab(int direction)
Description copied from interface: NavigatableTabbedPaneUI
Tab Navigation methods.

Specified by:
navigateSelectedTab in interface NavigatableTabbedPaneUI
Overrides:
navigateSelectedTab in class javax.swing.plaf.basic.BasicTabbedPaneUI

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.