/** * All purpose paint method that should do the right thing for all linear bouncing-box progress * bars. Override this if you are making another kind of progress bar. * * @see #paintDeterminate * @since 1.4 */ protected void paintIndeterminate(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) { return; } Insets b = progressBar.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); if (barRectWidth <= 0 || barRectHeight <= 0) { return; } Graphics2D g2 = (Graphics2D) g; // Paint the bouncing box. boxRect = getBox(boxRect); if (boxRect != null) { g2.setColor(progressBar.getForeground()); g2.fillRect(boxRect.x, boxRect.y, boxRect.width, boxRect.height); } // Deal with possible text painting if (progressBar.isStringPainted()) { if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { paintString(g2, b.left, b.top, barRectWidth, barRectHeight, boxRect.x, boxRect.width, b); } else { paintString(g2, b.left, b.top, barRectWidth, barRectHeight, boxRect.y, boxRect.height, b); } } }
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); if (c.getParent() instanceof JMenuBar) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor()); g.fillRect(x, y, w, h); } } else { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor()); g.fillRect(x, y, w, h); } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) { Graphics2D g2D = (Graphics2D) g; Composite composite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha()); g2D.setComposite(alpha); g.setColor(AbstractLookAndFeel.getMenuBackgroundColor()); g.fillRect(x, y, w, h); g2D.setComposite(composite); } else { g.setColor(AbstractLookAndFeel.getMenuBackgroundColor()); g.fillRect(x, y, w, h); } } if (menuItem.isSelected() && menuItem.isArmed()) { g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor()); } else { g.setColor(AbstractLookAndFeel.getMenuForegroundColor()); } }
/* * (non-Javadoc) * * @seeorg.jvnet.flamingo.common.ui.BasicCommandButtonUI# * paintButtonVerticalSeparator(java.awt.Graphics, int) */ @Override protected void paintButtonVerticalSeparator(Graphics graphics, Rectangle separatorArea) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(separatorArea.x, 0); SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities.getColorScheme( this.commandButton, ColorSchemeAssociationKind.SEPARATOR, ComponentState.getState(this.commandButton.getActionModel(), this.commandButton)); float fadeAlpha = this.getSeparatorAlpha(); g2d.setComposite(AlphaComposite.SrcOver.derive(fadeAlpha)); SeparatorPainterUtils.paintSeparator( this.commandButton, g2d, colorScheme, 1, this.commandButton.getHeight(), JSlider.VERTICAL, true, 4, 4, true); g2d.dispose(); }
/* * (non-Javadoc) * * @see * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#paintButtonBackground * (java.awt.Graphics, java.awt.Rectangle) */ @Override protected void paintButtonBackground(Graphics graphics, Rectangle toFill) { if (SubstanceCoreUtilities.isButtonNeverPainted(this.commandButton)) return; ButtonModel actionModel = this.commandButton.getActionModel(); PopupButtonModel popupModel = ((JCommandButton) this.commandButton).getPopupModel(); Rectangle actionArea = this.getLayoutInfo().actionClickArea; Rectangle popupArea = this.getLayoutInfo().popupClickArea; BufferedImage fullAlphaBackground = CommandButtonBackgroundDelegate.getCombinedCommandButtonBackground( this.commandButton, actionModel, actionArea, popupModel, popupArea); // Two special cases here: // 1. Button has flat appearance and doesn't show the popup // 2. Button is disabled. // For both cases, we need to set custom translucency. boolean isFlat = this.commandButton.isFlat() && !((JCommandButton) this.commandButton).getPopupModel().isPopupShowing(); boolean isSpecial = isFlat || !this.commandButton.isEnabled(); float extraAlpha = 1.0f; if (isSpecial) { if (isFlat) { float extraActionAlpha = 0.0f; for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : getActionTransitionTracker().getModelStateInfo().getStateContributionMap().entrySet()) { ComponentState activeState = activeEntry.getKey(); if (activeState.isDisabled()) continue; if (activeState == ComponentState.ENABLED) continue; extraActionAlpha += activeEntry.getValue().getContribution(); } float extraPopupAlpha = 0.0f; for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : getPopupTransitionTracker().getModelStateInfo().getStateContributionMap().entrySet()) { ComponentState activeState = activeEntry.getKey(); if (activeState.isDisabled()) continue; if (activeState == ComponentState.ENABLED) continue; extraPopupAlpha += activeEntry.getValue().getContribution(); } extraAlpha = Math.max(extraActionAlpha, extraPopupAlpha); } else { ComponentState actionAreaState = ComponentState.getState(actionModel, this.commandButton); if (actionAreaState.isDisabled()) { extraAlpha = SubstanceColorSchemeUtilities.getAlpha(this.commandButton, actionAreaState); } } } // System.out.println(extraAlpha); extraAlpha = Math.min(1.0f, extraAlpha); if (extraAlpha > 0.0f) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setComposite( LafWidgetUtilities.getAlphaComposite(this.commandButton, extraAlpha, graphics)); g2d.drawImage(fullAlphaBackground, 0, 0, null); g2d.dispose(); } }
private void internalPaintTabBackground( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { BufferedImage leftImg = null; BufferedImage middleImg = null; BufferedImage rightImg = null; Graphics2D g2 = (Graphics2D) g; AntialiasingManager.activateAntialiasing(g2); int tabOverlap = 0; if (isSelected) { if (tabPane.isEnabledAt(tabIndex)) { leftImg = DesktopUtilActivator.getImage(SELECTED_TAB_LEFT_BG); middleImg = DesktopUtilActivator.getImage(SELECTED_TAB_MIDDLE_BG); rightImg = DesktopUtilActivator.getImage(SELECTED_TAB_RIGHT_BG); tabOverlap = TAB_OVERLAP; } else { leftImg = DesktopUtilActivator.getImage(TAB_LEFT_BG); middleImg = DesktopUtilActivator.getImage(TAB_MIDDLE_BG); rightImg = DesktopUtilActivator.getImage(TAB_RIGHT_BG); } } else { leftImg = DesktopUtilActivator.getImage(TAB_LEFT_BG); middleImg = DesktopUtilActivator.getImage(TAB_MIDDLE_BG); rightImg = DesktopUtilActivator.getImage(TAB_RIGHT_BG); } // Remove the existing gap between the tabs and the panel, which is due // to the removal of the tabbed pane border. y++; // If the current tab is not the selected tab we paint it 2 more pixels // to the bottom in order to create the disabled look. if (!isSelected) y += 2; g2.drawImage(leftImg, x, y, null); g2.drawImage( middleImg, x + leftImg.getWidth(), y, w - leftImg.getWidth() - rightImg.getWidth() + tabOverlap, leftImg.getHeight(), null); g2.drawImage(rightImg, x + w - rightImg.getWidth() + tabOverlap, y, null); }
protected void paintRoundedBottomTabBorder( int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected) { Graphics2D g2D = (Graphics2D) g; Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int d = 2 * GAP; if (isSelected) { g.setColor(AbstractLookAndFeel.getTheme().getFrameColor()); } else { g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFrameColor(), 40)); } g.drawLine(x1 + GAP, y2, x2 - GAP, y2); g.drawArc(x1, y2 - d, d, d, 180, 90); g.drawArc(x2 - d, y2 - d, d, d, -90, 90); g.drawLine(x1, y1, x1, y2 - GAP - 1); g.drawLine(x2, y1, x2, y2 - GAP - 1); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint); }
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Graphics2D g2D = (Graphics2D) g; Object savedRenderingHint = null; if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) { savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); g2D.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint()); } if (menuItem.isSelected() && menuItem.isArmed()) { g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor()); } else { g.setColor(AbstractLookAndFeel.getMenuForegroundColor()); } super.paintText(g, menuItem, textRect, text); if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) { g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint); } }
/* * (non-Javadoc) * * @see * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#paintButtonIcon(java * .awt.Graphics, java.awt.Rectangle) */ @Override protected void paintButtonIcon(Graphics g, Rectangle iconRect) { JCommandButton jcb = (JCommandButton) this.commandButton; Icon regular = jcb.getIcon(); if (toUseDisabledIcon() && (jcb.getDisabledIcon() != null) && ((regular != null) && !regular.getClass().isAnnotationPresent(TransitionAware.class))) regular = jcb.getDisabledIcon(); if ((iconRect == null) || (regular == null) || (iconRect.width == 0) || (iconRect.height == 0)) { return; } boolean useThemed = SubstanceCoreUtilities.useThemedDefaultIcon(this.commandButton); if (regular != null) { Graphics2D g2d = (Graphics2D) g.create(); GhostPaintingUtils.paintGhostIcon(g2d, jcb, regular, iconRect); g2d.setComposite(LafWidgetUtilities.getAlphaComposite(jcb, g)); if (!useThemed) { regular.paintIcon(jcb, g2d, iconRect.x, iconRect.y); } else { StateTransitionTracker tracker = this.substanceVisualStateTracker.getActionStateTransitionTracker(); ButtonModel model = commandButton.getActionModel(); if (jcb.getCommandButtonKind() == CommandButtonKind.POPUP_ONLY) { tracker = this.substanceVisualStateTracker.getPopupStateTransitionTracker(); model = jcb.getPopupModel(); } CommandButtonBackgroundDelegate.paintThemedCommandButtonIcon( g2d, iconRect, jcb, regular, model, tracker); } g2d.dispose(); } }
private void drawHorizontalGradient( Graphics2D g, float ratio1, float ratio2, Color c1, Color c2, Color c3, int w, int h) { int mid = (int) (ratio1 * w); int mid2 = (int) (ratio2 * w); if (mid > 0) { g.setPaint(getGradient((float) 0, (float) 0, c1, (float) mid, (float) 0, c2)); g.fillRect(0, 0, mid, h); } if (mid2 > 0) { g.setColor(c2); g.fillRect(mid, 0, mid2, h); } if (mid > 0) { g.setPaint( getGradient((float) mid + mid2, (float) 0, c2, (float) mid * 2 + mid2, (float) 0, c1)); g.fillRect(mid + mid2, 0, mid, h); } if (w - mid * 2 - mid2 > 0) { g.setPaint(getGradient((float) mid * 2 + mid2, (float) 0, c1, w, (float) 0, c3)); g.fillRect(mid * 2 + mid2, 0, w - mid * 2 - mid2, h); } }
private void drawVerticalGradient( Graphics2D g, float ratio1, float ratio2, Color c1, Color c2, Color c3, int w, int h) { int mid = (int) (ratio1 * h); int mid2 = (int) (ratio2 * h); if (mid > 0) { g.setPaint(getGradient((float) 0, (float) 0, c1, (float) 0, (float) mid, c2)); g.fillRect(0, 0, w, mid); } if (mid2 > 0) { g.setColor(c2); g.fillRect(0, mid, w, mid2); } if (mid > 0) { g.setPaint( getGradient((float) 0, (float) mid + mid2, c2, (float) 0, (float) mid * 2 + mid2, c1)); g.fillRect(0, mid + mid2, w, mid); } if (h - mid * 2 - mid2 > 0) { g.setPaint(getGradient((float) 0, (float) mid * 2 + mid2, c1, (float) 0, (float) h, c3)); g.fillRect(0, mid * 2 + mid2, w, h - mid * 2 - mid2); } }
protected void paintFocus( Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { Graphics2D g2D = (Graphics2D) g; int width = b.getWidth(); int height = b.getHeight(); if (((width < 64) || (height < 16)) && ((b.getText() == null) || b.getText().length() == 0)) { g.setColor(AbstractLookAndFeel.getFocusColor()); BasicGraphicsUtils.drawDashedRect(g, 4, 3, width - 8, height - 6); } else { Object savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2D.setColor(AbstractLookAndFeel.getFocusColor()); int d = b.getHeight() - 4; g2D.drawRoundRect(2, 2, b.getWidth() - 5, b.getHeight() - 5, d, d); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRenderingHint); } }
/* * (non-Javadoc) * * @see * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#paint(java.awt.Graphics * , javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setFont( FlamingoUtilities.getFont(this.commandButton, "Ribbon.font", "Button.font", "Panel.font")); this.layoutInfo = this.layoutManager.getLayoutInfo(this.commandButton, g); commandButton.putClientProperty("icon.bounds", layoutInfo.iconRect); commandButton.putClientProperty("icon", commandButton.getIcon()); if (this.isPaintingBackground()) { this.paintButtonBackground(g2d, new Rectangle(0, 0, c.getWidth(), c.getHeight())); } // decide which command button model should be used to // compute the foreground color of the command button's text boolean useActionAreaForFg = layoutInfo.isTextInActionArea; StateTransitionTracker transitionTrackerForFg = useActionAreaForFg ? this.getActionTransitionTracker() : this.getPopupTransitionTracker(); ModelStateInfo modelStateInfoForFg = transitionTrackerForFg.getModelStateInfo(); ComponentState currStateForFg = modelStateInfoForFg.getCurrModelState(); Color fgColor = this.commandButton.getForeground(); if (fgColor instanceof UIResource) { float buttonAlpha = SubstanceColorSchemeUtilities.getAlpha(this.commandButton, currStateForFg); fgColor = SubstanceTextUtilities.getForegroundColor( this.commandButton, this.commandButton.getText(), modelStateInfoForFg, buttonAlpha); } if (layoutInfo.textLayoutInfoList != null) { for (CommandButtonLayoutManager.TextLayoutInfo mainTextLayoutInfo : layoutInfo.textLayoutInfoList) { if (mainTextLayoutInfo.text != null) { SubstanceTextUtilities.paintText( g2d, c, mainTextLayoutInfo.textRect, mainTextLayoutInfo.text, -1, g2d.getFont(), fgColor, g2d.getClipBounds()); } } } if (layoutInfo.extraTextLayoutInfoList != null) { Color disabledFgColor = SubstanceColorSchemeUtilities.getColorScheme( this.commandButton, ComponentState.DISABLED_UNSELECTED) .getForegroundColor(); float buttonAlpha = SubstanceColorSchemeUtilities.getAlpha( this.commandButton, ComponentState.DISABLED_UNSELECTED); if (buttonAlpha < 1.0f) { Color bgFillColor = SubstanceColorUtilities.getBackgroundFillColor(this.commandButton); disabledFgColor = SubstanceColorUtilities.getInterpolatedColor(disabledFgColor, bgFillColor, buttonAlpha); } if (currStateForFg.isDisabled()) { disabledFgColor = SubstanceColorUtilities.getInterpolatedColor( disabledFgColor, SubstanceColorUtilities.getBackgroundFillColor(c), 0.5); } for (CommandButtonLayoutManager.TextLayoutInfo extraTextLayoutInfo : layoutInfo.extraTextLayoutInfoList) { if (extraTextLayoutInfo.text != null) { SubstanceTextUtilities.paintText( g2d, c, extraTextLayoutInfo.textRect, extraTextLayoutInfo.text, -1, g2d.getFont(), disabledFgColor, g2d.getClipBounds()); } } } if (layoutInfo.iconRect != null) { this.paintButtonIcon(g2d, layoutInfo.iconRect); } if (layoutInfo.popupActionRect.getWidth() > 0) { paintPopupActionIcon(g2d, layoutInfo.popupActionRect); } if (this.isPaintingSeparators() && (layoutInfo.separatorArea != null)) { if (layoutInfo.separatorOrientation == CommandButtonSeparatorOrientation.HORIZONTAL) { this.paintButtonHorizontalSeparator(g2d, layoutInfo.separatorArea); } else { this.paintButtonVerticalSeparator(g2d, layoutInfo.separatorArea); } } // g2d.setColor(Color.red); // g2d.draw(layoutInfo.iconRect); // g2d.setColor(Color.blue); // if (layoutInfo.textLayoutInfoList != null) { // for (CommandButtonLayoutManager.TextLayoutInfo mainTextLayoutInfo : // layoutInfo.textLayoutInfoList) { // if (mainTextLayoutInfo.text != null) { // g2d.draw(mainTextLayoutInfo.textRect); // } // } // } // g2d.setColor(Color.magenta); // if (layoutInfo.extraTextLayoutInfoList != null) { // for (CommandButtonLayoutManager.TextLayoutInfo extraTextLayoutInfo : // layoutInfo.extraTextLayoutInfoList) { // if (extraTextLayoutInfo.text != null) { // g2d.draw(extraTextLayoutInfo.textRect); // } // } // } // g2d.setColor(Color.green); // g2d.draw(layoutInfo.popupActionRect); g2d.dispose(); }
/** * Paints the progress string. * * @param g Graphics used for drawing. * @param x x location of bounding box * @param y y location of bounding box * @param width width of bounding box * @param height height of bounding box * @param fillStart start location, in x or y depending on orientation, of the filled portion of * the progress bar. * @param amountFull size of the fill region, either width or height depending upon orientation. * @param b Insets of the progress bar. */ private void paintString( Graphics g, int x, int y, int width, int height, int fillStart, int amountFull, Insets b) { if (!(g instanceof Graphics2D)) { return; } Graphics2D g2 = (Graphics2D) g; String progressString = progressBar.getString(); g2.setFont(progressBar.getFont()); Point renderLocation = getStringPlacement(g2, progressString, x, y, width, height); Rectangle oldClip = g2.getClipBounds(); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { g2.setColor(getSelectionBackground()); SwingUtilities2.drawString( progressBar, g2, progressString, renderLocation.x, renderLocation.y); g2.setColor(getSelectionForeground()); g2.clipRect(fillStart, y, amountFull, height); SwingUtilities2.drawString( progressBar, g2, progressString, renderLocation.x, renderLocation.y); } else { // VERTICAL g2.setColor(getSelectionBackground()); AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2); g2.setFont(progressBar.getFont().deriveFont(rotate)); renderLocation = getStringPlacement(g2, progressString, x, y, width, height); SwingUtilities2.drawString( progressBar, g2, progressString, renderLocation.x, renderLocation.y); g2.setColor(getSelectionForeground()); g2.clipRect(x, fillStart, width, amountFull); SwingUtilities2.drawString( progressBar, g2, progressString, renderLocation.x, renderLocation.y); } g2.setClip(oldClip); }
/** * All purpose paint method that should do the right thing for almost all linear, determinate * progress bars. By setting a few values in the defaults table, things should work just fine to * paint your progress bar. Naturally, override this if you are making a circular or semi-circular * progress bar. * * @see #paintIndeterminate * @since 1.4 */ protected void paintDeterminate(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) { return; } Insets b = progressBar.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); if (barRectWidth <= 0 || barRectHeight <= 0) { return; } int cellLength = getCellLength(); int cellSpacing = getCellSpacing(); // amount of progress to draw int amountFull = getAmountFull(b, barRectWidth, barRectHeight); Graphics2D g2 = (Graphics2D) g; g2.setColor(progressBar.getForeground()); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { // draw the cells if (cellSpacing == 0 && amountFull > 0) { // draw one big Rect because there is no space between cells g2.setStroke( new BasicStroke((float) barRectHeight, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); } else { // draw each individual cell g2.setStroke( new BasicStroke( (float) barRectHeight, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.f, new float[] {cellLength, cellSpacing}, 0.f)); } if (BasicGraphicsUtils.isLeftToRight(c)) { g2.drawLine( b.left, (barRectHeight / 2) + b.top, amountFull + b.left, (barRectHeight / 2) + b.top); } else { g2.drawLine( (barRectWidth + b.left), (barRectHeight / 2) + b.top, barRectWidth + b.left - amountFull, (barRectHeight / 2) + b.top); } } else { // VERTICAL // draw the cells if (cellSpacing == 0 && amountFull > 0) { // draw one big Rect because there is no space between cells g2.setStroke( new BasicStroke((float) barRectWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); } else { // draw each individual cell g2.setStroke( new BasicStroke( (float) barRectWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0f, new float[] {cellLength, cellSpacing}, 0f)); } g2.drawLine( barRectWidth / 2 + b.left, b.top + barRectHeight, barRectWidth / 2 + b.left, b.top + barRectHeight - amountFull); } // Deal with possible text painting if (progressBar.isStringPainted()) { paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b); } }
protected void paintBackground(Graphics g, AbstractButton b) { if (!b.isContentAreaFilled() || (b.getParent() instanceof JMenuBar)) { return; } if (!(b.isBorderPainted() && (b.getBorder() instanceof UIResource))) { super.paintBackground(g, b); return; } int width = b.getWidth(); int height = b.getHeight(); ButtonModel model = b.getModel(); Graphics2D g2D = (Graphics2D) g; Composite composite = g2D.getComposite(); Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (((width < 64) || (height < 16)) && ((b.getText() == null) || b.getText().length() == 0)) { if (model.isSelected()) { Color color = ColorHelper.darker(b.getBackground(), 20); g2D.setColor(color); g2D.fillRect(0, 0, width - 1, height - 1); if (model.isEnabled()) { g2D.setColor(AbstractLookAndFeel.getFrameColor()); } else { g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20)); } g2D.drawRect(0, 0, width - 1, height - 1); } else { Color[] colors = null; if (b.getBackground() instanceof ColorUIResource) { if (!model.isEnabled()) { colors = AbstractLookAndFeel.getTheme().getDisabledColors(); } else if (b.isRolloverEnabled() && model.isRollover()) { colors = AbstractLookAndFeel.getTheme().getRolloverColors(); } else { colors = AbstractLookAndFeel.getTheme().getButtonColors(); } } else { colors = ColorHelper.createColorArr( ColorHelper.brighter(b.getBackground(), 20), ColorHelper.darker(b.getBackground(), 20), 20); } JTattooUtilities.fillHorGradient(g, colors, 0, 0, width - 1, height - 1); if (model.isEnabled()) { g2D.setColor(AbstractLookAndFeel.getFrameColor()); } else { g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20)); } g2D.drawRect(0, 0, width - 1, height - 1); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); g2D.setComposite(alpha); g2D.setColor(Color.white); g2D.drawRect(1, 1, width - 3, height - 3); } } else if (model.isPressed() && model.isArmed()) { int d = height - 2; Color color = AbstractLookAndFeel.getTheme().getSelectionBackgroundColor(); g2D.setColor(color); g2D.fillRoundRect(0, 0, width - 1, height - 1, d, d); g2D.setColor(ColorHelper.darker(color, 40)); g2D.drawRoundRect(0, 0, width - 1, height - 1, d, d); } else if (model.isSelected()) { int d = height - 2; Color color = ColorHelper.darker(b.getBackground(), 20); g2D.setColor(color); g2D.fillRoundRect(0, 0, width - 1, height - 1, d, d); if (model.isEnabled()) { g2D.setColor(AbstractLookAndFeel.getFrameColor()); } else { g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20)); } g2D.drawRoundRect(0, 0, width - 1, height - 1, d, d); } else { int d = height - 2; Color[] colors = null; if (b.getBackground() instanceof ColorUIResource) { if (!model.isEnabled()) { colors = AbstractLookAndFeel.getTheme().getDisabledColors(); } else if (b.isRolloverEnabled() && model.isRollover()) { colors = AbstractLookAndFeel.getTheme().getRolloverColors(); } else { colors = AbstractLookAndFeel.getTheme().getButtonColors(); } } else { colors = ColorHelper.createColorArr( ColorHelper.brighter(b.getBackground(), 20), ColorHelper.darker(b.getBackground(), 20), 20); } Shape savedClip = g.getClip(); Area clipArea = new Area(new RoundRectangle2D.Double(0, 0, width - 1, height - 1, d, d)); clipArea.intersect(new Area(savedClip)); g2D.setClip(clipArea); JTattooUtilities.fillHorGradient(g, colors, 0, 0, width, height); g2D.setClip(savedClip); if (model.isEnabled()) { g2D.setColor(AbstractLookAndFeel.getFrameColor()); } else { g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getFrameColor(), 20)); } g2D.drawRoundRect(0, 0, width - 1, height - 1, d, d); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); g2D.setComposite(alpha); g2D.setColor(Color.white); g2D.drawRoundRect(1, 1, width - 3, height - 3, d - 2, d - 2); } g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint); g2D.setComposite(composite); }
protected void paintText( Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) { g.setFont(font); View v = getTextViewForTab(tabIndex); if (v != null) { // html Graphics2D g2D = (Graphics2D) g; Object savedRenderingHint = null; if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) { savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); g2D.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint()); } v.paint(g, textRect); if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) { g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint); } } else { // plain text int mnemIndex = -1; if (JTattooUtilities.getJavaVersion() >= 1.4) { mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex); } if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) { if (isSelected && (tabPane.getBackgroundAt(tabIndex) instanceof UIResource)) { Color shadowColor = ColorHelper.darker(AcrylLookAndFeel.getWindowTitleColorDark(), 30); g.setColor(shadowColor); JTattooUtilities.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex, textRect.x - 1, textRect.y - 1 + metrics.getAscent()); JTattooUtilities.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex, textRect.x - 1, textRect.y + 1 + metrics.getAscent()); JTattooUtilities.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex, textRect.x + 1, textRect.y - 1 + metrics.getAscent()); JTattooUtilities.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex, textRect.x + 1, textRect.y + 1 + metrics.getAscent()); g.setColor(AbstractLookAndFeel.getTheme().getWindowTitleForegroundColor()); } else { g.setColor(tabPane.getForegroundAt(tabIndex)); } JTattooUtilities.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); } else { // tab disabled g.setColor(tabPane.getBackgroundAt(tabIndex).brighter()); JTattooUtilities.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); g.setColor(tabPane.getBackgroundAt(tabIndex).darker()); JTattooUtilities.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1); } } }