Quaqua 5.4.1 2009-07-14

ch.randelshofer.quaqua.jaguar
Class Quaqua13JaguarTabbedPaneUI

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.jaguar.Quaqua13JaguarTabbedPaneUI
All Implemented Interfaces:
NavigatableTabbedPaneUI, VisuallyLayoutable, javax.swing.SwingConstants
Direct Known Subclasses:
Quaqua14JaguarTabbedPaneUI

public class Quaqua13JaguarTabbedPaneUI
extends javax.swing.plaf.basic.BasicTabbedPaneUI
implements VisuallyLayoutable, NavigatableTabbedPaneUI

A replacement for the AquaTabbedPaneUI for Mac OS X 10.2 Jaguar. Tabs of tabbed panes are stacked instead of moved into a popup menu, if not enough space is available to render all tabs in a single line.

Supports the following client properties on the children of the JTabbedPane: Quaqua.TabbedPaneChild.contentBackground specifies the background Color to be used to fill the content border. Quaqua.TabbedPaneChild.contentInsets specifies the insets to be used to lay out the child component inside the JTabbedPane.

Version:
4.1 2009-04-27 Added support for client property Quaqua.TabbedPane.tabAlignment.
4.0 2007-11-03 Retrieving (some) border resources now from UIManager.
3.2 2006-12-24 by Karl von Randow: Use Images class to create artwork.
3.1 2006-09-04 Fixed keybord navigation problems.
3.0 2006-02-07 Reworked for QuaquaPantherJaguarTabbedPaneUI.
2.3 2005-09-08 Lazily create borders.
2.2 2005-06-19 Paint text antialiased.
2.1 2005-05-15 Dragged in more code from BasicTabbedPaneUI, because mouse clicks on the tab were not working with Java 1.5.
2.0.1 2005-04-17 Added one pixel to the bottom margin, when tabs are at the top, left or right. This is because, the cast shadow at the looks like a border line.
2.0 2005-04-02 More visual changes for tabs on the left and on the right. Support for dynamic component margin added.
1.2 2004-05-09 Support for rendering on inactive window added. Visual changes for tabs on the left and on the right.
1.1 2003-11-12 Support for tabs on the left and on the right added.
1.0.2 2003-10-04 Content Border Insets match now visually the insets of Apple's original Aqua LAF.
1.0.1 2003-09-12 Shift values in method getTabLabelShiftY changed.
1.0 2003-07-20 Created.
Author:
Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland

Nested Class Summary
 class Quaqua13JaguarTabbedPaneUI.QuaquaMouseHandler
          This inner class is marked "public" due to a compiler bug.
 class Quaqua13JaguarTabbedPaneUI.QuaquaPropertyChangeHandler
          This inner class is marked "public" due to a compiler bug.
 class Quaqua13JaguarTabbedPaneUI.TabbedPaneLayout
          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.FocusHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.MouseHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.PropertyChangeHandler, javax.swing.plaf.basic.BasicTabbedPaneUI.TabSelectionHandler
 
Field Summary
protected  java.awt.Color disabledForeground
           
protected  int minTabWidth
           
protected  java.awt.Color selectColor
           
protected  java.awt.Color selectHighlight
           
protected  java.awt.Color tabAreaBackground
           
 
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 ch.randelshofer.quaqua.VisuallyLayoutable
CLIP_BOUNDS, COMPONENT_BOUNDS, TEXT_BOUNDS
 
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
Quaqua13JaguarTabbedPaneUI()
           
 
Method Summary
protected  void addMnemonic(int index, int mnemonic)
          Adds the specified mnemonic at the specified index.
protected  int calculateMaxTabHeight(int tabPlacement)
           
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)
           
 int getBaseline(javax.swing.JComponent component, int width, int height)
          Returns the baseline for the specified component, or -1 if the baseline can not be determined.
protected  java.awt.Color getColorForGap(int currentRun, int x, int y)
           
protected  java.awt.Insets getContentBorderInsets(int tabPlacement)
           
 java.lang.Integer getIndexForMnemonic(int mnemonic)
           
protected  java.lang.String getPropertyPrefix()
           
protected  java.awt.Insets getTabAreaInsets(int tabPlacement)
           
protected  java.awt.Insets getTabInsets(int tabPlacement, int tabIndex)
           
protected  int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
          Overridden to do nothing for the Quaqua L&F.
protected  int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
          Overridden to return specific shift values for the Quaqua L&F.
protected  int getTabRunOverlay(int tabPlacement)
           
 java.awt.Rectangle getVisualBounds(javax.swing.JComponent c, int type, int width, int height)
          Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.
protected  java.awt.Insets getVisualMargin()
           
protected  void installDefaults()
           
 void navigateSelectedTab(int direction)
          Tab Navigation methods.
 void paint(java.awt.Graphics gr, javax.swing.JComponent c)
           
protected  void paintContentArea(java.awt.Graphics gr, int x, int y, int width, int height)
           
protected  void paintContentBorder(java.awt.Graphics g, int tabPlacement, int selectedIndex)
           
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)
          Overridden to do nothing for the Quaqua L&F.
protected  void paintHighlightBelowTab()
           
protected  void paintTabArea(java.awt.Graphics g, int tabPlacement, int selectedIndex)
          Paints the tabs in the tab area.
protected  void paintTabBackground(java.awt.Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
          Overridden to do nothing for the Quaqua L&F.
protected  void paintTabBorder(java.awt.Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
           
protected  void paintTabBorderBottom(int tabIndex, java.awt.Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected)
           
protected  void paintTabBorderLeft(int tabIndex, java.awt.Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected)
           
protected  void paintTabBorderRight(int tabIndex, java.awt.Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected)
           
protected  void paintTabBorderTop(int tabIndex, java.awt.Graphics g, int x, int y, int w, int h, int btm, int rght, 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)
           
protected  void repaintTabArea()
           
 boolean requestFocusForVisibleComponent()
           
protected  void resetMnemonics()
          Resets the mnemonics bindings to an empty state.
 void setPropertyPrefix(java.lang.String newValue)
           
protected  boolean shouldFillGap(int currentRun, int tabIndex, int x, int y)
           
protected  boolean shouldPadTabRun(int tabPlacement, int run)
           
protected  boolean shouldRotateTabRuns(int tabPlacement, int selectedRun)
           
 void update(java.awt.Graphics g, javax.swing.JComponent c)
           
protected  void updateMnemonics()
          Reloads the mnemonics.
 
Methods inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
assureRectsCreated, calculateMaxTabWidth, calculateTabAreaHeight, calculateTabAreaWidth, calculateTabHeight, calculateTabWidth, createChangeListener, createFocusListener, createScrollButton, expandTabRunsArray, getFocusIndex, getFontMetrics, getIconForTab, getMaximumSize, getMinimumSize, getNextTabIndex, getNextTabIndexInRun, getNextTabRun, getPreviousTabIndex, getPreviousTabIndexInRun, getPreviousTabRun, getRolloverTab, getRunForTab, getSelectedTabPadInsets, getTabBounds, getTabBounds, getTabRunCount, getTabRunIndent, getTabRunOffset, getTextViewForTab, getVisibleComponent, installComponents, installKeyboardActions, installListeners, installUI, lastTabInRun, layoutLabel, paintIcon, paintTab, rotateInsets, selectAdjacentRunTab, selectNextTab, selectNextTabInRun, selectPreviousTab, selectPreviousTabInRun, setRolloverTab, setVisibleComponent, shouldRotateTabRuns, tabForCoordinate, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getPreferredSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minTabWidth

protected int minTabWidth

tabAreaBackground

protected java.awt.Color tabAreaBackground

selectColor

protected java.awt.Color selectColor

selectHighlight

protected java.awt.Color selectHighlight

disabledForeground

protected java.awt.Color disabledForeground
Constructor Detail

Quaqua13JaguarTabbedPaneUI

public Quaqua13JaguarTabbedPaneUI()
Method Detail

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)

createLayoutManager

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

createPropertyChangeListener

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

createMouseListener

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

installDefaults

protected void installDefaults()
Overrides:
installDefaults 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

paintTabBorderTop

protected void paintTabBorderTop(int tabIndex,
                                 java.awt.Graphics g,
                                 int x,
                                 int y,
                                 int w,
                                 int h,
                                 int btm,
                                 int rght,
                                 boolean isSelected)

shouldFillGap

protected boolean shouldFillGap(int currentRun,
                                int tabIndex,
                                int x,
                                int y)

getColorForGap

protected java.awt.Color getColorForGap(int currentRun,
                                        int x,
                                        int y)

paintTabBorderLeft

protected void paintTabBorderLeft(int tabIndex,
                                  java.awt.Graphics g,
                                  int x,
                                  int y,
                                  int w,
                                  int h,
                                  int btm,
                                  int rght,
                                  boolean isSelected)

paintTabBorderBottom

protected void paintTabBorderBottom(int tabIndex,
                                    java.awt.Graphics g,
                                    int x,
                                    int y,
                                    int w,
                                    int h,
                                    int btm,
                                    int rght,
                                    boolean isSelected)

paintTabBorderRight

protected void paintTabBorderRight(int tabIndex,
                                   java.awt.Graphics g,
                                   int x,
                                   int y,
                                   int w,
                                   int h,
                                   int btm,
                                   int rght,
                                   boolean isSelected)

update

public void update(java.awt.Graphics g,
                   javax.swing.JComponent c)
Overrides:
update in class javax.swing.plaf.ComponentUI

paintTabBackground

protected void paintTabBackground(java.awt.Graphics g,
                                  int tabPlacement,
                                  int tabIndex,
                                  int x,
                                  int y,
                                  int w,
                                  int h,
                                  boolean isSelected)
Overridden to do nothing for the Quaqua L&F.

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

getTabLabelShiftX

protected int getTabLabelShiftX(int tabPlacement,
                                int tabIndex,
                                boolean isSelected)
Overridden to do nothing for the Quaqua L&F.

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

getVisualMargin

protected java.awt.Insets getVisualMargin()

getTabLabelShiftY

protected int getTabLabelShiftY(int tabPlacement,
                                int tabIndex,
                                boolean isSelected)
Overridden to return specific shift values for the Quaqua L&F. FIXME We should find another way to align the labels properly.

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

repaintTabArea

protected void repaintTabArea()

paint

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

paintTabArea

protected void paintTabArea(java.awt.Graphics g,
                            int tabPlacement,
                            int selectedIndex)
Paints the tabs in the tab area. Invoked by paint(). The graphics parameter must be a valid Graphics object. Tab placement may be either: JTabbedPane.TOP, JTabbedPane.BOTTOM, JTabbedPane.LEFT, or JTabbedPane.RIGHT. The selected index must be a valid tabbed pane tab index (0 to tab count - 1, inclusive) or -1 if no tab is currently selected. The handling of invalid parameters is unspecified.

Overrides:
paintTabArea in class javax.swing.plaf.basic.BasicTabbedPaneUI
Parameters:
g - the graphics object to use for rendering
tabPlacement - the placement for the tabs within the JTabbedPane
selectedIndex - the tab index of the selected component
Since:
1.4

updateMnemonics

protected void updateMnemonics()
Reloads the mnemonics. This should be invoked when a memonic changes, when the title of a mnemonic changes, or when tabs are added/removed.


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.


paintHighlightBelowTab

protected void paintHighlightBelowTab()

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)
Overridden to do nothing for the Quaqua L&F.

Overrides:
paintFocusIndicator 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

getTabAreaInsets

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

getContentBorderInsets

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

paintContentBorder

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

paintContentArea

protected void paintContentArea(java.awt.Graphics gr,
                                int x,
                                int y,
                                int width,
                                int height)

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

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

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

shouldRotateTabRuns

protected boolean shouldRotateTabRuns(int tabPlacement,
                                      int selectedRun)

shouldPadTabRun

protected boolean shouldPadTabRun(int tabPlacement,
                                  int run)
Overrides:
shouldPadTabRun 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

getVisualBounds

public java.awt.Rectangle getVisualBounds(javax.swing.JComponent c,
                                          int type,
                                          int width,
                                          int height)
Description copied from interface: VisuallyLayoutable
Returns the visual bounds for the specified component, or null if the visual bounds can not be determined.

Specified by:
getVisualBounds in interface VisuallyLayoutable
Parameters:
c - JComponent to calculate visual margin for
type - The type of the visual margin.
width - Width of the component
height - Height of the component
Returns:
The visual bounds in component coordinates.

getBaseline

public int getBaseline(javax.swing.JComponent component,
                       int width,
                       int height)
Description copied from interface: VisuallyLayoutable
Returns the baseline for the specified component, or -1 if the baseline can not be determined. The baseline is measured from the top of the component.

Specified by:
getBaseline in interface VisuallyLayoutable
Parameters:
component - JComponent to calculate baseline for
width - Width of the component to determine baseline for.
height - Height of the component to determine baseline for.
Returns:
baseline for the specified component

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

getIndexForMnemonic

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

requestFocusForVisibleComponent

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

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