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

📄 compieretabbedpaneui.java

📁 Java写的ERP系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
				break;
			case BOTTOM:
				h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
				break;
			case TOP:
			default:
				y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
				h -= (y - insets.top);
		}

		//  Fill region behind content area - basically a border
		Component comp = null;
		if (selectedIndex != -1)
			comp = tabPane.getComponentAt(selectedIndex);
		if (comp != null && comp instanceof JComponent)
		{
			JComponent jc = (JComponent)comp;
			CompiereColor bg = null;
			try
			{
				bg = (CompiereColor)jc.getClientProperty(CompierePLAF.BACKGROUND);
			}
			catch (Exception e)
			{
				System.err.println("CompiereTabbedPaneUI - ClientProperty: " + e.getMessage());
			}
			if (bg == null)
			{
				bg = new CompiereColor(jc.getBackground());
				jc.putClientProperty(CompierePLAF.BACKGROUND, bg);
			}
			bg.paintRect(g, jc, x,y, w,h);
		}
		//  Not a JComponent - paint flat
		else if (comp != null)
		{
			g.setColor(comp.getBackground());
			g.fillRect(x,y, w,h);
		}

		paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h);
		paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h);
		paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h);
		paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h);
	}   //  paintContentBorder

	/**
	 *  Paint left content border edge
	 *  @param g graphics
	 *  @param tabPlacement tab placement
	 *  @param selectedIndex index
	 *  @param x x
	 *  @param y y
	 *  @param w width
	 *  @param h height
	 */
	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);
		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, x, 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);    //  bug
		}
	}

	/**
	 *  Paint bottom content area edge
	 *  @param g graphics
	 *  @param tabPlacement tab placement
	 *  @param selectedIndex index
	 *  @param x x
	 *  @param y y
	 *  @param w width
	 *  @param h height
	 */
	protected void paintContentBorderBottomEdge (Graphics g, int tabPlacement,
		int selectedIndex, int x, int y, int w, int h)
	{
		boolean leftToRight = CompiereUtils.isLeftToRight(tabPane);
		int bottom = y + h - 1;
		int right = x + w - 1;
		Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect);
		g.setColor(shadow);

		// 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)      //  bug!!
				|| (selRect.x < x || selRect.x > x + w))
		{
			g.setColor(darkShadow);
			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);
			g.setColor(darkShadow);
			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);
			}
		}
	}   //  paintContentBorderBottomEdge

	/**
	 *  Paint right Contenr border edge
	 *  @param g graphics
	 *  @param tabPlacement tab placement
	 *  @param selectedIndex index
	 *  @param x x
	 *  @param y y
	 *  @param w width
	 *  @param h height
	 */
	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(shadow);

		// 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)      //  bug !!
				|| (selRect.y < y || selRect.y > y + h)
				)
		{
			g.setColor(darkShadow);
			g.drawLine(x+w-1, y, x+w-1, y+h-1);
		}
		else
		{
			// Break line to show visual connection to selected tab
			g.setColor(darkShadow);
			g.drawLine(x+w-1, y, x+w-1, selRect.y);
			if (selRect.y + selRect.height < y + h - 2)
			{
				g.setColor(darkShadow);
				g.drawLine(x+w-1, selRect.y + selRect.height, x+w-1, y+h-2);
			}
		}
	}   //  paintContentBorderRightEdge

	/**
	 *  Is Last Run
	 *  @param tabIndex index
	 *  @return true if last tab run
	 */
	private boolean isLastInRun (int tabIndex)
	{
		int run = getRunForTab( tabPane.getTabCount(), tabIndex );
		int lastIndex = lastTabInRun( tabPane.getTabCount(), run );
		return tabIndex == lastIndex;
	}   //  isLastRun

	/*************************************************************************/

	/**
	 *  Fill Tab gap triangle (no)
	 *  @param currentRun current run
	 *  @param tabIndex tab index
	 *  @param x x
	 *  @param y y
	 *  @return false
	 */
	protected boolean shouldFillGap (int currentRun, int tabIndex, int x, int y)
	{
		return false;
	}   //  shouldFillGap

	/**
	 *  Paint Top Tab Border
	 *  @param tabIndex index
	 *  @param g graphics
	 *  @param x x
	 *  @param y y
	 *  @param w width
	 *  @param h height
	 *  @param btm bottom
	 *  @param rght right
	 *  @param isSelected selected
	 */
	protected void paintTopTabBorder ( int tabIndex, Graphics g,
		int x, int y, int w, int h, int btm, int rght, boolean isSelected )
	{
		int currentRun = getRunForTab( tabPane.getTabCount(), tabIndex );
		int lastIndex = lastTabInRun( tabPane.getTabCount(), currentRun );
		int firstIndex = tabRuns[ currentRun ];
		boolean leftToRight = CompiereUtils.isLeftToRight(tabPane);
		int bottom = h - 1;
		int right = w - 1;

		// **   Paint Gap **
		if ( shouldFillGap( currentRun, tabIndex, x, y ) )
		{
			g.translate( x, y );
			if ( leftToRight )
			{
				g.setColor( getColorForGap( currentRun, x, y + 1 ) );
				g.fillRect( 1, 0, 5, 3 );
				g.fillRect( 1, 3, 2, 2 );
			}
			else
			{
				g.setColor( getColorForGap( currentRun, x + w - 1, y + 1 ) );
				g.fillRect( right - 5, 0, 5, 3 );
				g.fillRect( right - 2, 3, 2, 2 );
			}
			g.translate( -x, -y );
		}

		g.translate( x, y );
		//  ** Paint Border **
		g.setColor( darkShadow );
		if (leftToRight)
		{
			// Paint slant
			g.drawLine( 1, 5, 6, 0 );
			// Paint top
			g.drawLine( 6, 0, right, 0 );
			// Paint right
			if ( tabIndex==lastIndex )  // last tab in run
				g.drawLine( right, 1, right, bottom );
			// Paint left
			if ( tabIndex != tabRuns[ runCount - 1 ] )  // not the first tab in the last run
				g.drawLine( 0, 0, 0, bottom );
			else                                        // the first tab in the last run
				g.drawLine( 0, 6, 0, bottom );
		}
		else
		{
			// Paint slant
			g.drawLine( right - 1, 5, right - 6, 0 );
			// Paint top
			g.drawLine( right - 6, 0, 0, 0 );
			// Paint right
			if ( tabIndex != tabRuns[ runCount - 1 ] )  // not the first tab in the last run
				g.drawLine( right, 0, right, bottom );
			else                                        // the first tab in the last run
				g.drawLine( right, 6, right, bottom );
			// Paint left
			if ( tabIndex==lastIndex )                  // last tab in run
				g.drawLine( 0, 1, 0, bottom );
		}

		//  Paint button
		if (!isSelected)
			g.drawLine(0, bottom, right, bottom);       //  added

		// ** Paint Highlight **
		g.setColor( isSelected ? selectHighlight : highlight );
		if ( leftToRight )
		{
			// Paint slant
			g.drawLine( 1, 6, 6, 1 );
			// Paint top
			if (tabIndex == lastIndex)
				g.drawLine( 6, 1, right-1, 1 );
			else
				g.drawLine( 6, 1, right, 1 );       //  bug !!
			// Paint left
			g.drawLine( 1, 6, 1, bottom );

			// paint highlight in the gap on tab behind this one
			// on the left end (where they all line up)
			if ( tabIndex==firstIndex && tabIndex!=tabRuns[runCount - 1] )
			{
				//  first tab in run but not first tab in last run
				if (tabPane.getSelectedIndex()==tabRuns[currentRun+1])
				{
					// tab in front of selected tab
					g.setColor( selectHighlight );
				}
				else
				{
					// tab in front of normal tab
					g.setColor( highlight );
				}
				g.drawLine( 1, 0, 1, 4 );
			}
		}
		else
		{
			// Paint slant
			g.drawLine( right - 1, 6, right - 6, 1 );
			// Paint top
			g.drawLine( right - 6, 1, 1, 1 );

			// Paint left
			if ( tabIndex==lastIndex )      // last tab in run
				g.drawLine( 1, 1, 1, bottom );
			else
				g.drawLine( 0, 1, 0, bottom );
		}
		g.translate( -x, -y );
	}   //  paintTopTabBorder

	/**
	 *  Paint Border of Left Tab.
	 *  Does not fill triangle
	 *
	 *  @param tabIndex index
	 *  @param g graphics
	 *  @param x x
	 *  @param y y
	 *  @param w width
	 *  @param h height
	 *  @param btm bottom
	 *  @param rght right
	 *  @param isSelected selected
	 */
	protected void paintLeftTabBorder (int tabIndex, Graphics g,
		int x, int y, int w, int h, int btm, int rght, boolean isSelected)
	{
		int tabCount = tabPane.getTabCount();
		int currentRun = getRunForTab( tabCount, tabIndex );
		int lastIndex = lastTabInRun( tabCount, currentRun );
		int firstIndex = tabRuns[ currentRun ];

		g.translate( x, y );

		int bottom = h - 1;

⌨️ 快捷键说明

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