jdk/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
author yan
Mon, 30 Jun 2014 16:32:36 +0400
changeset 25178 dbab904451e9
parent 25118 d237e069dd9c
permissions -rw-r--r--
8046434: Fix doclint warnings from javax.swing.plaf.metal package Reviewed-by: alexsch Contributed-by: Andrei Eremeev <andrei.eremeev@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
     2
 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.metal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.plaf.basic.BasicTabbedPaneUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * The Metal subclass of BasicTabbedPaneUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20169
diff changeset
    44
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @author Tom Santos
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
    50
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public class MetalTabbedPaneUI extends BasicTabbedPaneUI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    53
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    54
     * The minimum width of a pane.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    55
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    protected int minTabWidth = 40;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // Background color for unselected tabs that don't have an explicitly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // set color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private Color unselectedBackground;
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    60
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    61
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    62
     * The color of tab's background.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    63
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    protected Color tabAreaBackground;
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    65
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    66
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    67
     * The color of the selected pane.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    68
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected Color selectColor;
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    70
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    71
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    72
     * The color of the highlight.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    73
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    protected Color selectHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private boolean tabsOpaque = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    // Whether or not we're using ocean. This is cached as it is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // extensively during painting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private boolean ocean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    // Selected border color for ocean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private Color oceanSelectedBorderColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    83
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    84
     * Constructs {@code MetalTabbedPaneUI}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    85
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    86
     * @param x a component
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    87
     * @return an instance of {@code MetalTabbedPaneUI}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
    88
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public static ComponentUI createUI( JComponent x ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        return new MetalTabbedPaneUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    protected LayoutManager createLayoutManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            return super.createLayoutManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        return new TabbedPaneLayout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        super.installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        tabAreaBackground = UIManager.getColor("TabbedPane.tabAreaBackground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        selectColor = UIManager.getColor("TabbedPane.selected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        selectHighlight = UIManager.getColor("TabbedPane.selectHighlight");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        unselectedBackground = UIManager.getColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                         "TabbedPane.unselectedBackground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        ocean = MetalLookAndFeel.usingOcean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            oceanSelectedBorderColor = UIManager.getColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                         "TabbedPane.borderHightlightColor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    protected void paintTabBorder( Graphics g, int tabPlacement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                   int tabIndex, int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                   boolean isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        int bottom = y + (h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        int right = x + (w-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        switch ( tabPlacement ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        case LEFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            paintLeftTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        case BOTTOM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            paintBottomTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        case RIGHT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            paintRightTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        case TOP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            paintTopTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   140
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   141
     * Paints the top tab border.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   142
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   143
     * @param tabIndex a tab index
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   144
     * @param g an instance of {@code Graphics}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   145
     * @param x an X coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   146
     * @param y an Y coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   147
     * @param w a width
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   148
     * @param h a height
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   149
     * @param btm bottom
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   150
     * @param rght right
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   151
     * @param isSelected a selection
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   152
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    protected void paintTopTabBorder( int tabIndex, Graphics g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                      int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                                      int btm, int rght,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                      boolean isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        int currentRun = getRunForTab( tabPane.getTabCount(), tabIndex );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        int lastIndex = lastTabInRun( tabPane.getTabCount(), currentRun );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        int firstIndex = tabRuns[ currentRun ];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        boolean leftToRight = MetalUtils.isLeftToRight(tabPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        int selectedIndex = tabPane.getSelectedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        int bottom = h - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        int right = w - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        // Paint Gap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (shouldFillGap( currentRun, tabIndex, x, y ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                g.setColor( getColorForGap( currentRun, x, y + 1 ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                g.fillRect( 1, 0, 5, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                g.fillRect( 1, 3, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                g.setColor( getColorForGap( currentRun, x + w - 1, y + 1 ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                g.fillRect( right - 5, 0, 5, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                g.fillRect( right - 2, 3, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        // Paint Border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            g.setColor( darkShadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            g.drawLine( 1, 5, 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            g.drawLine( 6, 0, right, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            // Paint right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if ( tabIndex==lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                // last tab in run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                g.drawLine( right, 1, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            if (ocean && tabIndex - 1 == selectedIndex &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                currentRun == getRunForTab(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                tabPane.getTabCount(), selectedIndex)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            if ( tabIndex != tabRuns[ runCount - 1 ] ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                // not the first tab in the last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    g.drawLine(0, 6, 0, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                    g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                    g.drawLine(0, 0, 0, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                    g.drawLine( 0, 0, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                // the first tab in the last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                g.drawLine( 0, 6, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            g.drawLine( right - 1, 5, right - 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            g.drawLine( right - 6, 0, 0, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            if ( tabIndex==lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                // last tab in run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                g.drawLine( 0, 1, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            // Paint right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            if (ocean && tabIndex - 1 == selectedIndex &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                currentRun == getRunForTab(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                tabPane.getTabCount(), selectedIndex)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                g.drawLine(right, 0, right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            else if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                g.drawLine(right, 6, right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                if (tabIndex != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                    g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                    g.drawLine(right, 0, right, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                if ( tabIndex != tabRuns[ runCount - 1 ] ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    // not the first tab in the last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                    g.drawLine( right, 0, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    // the first tab in the last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    g.drawLine( right, 6, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        // Paint Highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        g.setColor( isSelected ? selectHighlight : highlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            g.drawLine( 1, 6, 6, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            g.drawLine( 6, 1, (tabIndex == lastIndex) ? right - 1 : right, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            g.drawLine( 1, 6, 1, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            // paint highlight in the gap on tab behind this one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            // on the left end (where they all line up)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            if ( tabIndex==firstIndex && tabIndex!=tabRuns[runCount - 1] ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                //  first tab in run but not first tab in last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                if (tabPane.getSelectedIndex()==tabRuns[currentRun+1]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                    // tab in front of selected tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    g.setColor( selectHighlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                    // tab in front of normal tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                    g.setColor( highlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                g.drawLine( 1, 0, 1, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            g.drawLine( right - 1, 6, right - 6, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            g.drawLine( right - 6, 1, 1, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            if ( tabIndex==lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                // last tab in run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                g.drawLine( 1, 1, 1, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                g.drawLine( 0, 1, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   323
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   324
     * Returns {@code true} if the gap should be filled.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   325
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   326
     * @param currentRun the current run
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   327
     * @param tabIndex the tab index
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   328
     * @param x an X coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   329
     * @param y an Y coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   330
     * @return {@code true} if the gap should be filled
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   331
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    protected boolean shouldFillGap( int currentRun, int tabIndex, int x, int y ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        boolean result = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        if (!tabsOpaque) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        if ( currentRun == runCount - 2 ) {  // If it's the second to last row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            Rectangle lastTabBounds = getTabBounds( tabPane, tabPane.getTabCount() - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            Rectangle tabBounds = getTabBounds( tabPane, tabIndex );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            if (MetalUtils.isLeftToRight(tabPane)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                int lastTabRight = lastTabBounds.x + lastTabBounds.width - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                // is the right edge of the last tab to the right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                // of the left edge of the current tab?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                if ( lastTabRight > tabBounds.x + 2 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                int lastTabLeft = lastTabBounds.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                int currentTabRight = tabBounds.x + tabBounds.width - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                // is the left edge of the last tab to the left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                // of the right edge of the current tab?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                if ( lastTabLeft < currentTabRight - 2 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            // fill in gap for all other rows except last row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            result = currentRun != runCount - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   368
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   369
     * Returns the color of the gap.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   370
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   371
     * @param currentRun the current run
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   372
     * @param x an X coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   373
     * @param y an Y coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   374
     * @return the color of the gap
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   375
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    protected Color getColorForGap( int currentRun, int x, int y ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        final int shadowWidth = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        int selectedIndex = tabPane.getSelectedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        int startIndex = tabRuns[ currentRun + 1 ];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        int endIndex = lastTabInRun( tabPane.getTabCount(), currentRun + 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        int tabOverGap = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        // Check each tab in the row that is 'on top' of this row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        for ( int i = startIndex; i <= endIndex; ++i ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            Rectangle tabBounds = getTabBounds( tabPane, i );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            int tabLeft = tabBounds.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            int tabRight = (tabBounds.x + tabBounds.width) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            // Check to see if this tab is over the gap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            if ( MetalUtils.isLeftToRight(tabPane) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                if ( tabLeft <= x && tabRight - shadowWidth > x ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                    return selectedIndex == i ? selectColor : getUnselectedBackgroundAt( i );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                if ( tabLeft + shadowWidth < x && tabRight >= x ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                    return selectedIndex == i ? selectColor : getUnselectedBackgroundAt( i );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        return tabPane.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   403
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   404
     * Paints the left tab border.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   405
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   406
     * @param tabIndex a tab index
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   407
     * @param g an instance of {@code Graphics}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   408
     * @param x an X coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   409
     * @param y an Y coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   410
     * @param w a width
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   411
     * @param h a height
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   412
     * @param btm bottom
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   413
     * @param rght right
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   414
     * @param isSelected a selection
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   415
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    protected void paintLeftTabBorder( int tabIndex, Graphics g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                                       int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                                       int btm, int rght,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                                       boolean isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        int tabCount = tabPane.getTabCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        int currentRun = getRunForTab( tabCount, tabIndex );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        int lastIndex = lastTabInRun( tabCount, currentRun );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        int firstIndex = tabRuns[ currentRun ];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        int bottom = h - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        int right = w - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        // Paint part of the tab above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        if ( tabIndex != firstIndex && tabsOpaque ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            g.setColor( tabPane.getSelectedIndex() == tabIndex - 1 ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                        selectColor :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                        getUnselectedBackgroundAt( tabIndex - 1 ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            g.fillRect( 2, 0, 4, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            g.drawLine( 2, 3, 2, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        // Paint Highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            g.setColor(isSelected ? selectHighlight :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                       MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            g.setColor( isSelected ? selectHighlight : highlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        g.drawLine( 1, 6, 6, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        g.drawLine( 1, 6, 1, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        g.drawLine( 6, 1, right, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        if ( tabIndex != firstIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            if (tabPane.getSelectedIndex() == tabIndex - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                g.setColor(selectHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                g.setColor(ocean ? MetalLookAndFeel.getWhite() : highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            g.drawLine( 1, 0, 1, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        // Paint Border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            if (isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                g.setColor( darkShadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            g.setColor( darkShadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        g.drawLine( 1, 5, 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        g.drawLine( 6, 0, right, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        // Paint bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        if ( tabIndex == lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            g.drawLine( 0, bottom, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            if (tabPane.getSelectedIndex() == tabIndex - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                g.drawLine(0, 5, 0, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                g.drawLine(0, 0, 0, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            else if (isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                g.drawLine( 0, 6, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                if (tabIndex != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                    g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                    g.drawLine(0, 0, 0, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            else if ( tabIndex != firstIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                g.drawLine( 0, 0, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                g.drawLine( 0, 6, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        else { // metal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            if ( tabIndex != firstIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                g.drawLine( 0, 0, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                g.drawLine( 0, 6, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   533
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   534
     * Paints the bottom tab border.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   535
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   536
     * @param tabIndex a tab index
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   537
     * @param g an instance of {@code Graphics}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   538
     * @param x an X coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   539
     * @param y an Y coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   540
     * @param w a width
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   541
     * @param h a height
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   542
     * @param btm bottom
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   543
     * @param rght right
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   544
     * @param isSelected a selection
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   545
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    protected void paintBottomTabBorder( int tabIndex, Graphics g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                                         int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                                         int btm, int rght,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                                         boolean isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        int tabCount = tabPane.getTabCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        int currentRun = getRunForTab( tabCount, tabIndex );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        int lastIndex = lastTabInRun( tabCount, currentRun );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        int firstIndex = tabRuns[ currentRun ];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        boolean leftToRight = MetalUtils.isLeftToRight(tabPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        int bottom = h - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        int right = w - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        // Paint Gap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        if ( shouldFillGap( currentRun, tabIndex, x, y ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                g.setColor( getColorForGap( currentRun, x, y ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                g.fillRect( 1, bottom - 4, 3, 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                g.fillRect( 4, bottom - 1, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                g.setColor( getColorForGap( currentRun, x + w - 1, y ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                g.fillRect( right - 3, bottom - 3, 3, 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                g.fillRect( right - 5, bottom - 1, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                g.drawLine( right - 1, bottom - 4, right - 1, bottom - 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        // Paint Border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            g.setColor( darkShadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            g.drawLine( 1, bottom - 5, 6, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            // Paint bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            g.drawLine( 6, bottom, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            // Paint right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            if ( tabIndex == lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                g.drawLine( right, 0, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                g.drawLine(0, 0, 0, bottom - 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                if ((currentRun == 0 && tabIndex != 0) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                    (currentRun > 0 && tabIndex != tabRuns[currentRun - 1])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    g.drawLine(0, bottom - 5, 0, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                if (ocean && tabIndex == tabPane.getSelectedIndex() + 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                    g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                if ( tabIndex != tabRuns[ runCount - 1 ] ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                    g.drawLine( 0, 0, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                    g.drawLine( 0, 0, 0, bottom - 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            g.drawLine( right - 1, bottom - 5, right - 6, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            // Paint bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            g.drawLine( right - 6, bottom, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            if ( tabIndex==lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                // last tab in run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                g.drawLine( 0, 0, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            // Paint right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            if (ocean && tabIndex == tabPane.getSelectedIndex() + 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                g.drawLine(right, 0, right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            else if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                g.drawLine(right, 0, right, bottom - 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                if (tabIndex != firstIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                    g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                    g.drawLine(right, bottom - 5, right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            else if ( tabIndex != tabRuns[ runCount - 1 ] ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                // not the first tab in the last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                g.drawLine( right, 0, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                // the first tab in the last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                g.drawLine( right, 0, right, bottom - 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        // Paint Highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        g.setColor( isSelected ? selectHighlight : highlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            g.drawLine( 1, bottom - 6, 6, bottom - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            g.drawLine( 1, 0, 1, bottom - 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            // paint highlight in the gap on tab behind this one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            // on the left end (where they all line up)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            if ( tabIndex==firstIndex && tabIndex!=tabRuns[runCount - 1] ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                //  first tab in run but not first tab in last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                if (tabPane.getSelectedIndex()==tabRuns[currentRun+1]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                    // tab in front of selected tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                    g.setColor( selectHighlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                    // tab in front of normal tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                    g.setColor( highlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                g.drawLine( 1, bottom - 4, 1, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            if ( tabIndex==lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                // last tab in run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                g.drawLine( 1, 0, 1, bottom - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                g.drawLine( 0, 0, 0, bottom - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   703
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   704
     * Paints the right tab border.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   705
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   706
     * @param tabIndex a tab index
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   707
     * @param g an instance of {@code Graphics}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   708
     * @param x an X coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   709
     * @param y an Y coordinate
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   710
     * @param w a width
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   711
     * @param h a height
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   712
     * @param btm bottom
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   713
     * @param rght right
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   714
     * @param isSelected a selection
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   715
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    protected void paintRightTabBorder( int tabIndex, Graphics g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                                        int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                                        int btm, int rght,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                                        boolean isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        int tabCount = tabPane.getTabCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        int currentRun = getRunForTab( tabCount, tabIndex );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        int lastIndex = lastTabInRun( tabCount, currentRun );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        int firstIndex = tabRuns[ currentRun ];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        int bottom = h - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        int right = w - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        // Paint part of the tab above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        if ( tabIndex != firstIndex && tabsOpaque ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            g.setColor( tabPane.getSelectedIndex() == tabIndex - 1 ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                        selectColor :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                        getUnselectedBackgroundAt( tabIndex - 1 ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            g.fillRect( right - 5, 0, 5, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            g.fillRect( right - 2, 3, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        // Paint Highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        g.setColor( isSelected ? selectHighlight : highlight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        g.drawLine( right - 6, 1, right - 1, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        g.drawLine( 0, 1, right - 6, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        // Paint left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        if ( !isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            g.drawLine( 0, 1, 0, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        // Paint Border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            g.setColor( darkShadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        // Paint bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        if ( tabIndex == lastIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            g.drawLine( 0, bottom, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        // Paint slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        if (ocean && tabPane.getSelectedIndex() == tabIndex - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        g.drawLine( right - 6, 0, right, 6 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        // Paint top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        g.drawLine( 0, 0, right - 6, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        // Paint right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        if (ocean && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            g.drawLine(right, 6, right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            if (tabIndex != firstIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                g.drawLine(right, 0, right, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        else if (ocean && tabPane.getSelectedIndex() == tabIndex - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            g.drawLine(right, 0, right, 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            g.drawLine(right, 6, right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        else if ( tabIndex != firstIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            g.drawLine( right, 0, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            g.drawLine( right, 6, right, bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    public void update( Graphics g, JComponent c ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        if ( c.isOpaque() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            g.setColor( tabAreaBackground );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            g.fillRect( 0, 0, c.getWidth(),c.getHeight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        paint( g, c );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    protected void paintTabBackground( Graphics g, int tabPlacement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                                       int tabIndex, int x, int y, int w, int h, boolean isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        int slantWidth = h / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        if ( isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            g.setColor( selectColor );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            g.setColor( getUnselectedBackgroundAt( tabIndex ) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        if (MetalUtils.isLeftToRight(tabPane)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            switch ( tabPlacement ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                case LEFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                    g.fillRect( x + 5, y + 1, w - 5, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                    g.fillRect( x + 2, y + 4, 3, h - 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                case BOTTOM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                    g.fillRect( x + 2, y, w - 2, h - 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                    g.fillRect( x + 5, y + (h - 1) - 3, w - 5, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                case RIGHT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                    g.fillRect( x, y + 2, w - 4, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                    g.fillRect( x + (w - 1) - 3, y + 5, 3, h - 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                case TOP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                    g.fillRect( x + 4, y + 2, (w - 1) - 3, (h - 1) - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                    g.fillRect( x + 2, y + 5, 2, h - 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
            switch ( tabPlacement ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                case LEFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                    g.fillRect( x + 5, y + 1, w - 5, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                    g.fillRect( x + 2, y + 4, 3, h - 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                case BOTTOM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                    g.fillRect( x, y, w - 5, h - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                    g.fillRect( x + (w - 1) - 4, y, 4, h - 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                    g.fillRect( x + (w - 1) - 4, y + (h - 1) - 4, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                case RIGHT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                    g.fillRect( x + 1, y + 1, w - 5, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                    g.fillRect( x + (w - 1) - 3, y + 5, 3, h - 5 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                case TOP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                    g.fillRect( x, y + 2, (w - 1) - 3, (h - 1) - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    g.fillRect( x + (w - 1) - 3, y + 5, 3, h - 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    /**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 9230
diff changeset
   869
     * Overridden to do nothing for the Java L&amp;F.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    protected int getTabLabelShiftX( int tabPlacement, int tabIndex, boolean isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    /**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 9230
diff changeset
   877
     * Overridden to do nothing for the Java L&amp;F.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    protected int getTabLabelShiftY( int tabPlacement, int tabIndex, boolean isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    protected int getBaselineOffset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    public void paint( Graphics g, JComponent c ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        int tabPlacement = tabPane.getTabPlacement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        Insets insets = c.getInsets(); Dimension size = c.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        // Paint the background for the tab area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        if ( tabPane.isOpaque() ) {
25118
d237e069dd9c 8007563: When checking the default behaviour for a scroll tab layout and checking the 'opaque' checkbox, the area behind tabs is not red.
malenkov
parents: 22574
diff changeset
   899
            if (!c.isBackgroundSet() && (tabAreaBackground != null)) {
d237e069dd9c 8007563: When checking the default behaviour for a scroll tab layout and checking the 'opaque' checkbox, the area behind tabs is not red.
malenkov
parents: 22574
diff changeset
   900
                g.setColor(tabAreaBackground);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                g.setColor( c.getBackground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            switch ( tabPlacement ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            case LEFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                g.fillRect( insets.left, insets.top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                            calculateTabAreaWidth( tabPlacement, runCount, maxTabWidth ),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                            size.height - insets.bottom - insets.top );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            case BOTTOM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                int totalTabHeight = calculateTabAreaHeight( tabPlacement, runCount, maxTabHeight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                g.fillRect( insets.left, size.height - insets.bottom - totalTabHeight,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                            size.width - insets.left - insets.right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                            totalTabHeight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            case RIGHT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                int totalTabWidth = calculateTabAreaWidth( tabPlacement, runCount, maxTabWidth );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                g.fillRect( size.width - insets.right - totalTabWidth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                            insets.top, totalTabWidth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                            size.height - insets.top - insets.bottom );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
            case TOP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                g.fillRect( insets.left, insets.top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                            size.width - insets.right - insets.left,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                            calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                paintHighlightBelowTab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        super.paint( g, c );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   935
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   936
     * Paints highlights below tab.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
   937
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    protected void paintHighlightBelowTab( ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    protected void paintFocusIndicator(Graphics g, int tabPlacement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                                       Rectangle[] rects, int tabIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                                       Rectangle iconRect, Rectangle textRect,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                                       boolean isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        if ( tabPane.hasFocus() && isSelected ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            Rectangle tabRect = rects[tabIndex];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            boolean lastInRun = isLastInRun( tabIndex );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            g.setColor( focus );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            g.translate( tabRect.x, tabRect.y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
            int right = tabRect.width - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
            int bottom = tabRect.height - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
            boolean leftToRight = MetalUtils.isLeftToRight(tabPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            switch ( tabPlacement ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            case RIGHT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                g.drawLine( right - 6,2 , right - 2,6 );         // slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                g.drawLine( 1,2 , right - 6,2 );                 // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                g.drawLine( right - 2,6 , right - 2,bottom );    // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                g.drawLine( 1,2 , 1,bottom );                    // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                g.drawLine( 1,bottom , right - 2,bottom );       // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            case BOTTOM:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                    g.drawLine( 2, bottom - 6, 6, bottom - 2 );   // slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                    g.drawLine( 6, bottom - 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                                right, bottom - 2 );              // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                    g.drawLine( 2, 0, 2, bottom - 6 );            // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                    g.drawLine( 2, 0, right, 0 );                 // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                    g.drawLine( right, 0, right, bottom - 2 );    // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                    g.drawLine( right - 2, bottom - 6,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                                right - 6, bottom - 2 );          // slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                    g.drawLine( right - 2, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                                right - 2, bottom - 6 );          // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    if ( lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                        // last tab in run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                        g.drawLine( 2, bottom - 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                                    right - 6, bottom - 2 );      // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                        g.drawLine( 2, 0, right - 2, 0 );         // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                        g.drawLine( 2, 0, 2, bottom - 2 );        // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                        g.drawLine( 1, bottom - 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                                    right - 6, bottom - 2 );      // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                        g.drawLine( 1, 0, right - 2, 0 );         // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                        g.drawLine( 1, 0, 1, bottom - 2 );        // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
            case LEFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                g.drawLine( 2, 6, 6, 2 );                         // slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                g.drawLine( 2, 6, 2, bottom - 1);                 // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                g.drawLine( 6, 2, right, 2 );                     // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                g.drawLine( right, 2, right, bottom - 1 );        // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                g.drawLine( 2, bottom - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                            right, bottom - 1 );                  // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
            case TOP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
             default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                    if ( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                        g.drawLine( 2, 6, 6, 2 );                     // slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                        g.drawLine( 2, 6, 2, bottom - 1);             // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                        g.drawLine( 6, 2, right, 2 );                 // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                        g.drawLine( right, 2, right, bottom - 1 );    // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                        g.drawLine( 2, bottom - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                                    right, bottom - 1 );              // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                        g.drawLine( right - 2, 6, right - 6, 2 );     // slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                        g.drawLine( right - 2, 6,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                                    right - 2, bottom - 1);           // right
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                        if ( lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                            // last tab in run
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                            g.drawLine( right - 6, 2, 2, 2 );         // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                            g.drawLine( 2, 2, 2, bottom - 1 );        // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                            g.drawLine( right - 2, bottom - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                                        2, bottom - 1 );              // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                            g.drawLine( right - 6, 2, 1, 2 );         // top
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                            g.drawLine( 1, 2, 1, bottom - 1 );        // left
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                            g.drawLine( right - 2, bottom - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                                        1, bottom - 1 );              // bottom
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            g.translate( -tabRect.x, -tabRect.y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    protected void paintContentBorderTopEdge( Graphics g, int tabPlacement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                                              int selectedIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                                              int x, int y, int w, int h ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        boolean leftToRight = MetalUtils.isLeftToRight(tabPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        int right = x + w - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        Rectangle selRect = selectedIndex < 0? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                               getTabBounds(selectedIndex, calcRect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
            g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
            g.setColor(selectHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        // Draw unbroken line if tabs are not on TOP, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        // selected tab is not in run adjacent to content, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        // selected tab is not visible (SCROLL_TAB_LAYOUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
         if (tabPlacement != TOP || selectedIndex < 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            (selRect.y + selRect.height + 1 < y) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
            (selRect.x < x || selRect.x > x + w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            g.drawLine(x, y, x+w-2, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            if (ocean && tabPlacement == TOP) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                g.drawLine(x, y + 1, x+w-2, y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            // Break line to show visual connection to selected tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
            boolean lastInRun = isLastInRun(selectedIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
            if ( leftToRight || lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                g.drawLine(x, y, selRect.x + 1, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                g.drawLine(x, y, selRect.x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            if (selRect.x + selRect.width < right - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                if ( leftToRight && !lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                    g.drawLine(selRect.x + selRect.width, y, right - 1, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                    g.drawLine(selRect.x + selRect.width - 1, y, right - 1, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                g.drawLine(x+w-2, y, x+w-2, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                if ( leftToRight || lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                    g.drawLine(x, y + 1, selRect.x + 1, y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                    g.drawLine(x, y + 1, selRect.x, y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
                if (selRect.x + selRect.width < right - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                    if ( leftToRight && !lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                        g.drawLine(selRect.x + selRect.width, y + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                                   right - 1, y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                        g.drawLine(selRect.x + selRect.width - 1, y + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                                   right - 1, y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
                    g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
                    g.drawLine(x+w-2, y + 1, x+w-2, y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                                                int selectedIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                                                int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        boolean leftToRight = MetalUtils.isLeftToRight(tabPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        int bottom = y + h - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        int right = x + w - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        Rectangle selRect = selectedIndex < 0? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                               getTabBounds(selectedIndex, calcRect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        // Draw unbroken line if tabs are not on BOTTOM, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
        // selected tab is not in run adjacent to content, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        // selected tab is not visible (SCROLL_TAB_LAYOUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        if (tabPlacement != BOTTOM || selectedIndex < 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
             (selRect.y - 1 > h) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
             (selRect.x < x || selRect.x > x + w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
            if (ocean && tabPlacement == BOTTOM) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
            g.drawLine(x, y+h-1, x+w-1, y+h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
            // Break line to show visual connection to selected tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
            boolean lastInRun = isLastInRun(selectedIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
            if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            if ( leftToRight || lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                g.drawLine(x, bottom, selRect.x, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                g.drawLine(x, bottom, selRect.x - 1, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
            if (selRect.x + selRect.width < x + w - 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                if ( leftToRight && !lastInRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
                    g.drawLine(selRect.x + selRect.width, bottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                                                   right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
                    g.drawLine(selRect.x + selRect.width - 1, bottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                                                       right, bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                                              int selectedIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                                              int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        Rectangle selRect = selectedIndex < 0? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                               getTabBounds(selectedIndex, calcRect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
            g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
            g.setColor(selectHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
        // Draw unbroken line if tabs are not on LEFT, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        // selected tab is not in run adjacent to content, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
        // selected tab is not visible (SCROLL_TAB_LAYOUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
        if (tabPlacement != LEFT || selectedIndex < 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            (selRect.x + selRect.width + 1 < x) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
            (selRect.y < y || selRect.y > y + h)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
            g.drawLine(x, y + 1, x, y+h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
            if (ocean && tabPlacement == LEFT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
                g.drawLine(x + 1, y, x + 1, y + h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
            // Break line to show visual connection to selected tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
            g.drawLine(x, y, x, selRect.y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
            if (selRect.y + selRect.height < y + h - 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
              g.drawLine(x, selRect.y + selRect.height + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                         x, y+h+2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
            if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
                g.drawLine(x + 1, y + 1, x + 1, selRect.y + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
                if (selRect.y + selRect.height < y + h - 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
                    g.drawLine(x + 1, selRect.y + selRect.height + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
                               x + 1, y+h+2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
    protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
                                               int selectedIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
                                               int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        Rectangle selRect = selectedIndex < 0? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                               getTabBounds(selectedIndex, calcRect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        g.setColor(darkShadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        // Draw unbroken line if tabs are not on RIGHT, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        // selected tab is not in run adjacent to content, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        // selected tab is not visible (SCROLL_TAB_LAYOUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
        if (tabPlacement != RIGHT || selectedIndex < 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
             (selRect.x - 1 > w) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
             (selRect.y < y || selRect.y > y + h)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
            if (ocean && tabPlacement == RIGHT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
            g.drawLine(x+w-1, y, x+w-1, y+h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
            // Break line to show visual connection to selected tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            if (ocean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
                g.setColor(oceanSelectedBorderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
            g.drawLine(x+w-1, y, x+w-1, selRect.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
            if (selRect.y + selRect.height < y + h - 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                g.drawLine(x+w-1, selRect.y + selRect.height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                           x+w-1, y+h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
    protected int calculateMaxTabHeight( int tabPlacement ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        FontMetrics metrics = getFontMetrics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        int height = metrics.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        boolean tallerIcons = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
        for ( int i = 0; i < tabPane.getTabCount(); ++i ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
            Icon icon = tabPane.getIconAt( i );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
            if ( icon != null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                if ( icon.getIconHeight() > height ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                    tallerIcons = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        return super.calculateMaxTabHeight( tabPlacement ) -
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
                  (tallerIcons ? (tabInsets.top + tabInsets.bottom) : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    protected int getTabRunOverlay( int tabPlacement ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        // Tab runs laid out vertically should overlap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        // at least as much as the largest slant
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        if ( tabPlacement == LEFT || tabPlacement == RIGHT ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
            int maxTabHeight = calculateMaxTabHeight(tabPlacement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
            return maxTabHeight / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1254
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1255
     * Returns {@code true} if tab runs should be rotated.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1256
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1257
     * @param tabPlacement a tab placement
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1258
     * @param selectedRun a selected run
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1259
     * @return {@code true} if tab runs should be rotated.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1260
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
    protected boolean shouldRotateTabRuns( int tabPlacement, int selectedRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
    // Don't pad last run
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
    protected boolean shouldPadTabRun( int tabPlacement, int run ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
        return runCount > 1 && run < runCount - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
    private boolean isLastInRun( int tabIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
        int run = getRunForTab( tabPane.getTabCount(), tabIndex );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        int lastIndex = lastTabInRun( tabPane.getTabCount(), run );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        return tabIndex == lastIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     * Returns the color to use for the specified tab.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
    private Color getUnselectedBackgroundAt(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
        Color color = tabPane.getBackgroundAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        if (color instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
            if (unselectedBackground != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                return unselectedBackground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
        return color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * Returns the tab index of JTabbedPane the mouse is currently over
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    int getRolloverTabIndex() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
        return getRolloverTab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
     * This class should be treated as a &quot;protected&quot; inner class.
9230
c5674561cb9e 6985329: 9 classes in swing.plaf contains words inappropriate for public spec - about some compiler bug
alexp
parents: 5506
diff changeset
  1298
     * Instantiate it only within subclasses of {@code MetalTabbedPaneUI}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
    public class TabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1302
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1303
         * Constructs {@code TabbedPaneLayout}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 25118
diff changeset
  1304
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
        public TabbedPaneLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
            MetalTabbedPaneUI.this.super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        protected void normalizeTabRuns( int tabPlacement, int tabCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
                                     int start, int max ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
            // Only normalize the runs for top & bottom;  normalizing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
            // doesn't look right for Metal's vertical tabs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
            // because the last run isn't padded and it looks odd to have
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
            // fat tabs in the first vertical runs, but slimmer ones in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
            // last (this effect isn't noticeable for horizontal tabs).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
            if ( tabPlacement == TOP || tabPlacement == BOTTOM ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
                super.normalizeTabRuns( tabPlacement, tabCount, start, max );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        // Don't rotate runs!
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        protected void rotateTabRuns( int tabPlacement, int selectedRun ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
        // Don't pad selected tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        protected void padSelectedTab( int tabPlacement, int selectedIndex ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
}