protected void paintIndeterminate(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) { return; } Graphics2D g2D = (Graphics2D) g; Insets b = progressBar.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - (b.right + b.left); int barRectHeight = progressBar.getHeight() - (b.top + b.bottom); Color colors[]; if (progressBar.getForeground() instanceof UIResource) { if (!Utilities.isActive(c)) { colors = BaseLookAndFeel.getTheme().getInActiveColors(); } else if (c.isEnabled()) { colors = BaseLookAndFeel.getTheme().getProgressBarColors(); } else { colors = BaseLookAndFeel.getTheme().getDisabledColors(); } } else { Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40); Color loColor = ColorHelper.darker(progressBar.getForeground(), 20); colors = ColorHelper.createColorArr(hiColor, loColor, 20); } Color cHi = ColorHelper.darker(colors[colors.length - 1], 5); Color cLo = ColorHelper.darker(colors[colors.length - 1], 10); // Paint the bouncing box. Rectangle box = getBox(null); if (box != null) { g2D.setColor(progressBar.getForeground()); Utilities.draw3DBorder(g, cHi, cLo, box.x + 1, box.y + 1, box.width - 2, box.height - 2); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { Utilities.fillHorGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4); } else { Utilities.fillVerGradient(g, colors, box.x + 2, box.y + 2, box.width - 4, box.height - 4); } // Deal with possible text painting if (progressBar.isStringPainted()) { Object savedRenderingHint = null; if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) { savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); g2D.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, BaseLookAndFeel.getTheme().getTextAntiAliasingHint()); } if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.width, b); } else { paintString(g2D, b.left, b.top, barRectWidth, barRectHeight, box.height, b); } if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) { g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint); } } } }
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(); }
protected void paintDeterminate(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) { return; } Graphics2D g2D = (Graphics2D) g; Insets b = progressBar.getInsets(); // area for border int w = progressBar.getWidth() - (b.right + b.left); int h = progressBar.getHeight() - (b.top + b.bottom); // amount of progress to draw int amountFull = getAmountFull(b, w, h); Color colors[]; if (progressBar.getForeground() instanceof UIResource) { if (!Utilities.isActive(c)) { colors = BaseLookAndFeel.getTheme().getInActiveColors(); } else if (c.isEnabled()) { colors = BaseLookAndFeel.getTheme().getProgressBarColors(); } else { colors = BaseLookAndFeel.getTheme().getDisabledColors(); } } else { Color hiColor = ColorHelper.brighter(progressBar.getForeground(), 40); Color loColor = ColorHelper.darker(progressBar.getForeground(), 20); colors = ColorHelper.createColorArr(hiColor, loColor, 20); } Color cHi = ColorHelper.darker(colors[colors.length - 1], 5); Color cLo = ColorHelper.darker(colors[colors.length - 1], 10); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { if (Utilities.isLeftToRight(progressBar)) { Utilities.draw3DBorder(g, cHi, cLo, 1 + b.left, 2, amountFull - 2, h - 2); Utilities.fillHorGradient(g, colors, 2 + b.left, 3, amountFull - 4, h - 4); } else { Utilities.draw3DBorder( g, cHi, cLo, progressBar.getWidth() - amountFull - b.right + 2, 2, amountFull - 2, h - 2); Utilities.fillHorGradient( g, colors, progressBar.getWidth() - amountFull - b.right + 3, 3, amountFull - 4, h - 4); } } else { // VERTICAL Utilities.draw3DBorder(g, cHi, cLo, 2, h - amountFull + 2, w - 2, amountFull - 2); Utilities.fillVerGradient(g, colors, 3, h - amountFull + 3, w - 4, amountFull - 4); } // Deal with possible text painting if (progressBar.isStringPainted()) { Object savedRenderingHint = null; if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) { savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING); g2D.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, BaseLookAndFeel.getTheme().getTextAntiAliasingHint()); } paintString(g, b.left, b.top, w, h, amountFull, b); if (BaseLookAndFeel.getTheme().isTextAntiAliasingOn()) { g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint); } } }
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); }