0001: /*
0002: * @(#)WindowsTabbedPaneUI.java
0003: *
0004: * Copyright 2002 JIDE Software Inc. All rights reserved.
0005: */
0006:
0007: package com.jidesoft.plaf.vsnet;
0008:
0009: import com.jidesoft.plaf.UIDefaultsLookup;
0010: import com.jidesoft.plaf.basic.BasicJideTabbedPaneUI;
0011: import com.jidesoft.swing.JideSwingUtilities;
0012: import com.jidesoft.swing.JideTabbedPane;
0013: import com.jidesoft.utils.ColorUtils;
0014:
0015: import javax.swing.*;
0016: import javax.swing.plaf.ComponentUI;
0017: import javax.swing.plaf.UIResource;
0018: import java.awt.*;
0019:
0020: /**
0021: * JideTabbedPane UI implementation
0022: */
0023: public class VsnetJideTabbedPaneUI extends BasicJideTabbedPaneUI {
0024:
0025: protected Color _backgroundSelectedColorStart;
0026:
0027: protected Color _backgroundSelectedColorEnd;
0028:
0029: protected Color _backgroundUnselectedColorStart;
0030:
0031: protected Color _backgroundUnselectedColorEnd;
0032:
0033: public static ComponentUI createUI(JComponent c) {
0034: return new VsnetJideTabbedPaneUI();
0035: }
0036:
0037: @Override
0038: public void installColorTheme() {
0039: super .installColorTheme();
0040:
0041: int tabStyle = getTabShape();
0042: int colorTheme = getColorTheme();
0043: switch (tabStyle) {
0044: case JideTabbedPane.SHAPE_BOX:
0045: if (colorTheme == JideTabbedPane.COLOR_THEME_VSNET) {
0046: _selectColor1 = _shadow;
0047: _selectColor2 = _selectColor1;
0048: } else if (colorTheme == JideTabbedPane.COLOR_THEME_WINXP) {
0049: _selectColor1 = UIDefaultsLookup
0050: .getColor("TextArea.selectionBackground");
0051: _selectColor2 = _selectColor1;
0052: }
0053: _unselectColor1 = getPainter().getControlShadow();
0054:
0055: _unselectColor2 = _lightHighlight;
0056: break;
0057:
0058: case JideTabbedPane.SHAPE_EXCEL:
0059: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) {
0060: _selectColor2 = null;
0061: _selectColor3 = null;
0062: _unselectColor2 = _lightHighlight;
0063: _unselectColor3 = _shadow;
0064: }
0065: break;
0066: case JideTabbedPane.SHAPE_WINDOWS:
0067: case JideTabbedPane.SHAPE_WINDOWS_SELECTED:
0068: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) {
0069: _selectColor1 = getPainter().getTabbedPaneSelectDk();
0070: _selectColor2 = getPainter().getTabbedPaneSelectLt();
0071: _selectColor3 = getPainter().getControlDk();
0072: _unselectColor1 = getPainter().getControlDk();
0073: _unselectColor2 = null;
0074: _unselectColor3 = null;
0075: }
0076: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {
0077: _selectColor1 = getPainter().getTabbedPaneSelectDk();
0078: _selectColor2 = getPainter().getTabbedPaneSelectLt();
0079: _selectColor3 = getPainter().getControlDk();
0080: _unselectColor1 = getPainter().getControlDk();
0081: _unselectColor2 = null;
0082: _unselectColor3 = null;
0083: }
0084: break;
0085: }
0086:
0087: installBackgroundColor();
0088: }
0089:
0090: protected void installBackgroundColor() {
0091: int colorTheme = getColorTheme();
0092:
0093: switch (getTabShape()) {
0094: case JideTabbedPane.SHAPE_VSNET:
0095: _backgroundSelectedColorStart = _highlight;
0096: _backgroundSelectedColorEnd = _highlight;
0097: _backgroundUnselectedColorStart = null;
0098: _backgroundUnselectedColorEnd = null;
0099: break;
0100: case JideTabbedPane.SHAPE_ROUNDED_VSNET:
0101: if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K) {
0102: _backgroundSelectedColorStart = _highlight;
0103: _backgroundSelectedColorEnd = _highlight;
0104: _backgroundUnselectedColorStart = null;
0105: _backgroundUnselectedColorEnd = null;
0106: } else {
0107: _backgroundSelectedColorStart = _background;
0108: _backgroundSelectedColorEnd = _highlight;
0109: _backgroundUnselectedColorStart = null;
0110: _backgroundUnselectedColorEnd = null;
0111: }
0112: break;
0113: case JideTabbedPane.SHAPE_FLAT:
0114: case JideTabbedPane.SHAPE_ROUNDED_FLAT:
0115: _backgroundSelectedColorStart = _highlight;
0116: _backgroundSelectedColorEnd = _highlight;
0117: _backgroundUnselectedColorStart = _highlight;
0118: _backgroundUnselectedColorEnd = _highlight;
0119: break;
0120: case JideTabbedPane.SHAPE_BOX:
0121: if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K) {
0122: _backgroundSelectedColorStart = _highlight;
0123: _backgroundSelectedColorEnd = _highlight;
0124: _backgroundUnselectedColorStart = null;
0125: _backgroundUnselectedColorEnd = null;
0126: } else if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) {
0127: _backgroundSelectedColorStart = _lightHighlight;
0128: _backgroundSelectedColorEnd = _lightHighlight;
0129: _backgroundUnselectedColorStart = null;
0130: _backgroundUnselectedColorEnd = null;
0131: } else if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {
0132: _backgroundSelectedColorStart = _lightHighlight;
0133: _backgroundSelectedColorEnd = _highlight;
0134: _backgroundUnselectedColorStart = null;
0135: _backgroundUnselectedColorEnd = null;
0136: }
0137: break;
0138: case JideTabbedPane.SHAPE_EXCEL:
0139: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0140: _backgroundSelectedColorStart = _highlight;
0141: _backgroundSelectedColorEnd = _highlight;
0142: _backgroundUnselectedColorStart = _lightHighlight;
0143: _backgroundUnselectedColorEnd = _lightHighlight;
0144: } else if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) {
0145: _backgroundSelectedColorStart = _lightHighlight;
0146: _backgroundSelectedColorEnd = _lightHighlight;
0147: _backgroundUnselectedColorStart = _highlight;
0148: _backgroundUnselectedColorEnd = _highlight;
0149: } else /*if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP)*/{
0150: _backgroundSelectedColorStart = _lightHighlight;
0151: _backgroundSelectedColorEnd = _lightHighlight;
0152: _backgroundUnselectedColorStart = _lightHighlight;
0153: _backgroundUnselectedColorEnd = _highlight;
0154: }
0155: break;
0156: case JideTabbedPane.SHAPE_WINDOWS:
0157: case JideTabbedPane.SHAPE_WINDOWS_SELECTED:
0158: if (colorTheme == JideTabbedPane.COLOR_THEME_VSNET
0159: || colorTheme == JideTabbedPane.COLOR_THEME_WINXP) {
0160: _backgroundSelectedColorStart = _lightHighlight;
0161: _backgroundSelectedColorEnd = _lightHighlight;
0162: _backgroundUnselectedColorStart = _lightHighlight;
0163: _backgroundUnselectedColorEnd = _highlight;
0164: } else /*if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K)*/{
0165: _backgroundSelectedColorStart = _highlight;
0166: _backgroundSelectedColorEnd = _highlight;
0167: _backgroundUnselectedColorStart = _highlight;
0168: _backgroundUnselectedColorEnd = _highlight;
0169: }
0170: break;
0171: case JideTabbedPane.SHAPE_OFFICE2003:
0172: if (colorTheme == JideTabbedPane.COLOR_THEME_WIN2K) {
0173: _backgroundSelectedColorStart = _highlight;
0174: _backgroundSelectedColorEnd = _highlight;
0175: _backgroundUnselectedColorStart = _highlight;
0176: _backgroundUnselectedColorEnd = _highlight;
0177: } else if (colorTheme == JideTabbedPane.COLOR_THEME_WINXP) {
0178: _backgroundSelectedColorStart = _lightHighlight;
0179: _backgroundSelectedColorEnd = _lightHighlight;
0180: _backgroundUnselectedColorStart = _lightHighlight;
0181: _backgroundUnselectedColorEnd = _highlight;
0182: } else {
0183: _backgroundSelectedColorStart = _lightHighlight;
0184: _backgroundSelectedColorEnd = _lightHighlight;
0185: _backgroundUnselectedColorStart = _lightHighlight;
0186: _backgroundUnselectedColorEnd = _highlight;
0187: }
0188: break;
0189: }
0190: }
0191:
0192: @Override
0193: public void uninstallColorTheme() {
0194: super .uninstallColorTheme();
0195:
0196: _backgroundSelectedColorStart = null;
0197: _backgroundSelectedColorEnd = null;
0198: _backgroundUnselectedColorStart = null;
0199: _backgroundUnselectedColorEnd = null;
0200: }
0201:
0202: @Override
0203: public void paintBackground(Graphics g, Component c) {
0204: if (_tabPane.isOpaque()) {
0205: int width = c.getWidth();
0206: int height = c.getHeight();
0207: int h = 0;
0208: int w = 0;
0209:
0210: if (_tabPane.getTabCount() > 0) {
0211: h = _tabPane.getBoundsAt(0).height;
0212: w = _tabPane.getBoundsAt(0).width;
0213: } else {
0214: return;
0215: }
0216:
0217: int temp1 = -1;
0218: int temp2 = -1;
0219: if (isTabLeadingComponentVisible()) {
0220: if (h < _tabLeadingComponent.getSize().height) {
0221: h = _tabLeadingComponent.getSize().height;
0222: temp1 = _tabLeadingComponent.getSize().height;
0223: }
0224: if (w < _tabLeadingComponent.getSize().width) {
0225: w = _tabLeadingComponent.getSize().width;
0226: temp2 = _tabLeadingComponent.getSize().width;
0227: }
0228: }
0229:
0230: if (isTabTrailingComponentVisible()) {
0231: if (h < _tabTrailingComponent.getSize().height
0232: && temp1 < _tabTrailingComponent.getSize().height) {
0233: h = _tabTrailingComponent.getSize().height;
0234: }
0235: if (w < _tabTrailingComponent.getSize().width
0236: && temp2 < _tabTrailingComponent.getSize().width) {
0237: w = _tabTrailingComponent.getSize().width;
0238: }
0239: }
0240:
0241: if (getTabShape() == JideTabbedPane.SHAPE_BOX) {
0242: g.setColor(UIDefaultsLookup.getColor("control"));
0243: g.fillRect(0, 0, width, height);
0244: } else {
0245: if (getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) {
0246: g.setColor(_background);
0247: g.fillRect(0, 0, width, height);
0248: } else {
0249: g.setColor(UIDefaultsLookup.getColor("control"));
0250: g.fillRect(0, 0, width, height);
0251: }
0252: }
0253: }
0254: }
0255:
0256: @Override
0257: protected void paintTabAreaBackground(Graphics g, Rectangle rect,
0258: int tabPlacement) {
0259: if (_tabPane.isOpaque()) {
0260: int tabShape = getTabShape();
0261: if (tabShape != JideTabbedPane.SHAPE_BOX) {
0262: if (getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0263: g.setColor(UIDefaultsLookup.getColor("control"));
0264: g.fillRect(rect.x, rect.y, rect.width, rect.height);
0265:
0266: } else if (getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) {
0267: super .paintTabAreaBackground(g, rect, tabPlacement);
0268: } else {
0269: g.setColor(UIDefaultsLookup.getColor("control"));
0270: g.fillRect(rect.x, rect.y, rect.width, rect.height);
0271: }
0272: } else {
0273: g.setColor(UIDefaultsLookup.getColor("control"));
0274: g.fillRect(rect.x, rect.y, rect.width, rect.height);
0275: }
0276: }
0277: }
0278:
0279: @Override
0280: protected void paintTabBackground(Graphics g, int tabPlacement,
0281: int tabIndex, int x, int y, int w, int h, boolean isSelected) {
0282: super .paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h,
0283: isSelected);
0284:
0285: Graphics2D g2d = (Graphics2D) g;
0286:
0287: if (tabRegion != null) {
0288: Color[] colors = getGradientColors(tabIndex, isSelected);
0289: Color backgroundStart = colors[0];
0290: Color backgroundEnd = colors[1];
0291:
0292: if (backgroundEnd != null && backgroundStart != null) {
0293: switch (tabPlacement) {
0294: case LEFT:
0295: JideSwingUtilities.fillGradient(g2d, tabRegion,
0296: backgroundStart, backgroundEnd, false);
0297: break;
0298: case RIGHT:
0299: JideSwingUtilities.fillGradient(g2d, tabRegion,
0300: backgroundEnd, backgroundStart, false);
0301: break;
0302: case BOTTOM:
0303: JideSwingUtilities.fillGradient(g2d, tabRegion,
0304: backgroundEnd, backgroundStart, true);
0305: break;
0306: case TOP:
0307: default:
0308: JideSwingUtilities.fillGradient(g2d, tabRegion,
0309: backgroundStart, backgroundEnd, true);
0310: break;
0311: }
0312: }
0313: }
0314:
0315: if (getTabShape() == JideTabbedPane.SHAPE_WINDOWS_SELECTED) {
0316: if (_mouseEnter && tabIndex == _indexMouseOver
0317: && !isSelected
0318: && _tabPane.isEnabledAt(_indexMouseOver)) {
0319: paintTabBackgroundMouseOver(g, tabPlacement, tabIndex,
0320: x, y, w, h, isSelected,
0321: _backgroundUnselectedColorStart,
0322: _backgroundUnselectedColorEnd);
0323: }
0324: }
0325: }
0326:
0327: @Override
0328: protected void paintContentBorderTopEdge(Graphics g,
0329: int tabPlacement, int selectedIndex, int x, int y, int w,
0330: int h) {
0331:
0332: if (!PAINT_CONTENT_BORDER_EDGE) {
0333: return;
0334: }
0335:
0336: if (selectedIndex < 0) {
0337: return;
0338: }
0339:
0340: Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
0341:
0342: Rectangle viewRect = _tabScroller.viewport.getViewRect();
0343: Rectangle r = _rects[selectedIndex];
0344:
0345: int tabShape = getTabShape();
0346:
0347: Insets contentInsets = getContentBorderInsets(tabPlacement);
0348:
0349: if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) {
0350: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default
0351: g.setColor(_shadow);
0352: } else {// the color set is office2003
0353: g.setColor(_selectColor1);
0354: }
0355:
0356: if (contentInsets.left > 0) {
0357: g.drawLine(x, y, x, y + h - 1);// left
0358: }
0359: if (contentInsets.right > 0) {
0360: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0361: }
0362: if (contentInsets.bottom > 0) {
0363: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0364: }
0365:
0366: if (!_tabPane.isTabShown()
0367: || r.x >= viewRect.x + viewRect.width) {
0368: g.drawLine(x, y, x + w - 1, y);// top
0369: } else {
0370: g.drawLine(x, y, selRect.x - selRect.height + 2, y);// top left
0371: g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right
0372: }
0373: } else if (tabShape == JideTabbedPane.SHAPE_EXCEL) {
0374: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0375: g.setColor(Color.BLACK);
0376: } else {// the color set is vsnet
0377: g.setColor(getPainter().getControlShadow());
0378: }
0379:
0380: g.drawLine(x, y, selRect.x - selRect.height / 2 + 4, y);// top left
0381:
0382: if (contentInsets.left > 0) {
0383: g.drawLine(x, y, x, y + h - 1);// left
0384: }
0385: if (contentInsets.right > 0) {
0386: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0387: }
0388: if (contentInsets.bottom > 0) {
0389: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0390: }
0391:
0392: if (!_tabPane.isTabShown()
0393: || r.x >= viewRect.x + viewRect.width) {
0394: g.drawLine(x, y, x + w - 1, y);// top
0395: } else {
0396: if (!_tabPane.isShowIconsOnTab()
0397: && !_tabPane.isUseDefaultShowIconsOnTab()) {
0398: g.drawLine(selRect.x + selRect.width
0399: + selRect.height / 2 - 4, y, x + w - 1, y);// top right
0400: } else {
0401: g.drawLine(selRect.x + selRect.width
0402: + selRect.height / 2 - 6, y, x + w - 1, y);// top right
0403: }
0404: }
0405: } else if (tabShape == JideTabbedPane.SHAPE_WINDOWS
0406: || tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) {
0407: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET
0408: || _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp
0409: g.setColor(getPainter().getControlDk());
0410: } else {// the color set is default or office2003
0411: g.setColor(getBorderEdgeColor());
0412: }
0413:
0414: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET
0415: || _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp
0416: g.drawLine(x, y, selRect.x - 1, y);// top left
0417: } else {// the color set is default or office2003
0418: g.drawLine(x, y, selRect.x - 1, y);// top left
0419: }
0420:
0421: if (contentInsets.left > 0) {
0422: g.drawLine(x, y, x, y + h - 1);// left
0423: }
0424:
0425: if (!_tabPane.isTabShown()
0426: || r.x >= viewRect.x + viewRect.width) {
0427: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET
0428: || _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp
0429: g.setColor(getPainter().getControlDk());
0430: } else {// the color set is default or office2003
0431: g.setColor(_lightHighlight);
0432: }
0433:
0434: g.drawLine(x, y, x + w - 1, y);// top
0435: } else {
0436: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET
0437: || _tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WINXP) {// the color set is winxp
0438: g.setColor(getPainter().getControlDk());
0439: g.drawLine(selRect.x + selRect.width + 2, y, x + w
0440: - 1, y);// top right
0441: } else {// the color set is default or office2003
0442: g.setColor(_lightHighlight);
0443: g.drawLine(selRect.x + selRect.width + 2, y, x + w
0444: - 1, y);// top right
0445: }
0446: }
0447:
0448: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0449: g.setColor(new Color(115, 109, 99));
0450: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0451: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0452: } else {// the color set is winxp
0453: g.setColor(getPainter().getControlDk());
0454:
0455: if (contentInsets.left > 0) {
0456: g.drawLine(x, y, x, y + h - 1);// left
0457: }
0458: if (contentInsets.right > 0) {
0459: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0460: }
0461: if (contentInsets.bottom > 0) {
0462: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0463: }
0464: }
0465: } else if (tabShape == JideTabbedPane.SHAPE_VSNET) {
0466: g.setColor(_selectColor1);
0467:
0468: // Break line to show visual connection to selected tab
0469: g.drawLine(x, y, selRect.x, y);// top left
0470:
0471: if (contentInsets.left > 0) {
0472: g.drawLine(x, y, x, y + h - 1);// left
0473: }
0474:
0475: if (!_tabPane.isTabShown()
0476: || r.x >= viewRect.x + viewRect.width) {
0477: g.setColor(_selectColor1);
0478: g.drawLine(x, y, x + w - 1, y);// top
0479: } else {
0480: g.setColor(_selectColor2);
0481: g.drawLine(selRect.x + selRect.width - 1, y, selRect.x
0482: + selRect.width - 1, y);// a point
0483:
0484: g.setColor(_selectColor1);
0485: g.drawLine(selRect.x, y, selRect.x, y);// a point
0486:
0487: g.setColor(_selectColor1);
0488: g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right
0489: }
0490:
0491: g.setColor(_selectColor2);
0492: if (contentInsets.right > 0) {
0493: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0494: }
0495: if (contentInsets.bottom > 0) {
0496: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0497: }
0498:
0499: } else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) {
0500: g.setColor(_selectColor1);
0501:
0502: // Break line to show visual connection to selected tab
0503: g.drawLine(x, y, selRect.x, y);// top left
0504:
0505: if (contentInsets.left > 0) {
0506: g.drawLine(x, y, x, y + h - 1);// left
0507: }
0508:
0509: if (!_tabPane.isTabShown()
0510: || r.x >= viewRect.x + viewRect.width) {
0511: g.drawLine(x, y, x + w - 1, y);// top
0512: } else {
0513: g.drawLine(selRect.x + selRect.width - 1, y, selRect.x
0514: + selRect.width - 1, y);// a point
0515:
0516: g.drawLine(selRect.x, y, selRect.x, y);// a point
0517:
0518: g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right
0519: }
0520:
0521: g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);// right
0522: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0523: } else if (tabShape == JideTabbedPane.SHAPE_FLAT
0524: || tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) {
0525: g.setColor(_shadow);
0526:
0527: if (contentInsets.left > 0) {
0528: g.drawLine(x, y, x, y + h - 1);// left
0529: }
0530: if (contentInsets.right > 0) {
0531: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0532: }
0533: if (contentInsets.bottom > 0) {
0534: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0535: }
0536:
0537: g.drawLine(x, y, selRect.x, y);// top left
0538:
0539: if (!_tabPane.isTabShown()
0540: || r.x >= viewRect.x + viewRect.width) {
0541: g.drawLine(x, y, x + w - 1, y);// top
0542: } else {
0543: g.drawLine(selRect.x + selRect.width, y, x + w - 1, y);// top right
0544: }
0545: } else {
0546: super .paintContentBorderTopEdge(g, tabPlacement,
0547: selectedIndex, x, y, w, h);
0548: }
0549:
0550: }
0551:
0552: @Override
0553: protected void paintContentBorderBottomEdge(Graphics g,
0554: int tabPlacement, int selectedIndex, int x, int y, int w,
0555: int h) {
0556: if (!PAINT_CONTENT_BORDER_EDGE) {
0557: return;
0558: }
0559:
0560: if (selectedIndex < 0) {
0561: return;
0562: }
0563:
0564: Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
0565:
0566: Rectangle viewRect = _tabScroller.viewport.getViewRect();
0567: Rectangle r = _rects[selectedIndex];
0568:
0569: int tabShape = getTabShape();
0570:
0571: Insets contentInsets = getContentBorderInsets(tabPlacement);
0572:
0573: if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) {
0574: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default
0575: g.setColor(_shadow);
0576: } else {// the color set is office2003
0577: g.setColor(_selectColor1);
0578: }
0579: if (contentInsets.left > 0) {
0580: g.drawLine(x, y, x, y + h - 1);// left
0581: }
0582: if (contentInsets.right > 0) {
0583: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0584: }
0585: if (contentInsets.top > 0) {
0586: g.drawLine(x, y, x + w - 1, y);// top
0587: }
0588:
0589: if (!_tabPane.isTabShown()
0590: || r.x >= viewRect.x + viewRect.width) {
0591: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0592: } else {
0593: if (!_tabPane.isTabShown()) {
0594: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0595: } else {
0596: g.drawLine(x, y + h - 1, selRect.x - selRect.height
0597: + 2, y + h - 1);// bottom left
0598: g.drawLine(selRect.x + selRect.width, y + h - 1, x
0599: + w - 1, y + h - 1);// bottom right
0600: }
0601: }
0602: } else if (tabShape == JideTabbedPane.SHAPE_EXCEL) {
0603: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0604: g.setColor(Color.BLACK);
0605: } else {// the color set is vsnet
0606: g.setColor(getPainter().getControlShadow());
0607: }
0608:
0609: g.drawLine(x, y + h - 1,
0610: selRect.x - selRect.height / 2 + 4, y + h - 1);// bottom left
0611:
0612: if (contentInsets.left > 0) {
0613: g.drawLine(x, y, x, y + h - 1);// left
0614: }
0615: if (contentInsets.right > 0) {
0616: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0617: }
0618: if (contentInsets.top > 0) {
0619: g.drawLine(x, y, x + w - 1, y);// top
0620: }
0621:
0622: if (!_tabPane.isTabShown()
0623: || r.x >= viewRect.x + viewRect.width) {
0624: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0625: } else {
0626: if (!_tabPane.isShowIconsOnTab()
0627: && !_tabPane.isUseDefaultShowIconsOnTab()) {
0628: g.drawLine(selRect.x + selRect.width
0629: + selRect.height / 2 - 4, y + h - 1, x + w
0630: - 1, y + h - 1);// bottom right
0631: } else {
0632: g.drawLine(selRect.x + selRect.width
0633: + selRect.height / 2 - 6, y + h - 1, x + w
0634: - 1, y + h - 1);// bottom right
0635: }
0636: }
0637: } else if (tabShape == JideTabbedPane.SHAPE_WINDOWS
0638: || tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) {
0639: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0640: g.setColor(new Color(113, 111, 100));
0641: g.drawLine(x, y + h - 1, selRect.x - 2, y + h - 1);
0642: if (contentInsets.right > 0) {
0643: g.drawLine(x + w - 1, y + h - 1, x + w - 1, y);
0644: }
0645:
0646: if (!_tabPane.isTabShown()
0647: || r.x >= viewRect.x + viewRect.width) {
0648: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
0649: } else {
0650: g.drawLine(selRect.x + selRect.width, y + h - 1, x
0651: + w - 1, y + h - 1);
0652: g.setColor(UIDefaultsLookup.getColor("control"));
0653: g.drawLine(selRect.x, y + h - 1, selRect.x
0654: + selRect.width - 2, y + h - 1);
0655: g.drawLine(selRect.x, y + h - 2, selRect.x
0656: + selRect.width, y + h - 2);
0657: }
0658:
0659: g.setColor(new Color(255, 255, 255));
0660:
0661: if (contentInsets.left > 0) {
0662: g.drawLine(x, y, x, y + h - 2);
0663: }
0664: if (contentInsets.top > 0) {
0665: g.drawLine(x, y, x + w - 2, y);
0666: }
0667:
0668: } else {// the color set is winxp
0669: g.setColor(getPainter().getControlDk());
0670:
0671: g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);
0672:
0673: if (!_tabPane.isTabShown()
0674: || r.x >= viewRect.x + viewRect.width) {
0675: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
0676: } else {
0677: g.drawLine(selRect.x + selRect.width + 2,
0678: y + h - 1, x + w - 1, y + h - 1);
0679: }
0680:
0681: g.drawLine(selRect.x - 1, y + h - 1, selRect.x - 1, y
0682: + h - 1);
0683: g.drawLine(selRect.x + selRect.width + 2, y + h - 1,
0684: selRect.x + selRect.width + 2, y + h - 1);
0685:
0686: if (contentInsets.left > 0) {
0687: g.drawLine(x, y, x, y + h - 2);
0688: }
0689: if (contentInsets.top > 0) {
0690: g.drawLine(x, y, x + w - 2, y);
0691: }
0692: if (contentInsets.left > 0) {
0693: g.drawLine(x + w - 1, y + h - 1, x + w - 1, y);
0694: }
0695: }
0696: } else if (tabShape == JideTabbedPane.SHAPE_VSNET) {
0697: // Break line to show visual connection to selected tab
0698: g.setColor(_selectColor2);
0699: g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);// bottom left
0700:
0701: g.setColor(_selectColor1);
0702: g.drawLine(selRect.x, y + h - 1, selRect.x, y + h - 1);
0703:
0704: if (!_tabPane.isTabShown()
0705: || r.x >= viewRect.x + viewRect.width) {
0706: g.setColor(_selectColor2);
0707: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0708: } else {
0709: g.setColor(_selectColor2);
0710: g.drawLine(selRect.x + selRect.width - 1, y + h - 1, x
0711: + w - 2, y + h - 1); // bottom right
0712: }
0713:
0714: g.setColor(_selectColor2);
0715: if (contentInsets.right > 0) {
0716: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0717: }
0718:
0719: g.setColor(_selectColor1);
0720: if (contentInsets.left > 0) {
0721: g.drawLine(x, y, x, y + h - 2);// left
0722: }
0723: if (contentInsets.top > 0) {
0724: g.drawLine(x, y, x + w - 2, y);// top
0725: }
0726: } else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) {
0727: // Break line to show visual connection to selected tab
0728: g.setColor(_selectColor1);
0729: g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);// bottom left
0730:
0731: g.drawLine(selRect.x, y + h - 1, selRect.x, y + h - 1);
0732:
0733: if (!_tabPane.isTabShown()
0734: || r.x >= viewRect.x + viewRect.width) {
0735: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0736: } else {
0737: g.drawLine(selRect.x + selRect.width - 1, y + h - 1, x
0738: + w - 2, y + h - 1); // bottom right
0739: }
0740:
0741: if (contentInsets.left > 0) {
0742: g.drawLine(x, y, x, y + h - 2);// left
0743: }
0744: if (contentInsets.right > 0) {
0745: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0746: }
0747: if (contentInsets.top > 0) {
0748: g.drawLine(x, y, x + w - 2, y);// top
0749: }
0750: } else if (tabShape == JideTabbedPane.SHAPE_FLAT
0751: || tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) {
0752: g.setColor(_shadow);
0753: g.drawLine(x, y + h - 1, selRect.x - 1, y + h - 1);// bottom left
0754: if (contentInsets.left > 0) {
0755: g.drawLine(x, y, x, y + h - 1);// left
0756: }
0757: if (contentInsets.right > 0) {
0758: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0759: }
0760: if (contentInsets.top > 0) {
0761: g.drawLine(x, y, x + w - 1, y);// top
0762: }
0763: g.drawLine(selRect.x, y + h - 1, selRect.x, y + h - 1);// a point
0764:
0765: if (!_tabPane.isTabShown()
0766: || r.x >= viewRect.x + viewRect.width) {
0767: g.drawLine(x, y + h - 1, x + w - 2, y + h - 1);// bottom
0768: } else {
0769: g.drawLine(selRect.x + selRect.width, y + h - 1, x + w
0770: - 2, y + h - 1);// bottom right
0771: }
0772: } else {
0773: super .paintContentBorderBottomEdge(g, tabPlacement,
0774: selectedIndex, x, y, w, h);
0775: }
0776: }
0777:
0778: @Override
0779: protected void paintContentBorderLeftEdge(Graphics g,
0780: int tabPlacement, int selectedIndex, int x, int y, int w,
0781: int h) {
0782:
0783: if (!PAINT_CONTENT_BORDER_EDGE) {
0784: return;
0785: }
0786:
0787: if (selectedIndex < 0) {
0788: return;
0789: }
0790:
0791: Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
0792:
0793: Rectangle viewRect = _tabScroller.viewport.getViewRect();
0794: Rectangle r = _rects[selectedIndex];
0795:
0796: int tabShape = getTabShape();
0797:
0798: Insets contentInsets = getContentBorderInsets(tabPlacement);
0799:
0800: if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) {
0801: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default
0802: g.setColor(_shadow);
0803: } else {// the color set is office2003
0804: g.setColor(_selectColor1);
0805: }
0806:
0807: if (contentInsets.top > 0) {
0808: g.drawLine(x, y, x + w - 1, y);// top
0809: }
0810: if (contentInsets.right > 0) {
0811: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0812: }
0813: if (contentInsets.bottom > 0) {
0814: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0815: }
0816:
0817: if (!_tabPane.isTabShown()
0818: || r.y >= viewRect.y + viewRect.height) {
0819: g.drawLine(x, y, x, y + h - 1);// left
0820: } else {
0821: g.drawLine(x, y, x, selRect.y - selRect.width + 2);// left top
0822: g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left bottom
0823: }
0824: } else if (tabShape == JideTabbedPane.SHAPE_EXCEL) {
0825: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0826: g.setColor(Color.BLACK);
0827: } else {// the color set is vsnet
0828: g.setColor(getPainter().getControlShadow());
0829: }
0830:
0831: g.drawLine(x, y, x, selRect.y - selRect.width / 2 + 4);// left top
0832:
0833: if (contentInsets.top > 0) {
0834: g.drawLine(x, y, x + w - 1, y);// top
0835: }
0836: if (contentInsets.right > 0) {
0837: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0838: }
0839: if (contentInsets.bottom > 0) {
0840: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0841: }
0842:
0843: if (!_tabPane.isTabShown()
0844: || r.y >= viewRect.y + viewRect.height) {
0845: g.drawLine(x, y, x, y + h - 1);// left
0846: } else {
0847: g.drawLine(x, selRect.y + selRect.height
0848: + selRect.width / 2 - 4, x, y + h - 1);// left bottom
0849: }
0850: } else if (tabShape == JideTabbedPane.SHAPE_WINDOWS
0851: || tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) {
0852: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
0853: g.setColor(new Color(115, 109, 99));
0854: if (contentInsets.right > 0) {
0855: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0856: }
0857: if (contentInsets.bottom > 0) {
0858: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0859: }
0860:
0861: g.setColor(new Color(255, 255, 255));
0862: if (contentInsets.top > 0) {
0863: g.drawLine(x, y, x + w - 2, y);
0864: }
0865: g.drawLine(x, y, x, selRect.y - 1);
0866:
0867: if (!_tabPane.isTabShown()
0868: || r.y >= viewRect.y + viewRect.height) {
0869: g.drawLine(x, y, x, y + h - 2);
0870: } else {
0871: g.drawLine(x, selRect.y + selRect.height + 1, x, y
0872: + h - 2);
0873: }
0874:
0875: } else {// the color set is winxp
0876: g.setColor(getPainter().getControlDk());
0877:
0878: if (contentInsets.top > 0) {
0879: g.drawLine(x, y, x + w - 1, y);// top
0880: }
0881: if (contentInsets.right > 0) {
0882: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0883: }
0884: if (contentInsets.bottom > 0) {
0885: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0886: }
0887: g.drawLine(x, y, x, selRect.y - 2);
0888:
0889: if (!_tabPane.isTabShown()
0890: || r.y >= viewRect.y + viewRect.height) {
0891: g.drawLine(x, y, x, y + h - 2);
0892: } else {
0893: g.drawLine(x, selRect.y + selRect.height + 2, x, y
0894: + h - 2);
0895: }
0896: }
0897: } else if (tabShape == JideTabbedPane.SHAPE_VSNET) {
0898: g.setColor(_selectColor1);
0899:
0900: // Break line to show visual connection to selected tab
0901: g.drawLine(x, y, x, selRect.y);// left top
0902:
0903: if (contentInsets.top > 0) {
0904: g.drawLine(x, y, x + w - 1, y);// top
0905: }
0906:
0907: if (!_tabPane.isTabShown()
0908: || r.x >= viewRect.x + viewRect.width) {
0909: g.setColor(_selectColor1);
0910: g.drawLine(x, y, x, y + h - 1);// left
0911: } else {
0912: g.setColor(_selectColor1);
0913: g.drawLine(x, selRect.y, x, selRect.y);// a point
0914:
0915: g.setColor(_selectColor2);
0916: g.drawLine(x, selRect.y + selRect.height - 1, x,
0917: selRect.y + selRect.height - 1);// a point
0918:
0919: g.setColor(_selectColor1);
0920: g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left
0921: // bottom
0922: }
0923:
0924: g.setColor(_selectColor2);
0925: if (contentInsets.right > 0) {
0926: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0927: }
0928: if (contentInsets.bottom > 0) {
0929: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0930: }
0931: } else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) {
0932: g.setColor(_selectColor1);
0933:
0934: // Break line to show visual connection to selected tab
0935: g.drawLine(x, y, x, selRect.y);// left top
0936:
0937: if (!_tabPane.isTabShown()
0938: || r.x >= viewRect.x + viewRect.width) {
0939: g.drawLine(x, y, x, y + h - 1);// left
0940: } else {
0941: g.drawLine(x, selRect.y, x, selRect.y);// a point
0942: g.drawLine(x, selRect.y + selRect.height - 1, x,
0943: selRect.y + selRect.height - 1);// a point
0944: g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left
0945: // bottom
0946: }
0947:
0948: if (contentInsets.top > 0) {
0949: g.drawLine(x, y, x + w - 1, y);// top
0950: }
0951: if (contentInsets.right > 0) {
0952: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0953: }
0954: if (contentInsets.bottom > 0) {
0955: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0956: }
0957: } else if (tabShape == JideTabbedPane.SHAPE_FLAT
0958: || tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) {
0959: g.setColor(_shadow);
0960: if (contentInsets.top > 0) {
0961: g.drawLine(x, y, x + w - 1, y);// top
0962: }
0963: if (contentInsets.right > 0) {
0964: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
0965: }
0966: if (contentInsets.bottom > 0) {
0967: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
0968: }
0969: g.drawLine(x, y, x, selRect.y);// left top
0970:
0971: if (!_tabPane.isTabShown()
0972: || r.y >= viewRect.y + viewRect.height) {
0973: g.drawLine(x, y, x, y + h - 1);// left
0974: } else {
0975: g.drawLine(x, selRect.y + selRect.height, x, y + h - 1);// left bottom
0976: }
0977: } else {
0978: super .paintContentBorderLeftEdge(g, tabPlacement,
0979: selectedIndex, x, y, w, h);
0980: }
0981: }
0982:
0983: @Override
0984: protected void paintContentBorderRightEdge(Graphics g,
0985: int tabPlacement, int selectedIndex, int x, int y, int w,
0986: int h) {
0987:
0988: if (!PAINT_CONTENT_BORDER_EDGE) {
0989: return;
0990: }
0991:
0992: if (selectedIndex < 0) {
0993: return;
0994: }
0995:
0996: Rectangle selRect = getTabBounds(selectedIndex, _calcRect);
0997:
0998: Rectangle viewRect = _tabScroller.viewport.getViewRect();
0999: Rectangle r = _rects[selectedIndex];
1000:
1001: int tabShape = getTabShape();
1002:
1003: Insets contentInsets = getContentBorderInsets(tabPlacement);
1004:
1005: if (tabShape == JideTabbedPane.SHAPE_OFFICE2003) {
1006: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {// the color set is default
1007: g.setColor(_shadow);
1008: } else {// the color set is office2003
1009: g.setColor(_selectColor1);
1010: }
1011:
1012: if (contentInsets.top > 0) {
1013: g.drawLine(x, y, x + w - 1, y);// top
1014: }
1015: if (contentInsets.left > 0) {
1016: g.drawLine(x, y, x, y + h - 1);// left
1017: }
1018: if (contentInsets.bottom > 0) {
1019: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
1020: }
1021:
1022: if (!_tabPane.isTabShown()
1023: || r.y >= viewRect.y + viewRect.height) {
1024: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
1025: } else {
1026: g.drawLine(x + w - 1, y, x + w - 1, selRect.y
1027: - selRect.width + 2);// right top
1028: g.drawLine(x + w - 1, selRect.y + selRect.height, x + w
1029: - 1, y + h - 1);// right bottom
1030: }
1031: } else if (tabShape == JideTabbedPane.SHAPE_EXCEL) {
1032: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
1033: g.setColor(Color.BLACK);
1034: } else {// the color set is vsnet
1035: g.setColor(getPainter().getControlShadow());
1036: }
1037:
1038: g.drawLine(x + w - 1, y, x + w - 1, selRect.y
1039: - selRect.width / 2 + 4);// right top
1040:
1041: if (contentInsets.top > 0) {
1042: g.drawLine(x, y, x + w - 1, y);// top
1043: }
1044: if (contentInsets.left > 0) {
1045: g.drawLine(x, y, x, y + h - 1);// left
1046: }
1047: if (contentInsets.bottom > 0) {
1048: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
1049: }
1050:
1051: if (!_tabPane.isTabShown()
1052: || r.y >= viewRect.y + viewRect.height) {
1053: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
1054: } else {
1055: g.drawLine(x + w - 1, selRect.y + selRect.height
1056: + selRect.width / 2 - 4, x + w - 1, y + h - 1);// right bottom
1057: }
1058: } else if (tabShape == JideTabbedPane.SHAPE_WINDOWS
1059: || tabShape == JideTabbedPane.SHAPE_WINDOWS_SELECTED) {
1060: if (_tabPane.getColorTheme() == JideTabbedPane.COLOR_THEME_WIN2K) {
1061:
1062: g.setColor(new Color(115, 109, 99));
1063: g.drawLine(x + w - 1, y, x + w - 1, selRect.y - 2);
1064: if (contentInsets.bottom > 0) {
1065: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
1066: }
1067:
1068: if (!_tabPane.isTabShown()
1069: || r.y >= viewRect.y + viewRect.height) {
1070: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
1071: g.setColor(new Color(173, 170, 156));
1072: g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
1073: } else {
1074: g.drawLine(x + w - 1, selRect.y + selRect.height
1075: + 1, x + w - 1, y + h - 1);
1076: g.setColor(UIDefaultsLookup.getColor("control"));
1077: g.drawLine(x + w - 1, selRect.y, x + w - 1,
1078: selRect.y + selRect.height - 1);
1079: g.drawLine(x + w - 2, selRect.y, x + w - 2,
1080: selRect.y + selRect.height + 1);
1081: }
1082:
1083: g.setColor(new Color(255, 255, 255));
1084: if (contentInsets.top > 0) {
1085: g.drawLine(x, y, x + w - 2, y);// top
1086: }
1087: if (contentInsets.left > 0) {
1088: g.drawLine(x, y, x, y + h - 2);// left
1089: }
1090: } else {// the color set is winxp
1091: g.setColor(getPainter().getControlDk());
1092: if (contentInsets.top > 0) {
1093: g.drawLine(x, y, x + w - 1, y);// top
1094: }
1095: if (contentInsets.left > 0) {
1096: g.drawLine(x, y, x, y + h - 1);// left
1097: }
1098: if (contentInsets.bottom > 0) {
1099: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
1100: }
1101: g.drawLine(x + w - 1, y, x + w - 1, selRect.y - 2);
1102:
1103: if (!_tabPane.isTabShown()
1104: || r.y >= viewRect.y + viewRect.height) {
1105: g.drawLine(x + w - 1, y, x + w - 1, y + h - 2);
1106: } else {
1107: g.drawLine(x + w - 1, selRect.y + selRect.height
1108: + 2, x + w - 1, y + h - 2);
1109: }
1110:
1111: }
1112: } else if (tabShape == JideTabbedPane.SHAPE_VSNET) {
1113: g.setColor(getBorderEdgeColor());
1114:
1115: // Break line to show visual connection to selected tab
1116: g.setColor(_selectColor2);
1117: g.drawLine(x + w - 1, y, x + w - 1, selRect.y);// right top
1118: if (contentInsets.bottom > 0) {
1119: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
1120: }
1121:
1122: if (!_tabPane.isTabShown()
1123: || r.x >= viewRect.x + viewRect.width) {
1124: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
1125: } else {
1126: g.setColor(_selectColor2);
1127: g.drawLine(x + w - 1, selRect.y + selRect.height - 1, x
1128: + w - 1, selRect.y + selRect.height - 1);// a point
1129: g.drawLine(x + w - 1, selRect.y + selRect.height, x + w
1130: - 1, y + h - 1);// right bottom
1131: }
1132:
1133: g.setColor(_selectColor1);
1134: if (contentInsets.top > 0) {
1135: g.drawLine(x, y, x + w - 2, y);// top
1136: }
1137: if (contentInsets.left > 0) {
1138: g.drawLine(x, y, x, y + h - 2);// left
1139: }
1140: } else if (tabShape == JideTabbedPane.SHAPE_ROUNDED_VSNET) {
1141: g.setColor(_selectColor1);
1142:
1143: // Break line to show visual connection to selected tab
1144: g.drawLine(x + w - 1, y, x + w - 1, selRect.y - 1);// right top
1145:
1146: if (!_tabPane.isTabShown()
1147: || r.x >= viewRect.x + viewRect.width) {
1148: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
1149: } else {
1150: g.drawLine(x + w - 1, selRect.y, x + w - 1, selRect.y);// a point
1151: g.drawLine(x + w - 1, selRect.y + selRect.height - 1, x
1152: + w - 1, selRect.y + selRect.height - 1);// a point
1153: g.drawLine(x + w - 1, selRect.y + selRect.height, x + w
1154: - 1, y + h - 1);// right bottom
1155: }
1156:
1157: if (contentInsets.top > 0) {
1158: g.drawLine(x, y, x + w - 1, y);// top
1159: }
1160: if (contentInsets.left > 0) {
1161: g.drawLine(x, y, x, y + h - 2);// left
1162: }
1163: if (contentInsets.bottom > 0) {
1164: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
1165: }
1166: } else if (tabShape == JideTabbedPane.SHAPE_FLAT
1167: || tabShape == JideTabbedPane.SHAPE_ROUNDED_FLAT) {
1168: g.setColor(_shadow);
1169:
1170: if (contentInsets.top > 0) {
1171: g.drawLine(x, y, x + w - 1, y);// top
1172: }
1173: if (contentInsets.left > 0) {
1174: g.drawLine(x, y, x, y + h - 1);// left
1175: }
1176: if (contentInsets.bottom > 0) {
1177: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);// bottom
1178: }
1179: g.drawLine(x + w - 1, y, x + w - 1, selRect.y);// right top
1180:
1181: if (!_tabPane.isTabShown()
1182: || r.y >= viewRect.y + viewRect.height) {
1183: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);// right
1184: } else {
1185: g.drawLine(x + w - 1, selRect.y + selRect.height, x + w
1186: - 1, y + h - 1);// right bottom
1187: }
1188: } else {
1189: super .paintContentBorderRightEdge(g, tabPlacement,
1190: selectedIndex, x, y, w, h);
1191: }
1192: }
1193:
1194: @Override
1195: protected void paintContentBorder(Graphics g, int x, int y, int w,
1196: int h) {
1197: if (!PAINT_CONTENT_BORDER) {
1198: return;
1199: }
1200:
1201: Insets insets = getContentBorderInsets(_tabPane
1202: .getTabPlacement());
1203:
1204: JideTabbedPane.ColorProvider colorProvider = _tabPane
1205: .getTabColorProvider();
1206: boolean useDefault = true;
1207: if (colorProvider != null) {
1208: Color backgroundAt = colorProvider.getBackgroundAt(_tabPane
1209: .getSelectedIndex());
1210: if (backgroundAt != null) {
1211: g.setColor(backgroundAt);
1212: g.fillRect(x, y, w, h);
1213: useDefault = false;
1214: }
1215: }
1216:
1217: if (useDefault) {
1218: Color[] colors = getGradientColors(_tabPane
1219: .getSelectedIndex(), true);
1220: g.setColor(colors[1]);
1221: g.fillRect(x, y, w, insets.top); // top
1222: g.fillRect(x, y, insets.left, h); // left
1223: g.fillRect(x, y + h - insets.bottom, w, insets.bottom); // bottom
1224: g.fillRect(x + w - insets.right, y, insets.right, h); // right
1225: }
1226: }
1227:
1228: protected Color[] getGradientColors(int tabIndex, boolean isSelected) {
1229: Color backgroundEnd = null;
1230: Color backgroundStart = null;
1231:
1232: JideTabbedPane.ColorProvider colorProvider = _tabPane
1233: .getTabColorProvider();
1234: if (colorProvider != null) {
1235: backgroundEnd = colorProvider.getBackgroundAt(tabIndex);
1236: if (colorProvider instanceof JideTabbedPane.GradientColorProvider) {
1237: backgroundStart = ((JideTabbedPane.GradientColorProvider) colorProvider)
1238: .getTopBackgroundAt(tabIndex);
1239: } else {
1240: backgroundStart = backgroundEnd != null ? ColorUtils
1241: .getDerivedColor(backgroundEnd, colorProvider
1242: .getGradientRatio(tabIndex)) : null;
1243: }
1244: } else {
1245: Color color = _tabPane.getBackgroundAt(tabIndex);
1246: if (!(color instanceof UIResource)
1247: && color != _tabPane.getBackground()) {
1248: backgroundEnd = color;
1249: if (getColorTheme() == JideTabbedPane.COLOR_THEME_OFFICE2003) {
1250: backgroundStart = ColorUtils.getDerivedColor(color,
1251: 0.8f);
1252: } else {
1253: backgroundStart = color;
1254: }
1255: }
1256: }
1257:
1258: if (isSelected) {
1259: if (showFocusIndicator()) {
1260: if (backgroundEnd == null) {
1261: backgroundEnd = _backgroundSelectedColorEnd;
1262: }
1263: if (backgroundStart == null) {
1264: backgroundStart = _backgroundSelectedColorStart;
1265: }
1266: } else {
1267: if (getColorTheme() == JideTabbedPane.COLOR_THEME_VSNET) {
1268: if (backgroundEnd == null) {
1269: backgroundEnd = _backgroundSelectedColorEnd;
1270: }
1271: if (backgroundStart == null) {
1272: backgroundStart = _backgroundSelectedColorStart;
1273: }
1274: } else {
1275: if (backgroundEnd == null) {
1276: backgroundEnd = ColorUtils.getDerivedColor(
1277: _backgroundUnselectedColorEnd, 0.7f);
1278: }
1279: if (backgroundStart == null) {
1280: backgroundStart = ColorUtils.getDerivedColor(
1281: _backgroundUnselectedColorStart, 0.8f);
1282: }
1283: }
1284: }
1285: } else {
1286: if (getTabShape() != JideTabbedPane.SHAPE_WINDOWS_SELECTED) {
1287: if (backgroundEnd == null) {
1288: backgroundEnd = _backgroundUnselectedColorEnd;
1289: }
1290: if (backgroundStart == null) {
1291: backgroundStart = _backgroundUnselectedColorStart;
1292: }
1293: }
1294: }
1295: return new Color[] { backgroundStart, backgroundEnd };
1296: }
1297: }
|