Source Code Cross Referenced for Eclipse3xJideTabbedPaneUI.java in  » Swing-Library » jide-common » com » jidesoft » plaf » eclipse » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jide common » com.jidesoft.plaf.eclipse 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * @(#)Eclipse3xJideTabbedPaneUI.java 8/28/2006
0003:         *
0004:         * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
0005:         */
0006:
0007:        package com.jidesoft.plaf.eclipse;
0008:
0009:        import com.jidesoft.plaf.UIDefaultsLookup;
0010:        import com.jidesoft.plaf.vsnet.VsnetJideTabbedPaneUI;
0011:        import com.jidesoft.swing.JideSwingUtilities;
0012:        import com.jidesoft.swing.JideTabbedPane;
0013:
0014:        import javax.swing.*;
0015:        import javax.swing.plaf.ComponentUI;
0016:        import javax.swing.plaf.basic.BasicGraphicsUtils;
0017:        import javax.swing.text.View;
0018:        import java.awt.*;
0019:
0020:        /**
0021:         * A eclipse L&f implementation of JideTabbedPaneUI
0022:         */
0023:        public class Eclipse3xJideTabbedPaneUI extends VsnetJideTabbedPaneUI {
0024:            // pixels
0025:            protected int _closeButtonMargin;// margin around the close button
0026:
0027:            protected int _closeButtonMarginSize;// margin of the close button when every tab has a close button
0028:
0029:            protected int _iconMarginHorizon;// distance from icon to tab rect start when the tab is on the top or bottom
0030:
0031:            protected int _iconMarginVertical;// distance from icon to tab rect start when the tab is on the left or right
0032:
0033:            public static ComponentUI createUI(JComponent c) {
0034:                return new Eclipse3xJideTabbedPaneUI();
0035:            }
0036:
0037:            @Override
0038:            public void installUI(JComponent c) {
0039:                super .installUI(c);
0040:                _rectSizeExtend = 12;
0041:            }
0042:
0043:            @Override
0044:            protected void installDefaults() {
0045:                super .installDefaults();
0046:                // set the border of the tabbedpane
0047:                LookAndFeel.installBorder(_tabPane, "JideTabbedPane.border");
0048:                _closeButtonMargin = UIDefaultsLookup
0049:                        .getInt("JideTabbedPane.closeButtonMargin");
0050:                _closeButtonMarginSize = UIDefaultsLookup
0051:                        .getInt("JideTabbedPane.closeButtonMarginSize");
0052:                _iconMarginHorizon = UIDefaultsLookup
0053:                        .getInt("JideTabbedPane.iconMarginHorizon");
0054:                _iconMarginVertical = UIDefaultsLookup
0055:                        .getInt("JideTabbedPane.iconMarginVertical");
0056:            }
0057:
0058:            @Override
0059:            public void paintBackground(Graphics g, Component c) {
0060:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
0061:                    if (_tabPane.isOpaque()) {
0062:                        int width = c.getWidth();
0063:                        int height = c.getHeight();
0064:
0065:                        int temp1 = -1;
0066:                        int temp2 = -1;
0067:                        if (isTabLeadingComponentVisible()) {
0068:                            if (height < _tabLeadingComponent.getSize().height) {
0069:                                height = _tabLeadingComponent.getSize().height;
0070:                                temp1 = _tabLeadingComponent.getSize().height;
0071:                            }
0072:                            if (width < _tabLeadingComponent.getSize().width) {
0073:                                width = _tabLeadingComponent.getSize().width;
0074:                                temp2 = _tabLeadingComponent.getSize().width;
0075:                            }
0076:                        }
0077:
0078:                        if (isTabTrailingComponentVisible()) {
0079:                            if (height < _tabTrailingComponent.getSize().height
0080:                                    && temp1 < _tabTrailingComponent.getSize().height) {
0081:                                height = _tabTrailingComponent.getSize().height;
0082:                            }
0083:                            if (width < _tabTrailingComponent.getSize().width
0084:                                    && temp2 < _tabTrailingComponent.getSize().width) {
0085:                                width = _tabTrailingComponent.getSize().width;
0086:                            }
0087:                        }
0088:
0089:                        g.setColor(_background);
0090:                        g.fillRect(0, 0, width, height);
0091:                    }
0092:                } else {
0093:                    super .paintBackground(g, c);
0094:                }
0095:            }
0096:
0097:            @Override
0098:            protected void ensureCurrentLayout() {
0099:                /*
0100:                 * If tabPane doesn't have a peer yet, the validate() call will silently
0101:                 * fail. We handle that by forcing a layout if tabPane is still invalid.
0102:                 * See bug 4237677.
0103:                 */
0104:                if (!_tabPane.isValid()) {
0105:                    TabbedPaneLayout layout = (TabbedPaneLayout) _tabPane
0106:                            .getLayout();
0107:                    layout.calculateLayoutInfo();
0108:                }
0109:
0110:                // ensure the bounds of the close buttons when they are showed on the
0111:                // tab
0112:                if (scrollableTabLayoutEnabled() && isShowCloseButton()
0113:                        && isShowCloseButtonOnTab()) {
0114:                    for (int i = 0; i < _closeButtons.length; i++) {
0115:                        if (_tabPane.isShowCloseButtonOnSelectedTab()) {
0116:                            if (i != _tabPane.getSelectedIndex()) {
0117:                                _closeButtons[i].setBounds(0, 0, 0, 0);
0118:                                continue;
0119:                            }
0120:                        } else {
0121:                            if (i >= _rects.length) {
0122:                                _closeButtons[i].setBounds(0, 0, 0, 0);
0123:                                continue;
0124:                            }
0125:                        }
0126:
0127:                        if (!_tabPane.isTabClosableAt(i)) {
0128:                            _closeButtons[i].setBounds(0, 0, 0, 0);
0129:                            continue;
0130:                        }
0131:                        Dimension size = _closeButtons[i].getPreferredSize();
0132:
0133:                        Rectangle bounds = null;
0134:                        if (_closeButtonAlignment == SwingConstants.TRAILING) {
0135:                            if (_tabPane.getTabPlacement() == JideTabbedPane.TOP
0136:                                    || _tabPane.getTabPlacement() == JideTabbedPane.BOTTOM) {
0137:                                bounds = new Rectangle(
0138:                                        _rects[i].x + _rects[i].width
0139:                                                - size.width - 16,
0140:                                        _rects[i].y
0141:                                                + ((_rects[i].height - size.height) >> 1),
0142:                                        size.width, size.height);
0143:                            } else if (_tabPane.getTabPlacement() == JideTabbedPane.LEFT) {
0144:                                bounds = new Rectangle(
0145:                                        _rects[i].x
0146:                                                + ((_rects[i].width - size.width) >> 1),
0147:                                        _rects[i].y + _rects[i].height
0148:                                                - size.height - 16, size.width,
0149:                                        size.height);
0150:                            } else /*if (_tabPane.getTabPlacement() == JideTabbedPane.RIGHT)*/{
0151:                                bounds = new Rectangle(
0152:                                        _rects[i].x
0153:                                                + ((_rects[i].width - size.width) >> 1),
0154:                                        _rects[i].y + _rects[i].height
0155:                                                - size.height - 16, size.width,
0156:                                        size.height);
0157:                            }
0158:                        } else {
0159:                            bounds = new Rectangle(_rects[i].x + 4,
0160:                                    ((_rects[i].height - size.height) >> 1),
0161:                                    size.width, size.height);
0162:                        }
0163:                        _closeButtons[i].setIndex(i);
0164:                        if (!bounds.equals(_closeButtons[i].getBounds())) {
0165:                            _closeButtons[i].setBounds(bounds);
0166:                        }
0167:                        if (_tabPane.getSelectedIndex() == i) {
0168:                            _closeButtons[i]
0169:                                    .setBackground(_selectedColor == null ? _tabPane
0170:                                            .getBackgroundAt(i)
0171:                                            : _selectedColor);
0172:                        } else {
0173:                            _closeButtons[i].setBackground(_tabPane
0174:                                    .getBackgroundAt(i));
0175:                        }
0176:                    }
0177:                }
0178:
0179:            }
0180:
0181:            /**
0182:             * Paints the tabs in the tab area. Invoked by paint(). The graphics
0183:             * parameter must be a valid <code>Graphics</code> object. Tab placement
0184:             * may be either: <code>JTabbedPane.TOP</code>,
0185:             * <code>JTabbedPane.BOTTOM</code>, <code>JTabbedPane.LEFT</code>, or
0186:             * <code>JTabbedPane.RIGHT</code>. The selected index must be a valid
0187:             * tabbed pane tab index (0 to tab count - 1, inclusive) or -1 if no tab is
0188:             * currently selected. The handling of invalid parameters is unspecified.
0189:             *
0190:             * @param g             the graphics object to use for rendering
0191:             * @param tabPlacement  the placement for the tabs within the JTabbedPane
0192:             * @param selectedIndex the tab index of the selected component
0193:             */
0194:            @Override
0195:            protected void paintTabArea(Graphics g, int tabPlacement,
0196:                    int selectedIndex) {
0197:
0198:                if (!PAINT_TABAREA) {
0199:                    return;
0200:                }
0201:
0202:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
0203:                    int tabCount = _tabPane.getTabCount();
0204:
0205:                    Rectangle iconRect = new Rectangle(), textRect = new Rectangle();
0206:                    Rectangle clipRect = g.getClipBounds();
0207:                    Rectangle viewRect = _tabScroller.viewport.getViewRect();
0208:
0209:                    if (_tabPane.isOpaque()) {
0210:                        g.setColor(_tabBackground);
0211:                        g.fillRect(clipRect.x, clipRect.y, clipRect.width,
0212:                                clipRect.height);
0213:                    }
0214:
0215:                    // Paint tabRuns of tabs from back to front
0216:                    for (int i = _runCount - 1; i >= 0; i--) {
0217:                        int start = _tabRuns[i];
0218:                        int next = _tabRuns[(i == _runCount - 1) ? 0 : i + 1];
0219:                        int end = (next != 0 ? next - 1 : tabCount - 1);
0220:                        for (int j = start; j <= end; j++) {
0221:                            if (_rects[j].intersects(clipRect)) {// 两者是否相交
0222:                                paintTab(g, tabPlacement, _rects, j, iconRect,
0223:                                        textRect);
0224:                            }
0225:                        }
0226:                    }
0227:
0228:                    // Paint selected tab if its in the front run
0229:                    // since it may overlap other tabs
0230:                    if (selectedIndex >= 0
0231:                            && getRunForTab(tabCount, selectedIndex) == 0) {
0232:                        if (_rects[selectedIndex].intersects(clipRect)) {
0233:                            paintTab(g, tabPlacement, _rects, selectedIndex,
0234:                                    iconRect, textRect);
0235:                        }
0236:                    }
0237:
0238:                    if (_tabPane.isOpaque()) {
0239:                        g.setColor(_shadow);
0240:                        switch (tabPlacement) {
0241:                        case LEFT:
0242:                            if (!isTabLeadingComponentVisible()) {
0243:                                g.fillRect(viewRect.x, viewRect.y + 3, 1, 2);
0244:                                g
0245:                                        .fillRect(viewRect.x + 1,
0246:                                                viewRect.y + 2, 1, 1);
0247:                                g
0248:                                        .fillRect(viewRect.x + 2,
0249:                                                viewRect.y + 1, 1, 1);
0250:                                g.fillRect(viewRect.x + 3, viewRect.y, 2, 1);
0251:                            }
0252:
0253:                            if (isNoneTabTrailingComponentVisible()) {
0254:                                g.fillRect(viewRect.x + 3, viewRect.y
0255:                                        + viewRect.height - 1, 2, 1);
0256:                                g.fillRect(viewRect.x + 2, viewRect.y
0257:                                        + viewRect.height - 2, 1, 1);
0258:                                g.fillRect(viewRect.x + 1, viewRect.y
0259:                                        + viewRect.height - 3, 1, 1);
0260:                                g.fillRect(viewRect.x, viewRect.y
0261:                                        + viewRect.height - 5, 1, 2);
0262:                            }
0263:
0264:                            g.setColor(_tabBackground);
0265:                            g.fillRect(viewRect.x, viewRect.y, 3, 1);
0266:                            g.fillRect(viewRect.x, viewRect.y + 1, 2, 1);
0267:                            g.fillRect(viewRect.x, viewRect.y + 2, 1, 1);
0268:                            break;
0269:                        case RIGHT:
0270:                            if (!isTabLeadingComponentVisible()) {
0271:                                g.fillRect(viewRect.x + viewRect.width - 5,
0272:                                        viewRect.y, 2, 1);
0273:                                g.fillRect(viewRect.x + viewRect.width - 3,
0274:                                        viewRect.y + 1, 1, 1);
0275:                                g.fillRect(viewRect.x + viewRect.width - 2,
0276:                                        viewRect.y + 2, 1, 1);
0277:                                g.fillRect(viewRect.x + viewRect.width - 1,
0278:                                        viewRect.y + 3, 1, 2);
0279:                            }
0280:
0281:                            if (isNoneTabTrailingComponentVisible()) {
0282:                                g.fillRect(viewRect.x + viewRect.width - 5,
0283:                                        viewRect.y + viewRect.height - 1, 2, 1);
0284:                                g.fillRect(viewRect.x + viewRect.width - 3,
0285:                                        viewRect.y + viewRect.height - 2, 1, 1);
0286:                                g.fillRect(viewRect.x + viewRect.width - 2,
0287:                                        viewRect.y + viewRect.height - 3, 1, 1);
0288:                                g.fillRect(viewRect.x + viewRect.width - 1,
0289:                                        viewRect.y + viewRect.height - 5, 1, 2);
0290:                            }
0291:
0292:                            g.setColor(_tabBackground);
0293:                            g.fillRect(viewRect.x + viewRect.width - 3,
0294:                                    viewRect.y, 3, 1);
0295:                            g.fillRect(viewRect.x + viewRect.width - 2,
0296:                                    viewRect.y + 1, 2, 1);
0297:                            g.fillRect(viewRect.x + viewRect.width - 1,
0298:                                    viewRect.y + 2, 1, 1);
0299:                            break;
0300:                        case BOTTOM:
0301:                            if (!isTabLeadingComponentVisible()) {
0302:                                g.fillRect(viewRect.x + 3, viewRect.y
0303:                                        + viewRect.height - 1, 2, 1);
0304:                                g.fillRect(viewRect.x + 2, viewRect.y
0305:                                        + viewRect.height - 2, 1, 1);
0306:                                g.fillRect(viewRect.x + 1, viewRect.y
0307:                                        + viewRect.height - 3, 1, 1);
0308:                                g.fillRect(viewRect.x, viewRect.y
0309:                                        + viewRect.height - 5, 1, 2);
0310:                            }
0311:
0312:                            if (isNoneTabTrailingComponentVisible()) {
0313:                                g.fillRect(viewRect.x + viewRect.width - 5,
0314:                                        viewRect.y + viewRect.height - 1, 2, 1);
0315:                                g.fillRect(viewRect.x + viewRect.width - 3,
0316:                                        viewRect.y + viewRect.height - 2, 1, 1);
0317:                                g.fillRect(viewRect.x + viewRect.width - 2,
0318:                                        viewRect.y + viewRect.height - 3, 1, 1);
0319:                                g.fillRect(viewRect.x + viewRect.width - 1,
0320:                                        viewRect.y + viewRect.height - 5, 1, 2);
0321:                            }
0322:
0323:                            g.setColor(_tabBackground);
0324:                            g.fillRect(viewRect.x, viewRect.y + viewRect.height
0325:                                    - 1, 3, 1);
0326:                            g.fillRect(viewRect.x, viewRect.y + viewRect.height
0327:                                    - 2, 2, 1);
0328:                            g.fillRect(viewRect.x, viewRect.y + viewRect.height
0329:                                    - 3, 1, 1);
0330:                            break;
0331:                        case TOP:
0332:                        default:
0333:                            if (!isTabLeadingComponentVisible()) {
0334:                                g.fillRect(viewRect.x + 3, viewRect.y, 2, 1);
0335:                                g
0336:                                        .fillRect(viewRect.x + 2,
0337:                                                viewRect.y + 1, 1, 1);
0338:                                g
0339:                                        .fillRect(viewRect.x + 1,
0340:                                                viewRect.y + 2, 1, 1);
0341:                                g.fillRect(viewRect.x, viewRect.y + 3, 1, 2);
0342:                            }
0343:
0344:                            if (isNoneTabTrailingComponentVisible()) {
0345:                                g.fillRect(viewRect.x + viewRect.width - 5,
0346:                                        viewRect.y, 2, 1);
0347:                                g.fillRect(viewRect.x + viewRect.width - 3,
0348:                                        viewRect.y + 1, 1, 1);
0349:                                g.fillRect(viewRect.x + viewRect.width - 2,
0350:                                        viewRect.y + 2, 1, 1);
0351:                                g.fillRect(viewRect.x + viewRect.width - 1,
0352:                                        viewRect.y + 3, 1, 2);
0353:                            }
0354:
0355:                            g.setColor(_tabBackground);
0356:                            g.fillRect(viewRect.x, viewRect.y, 3, 1);
0357:                            g.fillRect(viewRect.x, viewRect.y + 1, 2, 1);
0358:                            g.fillRect(viewRect.x, viewRect.y + 2, 1, 1);
0359:                        }
0360:                    }
0361:                } else {
0362:                    super .paintTabArea(g, tabPlacement, selectedIndex);
0363:                }
0364:            }
0365:
0366:            private boolean isNoneTabTrailingComponentVisible() {
0367:                return !_tabScroller.scrollForwardButton.isVisible()
0368:                        && !_tabScroller.scrollBackwardButton.isVisible()
0369:                        && !_tabScroller.closeButton.isVisible()
0370:                        && !isTabTrailingComponentVisible();
0371:            }
0372:
0373:            @Override
0374:            protected void layoutLabel(int tabPlacement, FontMetrics metrics,
0375:                    int tabIndex, String title, Icon icon, Rectangle tabRect,
0376:                    Rectangle iconRect, Rectangle textRect, boolean isSelected) {
0377:                textRect.x = textRect.y = iconRect.x = iconRect.y = 0;
0378:
0379:                View v = getTextViewForTab(tabIndex);
0380:                if (v != null) {
0381:                    _tabPane.putClientProperty("html", v);
0382:                }
0383:
0384:                SwingUtilities.layoutCompoundLabel(_tabPane, metrics, title,
0385:                        icon, SwingUtilities.CENTER, SwingUtilities.CENTER,
0386:                        SwingUtilities.CENTER, SwingUtilities.TRAILING,
0387:                        tabRect, iconRect, textRect, _textIconGap);
0388:
0389:                _tabPane.putClientProperty("html", null);
0390:
0391:                if (tabPlacement == JideTabbedPane.TOP
0392:                        || tabPlacement == JideTabbedPane.BOTTOM) {
0393:                    iconRect.x = tabRect.x + _iconMarginHorizon;
0394:                    textRect.x = (icon != null ? iconRect.x + iconRect.width
0395:                            + _textIconGap : tabRect.x + _textPadding);
0396:                    iconRect.width = Math.min(iconRect.width, tabRect.width
0397:                            - _tabRectPadding);
0398:                    textRect.width = tabRect.width - _tabRectPadding
0399:                            - iconRect.width
0400:                            - (icon != null ? _textIconGap : _noIconMargin);
0401:
0402:                    if ((getTabResizeMode() == JideTabbedPane.RESIZE_MODE_FIT || _tabPane
0403:                            .getTabResizeMode() == JideTabbedPane.RESIZE_MODE_FIXED)) {
0404:                        textRect.width -= 10;
0405:                        if (isShowCloseButton() && isShowCloseButtonOnTab()) {
0406:                            if (_tabPane.isShowCloseButtonOnSelectedTab()) {
0407:                                if (isSelected) {
0408:                                    textRect.width -= _closeButtons[tabIndex]
0409:                                            .getPreferredSize().width;
0410:                                }
0411:                            } else {
0412:                                textRect.width -= _closeButtons[tabIndex]
0413:                                        .getPreferredSize().width;
0414:                            }
0415:                        }
0416:                    } else if (getTabResizeMode() == JideTabbedPane.RESIZE_MODE_COMPRESSED
0417:                            && isShowCloseButton() && isShowCloseButtonOnTab()) {
0418:                        if (!_tabPane.isShowCloseButtonOnSelectedTab()) {
0419:                            if (!isSelected) {
0420:                                iconRect.width = iconRect.width
0421:                                        + _closeButtons[tabIndex]
0422:                                                .getPreferredSize().width
0423:                                        + _closeButtonMarginSize;
0424:                                textRect.width = 0;
0425:                            }
0426:                        }
0427:                    }
0428:                } else {
0429:                    iconRect.y = tabRect.y + _iconMarginVertical;
0430:                    textRect.y = (icon != null ? iconRect.y + iconRect.height
0431:                            + _textIconGap : tabRect.y + _textPadding);
0432:                    iconRect.x = tabRect.x + 3;
0433:                    textRect.x = tabRect.x + 3;
0434:                    textRect.width = tabRect.width - _textMarginVertical;
0435:                    textRect.height = tabRect.height - _tabRectPadding
0436:                            - iconRect.height
0437:                            - (icon != null ? _textIconGap : _noIconMargin);
0438:
0439:                    if ((getTabResizeMode() == JideTabbedPane.RESIZE_MODE_FIT || _tabPane
0440:                            .getTabResizeMode() == JideTabbedPane.RESIZE_MODE_FIXED)) {
0441:                        textRect.height -= 10;
0442:                        if (isShowCloseButton() && isShowCloseButtonOnTab()) {
0443:                            if (_tabPane.isShowCloseButtonOnSelectedTab()) {
0444:                                if (isSelected) {
0445:                                    textRect.height -= _closeButtons[tabIndex]
0446:                                            .getPreferredSize().height;
0447:                                }
0448:                            } else {
0449:                                textRect.height -= _closeButtons[tabIndex]
0450:                                        .getPreferredSize().height;
0451:                            }
0452:                        }
0453:                    } else if (getTabResizeMode() == JideTabbedPane.RESIZE_MODE_COMPRESSED
0454:                            && isShowCloseButton() && isShowCloseButtonOnTab()) {
0455:                        if (!_tabPane.isShowCloseButtonOnSelectedTab()) {
0456:                            if (!isSelected) {
0457:                                iconRect.height = iconRect.height
0458:                                        + _closeButtons[tabIndex]
0459:                                                .getPreferredSize().height
0460:                                        + _closeButtonMarginSize;
0461:                                textRect.height = 0;
0462:                            }
0463:                        }
0464:
0465:                    }
0466:                }
0467:
0468:            }
0469:
0470:            /**
0471:             * this function draws the border around each tab note that this function
0472:             * does now draw the background of the tab. that is done elsewhere
0473:             */
0474:            @Override
0475:            protected void paintTabBorder(Graphics g, int tabPlacement,
0476:                    int tabIndex, int x, int y, int w, int h, boolean isSelected) {
0477:                if (!PAINT_TAB_BORDER) {
0478:                    return;
0479:                }
0480:
0481:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
0482:                    g.setColor(_lightHighlight);
0483:                    switch (tabPlacement) {
0484:                    case LEFT:
0485:                        if (!isTabLeadingComponentVisible())
0486:                            y--;
0487:
0488:                        if (isSelected) {
0489:                            g.setColor(_shadow);
0490:                            g.drawLine(x + 5, y, x + w - 1, y);// top
0491:
0492:                            // top left arc
0493:                            g.drawLine(x + 4, y + 1, x + 3, y + 1);
0494:                            g.drawLine(x + 2, y + 2, x + 2, y + 2);
0495:                            g.drawLine(x + 1, y + 3, x + 1, y + 3);
0496:                            g.drawLine(x, y + 4, x, y + 5);
0497:
0498:                            if (isTabTopVisible(tabPlacement)) {
0499:                                g.drawLine(x, y + 5, x, y + h - 21);
0500:                            }
0501:
0502:                            // bottom left arc
0503:                            g.drawLine(x, y + h - 21, x, y + h - 19);
0504:                            g.drawLine(x + 1, y + h - 18, x + 1, y + h - 16);
0505:                            g.drawLine(x + 2, y + h - 15, x + 2, y + h - 14);
0506:                            g.drawLine(x + 3, y + h - 13, x + 3, y + h - 13);
0507:                            g.drawLine(x + 4, y + h - 12, x + 4, y + h - 11);
0508:
0509:                            // bottom
0510:                            for (int i = 0; i < w - 10; i++) {
0511:                                g.drawLine(x + 5 + i, y + h - 10 + i,
0512:                                        x + 5 + i, y + h - 10 + i);
0513:                            }
0514:
0515:                            // bottom right arc
0516:                            g.drawLine(x + w - 5, y + h + w - 20, x + w - 5, y
0517:                                    + h + w - 19);
0518:                            g.drawLine(x + w - 4, y + h + w - 18, x + w - 4, y
0519:                                    + h + w - 18);
0520:                            g.drawLine(x + w - 3, y + h + w - 17, x + w - 3, y
0521:                                    + h + w - 16);
0522:                            g.drawLine(x + w - 2, y + h + w - 15, x + w - 2, y
0523:                                    + h + w - 13);
0524:                            g.drawLine(x + w - 1, y + h + w - 12, x + w - 1, y
0525:                                    + h + w - 10);
0526:
0527:                            if (!isTabLeadingComponentVisible())
0528:                                y++;
0529:                            break;
0530:                        }
0531:
0532:                        // not selected
0533:                        if (tabIndex > _tabPane.getSelectedIndex()) {
0534:                            g.setColor(_shadow);
0535:                            g.drawLine(x, y + h - 1, (x + w) - 1, y + h - 1);// bottom
0536:
0537:                            break;
0538:                        }
0539:
0540:                        if (tabIndex >= _tabPane.getSelectedIndex()
0541:                                || tabIndex == 0)
0542:                            break;
0543:
0544:                        g.setColor(_shadow);
0545:                        g.drawLine(x, y - 1, x + w - 1, y - 1);// top
0546:
0547:                        break;
0548:                    case RIGHT:
0549:                        if (!isTabLeadingComponentVisible())
0550:                            y--;
0551:
0552:                        if (isSelected) {
0553:                            g.setColor(_shadow);
0554:
0555:                            g.drawLine(x, y, x + w - 6, y);// top
0556:
0557:                            // top right arc
0558:                            g.drawLine(x + w - 5, y + 1, x + w - 4, y + 1);
0559:                            g.drawLine(x + w - 3, y + 2, x + w - 3, y + 2);
0560:                            g.drawLine(x + w - 2, y + 3, x + w - 2, y + 3);
0561:                            g.drawLine(x + w - 1, y + 4, x + w - 1, y + 5);
0562:
0563:                            if (isTabTopVisible(tabPlacement)) {
0564:                                g.drawLine(x + w - 1, y + 5, x + w - 1, y + h
0565:                                        - 21);
0566:                            }
0567:
0568:                            // bottom right arc
0569:                            g.drawLine(x + w - 1, y + h - 21, x + w - 1, y + h
0570:                                    - 19);
0571:                            g.drawLine(x + w - 2, y + h - 18, x + w - 2, y + h
0572:                                    - 16);
0573:                            g.drawLine(x + w - 3, y + h - 15, x + w - 3, y + h
0574:                                    - 14);
0575:                            g.drawLine(x + w - 4, y + h - 13, x + w - 4, y + h
0576:                                    - 13);
0577:                            g.drawLine(x + w - 5, y + h - 12, x + w - 5, y + h
0578:                                    - 11);
0579:
0580:                            // bottom
0581:                            for (int i = 0; i < w - 10; i++) {
0582:                                g.drawLine(x + w - 6 - i, y + h - 10 + i, x + w
0583:                                        - 6 - i, y + h - 10 + i);
0584:                            }
0585:
0586:                            // bottom left arc
0587:                            g.drawLine(x + 4, y + h + w - 20, x + 4, y + h + w
0588:                                    - 19);
0589:                            g.drawLine(x + 3, y + h + w - 18, x + 3, y + h + w
0590:                                    - 18);
0591:                            g.drawLine(x + 2, y + h + w - 17, x + 2, y + h + w
0592:                                    - 16);
0593:                            g.drawLine(x + 1, y + h + w - 15, x + 1, y + h + w
0594:                                    - 13);
0595:                            g.drawLine(x, y + h + w - 12, x, y + h + w - 10);
0596:                            break;
0597:
0598:                        }
0599:
0600:                        // not selected
0601:                        if (tabIndex > _tabPane.getSelectedIndex()) {
0602:                            g.setColor(_shadow);
0603:                            g.drawLine(x, y + h - 1, (x + w) - 1, y + h - 1);// bottom
0604:
0605:                            break;
0606:                        }
0607:
0608:                        if (tabIndex >= _tabPane.getSelectedIndex()
0609:                                || tabIndex == 0)
0610:                            break;
0611:
0612:                        g.setColor(_shadow);
0613:                        g.drawLine(x, y - 1, x + w - 1, y - 1);// top
0614:
0615:                        break;
0616:                    case BOTTOM:
0617:                        if (!isTabLeadingComponentVisible()) {
0618:                            x--;
0619:                        }
0620:                        if (isSelected) {
0621:
0622:                            g.setColor(_shadow);
0623:
0624:                            g.drawLine(x, y + h - 6, x, y);// left
0625:
0626:                            // left bottom arc
0627:                            g.drawLine(x + 1, y + h - 5, x + 1, y + h - 4);
0628:                            g.drawLine(x + 2, y + h - 3, x + 2, y + h - 3);
0629:                            g.drawLine(x + 3, y + h - 2, x + 3, y + h - 2);
0630:                            g.drawLine(x + 4, y + h - 1, x + 5, y + h - 1);
0631:
0632:                            if (isTabTopVisible(tabPlacement)) {
0633:                                g.drawLine(x + 5, y + h - 1, x + w - 20, y + h
0634:                                        - 1);
0635:                            }
0636:
0637:                            // right bottom arc
0638:                            g.drawLine(x + w - 20, y + h - 1, x + w - 18, y + h
0639:                                    - 1);
0640:                            g.drawLine(x + w - 17, y + h - 2, x + w - 15, y + h
0641:                                    - 2);
0642:                            g.drawLine(x + w - 14, y + h - 3, x + w - 13, y + h
0643:                                    - 3);
0644:                            g.drawLine(x + w - 12, y + h - 4, x + w - 12, y + h
0645:                                    - 4);
0646:                            g.drawLine(x + w - 11, y + h - 5, x + w - 10, y + h
0647:                                    - 5);
0648:
0649:                            // right
0650:                            for (int i = 0; i < h - 10; i++) {
0651:                                g.drawLine(x + w - 9 + i, y + h - 6 - i, x + w
0652:                                        - 9 + i, y + h - 6 - i);
0653:                            }
0654:
0655:                            // right top arc
0656:                            g.drawLine(x + w + h - 19, y + 4, x + w + h - 18,
0657:                                    y + 4);
0658:                            g.drawLine(x + w + h - 17, y + 3, x + w + h - 17,
0659:                                    y + 3);
0660:                            g.drawLine(x + w + h - 16, y + 2, x + w + h - 15,
0661:                                    y + 2);
0662:                            g.drawLine(x + w + h - 14, y + 1, x + w + h - 12,
0663:                                    y + 1);
0664:                            g.drawLine(x + w + h - 11, y, x + w + h - 9, y);
0665:                            break;
0666:                        }
0667:
0668:                        // not selected
0669:                        if (tabIndex > _tabPane.getSelectedIndex()) {
0670:                            g.setColor(_shadow);
0671:                            g.drawLine((x + w) - 2, y - 1, (x + w) - 2, y + h);// right
0672:                            break;
0673:                        }
0674:
0675:                        if (tabIndex >= _tabPane.getSelectedIndex()
0676:                                || tabIndex == 0)
0677:                            break;
0678:
0679:                        g.setColor(_shadow);
0680:                        g.drawLine(x, y - 1, x, y + h);// left
0681:                        break;
0682:                    case TOP:
0683:                    default:
0684:                        if (!isTabLeadingComponentVisible())
0685:                            x--;
0686:
0687:                        if (isSelected) {
0688:                            g.setColor(_shadow);
0689:
0690:                            g.drawLine(x, y + 5, x, y + h);// left
0691:
0692:                            // left top arc
0693:                            g.drawLine(x + 4, y, x + 5, y);
0694:                            g.drawLine(x + 3, y + 1, x + 3, y + 1);
0695:                            g.drawLine(x + 2, y + 2, x + 2, y + 2);
0696:                            g.drawLine(x + 1, y + 3, x + 1, y + 4);
0697:
0698:                            if (isTabTopVisible(tabPlacement)) {
0699:                                g.drawLine(x + 5, y, x + w - 20, y);
0700:                            }
0701:
0702:                            // right top arc
0703:                            g.drawLine(x + w - 20, y, x + w - 18, y);
0704:                            g.drawLine(x + w - 17, y + 1, x + w - 15, y + 1);
0705:                            g.drawLine(x + w - 14, y + 2, x + w - 13, y + 2);
0706:                            g.drawLine(x + w - 12, y + 3, x + w - 12, y + 3);
0707:                            g.drawLine(x + w - 11, y + 4, x + w - 10, y + 4);
0708:
0709:                            // right
0710:                            for (int i = 0; i < h - 10; i++) {
0711:                                g.drawLine(x + w - 9 + i, y + 5 + i, x + w - 9
0712:                                        + i, y + 5 + i);
0713:                            }
0714:
0715:                            // right bottom arc
0716:                            g.drawLine(x + w + h - 19, y + h - 5, x + w + h
0717:                                    - 18, y + h - 5);
0718:                            g.drawLine(x + w + h - 17, y + h - 4, x + w + h
0719:                                    - 17, y + h - 4);
0720:                            g.drawLine(x + w + h - 16, y + h - 3, x + w + h
0721:                                    - 15, y + h - 3);
0722:                            g.drawLine(x + w + h - 14, y + h - 2, x + w + h
0723:                                    - 12, y + h - 2);
0724:                            g.drawLine(x + w + h - 11, y + h - 1,
0725:                                    x + w + h - 9, y + h - 1);
0726:                            break;
0727:                        }
0728:
0729:                        if (tabIndex > _tabPane.getSelectedIndex()) {
0730:                            g.setColor(_shadow);
0731:                            g
0732:                                    .drawLine((x + w) - 2, y, (x + w) - 2, y
0733:                                            + (h - 1));// right
0734:                            break;
0735:                        }
0736:
0737:                        if (tabIndex >= _tabPane.getSelectedIndex()
0738:                                || tabIndex == 0)
0739:                            break;
0740:                        g.setColor(_shadow);
0741:                        g.drawLine(x, y, x, y + (h - 1));// left
0742:                        break;
0743:                    }
0744:                } else {
0745:                    super .paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h,
0746:                            isSelected);
0747:                }
0748:            }
0749:
0750:            @Override
0751:            protected void paintTabBackground(Graphics g, int tabPlacement,
0752:                    int tabIndex, int x, int y, int w, int h, boolean isSelected) {
0753:                if (!PAINT_TAB_BACKGROUND) {
0754:                    return;
0755:                }
0756:
0757:                if (!isSelected) {
0758:                    return;
0759:                }
0760:
0761:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
0762:                    Graphics2D g2d = (Graphics2D) g;
0763:                    Color background1;
0764:                    Color background2;
0765:                    if (showFocusIndicator()) {
0766:                        background1 = UIDefaultsLookup
0767:                                .getColor("DockableFrame.activeTitleBackground");
0768:                        background2 = UIDefaultsLookup
0769:                                .getColor("DockableFrame.activeTitleBackground2");
0770:                    } else {
0771:                        background1 = Color.WHITE;
0772:                        background2 = _background;
0773:                    }
0774:
0775:                    switch (tabPlacement) {
0776:                    case LEFT: {
0777:                        if (!isTabLeadingComponentVisible())
0778:                            y--;
0779:                        int[] xp = { x + w, x + 5, x, x, x + 6, x + w - 6,
0780:                                x + w };
0781:                        int[] yp = { y, y, y + 4, y + h - 19, y + h - 8,
0782:                                y + h + w - 21, y + h + w - 10 };
0783:                        int np = yp.length;
0784:                        Polygon p = new Polygon(xp, yp, np);
0785:                        JideSwingUtilities.fillGradient(g2d, p, background1,
0786:                                background2, false);
0787:                    }
0788:                        break;
0789:                    case RIGHT: {
0790:                        if (!isTabLeadingComponentVisible())
0791:                            y--;
0792:                        int[] xp = { x, x + w - 6, x + w, x + w, x + w - 5,
0793:                                x + 5, x };
0794:                        int[] yp = { y, y, y + 4, y + h - 21, y + h - 10,
0795:                                y + h + w - 21, y + h + w - 10 };
0796:                        int np = yp.length;
0797:                        Polygon p = new Polygon(xp, yp, np);
0798:                        JideSwingUtilities.fillGradient(g2d, p, background2,
0799:                                background1, false);
0800:                    }
0801:                        break;
0802:                    case BOTTOM: {
0803:                        if (!isTabLeadingComponentVisible())
0804:                            x--;
0805:                        // not box style
0806:                        int[] xp = { x, x, x + 6, x + w - 20, x + w - 16,
0807:                                x + w - 14, x + w - 12, x + w - 9,
0808:                                x + w + h - 19, x + w + h - 10, x + w + h - 12 };
0809:                        int[] yp = { y, y + h - 6, y + h, y + h, y + h - 2,
0810:                                y + h - 3, y + h - 4, y + h - 6, y + 4, y + 1,
0811:                                y };
0812:                        int np = yp.length;
0813:                        Polygon p = new Polygon(xp, yp, np);
0814:                        JideSwingUtilities.fillGradient(g2d, p, background2,
0815:                                background1, true);
0816:                    }
0817:                        break;
0818:                    case TOP:
0819:                    default: {
0820:                        if (!isTabLeadingComponentVisible())
0821:                            x--;
0822:                        int[] xp = { x, x, x + 2, x + 3, x + 6, x + w - 20,
0823:                                x + w - 14, x + w - 12, x + w - 9,
0824:                                x + w + h - 20, x + w + h - 9 };
0825:                        int[] yp = { y + h, y + 5, y + 2, y + 1, y, y, y + 2,
0826:                                y + 3, y + 5, y + h - 6, y + h };
0827:                        int np = xp.length;
0828:                        Polygon p = new Polygon(xp, yp, np);
0829:                        JideSwingUtilities.fillGradient(g2d, p, background1,
0830:                                background2, true);
0831:                    }
0832:                        break;
0833:                    }
0834:                } else {
0835:                    super .paintTabBackground(g, tabPlacement, tabIndex, x, y,
0836:                            w, h, isSelected);
0837:                }
0838:            }
0839:
0840:            @Override
0841:            protected void paintContentBorder(Graphics g, int tabPlacement,
0842:                    int selectedIndex) {
0843:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
0844:                    int width = _tabPane.getWidth();
0845:                    int height = _tabPane.getHeight();
0846:                    Insets insets = _tabPane.getInsets();
0847:
0848:                    int x = insets.left;
0849:                    int y = insets.top;
0850:                    int w = width - insets.right - insets.left;
0851:                    int h = height - insets.top - insets.bottom;
0852:
0853:                    int temp = -1;
0854:                    switch (tabPlacement) {
0855:                    case LEFT:
0856:                        x += calculateTabAreaWidth(tabPlacement, _runCount,
0857:                                _maxTabWidth);
0858:                        if (isTabLeadingComponentVisible()) {
0859:                            if (_tabLeadingComponent.getSize().width > calculateTabAreaWidth(
0860:                                    tabPlacement, _runCount, _maxTabWidth)) {
0861:                                x = insets.left
0862:                                        + _tabLeadingComponent.getSize().width;
0863:                                temp = _tabLeadingComponent.getSize().width;
0864:                            }
0865:                        }
0866:                        if (isTabTrailingComponentVisible()) {
0867:                            if (_maxTabWidth < _tabTrailingComponent.getSize().width
0868:                                    && temp < _tabTrailingComponent.getSize().width) {
0869:                                x = insets.left
0870:                                        + _tabTrailingComponent.getSize().width;
0871:                            }
0872:                        }
0873:                        w -= (x - insets.left);
0874:                        break;
0875:                    case RIGHT:
0876:                        w -= calculateTabAreaWidth(tabPlacement, _runCount,
0877:                                _maxTabWidth);
0878:                        break;
0879:                    case BOTTOM:
0880:                        h -= calculateTabAreaHeight(tabPlacement, _runCount,
0881:                                _maxTabHeight);
0882:                        break;
0883:                    case TOP:
0884:                    default:
0885:                        y += calculateTabAreaHeight(tabPlacement, _runCount,
0886:                                _maxTabHeight);
0887:                        if (isTabLeadingComponentVisible()) {
0888:                            if (_tabLeadingComponent.getSize().height > calculateTabAreaHeight(
0889:                                    tabPlacement, _runCount, _maxTabHeight)) {
0890:                                y = insets.top
0891:                                        + _tabLeadingComponent.getSize().height;
0892:                                temp = _tabLeadingComponent.getSize().height;
0893:                            }
0894:                        }
0895:                        if (isTabTrailingComponentVisible()) {
0896:                            if (_maxTabHeight < _tabTrailingComponent.getSize().height
0897:                                    && temp < _tabTrailingComponent.getSize().height) {
0898:                                y = insets.top
0899:                                        + _tabTrailingComponent.getSize().height;
0900:                            }
0901:                        }
0902:                        h -= (y - insets.top);
0903:                    }
0904:
0905:                    // Fill region behind content area
0906:                    paintContentBorder(g, x, y, w, h);
0907:
0908:                    Rectangle viewRect = _tabScroller.viewport.getViewRect();
0909:                    Rectangle r = _rects[selectedIndex];
0910:                    Rectangle button = _tabScroller.scrollForwardButton
0911:                            .getBounds();
0912:                    Rectangle panel = _tabScroller.tabPanel.getBounds();
0913:                    int lsize = 0;
0914:
0915:                    if (_tabPane.getTabPlacement() == TOP
0916:                            || _tabPane.getTabPlacement() == BOTTOM) {
0917:                        if (isTabLeadingComponentVisible()) {
0918:                            lsize = _tabLeadingComponent.getSize().width;
0919:                        }
0920:                    } else {
0921:                        if (isTabLeadingComponentVisible()) {
0922:                            lsize = _tabLeadingComponent.getSize().height;
0923:                        }
0924:                    }
0925:
0926:                    switch (tabPlacement) {
0927:                    case LEFT:
0928:                        if (r.y < viewRect.y + viewRect.height
0929:                                && r.y
0930:                                        + r.height
0931:                                        + _tabPane.getBoundsAt(selectedIndex).width
0932:                                        - 9 > viewRect.y + viewRect.height) {
0933:
0934:                            if (selectedIndex != _tabPane.getTabCount() - 1) {
0935:                                viewRect.y += (r.y
0936:                                        + r.height
0937:                                        + _tabPane.getBoundsAt(selectedIndex).width
0938:                                        - 9 - (viewRect.y + viewRect.height));
0939:                                _tabScroller.viewport
0940:                                        .setViewPosition(new Point(viewRect.x,
0941:                                                viewRect.y));
0942:                            } else {
0943:                                if (panel.y + panel.height + lsize > button.y) {
0944:                                    viewRect.y += (r.y
0945:                                            + r.height
0946:                                            + _tabPane
0947:                                                    .getBoundsAt(selectedIndex).width
0948:                                            - 9 - (viewRect.y + viewRect.height));
0949:                                    _tabScroller.viewport
0950:                                            .setViewPosition(new Point(
0951:                                                    viewRect.x, viewRect.y));
0952:                                } else {
0953:                                    _tabScroller.viewport.setSize(
0954:                                            viewRect.width, viewRect.height
0955:                                                    + getLayoutSize());
0956:                                }
0957:
0958:                            }
0959:
0960:                        }
0961:                        paintContentBorderLeftEdge(g, tabPlacement,
0962:                                selectedIndex, x, y, w, h);
0963:                        break;
0964:
0965:                    case RIGHT:
0966:                        if (r.y < viewRect.y + viewRect.height
0967:                                && r.y
0968:                                        + r.height
0969:                                        + _tabPane.getBoundsAt(selectedIndex).width
0970:                                        - 9 > viewRect.y + viewRect.height) {
0971:
0972:                            if (selectedIndex != _tabPane.getTabCount() - 1) {
0973:                                viewRect.y += (r.y
0974:                                        + r.height
0975:                                        + _tabPane.getBoundsAt(selectedIndex).width
0976:                                        - 9 - (viewRect.y + viewRect.height));
0977:                                _tabScroller.viewport
0978:                                        .setViewPosition(new Point(viewRect.x,
0979:                                                viewRect.y));
0980:                            } else {
0981:                                if (panel.y + panel.height + lsize > button.y) {
0982:                                    viewRect.y += (r.y
0983:                                            + r.height
0984:                                            + _tabPane
0985:                                                    .getBoundsAt(selectedIndex).width
0986:                                            - 9 - (viewRect.y + viewRect.height));
0987:                                    _tabScroller.viewport
0988:                                            .setViewPosition(new Point(
0989:                                                    viewRect.x, viewRect.y));
0990:                                } else {
0991:                                    _tabScroller.viewport.setSize(
0992:                                            viewRect.width, viewRect.height
0993:                                                    + getLayoutSize());
0994:                                }
0995:
0996:                            }
0997:
0998:                        }
0999:                        paintContentBorderRightEdge(g, tabPlacement,
1000:                                selectedIndex, x, y, w, h);
1001:                        break;
1002:
1003:                    case BOTTOM:
1004:                        if (r.x < viewRect.x + viewRect.width
1005:                                && r.x
1006:                                        + r.width
1007:                                        + _tabPane.getBoundsAt(selectedIndex).height
1008:                                        - 9 > viewRect.x + viewRect.width) {
1009:                            if (selectedIndex != _tabPane.getTabCount() - 1) {
1010:                                viewRect.x += (r.x
1011:                                        + r.width
1012:                                        + _tabPane.getBoundsAt(selectedIndex).height
1013:                                        - 9 - (viewRect.x + viewRect.width));
1014:                                _tabScroller.viewport
1015:                                        .setViewPosition(new Point(viewRect.x,
1016:                                                viewRect.y));
1017:                            } else {
1018:                                if (panel.x + panel.width + lsize > button.x) {
1019:                                    viewRect.x += (r.x
1020:                                            + r.width
1021:                                            + _tabPane
1022:                                                    .getBoundsAt(selectedIndex).height
1023:                                            - 9 - (viewRect.x + viewRect.width));
1024:                                    _tabScroller.viewport
1025:                                            .setViewPosition(new Point(
1026:                                                    viewRect.x, viewRect.y));
1027:                                } else {
1028:                                    _tabScroller.viewport.setSize(
1029:                                            viewRect.width + getLayoutSize(),
1030:                                            viewRect.height);
1031:                                }
1032:
1033:                            }
1034:
1035:                        }
1036:                        paintContentBorderBottomEdge(g, tabPlacement,
1037:                                selectedIndex, x, y, w, h);
1038:                        break;
1039:
1040:                    case TOP:
1041:                    default:
1042:
1043:                        if (r.x < viewRect.x + viewRect.width
1044:                                && r.x
1045:                                        + r.width
1046:                                        + _tabPane.getBoundsAt(selectedIndex).height
1047:                                        - 9 > viewRect.x + viewRect.width) {
1048:                            if (selectedIndex != _tabPane.getTabCount() - 1) {
1049:                                viewRect.x += (r.x
1050:                                        + r.width
1051:                                        + _tabPane.getBoundsAt(selectedIndex).height
1052:                                        - 9 - (viewRect.x + viewRect.width));
1053:                                _tabScroller.viewport
1054:                                        .setViewPosition(new Point(viewRect.x,
1055:                                                viewRect.y));
1056:                            } else {
1057:                                if (panel.x + panel.width + lsize > button.x) {
1058:                                    viewRect.x += (r.x
1059:                                            + r.width
1060:                                            + _tabPane
1061:                                                    .getBoundsAt(selectedIndex).height
1062:                                            - 9 - (viewRect.x + viewRect.width));
1063:                                    _tabScroller.viewport
1064:                                            .setViewPosition(new Point(
1065:                                                    viewRect.x, viewRect.y));
1066:
1067:                                } else {
1068:                                    _tabScroller.viewport.setSize(
1069:                                            viewRect.width + getLayoutSize(),
1070:                                            viewRect.height);
1071:                                }
1072:                            }
1073:                        }
1074:
1075:                        paintContentBorderTopEdge(g, tabPlacement,
1076:                                selectedIndex, x, y, w, h);
1077:                        break;
1078:
1079:                    }
1080:
1081:                    g.setColor(_shadow);
1082:                    if (_tabPane.isTabShown()) {
1083:                        switch (tabPlacement) {
1084:                        case LEFT:
1085:                            g.drawLine(width - 1, 0, width - 1, height - 1);
1086:                            g.drawLine(6, 0, width - 1, 0);
1087:                            g.drawLine(6, height - 1, width - 1, height - 1);
1088:                            g.drawLine(0, 6, 0, height - 7);
1089:
1090:                            g.drawLine(1, height - 6, 1, height - 5);
1091:                            g.drawLine(2, height - 4, 2, height - 4);
1092:                            g.drawLine(3, height - 3, 3, height - 3);
1093:                            g.drawLine(4, height - 2, 5, height - 2);
1094:
1095:                            g.drawLine(4, 1, 5, 1);
1096:                            g.drawLine(3, 2, 3, 2);
1097:                            g.drawLine(2, 3, 2, 3);
1098:                            g.drawLine(1, 4, 1, 5);
1099:                            break;
1100:                        case RIGHT:
1101:                            g.drawLine(0, 0, 0, height - 1);
1102:                            g.drawLine(0, 0, width - 7, 0);
1103:                            g.drawLine(0, height - 1, width - 7, height - 1);
1104:                            g.drawLine(width - 1, 6, width - 1, height - 7);
1105:
1106:                            g.drawLine(width - 2, height - 6, width - 2,
1107:                                    height - 5);
1108:                            g.drawLine(width - 3, height - 4, width - 3,
1109:                                    height - 4);
1110:                            g.drawLine(width - 4, height - 3, width - 4,
1111:                                    height - 3);
1112:                            g.drawLine(width - 5, height - 2, width - 6,
1113:                                    height - 2);
1114:
1115:                            g.drawLine(width - 6, 1, width - 5, 1);
1116:                            g.drawLine(width - 4, 2, width - 4, 2);
1117:                            g.drawLine(width - 3, 3, width - 3, 3);
1118:                            g.drawLine(width - 2, 4, width - 2, 5);
1119:                            break;
1120:                        case BOTTOM:
1121:                            g.drawLine(0, 0, width - 1, 0);
1122:                            g.drawLine(0, 0, 0, height - 7);
1123:                            g.drawLine(width - 1, 0, width - 1, height - 7);
1124:                            g.drawLine(6, height - 1, width - 7, height - 1);
1125:
1126:                            g.drawLine(width - 6, height - 2, width - 5,
1127:                                    height - 2);
1128:                            g.drawLine(width - 4, height - 3, width - 4,
1129:                                    height - 3);
1130:                            g.drawLine(width - 3, height - 4, width - 3,
1131:                                    height - 4);
1132:                            g.drawLine(width - 2, height - 5, width - 2,
1133:                                    height - 6);
1134:
1135:                            g.drawLine(1, height - 6, 1, height - 5);
1136:                            g.drawLine(2, height - 4, 2, height - 4);
1137:                            g.drawLine(3, height - 3, 3, height - 3);
1138:                            g.drawLine(4, height - 2, 5, height - 2);
1139:                            break;
1140:                        case TOP:
1141:                        default:
1142:                            g.drawLine(6, 0, width - 7, 0);
1143:                            g.drawLine(0, height - 1, width - 1, height - 1);
1144:                            g.drawLine(width - 1, 6, width - 1, height - 1);
1145:                            g.drawLine(0, 6, 0, height - 1);
1146:
1147:                            g.drawLine(width - 6, 1, width - 5, 1);
1148:                            g.drawLine(width - 4, 2, width - 4, 2);
1149:                            g.drawLine(width - 3, 3, width - 3, 3);
1150:                            g.drawLine(width - 2, 4, width - 2, 5);
1151:
1152:                            g.drawLine(4, 1, 5, 1);
1153:                            g.drawLine(3, 2, 3, 2);
1154:                            g.drawLine(2, 3, 2, 3);
1155:                            g.drawLine(1, 4, 1, 5);
1156:                            break;
1157:                        }
1158:                    } else {
1159:                        g.drawRect(0, 0, width - 1, height - 1);
1160:                    }
1161:                } else {
1162:                    super .paintContentBorder(g, tabPlacement, selectedIndex);
1163:                }
1164:
1165:            }
1166:
1167:            // paint the component border of every tab
1168:            @Override
1169:            protected void paintContentBorder(Graphics g, int x, int y, int w,
1170:                    int h) {
1171:                if (!PAINT_CONTENT_BORDER) {
1172:                    return;
1173:                }
1174:
1175:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
1176:                    if (showFocusIndicator()) {
1177:                        Insets insets = getContentBorderInsets(_tabPane
1178:                                .getTabPlacement());
1179:                        Color selectedTitleColor2 = UIDefaultsLookup
1180:                                .getColor("DockableFrame.activeTitleBackground2");
1181:                        g.setColor(selectedTitleColor2);
1182:                        g.fillRect(x, y, w, insets.top); // top
1183:                        g.fillRect(x, y, insets.left, h); // left
1184:                        g.fillRect(x, y + h - insets.bottom, w, insets.bottom); // bottom
1185:                        g.fillRect(x + w - insets.right, y, insets.right, h); // right
1186:                    }
1187:                } else {
1188:                    super .paintContentBorder(g, x, y, w, h);
1189:                }
1190:            }
1191:
1192:            // paint the top line of the content when the tab is on the top
1193:            @Override
1194:            protected void paintContentBorderTopEdge(Graphics g,
1195:                    int tabPlacement, int selectedIndex, int x, int y, int w,
1196:                    int h) {
1197:                if (!PAINT_CONTENT_BORDER_EDGE) {
1198:                    return;
1199:                }
1200:
1201:                if (selectedIndex < 0) {
1202:                    return;
1203:                }
1204:
1205:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
1206:                    Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
1207:
1208:                    Rectangle viewRect = _tabScroller.viewport.getViewRect();
1209:                    Rectangle r = _rects[selectedIndex];
1210:
1211:                    g.setColor(getPainter().getControlShadow());
1212:
1213:                    // Break line to show visual connection to selected tab
1214:                    if (isTabLeadingComponentVisible() && selRect.x > 0) {
1215:                        g.drawLine(x, y, selRect.x, y);
1216:                    }
1217:
1218:                    if (r.x > viewRect.x) {
1219:                        g.drawLine(x, y, selRect.x - 1, y);
1220:                    }
1221:
1222:                    if (_tabPane.isTabShown()) {
1223:                        if (r.x >= viewRect.x + viewRect.width) {
1224:                            g.drawLine(x, y, x + w - 1, y);
1225:                        } else {
1226:                            g
1227:                                    .drawLine(
1228:                                            selRect.x
1229:                                                    + selRect.width
1230:                                                    + _tabPane
1231:                                                            .getBoundsAt(selectedIndex).height
1232:                                                    - 9, y, x + w - 1, y);
1233:                        }
1234:                    }
1235:                } else {
1236:                    super .paintContentBorderTopEdge(g, tabPlacement,
1237:                            selectedIndex, x, y, w, h);
1238:                }
1239:            }
1240:
1241:            // paint the bottom line of the content when the tab is on the bottom
1242:            @Override
1243:            protected void paintContentBorderBottomEdge(Graphics g,
1244:                    int tabPlacement, int selectedIndex, int x, int y, int w,
1245:                    int h) {
1246:                if (!PAINT_CONTENT_BORDER_EDGE) {
1247:                    return;
1248:                }
1249:
1250:                if (selectedIndex < 0) {
1251:                    return;
1252:                }
1253:
1254:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
1255:                    Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
1256:
1257:                    g.setColor(getPainter().getControlShadow());
1258:
1259:                    Rectangle viewRect = _tabScroller.viewport.getViewRect();
1260:                    Rectangle r = _rects[selectedIndex];
1261:
1262:                    if (isTabLeadingComponentVisible() && selRect.x > 0) {
1263:                        g.drawLine(x, y + h - 1, selRect.x, y + h - 1);
1264:                    }
1265:
1266:                    // Break line to show visual connection to selected tab
1267:                    if (r.x > viewRect.x) {
1268:                        g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);
1269:                    }
1270:
1271:                    if (_tabPane.isTabShown()) {
1272:                        if (r.x >= viewRect.x + viewRect.width) {
1273:                            g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
1274:                        } else {
1275:                            g
1276:                                    .drawLine(
1277:                                            selRect.x
1278:                                                    + selRect.width
1279:                                                    + _tabPane
1280:                                                            .getBoundsAt(selectedIndex).height
1281:                                                    - 9, y + h - 1, x + w - 1,
1282:                                            y + h - 1);
1283:                        }
1284:                    }
1285:                } else {
1286:                    super .paintContentBorderBottomEdge(g, tabPlacement,
1287:                            selectedIndex, x, y, w, h);
1288:                }
1289:
1290:            }
1291:
1292:            //  paint the left line of the content when the tab is on the left
1293:
1294:            @Override
1295:            protected void paintContentBorderLeftEdge(Graphics g,
1296:                    int tabPlacement, int selectedIndex, int x, int y, int w,
1297:                    int h) {
1298:                if (!PAINT_CONTENT_BORDER_EDGE) {
1299:                    return;
1300:                }
1301:
1302:                if (selectedIndex < 0) {
1303:                    return;
1304:                }
1305:
1306:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
1307:                    Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
1308:
1309:                    Rectangle viewRect = _tabScroller.viewport.getViewRect();
1310:                    Rectangle r = _rects[selectedIndex];
1311:
1312:                    g.setColor(getPainter().getControlShadow());
1313:
1314:                    if (isTabLeadingComponentVisible() && selRect.y > 0) {
1315:                        g.drawLine(x, y, x, selRect.y);
1316:                    }
1317:
1318:                    // Break line to show visual connection to selected tab
1319:                    if (r.y - 2 > viewRect.y) {
1320:                        g.drawLine(x, y, x, selRect.y - 3);
1321:                    }
1322:
1323:                    if (_tabPane.isTabShown()) {
1324:                        if (r.y >= viewRect.y + viewRect.height) {
1325:                            g.drawLine(x, y, x, y + h - 1);
1326:                        } else {
1327:                            g.drawLine(x, selRect.y + selRect.height
1328:                                    + _tabPane.getBoundsAt(selectedIndex).width
1329:                                    - 9, x, y + h - 1);
1330:                        }
1331:                    }
1332:                } else {
1333:                    super .paintContentBorderLeftEdge(g, tabPlacement,
1334:                            selectedIndex, x, y, w, h);
1335:                }
1336:            }
1337:
1338:            //  paint the right line of the content when the tab is on the right
1339:
1340:            @Override
1341:            protected void paintContentBorderRightEdge(Graphics g,
1342:                    int tabPlacement, int selectedIndex, int x, int y, int w,
1343:                    int h) {
1344:                if (!PAINT_CONTENT_BORDER_EDGE) {
1345:                    return;
1346:                }
1347:
1348:                if (selectedIndex < 0) {
1349:                    return;
1350:                }
1351:
1352:                if (getTabShape() == JideTabbedPane.SHAPE_ECLIPSE3X) {
1353:                    Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
1354:
1355:                    Rectangle viewRect = _tabScroller.viewport.getViewRect();
1356:                    Rectangle r = _rects[selectedIndex];
1357:
1358:                    g.setColor(getPainter().getControlShadow());
1359:
1360:                    if (isTabLeadingComponentVisible() && selRect.y > 0) {
1361:                        g.drawLine(x + w - 1, y, x + w - 1, selRect.y);
1362:                    }
1363:
1364:                    // Break line to show visual connection to selected tab
1365:                    if (r.y - 2 > viewRect.y) {
1366:                        g.drawLine(x + w - 1, y, x + w - 1, selRect.y - 3);
1367:                    }
1368:
1369:                    if (_tabPane.isTabShown()) {
1370:                        if (r.y >= viewRect.y + viewRect.height) {
1371:                            g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
1372:                        } else {
1373:                            g.drawLine(x + w - 1, selRect.y + selRect.height
1374:                                    + _tabPane.getBoundsAt(selectedIndex).width
1375:                                    - 9, x + w - 1, y + h - 1);
1376:                        }
1377:                    }
1378:                } else {
1379:                    super .paintContentBorderRightEdge(g, tabPlacement,
1380:                            selectedIndex, x, y, w, h);
1381:                }
1382:            }
1383:
1384:            @Override
1385:            protected Rectangle getTabsTextBoundsAt(int tabIndex) {
1386:                Rectangle tabRect = _tabPane.getBoundsAt(tabIndex);
1387:                Rectangle iconRect = new Rectangle(), textRect = new Rectangle();
1388:
1389:                String title = _tabPane.getDisplayTitleAt(tabIndex);
1390:                Icon icon = getIconForTab(tabIndex);
1391:
1392:                SwingUtilities.layoutCompoundLabel(_tabPane, _tabPane
1393:                        .getGraphics().getFontMetrics(_tabPane.getFont()),
1394:                        title, icon, SwingUtilities.CENTER,
1395:                        SwingUtilities.CENTER, SwingUtilities.CENTER,
1396:                        SwingUtilities.TRAILING, tabRect, iconRect, textRect,
1397:                        icon == null ? 0 : _textIconGap);
1398:
1399:                if (_tabPane.getTabPlacement() == JideTabbedPane.TOP
1400:                        || _tabPane.getTabPlacement() == JideTabbedPane.BOTTOM) {
1401:                    iconRect.x = tabRect.x + _iconMarginHorizon;
1402:                    textRect.x = (icon != null ? iconRect.x + iconRect.width
1403:                            + _textIconGap : tabRect.x + _textPadding);
1404:                } else {
1405:                    iconRect.y = tabRect.y + _iconMarginVertical;
1406:                    textRect.y = (icon != null ? iconRect.y + iconRect.height
1407:                            + _textIconGap : tabRect.y + _textPadding);
1408:                    iconRect.x = tabRect.x + 2;
1409:                    textRect.x = tabRect.x + 2;
1410:                }
1411:
1412:                return textRect;
1413:            }
1414:
1415:            @Override
1416:            protected void paintFocusIndicator(Graphics g, int tabPlacement,
1417:                    Rectangle[] rects, int tabIndex, Rectangle iconRect,
1418:                    Rectangle textRect, boolean isSelected) {
1419:                Rectangle tabRect = rects[tabIndex];
1420:                if (_tabPane.hasFocus() && isSelected) {
1421:                    int x, y, w, h;
1422:                    g.setColor(_focus);
1423:                    switch (tabPlacement) {
1424:                    case LEFT:
1425:                        x = tabRect.x + 2;
1426:                        y = tabRect.y + 3;
1427:                        w = tabRect.width - 4;
1428:                        h = tabRect.height - 19;
1429:                        break;
1430:                    case RIGHT:
1431:                        x = tabRect.x + 2;
1432:                        y = tabRect.y + 3;
1433:                        w = tabRect.width - 4;
1434:                        h = tabRect.height - 19;
1435:                        break;
1436:                    case BOTTOM:
1437:                        x = tabRect.x + 3;
1438:                        y = tabRect.y + 2;
1439:                        w = tabRect.width - 19;
1440:                        h = tabRect.height - 3;
1441:                        break;
1442:                    case TOP:
1443:                    default:
1444:                        x = tabRect.x + 3;
1445:                        y = tabRect.y + 2;
1446:                        w = tabRect.width - 19;
1447:                        h = tabRect.height - 3;
1448:                    }
1449:                    BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);
1450:                }
1451:            }
1452:
1453:            @Override
1454:            protected TabCloseButton createNoFocusButton(int type) {
1455:                return new Eclipse3xTabCloseButton(type);
1456:            }
1457:
1458:            public class Eclipse3xTabCloseButton extends TabCloseButton {
1459:                public Eclipse3xTabCloseButton(int type) {
1460:                    super (type);
1461:                }
1462:
1463:                @Override
1464:                public Dimension getPreferredSize() {
1465:                    return new Dimension(15, 15);
1466:                }
1467:
1468:                @Override
1469:                protected void paintComponent(Graphics g) {
1470:                    if (!isEnabled()) {
1471:                        setMouseOver(false);
1472:                        setMousePressed(false);
1473:                    }
1474:                    g.setColor(UIDefaultsLookup.getColor("controlShadow")
1475:                            .darker());
1476:                    int centerX = getWidth() >> 1;
1477:                    int centerY = getHeight() >> 1;
1478:                    switch (getType()) {
1479:                    case CLOSE_BUTTON:
1480:                        g.drawLine(centerX - 4, centerY - 4, centerX - 2,
1481:                                centerY - 4); // top-left top
1482:                        g.drawLine(centerX - 4, centerY - 4, centerX - 4,
1483:                                centerY - 2); // top-left left
1484:
1485:                        g.drawLine(centerX - 1, centerY - 3, centerX - 0,
1486:                                centerY - 2); // top-left top-diag
1487:                        g.drawLine(centerX - 3, centerY - 1, centerX - 2,
1488:                                centerY - 0); // top-left left-diag
1489:
1490:                        g.drawLine(centerX + 3, centerY - 4, centerX + 5,
1491:                                centerY - 4); // top-right top
1492:                        g.drawLine(centerX + 5, centerY - 4, centerX + 5,
1493:                                centerY - 2); // top-right right
1494:
1495:                        g.drawLine(centerX + 2, centerY - 3, centerX + 1,
1496:                                centerY - 2); // top-right top-diag
1497:                        g.drawLine(centerX + 4, centerY - 1, centerX + 3,
1498:                                centerY - 0); // top-right right-diag
1499:
1500:                        g.drawLine(centerX - 4, centerY + 5, centerX - 2,
1501:                                centerY + 5); // bottom-left bottom
1502:                        g.drawLine(centerX - 4, centerY + 5, centerX - 4,
1503:                                centerY + 3); // bottom-left left
1504:
1505:                        g.drawLine(centerX - 1, centerY + 4, centerX - 0,
1506:                                centerY + 3); // bottom-left bottom-diag
1507:                        g.drawLine(centerX - 3, centerY + 2, centerX - 2,
1508:                                centerY + 1); // bottom-left left-diag
1509:
1510:                        g.drawLine(centerX + 3, centerY + 5, centerX + 5,
1511:                                centerY + 5); // bottom-right bottom
1512:                        g.drawLine(centerX + 5, centerY + 5, centerX + 5,
1513:                                centerY + 3); // bottom-right right
1514:
1515:                        g.drawLine(centerX + 2, centerY + 4, centerX + 1,
1516:                                centerY + 3); // bottom-right bottom-diag
1517:                        g.drawLine(centerX + 4, centerY + 2, centerX + 3,
1518:                                centerY + 1); // bottom-right right-diag
1519:
1520:                        if (isMouseOver()) {
1521:                            g.setColor(new Color(252, 160, 160));
1522:                        } else {
1523:                            g.setColor(Color.WHITE);
1524:                        }
1525:                        g.drawLine(centerX - 2, centerY - 3, centerX + 4,
1526:                                centerY + 3);
1527:                        g.drawLine(centerX - 3, centerY - 3, centerX + 4,
1528:                                centerY + 4);
1529:                        g.drawLine(centerX - 3, centerY - 2, centerX + 3,
1530:                                centerY + 4);
1531:
1532:                        g.drawLine(centerX - 3, centerY + 3, centerX + 3,
1533:                                centerY - 3);
1534:                        g.drawLine(centerX - 3, centerY + 4, centerX + 4,
1535:                                centerY - 3);
1536:                        g.drawLine(centerX - 2, centerY + 4, centerX + 4,
1537:                                centerY - 2);
1538:                        break;
1539:                    default:
1540:                        super.paintComponent(g);
1541:                    }
1542:                }
1543:            }
1544:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.