protected Color[] getTabColors(int tabIndex, boolean isSelected) { if ((tabIndex >= 0) && (tabIndex < tabPane.getTabCount())) { boolean isEnabled = tabPane.isEnabledAt(tabIndex); Color backColor = tabPane.getBackgroundAt(tabIndex); Color colorArr[] = AbstractLookAndFeel.getTheme().getTabColors(); if ((backColor instanceof UIResource)) { if (isSelected) { colorArr = AbstractLookAndFeel.getTheme().getDefaultColors(); } else if (tabIndex == rolloverIndex && isEnabled) { colorArr = AbstractLookAndFeel.getTheme().getRolloverColors(); } else { colorArr = AbstractLookAndFeel.getTheme().getTabColors(); } } else { if (isSelected) { if (tabPane.getTabPlacement() == BOTTOM) { colorArr = ColorHelper.createColorArr(backColor, ColorHelper.brighter(backColor, 50), 20); } else { colorArr = ColorHelper.createColorArr(ColorHelper.brighter(backColor, 50), backColor, 20); } } else { if (tabIndex == rolloverIndex && isEnabled) { colorArr = ColorHelper.createColorArr( ColorHelper.brighter(backColor, 80), ColorHelper.brighter(backColor, 20), 20); } else { colorArr = ColorHelper.createColorArr( ColorHelper.brighter(backColor, 40), ColorHelper.darker(backColor, 10), 20); } } } return colorArr; } return AbstractLookAndFeel.getTheme().getTabColors(); }
public void setUpColorArrs() { super.setUpColorArrs(); Color topHi = white; Color topLo = buttonColorLight; Color bottomHi = ColorHelper.brighter(buttonColorDark, 40); Color bottomLo = buttonColorDark; Color topColors[] = ColorHelper.createColorArr(topHi, topLo, 11); Color bottomColors[] = ColorHelper.createColorArr(bottomHi, bottomLo, 13); BUTTON_COLORS = new Color[24]; System.arraycopy(topColors, 0, BUTTON_COLORS, 0, 11); System.arraycopy(bottomColors, 0, BUTTON_COLORS, 11, 13); CHECKBOX_COLORS = BUTTON_COLORS; DEFAULT_COLORS = ColorHelper.createColorArr(controlColorLight, controlColorDark, 24); HIDEFAULT_COLORS = new Color[20]; for (int i = 0; i < 20; i++) { HIDEFAULT_COLORS[i] = ColorHelper.brighter(DEFAULT_COLORS[i], 40); } SELECTED_COLORS = ColorHelper.createColorArr(selectionBackgroundColorLight, selectionBackgroundColorDark, 20); SELECTION_COLORS = SELECTED_COLORS; // ColorHelper.createColorArr(selectionBackgroundColorLight, // selectionBackgroundColorDark, 20); MENU_SELECTION_COLORS = ColorHelper.createColorArr( menuSelectionBackgroundColorLight, menuSelectionBackgroundColorDark, 20); topHi = rolloverColorLight; topLo = rolloverColorDark; bottomHi = ColorHelper.darker(rolloverColorDark, 6); bottomLo = ColorHelper.darker(rolloverColorDark, 10); topColors = ColorHelper.createColorArr(topHi, topLo, 11); bottomColors = ColorHelper.createColorArr(bottomHi, bottomLo, 13); ROLLOVER_COLORS = new Color[24]; System.arraycopy(topColors, 0, ROLLOVER_COLORS, 0, 11); System.arraycopy(bottomColors, 0, ROLLOVER_COLORS, 11, 13); PRESSED_COLORS = ColorHelper.createColorArr(buttonColorDark, buttonColorLight, 24); DISABLED_COLORS = ColorHelper.createColorArr(superLightGray, extraLightGray, 24); ACTIVE_COLORS = DEFAULT_COLORS; INACTIVE_COLORS = BUTTON_COLORS; WINDOW_TITLE_COLORS = ColorHelper.createColorArr(windowTitleColorLight, windowTitleColorDark, 24); WINDOW_INACTIVE_TITLE_COLORS = ColorHelper.createColorArr(windowInactiveTitleColorLight, windowInactiveTitleColorDark, 24); TOOLBAR_COLORS = ColorHelper.createColorArr(toolbarColorLight, toolbarColorDark, 24); MENUBAR_COLORS = ColorHelper.createColorArr(menuColorLight, menuColorDark, 24); TAB_COLORS = BUTTON_COLORS; // ColorHelper.createColorArr(controlColorLight, controlColorDark, 24); COL_HEADER_COLORS = BUTTON_COLORS; THUMB_COLORS = ColorHelper.createColorArr(backgroundColorLight, backgroundColorDark, 24); Color hiColor = ColorHelper.brighter(backgroundColor, 30); Color loColor = ColorHelper.brighter(backgroundColor, 10); TRACK_COLORS = ColorHelper.createColorArr(loColor, hiColor, 24); SLIDER_COLORS = THUMB_COLORS; PROGRESSBAR_COLORS = SLIDER_COLORS; }
public void setUpColorArrs() { super.setUpColorArrs(); // Generate the color arrays DEFAULT_COLORS = ColorHelper.createColorArr(controlColorLight, controlColorDark, 20); HIDEFAULT_COLORS = ColorHelper.createColorArr( ColorHelper.brighter(controlColorLight, 90), ColorHelper.brighter(controlColorDark, 30), 20); ACTIVE_COLORS = DEFAULT_COLORS; INACTIVE_COLORS = ColorHelper.createColorArr(Color.white, backgroundColor, 20); ROLLOVER_COLORS = ColorHelper.createColorArr(rolloverColorLight, rolloverColorDark, 20); SELECTED_COLORS = DEFAULT_COLORS; PRESSED_COLORS = ColorHelper.createColorArr(controlColorDark, controlColorLight, 20); DISABLED_COLORS = ColorHelper.createColorArr(Color.white, new Color(230, 230, 230), 20); WINDOW_TITLE_COLORS = ColorHelper.createColorArr(windowTitleColorLight, windowTitleColorDark, 20); WINDOW_INACTIVE_TITLE_COLORS = ColorHelper.createColorArr(windowInactiveTitleColorLight, windowInactiveTitleColorDark, 20); MENUBAR_COLORS = ColorHelper.createColorArr(menuColorLight, menuColorDark, 20); TOOLBAR_COLORS = ColorHelper.createColorArr(toolbarColorLight, toolbarColorDark, 20); BUTTON_COLORS = ColorHelper.createColorArr(buttonColorLight, buttonColorDark, 20); TAB_COLORS = ColorHelper.createColorArr(Color.white, backgroundColor, 20); CHECKBOX_COLORS = TAB_COLORS; COL_HEADER_COLORS = MENUBAR_COLORS; TRACK_COLORS = ColorHelper.createColorArr(backgroundColor, Color.white, 16); THUMB_COLORS = DEFAULT_COLORS; SLIDER_COLORS = DEFAULT_COLORS; PROGRESSBAR_COLORS = DEFAULT_COLORS; }
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); }