@Override protected void paintContentBorderTopEdge( Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { if (tabPane.getTabCount() < 1) return; g.setColor(shadow); g.drawLine(x, y, x + w - 2, y); }
@Override protected void paintTabBackground( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { g = g.create(); try { internalPaintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected); } finally { g.dispose(); } }
@Override protected void paintContentBorderBottomEdge( Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { if (tabPane.getTabCount() < 1) return; g.setColor(shadow); g.drawLine(x + 1, y + h - 3, x + w - 2, y + h - 3); g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); g.setColor(shadow.brighter()); g.drawLine(x + 2, y + h - 1, x + w - 1, y + h - 1); }
/** @{inheritDoc} */ @Override public void paintComponent(Graphics g) { super.paintComponent(g); g = g.create(); try { AntialiasingManager.activateAntialiasing(g); g.setColor(Color.DARK_GRAY); g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 10, 10); } finally { g.dispose(); } }
/** * Paints a customized background. * * @param g the <tt>Graphics</tt> object through which we paint */ @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g = g.create(); if (!(treeNode instanceof GroupNode) && !isSelected) return; AntialiasingManager.activateAntialiasing(g); Graphics2D g2 = (Graphics2D) g; try { internalPaintComponent(g2); } finally { g.dispose(); } }
/** * Draw the icon at the specified location. Paints this component as an icon. * * @param c the component which can be used as observer * @param g the <tt>Graphics</tt> object used for painting * @param x the position on the X coordinate * @param y the position on the Y coordinate */ public void paintIcon(Component c, Graphics g, int x, int y) { g = g.create(); try { Graphics2D g2 = (Graphics2D) g; AntialiasingManager.activateAntialiasing(g2); g2.setColor(Color.WHITE); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f)); g2.fillRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10); g2.setColor(Color.DARK_GRAY); g2.drawRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10); // Indent component content from the border. g2.translate(x + 5, y + 5); super.paint(g2); g2.translate(x, y); } finally { g.dispose(); } }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); g = g.create(); try { AntialiasingManager.activateAntialiasing(g); Graphics2D g2 = (Graphics2D) g; if (bgImage != null) g2.drawImage(bgImage.getImage(), 30, 30, null); g2.drawImage( ImageLoader.getImage(ImageLoader.AUTH_WINDOW_BACKGROUND), 0, 0, this.getWidth(), this.getHeight(), null); } finally { g.dispose(); } }
@Override public void paint(Graphics g) { Color origColor; boolean isPressed, isRollOver, isEnabled; int w, h, size; w = getWidth(); h = getHeight(); origColor = g.getColor(); isPressed = getModel().isPressed(); isRollOver = getModel().isRollover(); isEnabled = isEnabled(); g.setColor(getBackground()); g.fillRect(0, 0, w, h); g.setColor(shadow); // Using the background color set above if (direction == WEST) { g.drawLine(0, 0, 0, h - 1); // left g.drawLine(w - 1, 0, w - 1, 0); // right } else g.drawLine(w - 2, h - 1, w - 2, 0); // right g.drawLine(0, 0, w - 2, 0); // top if (isRollOver) { // do highlights or shadows Color color1; Color color2; if (isPressed) { color2 = Color.WHITE; color1 = shadow; } else { color1 = Color.WHITE; color2 = shadow; } g.setColor(color1); if (direction == WEST) { g.drawLine(1, 1, 1, h - 1); // left g.drawLine(1, 1, w - 2, 1); // top g.setColor(color2); g.drawLine(w - 1, h - 1, w - 1, 1); // right } else { g.drawLine(0, 1, 0, h - 1); g.drawLine(0, 1, w - 3, 1); // top g.setColor(color2); g.drawLine(w - 3, h - 1, w - 3, 1); // right } } // g.drawLine(0, h - 1, w - 1, h - 1); //bottom // If there's no room to draw arrow, bail if (h < 5 || w < 5) { g.setColor(origColor); return; } if (isPressed) { g.translate(1, 1); } // Draw the arrow size = Math.min((h - 4) / 3, (w - 4) / 3); size = Math.max(size, 2); boolean highlight = false; if (!highlightedTabs.isEmpty() && ((direction == WEST && tabScroller.scrollBackwardButton.isEnabled()) || (direction == EAST && tabScroller.scrollForwardButton.isEnabled()))) { Rectangle viewRect = tabScroller.viewport.getViewRect(); if (direction == WEST) { int leadingTabIndex = getClosestTab(viewRect.x, viewRect.y); for (int i = 0; i < leadingTabIndex; i++) { if (highlightedTabs.contains(i) && !isScrollTabVisible(i)) { highlight = true; break; } } } else { int leadingTabIndex = getClosestTab(viewRect.x + viewRect.y, viewRect.y); for (int i = leadingTabIndex; i < tabPane.getTabCount(); i++) { if (highlightedTabs.contains(i) && !isScrollTabVisible(i)) { highlight = true; break; } } } if (highlight) { Image img = DesktopUtilActivator.getImage( direction == WEST ? "service.gui.icons.TAB_UNREAD_BACKWARD_ICON" : "service.gui.icons.TAB_UNREAD_FORWARD_ICON"); int wi = img.getWidth(null); g.drawImage(img, (w - wi) / 2, (h - size) / 2 - 2 /* 2 borders 1px width*/, null); } } if (!highlight) paintTriangle(g, (w - size) / 2, (h - size) / 2, size, direction, isEnabled); // Reset the Graphics back to it's original settings if (isPressed) { g.translate(-1, -1); } g.setColor(origColor); }
@Override protected void paintText( Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) { g.setFont(font); int titleWidth = SwingUtilities.computeStringWidth(metrics, title); int preferredWidth = 0; if (isOneActionButtonEnabled()) { preferredWidth = calculateTabWidth(tabPlacement, tabIndex, metrics) - WIDTHDELTA - 15; if (isCloseEnabled()) preferredWidth -= BUTTONSIZE; if (isMaxEnabled()) preferredWidth -= BUTTONSIZE; } else { preferredWidth = titleWidth; } while (titleWidth > preferredWidth) { if (title.endsWith("...")) title = title.substring(0, title.indexOf("...") - 1).concat("..."); else title = title.substring(0, title.length() - 4).concat("..."); titleWidth = SwingUtilities.computeStringWidth(metrics, title); } textRect.width = titleWidth; View v = getTextViewForTab(tabIndex); if (v != null) { // html v.paint(g, textRect); } else { // plain text int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex); if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) { if (isSelected) g.setColor(TAB_SELECTED_FOREGROUND_COLOR); else { if (this.isTabHighlighted(tabIndex)) { g.setColor(TAB_HIGHLIGHT_FOREGROUND_COLOR); } else g.setColor(tabPane.getForegroundAt(tabIndex)); } BasicGraphicsUtils.drawString( g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); } else { // tab disabled g.setColor(tabPane.getBackgroundAt(tabIndex).brighter()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); g.setColor(tabPane.getBackgroundAt(tabIndex).darker()); BasicGraphicsUtils.drawStringUnderlineCharAt( g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1); } } }