1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45:
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52:
53:
56: public class MetalTabbedPaneUI extends BasicTabbedPaneUI
57: {
58:
59:
68: public class TabbedPaneLayout
69: extends BasicTabbedPaneUI.TabbedPaneLayout
70: {
71:
74: public TabbedPaneLayout()
75: {
76:
77: }
78:
79:
87: protected void rotateTabRuns(int tabPlacement, int selectedRun)
88: {
89:
90: }
91:
92:
100: protected void padSelectedTab(int tabPlacement, int selectedIndex)
101: {
102:
103:
104: }
105:
106:
110: protected void normalizeTabRuns(int tabPlacement, int tabCount, int start,
111: int max)
112: {
113: if (tabPlacement == TOP || tabPlacement == BOTTOM)
114: super.normalizeTabRuns(tabPlacement, tabCount, start, max);
115: }
116: }
117:
118:
121: protected int minTabWidth;
122:
123:
126: protected Color selectColor;
127:
128:
131: protected Color selectHighlight;
132:
133:
136: protected Color tabAreaBackground;
137:
138:
139: private Graphics hg;
140:
141:
144: private boolean tabsOpaque;
145:
146:
149: public MetalTabbedPaneUI()
150: {
151: super();
152: }
153:
154:
161: public static ComponentUI createUI(JComponent component)
162: {
163: return new MetalTabbedPaneUI();
164: }
165:
166:
171: protected LayoutManager createLayoutManager()
172: {
173: return (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
174: ? new MetalTabbedPaneUI.TabbedPaneLayout()
175: : super.createLayoutManager();
176: }
177:
178:
191: protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
192: int x, int y, int w, int h, boolean isSelected)
193: {
194: int bottom = y + h - 1;
195: int right = x + w - 1;
196:
197: switch (tabPlacement)
198: {
199: case LEFT:
200: paintLeftTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
201: break;
202: case BOTTOM:
203: paintBottomTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
204: break;
205: case RIGHT:
206: paintRightTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
207: break;
208: case TOP:
209: default:
210: paintTopTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
211: }
212: }
213:
214:
228: protected void paintTopTabBorder(int tabIndex, Graphics g, int x, int y,
229: int w, int h, int btm, int rght, boolean isSelected)
230: {
231: int tabCount = tabPane.getTabCount();
232: int currentRun = getRunForTab(tabCount, tabIndex);
233: int right = w - 1;
234: int bottom = h - 1;
235:
236:
237: if (shouldFillGap(currentRun, tabIndex, x, y))
238: {
239: g.translate(x, y);
240: g.setColor(getColorForGap(currentRun, x, y + 1));
241: g.fillRect(1, 0, 5, 3);
242: g.fillRect(1, 3, 2, 2);
243: g.translate(-x, -y);
244: }
245:
246: g.translate(x, y);
247:
248: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
249: Color oceanSelectedBorder =
250: UIManager.getColor("TabbedPane.borderHightlightColor");
251: if (isOcean && isSelected)
252: g.setColor(oceanSelectedBorder);
253: else
254: g.setColor(darkShadow);
255:
256:
257: g.drawLine(1, 5, 6, 0);
258:
259: g.drawLine(6, 0, right, 0);
260:
261: int lastIndex = lastTabInRun(tabCount, currentRun);
262: if (tabIndex == lastIndex)
263: g.drawLine(right, 1, right, bottom);
264:
265: int selectedIndex = tabPane.getSelectedIndex();
266: if (isOcean && tabIndex - 1 == selectedIndex
267: && currentRun == getRunForTab(tabCount, selectedIndex))
268: {
269: g.setColor(oceanSelectedBorder);
270: }
271: if (tabIndex != tabRuns[runCount - 1])
272: {
273: if (isOcean && isSelected)
274: {
275: g.drawLine(0, 6, 0, bottom);
276: g.setColor(darkShadow);
277: g.drawLine(0, 0, 0, 5);
278: }
279: else
280: {
281: g.drawLine(0, 0, 0, bottom);
282: }
283: }
284: else
285: {
286: g.drawLine(0, 6, 0, bottom);
287: }
288:
289:
290: g.setColor(isSelected ? selectHighlight : highlight);
291:
292: g.drawLine(1, 6, 6, 1);
293:
294: g.drawLine(6, 1, right, 1);
295:
296: g.drawLine(1, 6, 1, bottom);
297: int firstIndex = tabRuns[currentRun];
298: if (tabIndex == firstIndex && tabIndex != tabRuns[runCount - 1])
299: {
300: if (tabPane.getSelectedIndex() == tabRuns[currentRun + 1])
301: g.setColor(selectHighlight);
302: else
303: g.setColor(highlight);
304: g.drawLine(1, 0, 1, 4);
305: }
306:
307: g.translate(-x, -y);
308: }
309:
310:
324: protected void paintLeftTabBorder(int tabIndex, Graphics g, int x, int y,
325: int w, int h, int btm, int rght, boolean isSelected)
326: {
327: g.translate(x, y);
328: int bottom = h - 1;
329: int right = w - 1;
330:
331: int tabCount = tabPane.getTabCount();
332: int currentRun = getRunForTab(tabCount, tabIndex);
333: int firstIndex = tabRuns[currentRun];
334:
335:
336: if (tabIndex != firstIndex && tabIndex > 0 && tabsOpaque)
337: {
338: Color c;
339: if (tabPane.getSelectedIndex() == tabIndex - 1)
340: c = selectColor;
341: else
342: c = getUnselectedBackground(tabIndex - 1);
343: g.setColor(c);
344: g.fillRect(2, 0, 4, 3);
345: g.drawLine(2, 3, 2, 3);
346: }
347:
348:
349: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
350: if (isOcean)
351: {
352: g.setColor(isSelected ? selectHighlight : MetalLookAndFeel.getWhite());
353: }
354: else
355: {
356: g.setColor(isSelected ? selectHighlight : highlight);
357: }
358:
359: g.drawLine(1, 6, 6, 1);
360:
361: g.drawLine(1, 6, 1, bottom);
362:
363: g.drawLine(6, 1, right, 1);
364: if (tabIndex != firstIndex)
365: {
366: if (isOcean)
367: {
368: g.setColor(MetalLookAndFeel.getWhite());
369: }
370: g.drawLine(1, 0, 1, 4);
371: }
372:
373:
374: Color oceanSelectedBorder =
375: UIManager.getColor("TabbedPane.borderHightlightColor");
376: if (isOcean && isSelected)
377: {
378: g.setColor(oceanSelectedBorder);
379: }
380: else
381: {
382: g.setColor(darkShadow);
383: }
384:
385:
386: g.drawLine(1, 5, 6, 0);
387:
388: g.drawLine(6, 0, right, 0);
389:
390: int lastIndex = lastTabInRun(tabCount, currentRun);
391: if (tabIndex == lastIndex)
392: {
393: g.drawLine(0, bottom, right, bottom);
394: }
395:
396: if (isOcean)
397: {
398: if (tabPane.getSelectedIndex() == tabIndex - 1)
399: {
400: g.drawLine(0, 6, 0, bottom);
401: if (tabIndex != firstIndex)
402: {
403: g.setColor(oceanSelectedBorder);
404: g.drawLine(0, 0, 0, 5);
405: }
406: }
407: else if (isSelected)
408: {
409: g.drawLine(0, 5, 0, bottom);
410: if (tabIndex != firstIndex)
411: {
412: g.setColor(darkShadow);
413: g.drawLine(0, 0, 0, 5);
414: }
415: }
416: else if (tabIndex != firstIndex)
417: {
418: g.drawLine(0, 0, 0, bottom);
419: }
420: else
421: {
422: g.drawLine(0, 6, 0, bottom);
423: }
424: }
425: else
426: {
427: if (tabIndex != firstIndex)
428: {
429: g.drawLine(0, 0, 0, bottom);
430: }
431: else
432: {
433: g.drawLine(0, 6, 0, bottom);
434: }
435: }
436:
437: g.translate(-x, -y);
438: }
439:
440:
454: protected void paintRightTabBorder(int tabIndex, Graphics g, int x, int y,
455: int w, int h, int btm, int rght, boolean isSelected)
456: {
457: g.translate(x, y);
458: int bottom = h - 1;
459: int right = w - 1;
460:
461: int tabCount = tabPane.getTabCount();
462: int currentRun = getRunForTab(tabCount, tabIndex);
463: int firstIndex = tabRuns[currentRun];
464:
465:
466: if (tabIndex != firstIndex && tabIndex > 0 && tabsOpaque)
467: {
468: Color c;
469: if (tabPane.getSelectedIndex() == tabIndex - 1)
470: c = selectColor;
471: else
472: c = getUnselectedBackground(tabIndex - 1);
473: g.setColor(c);
474: g.fillRect(right - 5, 0, 5, 3);
475: g.fillRect(right - 2, 3, 2, 2);
476: }
477:
478:
479: g.setColor(isSelected ? selectHighlight : highlight);
480:
481:
482: g.drawLine(right - 6, 1, right - 1, 6);
483:
484: g.drawLine(0, 1, right - 6, 1);
485:
486: if (! isSelected)
487: {
488: g.drawLine(0, 1, 0, bottom);
489: }
490:
491:
492: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
493: Color oceanSelectedBorder =
494: UIManager.getColor("TabbedPane.borderHightlightColor");
495: if (isOcean && isSelected)
496: {
497: g.setColor(oceanSelectedBorder);
498: }
499: else
500: {
501: g.setColor(darkShadow);
502: }
503:
504:
505: int lastIndex = lastTabInRun(tabCount, currentRun);
506: if (tabIndex == lastIndex)
507: {
508: g.drawLine(0, bottom, right, bottom);
509: }
510:
511: if (isOcean && tabPane.getSelectedIndex() == tabIndex - 1)
512: {
513: g.setColor(oceanSelectedBorder);
514: }
515: g.drawLine(right - 6, 0, right, 6);
516:
517: g.drawLine(0, 0, right - 6, 0);
518:
519: if (isOcean && isSelected)
520: {
521: g.drawLine(right, 6, right, bottom);
522: if (tabIndex != firstIndex)
523: {
524: g.setColor(darkShadow);
525: g.drawLine(right, 0, right, 5);
526: }
527: }
528: else if (isOcean && tabPane.getSelectedIndex() == tabIndex - 1)
529: {
530: if (tabIndex != firstIndex)
531: {
532: g.setColor(oceanSelectedBorder);
533: g.drawLine(right, 0, right, 6);
534: }
535: g.setColor(darkShadow);
536: g.drawLine(right, 7, right, bottom);
537: }
538: else if (tabIndex != firstIndex)
539: {
540: g.drawLine(right, 0, right, bottom);
541: }
542: else
543: {
544: g.drawLine(right, 6, right, bottom);
545: }
546: g.translate(-x, -y);
547: }
548:
549:
563: protected void paintBottomTabBorder(int tabIndex, Graphics g, int x, int y,
564: int w, int h, int btm, int rght, boolean isSelected)
565: {
566: int bottom = h - 1;
567: int right = w - 1;
568:
569: int tabCount = tabPane.getTabCount();
570: int currentRun = getRunForTab(tabCount, tabIndex);
571:
572: if (shouldFillGap(currentRun, tabIndex, x, y))
573: {
574: g.translate(x, y);
575: g.setColor(getColorForGap(currentRun, x, y));
576: g.fillRect(1, bottom - 4, 3, 5);
577: g.fillRect(4, bottom - 1, 2, 2);
578: g.translate(-x, -y);
579: }
580:
581: g.translate(x, y);
582:
583:
584: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
585: Color oceanSelectedBorder =
586: UIManager.getColor("TabbedPane.borderHightlightColor");
587: if (isOcean && isSelected)
588: {
589: g.setColor(oceanSelectedBorder);
590: }
591: else
592: {
593: g.setColor(darkShadow);
594: }
595:
596: g.drawLine(1, bottom - 5, 6, bottom);
597:
598: g.drawLine(6, bottom, right, bottom);
599:
600: int lastIndex = lastTabInRun(tabCount, currentRun);
601: if (tabIndex == lastIndex)
602: {
603: g.drawLine(right, 0, right, bottom);
604: }
605:
606: if (isOcean && isSelected)
607: {
608: g.drawLine(0, 0, 0, bottom - 5);
609:
610:
611:
612: if (tabIndex != tabRuns[runCount-1])
613: {
614: g.setColor(darkShadow);
615: g.drawLine(0, bottom - 5, 0, bottom);
616: }
617: }
618: else
619: {
620: if (isOcean && tabIndex == tabPane.getSelectedIndex() + 1)
621: {
622: g.setColor(oceanSelectedBorder);
623: }
624: if (tabIndex != tabRuns[runCount - 1])
625: {
626: g.drawLine(0, 0, 0, bottom);
627: }
628: else
629: {
630: g.drawLine(0, 0, 0, bottom - 6);
631: }
632: }
633:
634:
635: g.setColor(isSelected ? selectHighlight : highlight);
636:
637: g.drawLine(1, bottom - 6, 6, bottom - 1);
638:
639: g.drawLine(1, 0, 1, bottom - 6);
640:
641: int firstIndex = tabRuns[currentRun];
642: if (tabIndex == firstIndex && tabIndex != tabRuns[runCount - 1])
643: {
644: if (tabPane.getSelectedIndex() == tabRuns[currentRun + 1])
645: {
646: g.setColor(selectHighlight);
647: }
648: else
649: {
650: g.setColor(highlight);
651: }
652: g.drawLine(1, bottom - 4, 1, bottom);
653: }
654:
655: g.translate(-x, -y);
656: }
657:
658:
671: protected void paintTabBackground(Graphics g, int tabPlacement,
672: int tabIndex, int x, int y, int w, int h, boolean isSelected)
673: {
674: if (isSelected)
675: g.setColor(selectColor);
676: else
677: g.setColor(getUnselectedBackground(tabIndex));
678:
679: switch (tabPlacement)
680: {
681: case LEFT:
682: g.fillRect(x + 5, y + 1, w - 5, h - 1);
683: g.fillRect(x + 2, y + 4, 3, h - 4);
684: break;
685: case BOTTOM:
686: g.fillRect(x + 2, y, w - 2, h - 3);
687: g.fillRect(x + 5, y + h - 4, w - 5, 3);
688: break;
689: case RIGHT:
690: g.fillRect(x, y + 1, w - 4, h - 1);
691: g.fillRect(x + w - 4, y + 5, 3, h - 5);
692: break;
693: case TOP:
694: default:
695: g.fillRect(x + 4, y + 2, w - 4, h - 2);
696: g.fillRect(x + 2, y + 5, 2, h - 5);
697: }
698: }
699:
700:
711: protected void paintFocusIndicator(Graphics g, int tabPlacement,
712: Rectangle[] rects, int tabIndex,
713: Rectangle iconRect, Rectangle textRect,
714: boolean isSelected)
715: {
716: if (tabPane.hasFocus() && isSelected)
717: {
718: Rectangle rect = rects[tabIndex];
719:
720: g.setColor(focus);
721: g.translate(rect.x, rect.y);
722:
723: switch (tabPlacement)
724: {
725: case LEFT:
726:
727: g.drawLine(7, 2, rect.width-2, 2);
728:
729:
730: g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3);
731:
732:
733: g.drawLine(rect.width-2, rect.height-2, 3, rect.height-2);
734:
735:
736: g.drawLine(2, rect.height-3, 2, 7);
737:
738:
739: g.drawLine(2, 6, 6, 2);
740: break;
741: case RIGHT:
742:
743: g.drawLine(1, 2, rect.width-8, 2);
744:
745:
746: g.drawLine(rect.width-7, 2, rect.width-3, 6);
747:
748:
749: g.drawLine(rect.width-3, 7, rect.width-3, rect.height-3);
750:
751:
752: g.drawLine(rect.width-3, rect.height-2, 2, rect.height-2);
753:
754:
755: g.drawLine(1, rect.height-2, 1, 2);
756: break;
757: case BOTTOM:
758:
759: g.drawLine(2, 1, rect.width-2, 1);
760:
761:
762: g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3);
763:
764:
765: g.drawLine(7, rect.height-3, rect.width-2, rect.height-3);
766:
767:
768: g.drawLine(6, rect.height-3, 2, rect.height-7);
769:
770:
771: g.drawLine(2, rect.height-8, 2, 2);
772:
773: break;
774: case TOP:
775: default:
776:
777: g.drawLine(6, 2, rect.width-2, 2);
778:
779:
780: g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3);
781:
782:
783: g.drawLine(3, rect.height-3, rect.width-2, rect.height-3);
784:
785:
786: g.drawLine(2, rect.height-3, 2, 7);
787:
788:
789: g.drawLine(2, 6, 6, 2);
790:
791: }
792:
793: g.translate(-rect.x, -rect.y);
794: }
795: }
796:
797:
807: protected boolean shouldPadTabRun(int tabPlacement, int run)
808: {
809:
810:
811: return run < this.runCount - 1;
812: }
813:
814:
818: protected void installDefaults()
819: {
820: super.installDefaults();
821: selectColor = UIManager.getColor("TabbedPane.selected");
822: selectHighlight = UIManager.getColor("TabbedPane.selectHighlight");
823: tabAreaBackground = UIManager.getColor("TabbedPane.tabAreaBackground");
824: tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
825: minTabWidth = 0;
826: }
827:
828:
837: protected Color getColorForGap(int currentRun, int x, int y)
838: {
839: int index = tabForCoordinate(tabPane, x, y);
840: int selected = tabPane.getSelectedIndex();
841: if (selected == index)
842: return selectColor;
843: return tabAreaBackground;
844: }
845:
846:
856: protected boolean shouldFillGap(int currentRun, int tabIndex, int x, int y)
857: {
858:
859: return false;
860: }
861:
862:
865: protected void paintHighlightBelowTab()
866: {
867: int selected = tabPane.getSelectedIndex();
868: int tabPlacement = tabPane.getTabPlacement();
869: Rectangle bounds = getTabBounds(tabPane, selected);
870:
871: hg.setColor(selectColor);
872: int x = bounds.x;
873: int y = bounds.y;
874: int w = bounds.width;
875: int h = bounds.height;
876:
877: if (tabPlacement == TOP)
878: hg.fillRect(x, y + h - 2, w, 30);
879: else if (tabPlacement == LEFT)
880: hg.fillRect(x + w - 1, y, 20, h);
881: else if (tabPlacement == BOTTOM)
882: hg.fillRect(x, y - h + 2, w, 30);
883: else if (tabPlacement == RIGHT)
884: hg.fillRect(x - 18, y, 20, h);
885: else
886: throw new AssertionError("Unrecognised 'tabPlacement' argument.");
887: hg = null;
888: }
889:
890:
898: protected boolean shouldRotateTabRuns(int tabPlacement,
899: int selectedRun)
900: {
901:
902: return false;
903: }
904:
905: protected int calculateMaxTabHeight(int tabPlacement)
906: {
907:
908: return super.calculateMaxTabHeight(tabPlacement);
909: }
910:
911:
921: protected int getTabRunOverlay(int tabPlacement)
922: {
923: int overlay = 0;
924: if (tabPlacement == LEFT || tabPlacement == RIGHT)
925: {
926: int maxHeight = calculateMaxTabHeight(tabPlacement);
927: overlay = maxTabHeight / 2;
928: }
929: return overlay;
930: }
931:
932:
943: protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
944: int selectedIndex, int x, int y,
945: int w, int h)
946: {
947: Color oceanSelectedBorder =
948: UIManager.getColor("TabbedPane.borderHightlightColor");
949: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
950: if (isOcean)
951: {
952: g.setColor(oceanSelectedBorder);
953: }
954: else
955: {
956: g.setColor(selectHighlight);
957: }
958:
959: Rectangle rect = selectedIndex < 0 ? null :
960: getTabBounds(selectedIndex, calcRect);
961:
962:
963:
964:
965: if (tabPlacement != TOP || selectedIndex < 0
966: || rect.y + rect.height + 1 < y || rect.x < x || rect.x > x + w)
967: {
968: g.drawLine(x, y, x + w - 2, y);
969: if (isOcean && tabPlacement == TOP)
970: {
971: g.setColor(MetalLookAndFeel.getWhite());
972: g.drawLine(x, y + 1, x + w - 2, y + 1);
973: }
974: }
975: else
976: {
977: boolean isLast = isLastTabInRun(selectedIndex);
978: if (isLast)
979: {
980: g.drawLine(x, y, rect.x + 1, y);
981: }
982: else
983: {
984: g.drawLine(x, y, rect.x, y);
985: }
986:
987: int right = x + w - 1;
988: if (rect.x + rect.width < right - 1)
989: {
990: if (isLast)
991: {
992: g.drawLine(rect.x + rect.width - 1, y, right - 1, y);
993: }
994: else
995: {
996: g.drawLine(rect.x + rect.width, y, right - 1, y);
997: }
998: }
999: else
1000: {
1001: g.setColor(shadow);
1002: g.drawLine(x + w - 2, y, x + w - 2, y);
1003: }
1004:
1005:
1006: if (isOcean)
1007: {
1008: g.setColor(MetalLookAndFeel.getWhite());
1009: if (isLast)
1010: {
1011: g.drawLine(x, y + 1, rect.x + 1, y + 1);
1012: }
1013: else
1014: {
1015: g.drawLine(x, y + 1, rect.x, y + 1);
1016: }
1017:
1018: if (rect.x + rect.width < right - 1)
1019: {
1020: if (isLast)
1021: {
1022: g.drawLine(rect.x + rect.width - 1, y + 1, right - 1,
1023: y + 1);
1024: }
1025: else
1026: {
1027: g.drawLine(rect.x + rect.width, y + 1, right - 1, y + 1);
1028: }
1029: }
1030: else
1031: {
1032: g.setColor(shadow);
1033: g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1034: }
1035: }
1036: }
1037: }
1038:
1039:
1050: protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
1051: int selectedIndex, int x, int y,
1052: int w, int h)
1053: {
1054: g.setColor(darkShadow);
1055:
1056:
1057:
1058:
1059: Rectangle rect = selectedIndex < 0 ? null :
1060: getTabBounds(selectedIndex, calcRect);
1061: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
1062: Color oceanSelectedBorder =
1063: UIManager.getColor("TabbedPane.borderHightlightColor");
1064: if (tabPlacement != BOTTOM || selectedIndex < 0 || rect.y - 1 > h
1065: || rect.x < x || rect.x > x + w)
1066: {
1067: if (isOcean && tabPlacement == BOTTOM)
1068: {
1069: g.setColor(oceanSelectedBorder);
1070: }
1071: g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
1072: }
1073: else
1074: {
1075: boolean isLast = isLastTabInRun(selectedIndex);
1076: if (isOcean)
1077: {
1078: g.setColor(oceanSelectedBorder);
1079: }
1080:
1081: int bottom = y + h - 1;
1082: int right = x + w - 1;
1083: if (isLast)
1084: {
1085: g.drawLine(x, bottom, rect.x, bottom);
1086: }
1087: else
1088: {
1089: g.drawLine(x, bottom, rect.x - 1, bottom);
1090: }
1091:
1092: if (rect.x + rect.width < x + w - 2)
1093: {
1094: if (isLast)
1095: {
1096: g.drawLine(rect.x + rect.width - 1, bottom, right, bottom);
1097: }
1098: else
1099: {
1100: g.drawLine(rect.x + rect.width, bottom, right, bottom);
1101: }
1102: }
1103: }
1104: }
1105:
1106:
1117: protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
1118: int selectedIndex, int x, int y,
1119: int w, int h)
1120: {
1121: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
1122: Color oceanSelectedBorder =
1123: UIManager.getColor("TabbedPane.borderHightlightColor");
1124: Rectangle rect = selectedIndex < 0 ? null :
1125: getTabBounds(selectedIndex, calcRect);
1126:
1127: if (isOcean)
1128: {
1129: g.setColor(oceanSelectedBorder);
1130: }
1131: else
1132: {
1133: g.setColor(selectHighlight);
1134: }
1135:
1136:
1137:
1138:
1139: if (tabPlacement != LEFT || selectedIndex < 0
1140: || rect.x + rect.width + 1 < x || rect.y < y || rect.y > y + h)
1141: {
1142: g.drawLine(x, y + 1, x, y + h - 2);
1143: if (isOcean && tabPlacement == LEFT)
1144: {
1145: g.setColor(MetalLookAndFeel.getWhite());
1146: g.drawLine(x, y + 1, x, y + h - 2);
1147: }
1148: }
1149: else
1150: {
1151: g.drawLine(x, y, x, rect.y + 1);
1152: if (rect.y + rect.height < y + h - 2)
1153: {
1154: g.drawLine(x, rect.y + rect.height + 1, x, y + h + 2);
1155: }
1156: if (isOcean)
1157: {
1158: g.setColor(MetalLookAndFeel.getWhite());
1159: g.drawLine(x + 1, y + 1, x + 1, rect.y + 1);
1160: if (rect.y + rect.height < y + h - 2)
1161: {
1162: g.drawLine(x + 1, rect.y + rect.height + 1, x + 1, y + h + 2);
1163: }
1164: }
1165: }
1166:
1167: }
1168:
1169:
1180: protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
1181: int selectedIndex, int x, int y,
1182: int w, int h)
1183: {
1184: g.setColor(darkShadow);
1185: Rectangle rect = selectedIndex < 0 ? null :
1186: getTabBounds(selectedIndex, calcRect);
1187: boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
1188: Color oceanSelectedBorder =
1189: UIManager.getColor("TabbedPane.borderHightlightColor");
1190:
1191:
1192:
1193:
1194: if (tabPlacement != RIGHT || selectedIndex < 0 || rect.x - 1 > w
1195: || rect.y < y || rect.y > y + h)
1196: {
1197: if (isOcean && tabPlacement == RIGHT)
1198: {
1199: g.setColor(oceanSelectedBorder);
1200: }
1201: g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
1202: }
1203: else
1204: {
1205: if (isOcean)
1206: {
1207: g.setColor(oceanSelectedBorder);
1208: }
1209: g.drawLine(x + w - 1, y, x + w - 1, rect.y);
1210:
1211: if (rect.y + rect.height < y + h - 2)
1212: {
1213: g.drawLine(x + w - 1, rect.y + rect.height, x + w - 1, y + h - 2);
1214: }
1215: }
1216: }
1217:
1218:
1225: private boolean isLastTabInRun(int tabIndex)
1226: {
1227: int count = tabPane.getTabCount();
1228: int run = getRunForTab(count, tabIndex);
1229: int lastIndex = lastTabInRun(count, run);
1230: return tabIndex == lastIndex;
1231: }
1232:
1233:
1245: private Color getUnselectedBackground(int tabIndex)
1246: {
1247: Color bg = tabPane.getBackgroundAt(tabIndex);
1248: Color unselectedBackground =
1249: UIManager.getColor("TabbedPane.unselectedBackground");
1250: if (bg instanceof UIResource && unselectedBackground != null)
1251: bg = unselectedBackground;
1252: return bg;
1253: }
1254:
1255: protected int getTabLabelShiftX(int tabPlacement,
1256: int index,
1257: boolean isSelected)
1258: {
1259: return 0;
1260: }
1261:
1262: protected int getTabLabelShiftY(int tabPlacement,
1263: int index,
1264: boolean isSelected)
1265: {
1266: return 0;
1267: }
1268:
1269: }