⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metaltabbedpaneui.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            case RIGHT:                int totalTabWidth = calculateTabAreaWidth( tabPlacement, runCount, maxTabWidth );                g.fillRect( size.width - insets.right - totalTabWidth,                            insets.top, totalTabWidth,                             size.height - insets.top - insets.bottom );                break;            case TOP:            default:                g.fillRect( insets.left, insets.top,                             size.width - insets.right - insets.left,                             calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) );                paintHighlightBelowTab();            }        }        super.paint( g, c );    }    protected void paintHighlightBelowTab( ) {    }    protected void paintFocusIndicator(Graphics g, int tabPlacement,                                       Rectangle[] rects, int tabIndex,                                        Rectangle iconRect, Rectangle textRect,                                       boolean isSelected) {        if ( tabPane.hasFocus() && isSelected ) {            Rectangle tabRect = rects[tabIndex];	    boolean lastInRun = isLastInRun( tabIndex );            g.setColor( focus );            g.translate( tabRect.x, tabRect.y );            int right = tabRect.width - 1;            int bottom = tabRect.height - 1;	    boolean leftToRight = MetalUtils.isLeftToRight(tabPane);            switch ( tabPlacement ) {            case RIGHT:                g.drawLine( right - 6,2 , right - 2,6 );         // slant                g.drawLine( 1,2 , right - 6,2 );                 // top                g.drawLine( right - 2,6 , right - 2,bottom );    // right                g.drawLine( 1,2 , 1,bottom );                    // left                g.drawLine( 1,bottom , right - 2,bottom );       // bottom                break;            case BOTTOM:	        if ( leftToRight ) {		    g.drawLine( 2, bottom - 6, 6, bottom - 2 );   // slant		    g.drawLine( 6, bottom - 2,				right, bottom - 2 );              // bottom		    g.drawLine( 2, 0, 2, bottom - 6 );            // left		    g.drawLine( 2, 0, right, 0 );                 // top		    g.drawLine( right, 0, right, bottom - 2 );    // right		} else {		    g.drawLine( right - 2, bottom - 6,				right - 6, bottom - 2 );          // slant		    g.drawLine( right - 2, 0,				right - 2, bottom - 6 );          // right		    if ( lastInRun ) {			// last tab in run			g.drawLine( 2, bottom - 2,				    right - 6, bottom - 2 );      // bottom			g.drawLine( 2, 0, right - 2, 0 );         // top			g.drawLine( 2, 0, 2, bottom - 2 );        // left		    } else {			g.drawLine( 1, bottom - 2,				    right - 6, bottom - 2 );      // bottom			g.drawLine( 1, 0, right - 2, 0 );         // top			g.drawLine( 1, 0, 1, bottom - 2 );        // left		    }		}                break;            case LEFT:                g.drawLine( 2, 6, 6, 2 );                         // slant                g.drawLine( 2, 6, 2, bottom - 1);                 // left                g.drawLine( 6, 2, right, 2 );                     // top                g.drawLine( right, 2, right, bottom - 1 );        // right                g.drawLine( 2, bottom - 1,                             right, bottom - 1 );                  // bottom                break;            case TOP:             default:		    if ( leftToRight ) {		        g.drawLine( 2, 6, 6, 2 );                     // slant			g.drawLine( 2, 6, 2, bottom - 1);             // left			g.drawLine( 6, 2, right, 2 );                 // top			g.drawLine( right, 2, right, bottom - 1 );    // right			g.drawLine( 2, bottom - 1,				    right, bottom - 1 );              // bottom		    }		    else {		        g.drawLine( right - 2, 6, right - 6, 2 );     // slant			g.drawLine( right - 2, 6,				    right - 2, bottom - 1);           // right			if ( lastInRun ) {			    // last tab in run			    g.drawLine( right - 6, 2, 2, 2 );         // top			    g.drawLine( 2, 2, 2, bottom - 1 );        // left			    g.drawLine( right - 2, bottom - 1,					2, bottom - 1 );              // bottom			}			else {			    g.drawLine( right - 6, 2, 1, 2 );         // top			    g.drawLine( 1, 2, 1, bottom - 1 );        // left			    g.drawLine( right - 2, bottom - 1,					1, bottom - 1 );              // bottom			}		    }            }            g.translate( -tabRect.x, -tabRect.y );        }    }    protected void paintContentBorderTopEdge( Graphics g, int tabPlacement,                                              int selectedIndex,                                              int x, int y, int w, int h ) {    	boolean leftToRight = MetalUtils.isLeftToRight(tabPane);	int right = x + w - 1;        Rectangle selRect = selectedIndex < 0? null :	                       getTabBounds(selectedIndex, calcRect);        if (ocean) {            g.setColor(oceanSelectedBorderColor);        }        else {            g.setColor(selectHighlight);        }	// Draw unbroken line if tabs are not on TOP, OR	// selected tab is not in run adjacent to content, OR	// selected tab is not visible (SCROLL_TAB_LAYOUT)	//         if (tabPlacement != TOP || selectedIndex < 0 ||             (selRect.y + selRect.height + 1 < y) ||	    (selRect.x < x || selRect.x > x + w)) {            g.drawLine(x, y, x+w-2, y);            if (ocean && tabPlacement == TOP) {                g.setColor(MetalLookAndFeel.getWhite());                g.drawLine(x, y + 1, x+w-2, y + 1);            }        } else { 	    // Break line to show visual connection to selected tab	    boolean lastInRun = isLastInRun(selectedIndex);	    if ( leftToRight || lastInRun ) {	        g.drawLine(x, y, selRect.x + 1, y);	    } else {	        g.drawLine(x, y, selRect.x, y);	    }            if (selRect.x + selRect.width < right - 1) {	        if ( leftToRight && !lastInRun ) {		    g.drawLine(selRect.x + selRect.width, y, right - 1, y);		} else {		    g.drawLine(selRect.x + selRect.width - 1, y, right - 1, y);		}            } else {	        g.setColor(shadow);                 g.drawLine(x+w-2, y, x+w-2, y);            }            if (ocean) {                g.setColor(MetalLookAndFeel.getWhite());                if ( leftToRight || lastInRun ) {                    g.drawLine(x, y + 1, selRect.x + 1, y + 1);                } else {                    g.drawLine(x, y + 1, selRect.x, y + 1);                }                if (selRect.x + selRect.width < right - 1) {                    if ( leftToRight && !lastInRun ) {                        g.drawLine(selRect.x + selRect.width, y + 1,                                   right - 1, y + 1);                    } else {                        g.drawLine(selRect.x + selRect.width - 1, y + 1,                                   right - 1, y + 1);                    }                } else {                    g.setColor(shadow);                     g.drawLine(x+w-2, y + 1, x+w-2, y + 1);                }            }        }    }    protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,                                                int selectedIndex,                                                int x, int y, int w, int h) { 	boolean leftToRight = MetalUtils.isLeftToRight(tabPane);        int bottom = y + h - 1;	int right = x + w - 1;        Rectangle selRect = selectedIndex < 0? null :	                       getTabBounds(selectedIndex, calcRect);        g.setColor(darkShadow);	// Draw unbroken line if tabs are not on BOTTOM, OR	// selected tab is not in run adjacent to content, OR	// selected tab is not visible (SCROLL_TAB_LAYOUT)	//        if (tabPlacement != BOTTOM || selectedIndex < 0 ||             (selRect.y - 1 > h) ||	     (selRect.x < x || selRect.x > x + w)) {            if (ocean && tabPlacement == BOTTOM) {                g.setColor(oceanSelectedBorderColor);            }            g.drawLine(x, y+h-1, x+w-1, y+h-1);        } else {	    // Break line to show visual connection to selected tab	    boolean lastInRun = isLastInRun(selectedIndex);            if (ocean) {                g.setColor(oceanSelectedBorderColor);            }	    if ( leftToRight || lastInRun ) {	        g.drawLine(x, bottom, selRect.x, bottom);	    } else {	        g.drawLine(x, bottom, selRect.x - 1, bottom);	    }            if (selRect.x + selRect.width < x + w - 2) {	        if ( leftToRight && !lastInRun ) {		    g.drawLine(selRect.x + selRect.width, bottom,			                           right, bottom);		} else {		    g.drawLine(selRect.x + selRect.width - 1, bottom,			                               right, bottom);		}            }         }    }    protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,                                              int selectedIndex,                                              int x, int y, int w, int h) {         Rectangle selRect = selectedIndex < 0? null :	                       getTabBounds(selectedIndex, calcRect);        if (ocean) {            g.setColor(oceanSelectedBorderColor);        }        else {            g.setColor(selectHighlight);         }	// Draw unbroken line if tabs are not on LEFT, OR	// selected tab is not in run adjacent to content, OR	// selected tab is not visible (SCROLL_TAB_LAYOUT)	//        if (tabPlacement != LEFT || selectedIndex < 0 ||            (selRect.x + selRect.width + 1 < x) ||	    (selRect.y < y || selRect.y > y + h)) {            g.drawLine(x, y + 1, x, y+h-2);            if (ocean && tabPlacement == LEFT) {                g.setColor(MetalLookAndFeel.getWhite());                g.drawLine(x + 1, y, x + 1, y + h - 2);            }        } else {	    // Break line to show visual connection to selected tab            g.drawLine(x, y, x, selRect.y + 1);            if (selRect.y + selRect.height < y + h - 2) {	      g.drawLine(x, selRect.y + selRect.height + 1, 			 x, y+h+2);            }             if (ocean) {                g.setColor(MetalLookAndFeel.getWhite());                g.drawLine(x + 1, y + 1, x + 1, selRect.y + 1);                if (selRect.y + selRect.height < y + h - 2) {                    g.drawLine(x + 1, selRect.y + selRect.height + 1,                                x + 1, y+h+2);                }            }        }    }    protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,                                               int selectedIndex,                                               int x, int y, int w, int h) {        Rectangle selRect = selectedIndex < 0? null :	                       getTabBounds(selectedIndex, calcRect);        g.setColor(darkShadow);	// Draw unbroken line if tabs are not on RIGHT, OR	// selected tab is not in run adjacent to content, OR	// selected tab is not visible (SCROLL_TAB_LAYOUT)	//        if (tabPlacement != RIGHT || selectedIndex < 0 ||             (selRect.x - 1 > w) ||	     (selRect.y < y || selRect.y > y + h)) {            if (ocean && tabPlacement == RIGHT) {                g.setColor(oceanSelectedBorderColor);            }            g.drawLine(x+w-1, y, x+w-1, y+h-1);        } else {	    // Break line to show visual connection to selected tab            if (ocean) {                g.setColor(oceanSelectedBorderColor);            }            g.drawLine(x+w-1, y, x+w-1, selRect.y);            if (selRect.y + selRect.height < y + h - 2) {                g.drawLine(x+w-1, selRect.y + selRect.height,                            x+w-1, y+h-2);            }         }    }    protected int calculateMaxTabHeight( int tabPlacement ) {        FontMetrics metrics = getFontMetrics();        int height = metrics.getHeight();        boolean tallerIcons = false;        for ( int i = 0; i < tabPane.getTabCount(); ++i ) {            Icon icon = tabPane.getIconAt( i );            if ( icon != null ) {                if ( icon.getIconHeight() > height ) {                    tallerIcons = true;                    break;                }            }        }        return super.calculateMaxTabHeight( tabPlacement ) -                   (tallerIcons ? (tabInsets.top + tabInsets.bottom) : 0);    }    protected int getTabRunOverlay( int tabPlacement ) {        // Tab runs laid out vertically should overlap        // at least as much as the largest slant        if ( tabPlacement == LEFT || tabPlacement == RIGHT ) {            int maxTabHeight = calculateMaxTabHeight(tabPlacement);            return maxTabHeight / 2;        }        return 0;    }    // Don't rotate runs!    protected boolean shouldRotateTabRuns( int tabPlacement, int selectedRun ) {        return false;    }    // Don't pad last run    protected boolean shouldPadTabRun( int tabPlacement, int run ) {        return runCount > 1 && run < runCount - 1;    }    private boolean isLastInRun( int tabIndex ) {        int run = getRunForTab( tabPane.getTabCount(), tabIndex );	int lastIndex = lastTabInRun( tabPane.getTabCount(), run );	return tabIndex == lastIndex;    }    /**     * Returns the color to use for the specified tab.     */    private Color getUnselectedBackgroundAt(int index) {        Color color = tabPane.getBackgroundAt(index);        if (color instanceof UIResource) {            if (unselectedBackground != null) {                return unselectedBackground;            }        }        return color;    }    /**     * Returns the tab index of JTabbedPane the mouse is currently over     */    int getRolloverTabIndex() {    	return getRolloverTab();    }    /**     * This inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; inner class.     * Instantiate it only within subclasses of MetalTabbedPaneUI.     */      public class TabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout {	public TabbedPaneLayout() {	    MetalTabbedPaneUI.this.super();	}        protected void normalizeTabRuns( int tabPlacement, int tabCount,                                      int start, int max ) {            // Only normalize the runs for top & bottom;  normalizing            // doesn't look right for Metal's vertical tabs            // because the last run isn't padded and it looks odd to have            // fat tabs in the first vertical runs, but slimmer ones in the            // last (this effect isn't noticeable for horizontal tabs).            if ( tabPlacement == TOP || tabPlacement == BOTTOM ) {                super.normalizeTabRuns( tabPlacement, tabCount, start, max );            }        }        // Don't rotate runs!        protected void rotateTabRuns( int tabPlacement, int selectedRun ) {        }        // Don't pad selected tab        protected void padSelectedTab( int tabPlacement, int selectedIndex ) {        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -