Search in sources :

Example 81 with Composite

use of java.awt.Composite in project LoboEvolution by LoboEvolution.

the class BaseSliderUI method paintThumb.

/**
 * {@inheritDoc}
 */
@Override
public void paintThumb(Graphics g) {
    Icon icon;
    if (slider.getOrientation() == SwingConstants.HORIZONTAL) {
        if ((isRollover || isDragging()) && slider.isEnabled()) {
            icon = getThumbHorIconRollover();
        } else {
            icon = getThumbHorIcon();
        }
    } else {
        if ((isRollover || isDragging()) && slider.isEnabled()) {
            icon = getThumbVerIconRollover();
        } else {
            icon = getThumbVerIcon();
        }
    }
    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposite = g2D.getComposite();
    if (!slider.isEnabled()) {
        g.setColor(AbstractLookAndFeel.getBackgroundColor());
        g.fillRect(thumbRect.x + 1, thumbRect.y + 1, thumbRect.width - 2, thumbRect.height - 2);
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
        g2D.setComposite(alpha);
    }
    icon.paintIcon(null, g, thumbRect.x, thumbRect.y);
    g2D.setComposite(savedComposite);
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Icon(javax.swing.Icon) Graphics2D(java.awt.Graphics2D)

Example 82 with Composite

use of java.awt.Composite in project LoboEvolution by LoboEvolution.

the class BaseSplitPaneDivider method paint.

/**
 * {@inheritDoc}
 */
@Override
public void paint(final Graphics g) {
    if (!isFlatMode()) {
        Graphics2D g2D = (Graphics2D) g;
        Composite savedComposite = g2D.getComposite();
        int width = getSize().width;
        int height = getSize().height;
        int dx = 0;
        int dy = 0;
        if (width % 2 == 1) {
            dx = 1;
        }
        if (height % 2 == 1) {
            dy = 1;
        }
        Color color = AbstractLookAndFeel.getBackgroundColor();
        Color cHi = ColorHelper.brighter(color, 25);
        Color cLo = ColorHelper.darker(color, 5);
        Color[] colors = ColorHelper.createColorArr(cHi, cLo, 10);
        if (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel) {
            AbstractLookAndFeel laf = (AbstractLookAndFeel) UIManager.getLookAndFeel();
            if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
                JTattooUtilities.fillVerGradient(g, colors, 0, 0, width, height);
                Icon horBumps = laf.getIconFactory().getSplitterHorBumpIcon();
                if (horBumps != null && width > horBumps.getIconWidth()) {
                    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
                    g2D.setComposite(alpha);
                    if (splitPane.isOneTouchExpandable() && centerOneTouchButtons) {
                        int centerY = height / 2;
                        int x = (width - horBumps.getIconWidth()) / 2 + dx;
                        int y = centerY - horBumps.getIconHeight() - 40;
                        horBumps.paintIcon(this, g, x, y);
                        y = centerY + 40;
                        horBumps.paintIcon(this, g, x, y);
                    } else {
                        int x = (width - horBumps.getIconWidth()) / 2 + dx;
                        int y = (height - horBumps.getIconHeight()) / 2;
                        horBumps.paintIcon(this, g, x, y);
                    }
                }
            } else {
                JTattooUtilities.fillHorGradient(g, colors, 0, 0, width, height);
                Icon verBumps = laf.getIconFactory().getSplitterVerBumpIcon();
                if (verBumps != null && height > verBumps.getIconHeight()) {
                    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
                    g2D.setComposite(alpha);
                    if (splitPane.isOneTouchExpandable() && centerOneTouchButtons) {
                        int centerX = width / 2;
                        int x = centerX - verBumps.getIconWidth() - 40;
                        int y = (height - verBumps.getIconHeight()) / 2 + dy;
                        verBumps.paintIcon(this, g, x, y);
                        x = centerX + 40;
                        verBumps.paintIcon(this, g, x, y);
                    } else {
                        int x = (width - verBumps.getIconWidth()) / 2;
                        int y = (height - verBumps.getIconHeight()) / 2 + dy;
                        verBumps.paintIcon(this, g, x, y);
                    }
                }
            }
        }
        g2D.setComposite(savedComposite);
    }
    paintComponents(g);
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Icon(javax.swing.Icon) Graphics2D(java.awt.Graphics2D)

Example 83 with Composite

use of java.awt.Composite in project LoboEvolution by LoboEvolution.

the class BaseTabbedPaneUI method paintRightTabBorder.

/**
 * <p>paintRightTabBorder.</p>
 *
 * @param tabIndex a int.
 * @param g a {@link java.awt.Graphics} object.
 * @param x1 a int.
 * @param y1 a int.
 * @param x2 a int.
 * @param y2 a int.
 * @param isSelected a boolean.
 */
protected void paintRightTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected) {
    Graphics2D g2D = (Graphics2D) g;
    int tc = tabPane.getTabCount();
    int currentRun = getRunForTab(tc, tabIndex);
    int lastIndex = lastTabInRun(tc, currentRun);
    int firstIndex = tabRuns[currentRun];
    Color loColor = getLoBorderColor(tabIndex);
    Color hiColor = getHiBorderColor(tabIndex);
    Composite savedComposite = g2D.getComposite();
    AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
    g2D.setComposite(alpha);
    g.setColor(hiColor);
    g.drawLine(x1, y1 + 1, x2 - GAP - 1, y1 + 1);
    g.drawLine(x2 - GAP, y1 + 1, x2 - 1, y1 + GAP);
    g2D.setComposite(savedComposite);
    g.setColor(loColor);
    g.drawLine(x1, y1, x2 - GAP, y1);
    g.drawLine(x2 - GAP, y1, x2, y1 + GAP);
    g.drawLine(x2, y1 + GAP, x2, y2);
    if (tabIndex == lastIndex) {
        g.drawLine(x2, y2, x1, y2);
    }
    // paint gap
    int gapTabIndex = getTabAtLocation(x1 + 2, y1 - 2);
    Color gapColor = getGapColor(gapTabIndex);
    g.setColor(gapColor);
    for (int i = 0; i < GAP; i++) {
        g.drawLine(x2 - GAP + i + 1, y1 + i, x2, y1 + i);
    }
    if (tabIndex != firstIndex || currentRun != runCount - 1) {
        loColor = getLoBorderColor(gapTabIndex);
        g.setColor(loColor);
        g.drawLine(x2, y1, x2, y1 + GAP - 1);
    }
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Point(java.awt.Point) Graphics2D(java.awt.Graphics2D)

Example 84 with Composite

use of java.awt.Composite in project LoboEvolution by LoboEvolution.

the class BaseToolTipUI method paint.

/**
 * {@inheritDoc}
 */
@Override
public void paint(final Graphics g, final JComponent c) {
    Graphics2D g2D = (Graphics2D) g;
    Composite savedComposit = g2D.getComposite();
    Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int borderSize = AbstractLookAndFeel.getTheme().getTooltipBorderSize();
    int shadowSize = AbstractLookAndFeel.getTheme().getTooltipShadowSize();
    int w = c.getWidth();
    int h = c.getHeight();
    Color backColor = AbstractLookAndFeel.getTheme().getTooltipBackgroundColor();
    // We can't draw the fancyLayout if popup is medium weight
    boolean mediumWeight = false;
    Container parent = c.getParent();
    while (parent != null) {
        if (parent.getClass().getName().indexOf("MediumWeight") > 0) {
            mediumWeight = true;
            break;
        }
        parent = parent.getParent();
    }
    // Paint the tooltip with a shadow border
    if (!mediumWeight && fancyLayout && shadowSize > 0) {
        parent = c.getParent();
        while (parent != null) {
            if (parent.getClass().getName().indexOf("HeavyWeightWindow") > 0 && parent instanceof Window) {
                // Make the popup transparent
                Window window = (Window) parent;
                // Add a component listener to revert this operation if popup is closed
                window.addComponentListener(popupWindowListener);
                DecorationHelper.setTranslucentWindow(window, true);
                break;
            }
            parent = parent.getParent();
        }
        // draw the shadow
        g2D.setColor(AbstractLookAndFeel.getTheme().getShadowColor());
        float[] composites = { 0.01f, 0.02f, 0.04f, 0.06f, 0.08f, 0.12f };
        int shadowOffset = AbstractLookAndFeel.getTheme().isTooltipCastShadow() ? shadowSize : 0;
        for (int i = 0; i < shadowSize; i++) {
            g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, composites[i >= composites.length ? composites.length - 1 : i]));
            g2D.fillRoundRect(i + shadowOffset, borderSize + i, w - 2 * i - shadowOffset, h - borderSize - 2 * i, 12 - i, 12 - i);
        }
        g2D.setComposite(savedComposit);
        // Draw background with borders
        if (ColorHelper.getGrayValue(backColor) < 128) {
            g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getTheme().getBackgroundColor(), 20));
        } else {
            g2D.setColor(Color.white);
        }
        // g2D.fillRoundRect(shadowSize, 0, w - (2 * shadowSize) - 1, h - shadowSize -
        // 1, 6, 6);
        g2D.fillRoundRect(shadowSize, 0, w - 2 * shadowSize - 1, h - shadowSize - 1, shadowSize, shadowSize);
        g2D.setColor(ColorHelper.darker(backColor, 40));
        // g2D.drawRoundRect(shadowSize, 0, w - (2 * shadowSize) - 1, h - shadowSize -
        // 1, 6, 6);
        g2D.drawRoundRect(shadowSize, 0, w - 2 * shadowSize - 1, h - shadowSize - 1, shadowSize, shadowSize);
        g2D.setColor(ColorHelper.darker(backColor, 10));
        g2D.drawRect(borderSize + shadowSize - 1, borderSize - 1, w - 2 * borderSize - 2 * shadowSize + 1, h - 2 * borderSize - shadowSize + 1);
        g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
        // Draw the text. This must be done within an offscreen image because of a bug
        // in the jdk, wich causes ugly antialiased font rendering when background is
        // transparent and popup is heavy weight.
        BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics2D big = bi.createGraphics();
        big.setClip(0, 0, w, h);
        Paint savedPaint = big.getPaint();
        Color cHi;
        Color cLo;
        if (ColorHelper.getGrayValue(backColor) < 128) {
            cHi = ColorHelper.brighter(backColor, 10);
            cLo = ColorHelper.darker(backColor, 20);
        } else {
            cHi = ColorHelper.brighter(backColor, 40);
            cLo = ColorHelper.darker(backColor, 5);
        }
        big.setPaint(new GradientPaint(0, borderSize, cHi, 0, h - 2 * borderSize - shadowSize, cLo));
        big.fillRect(borderSize + shadowSize, borderSize, w - 2 * borderSize - 2 * shadowSize, h - 2 * borderSize - shadowSize);
        big.setPaint(savedPaint);
        if (c instanceof JToolTip) {
            JToolTip tip = (JToolTip) c;
            if (tip.getComponent() != null && tip.getComponent().isEnabled()) {
                c.setForeground(AbstractLookAndFeel.getTheme().getTooltipForegroundColor());
            } else {
                c.setForeground(AbstractLookAndFeel.getTheme().getDisabledForegroundColor());
            }
        }
        super.paint(big, c);
        g2D.setClip(borderSize + shadowSize, borderSize, w - 2 * borderSize - 2 * shadowSize, h - 2 * borderSize - shadowSize);
        g2D.drawImage(bi, 0, 0, null);
    } else {
        // Draw background with borders
        if (ColorHelper.getGrayValue(backColor) < 128) {
            g2D.setColor(ColorHelper.brighter(AbstractLookAndFeel.getTheme().getBackgroundColor(), 20));
        } else {
            g2D.setColor(Color.white);
        }
        g2D.fillRect(0, 0, w, h);
        g2D.setColor(ColorHelper.darker(backColor, 40));
        g2D.drawRect(0, 0, w - 1, h - 1);
        g2D.setColor(ColorHelper.darker(backColor, 10));
        g2D.drawRect(borderSize - 1, borderSize - 1, w - (2 * borderSize - 1), h - (2 * borderSize - 1));
        g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint);
        Paint savedPaint = g2D.getPaint();
        Color cHi;
        Color cLo;
        if (ColorHelper.getGrayValue(backColor) < 128) {
            cHi = ColorHelper.brighter(backColor, 10);
            cLo = ColorHelper.darker(backColor, 20);
        } else {
            cHi = ColorHelper.brighter(backColor, 40);
            cLo = ColorHelper.darker(backColor, 5);
        }
        g2D.setPaint(new GradientPaint(0, borderSize, cHi, 0, h - 2 * borderSize, cLo));
        g2D.fillRect(borderSize, borderSize, w - 2 * borderSize, h - 2 * borderSize);
        g2D.setPaint(savedPaint);
        super.paint(g, c);
    }
}
Also used : Window(java.awt.Window) JToolTip(javax.swing.JToolTip) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) Container(java.awt.Container)

Example 85 with Composite

use of java.awt.Composite in project LoboEvolution by LoboEvolution.

the class AcrylScrollBarUI method paintThumb.

/**
 * {@inheritDoc}
 */
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
    if (!c.isEnabled()) {
        return;
    }
    g.translate(thumbBounds.x, thumbBounds.y);
    Color[] colors = getThumbColors();
    Color frameColor = AbstractLookAndFeel.getFrameColor();
    if (!JTattooUtilities.isActive(scrollbar)) {
        frameColor = ColorHelper.brighter(frameColor, 80);
    }
    if (isRollover || isDragging) {
        frameColor = AbstractLookAndFeel.getTheme().getRolloverColorDark();
    }
    if (scrollbar.getOrientation() == Adjustable.VERTICAL) {
        JTattooUtilities.fillVerGradient(g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
        JTattooUtilities.draw3DBorder(g, frameColor, ColorHelper.darker(frameColor, 15), 0, 0, thumbBounds.width, thumbBounds.height);
        Graphics2D g2D = (Graphics2D) g;
        Composite composite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
        g2D.setComposite(alpha);
        if (!AbstractLookAndFeel.getTheme().isMacStyleScrollBarOn()) {
            int dx = 5;
            int dy = thumbBounds.height / 2 - 3;
            int dw = thumbBounds.width - 11;
            Color c1 = Color.white;
            Color c2 = Color.darkGray;
            for (int i = 0; i < 4; i++) {
                g.setColor(c1);
                g.drawLine(dx, dy, dx + dw, dy);
                dy++;
                g.setColor(c2);
                g.drawLine(dx, dy, dx + dw, dy);
                dy++;
            }
        }
        g2D.setComposite(composite);
    } else {
        // HORIZONTAL
        JTattooUtilities.fillHorGradient(g, colors, 1, 1, thumbBounds.width - 1, thumbBounds.height - 1);
        JTattooUtilities.draw3DBorder(g, frameColor, ColorHelper.darker(frameColor, 10), 0, 0, thumbBounds.width, thumbBounds.height);
        int dx = thumbBounds.width / 2 - 3;
        int dy = 5;
        int dh = thumbBounds.height - 11;
        Graphics2D g2D = (Graphics2D) g;
        Composite composite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
        g2D.setComposite(alpha);
        if (!AbstractLookAndFeel.getTheme().isMacStyleScrollBarOn()) {
            Color c1 = Color.white;
            Color c2 = Color.darkGray;
            for (int i = 0; i < 4; i++) {
                g.setColor(c1);
                g.drawLine(dx, dy, dx, dy + dh);
                dx++;
                g.setColor(c2);
                g.drawLine(dx, dy, dx, dy + dh);
                dx++;
            }
        }
        g2D.setComposite(composite);
    }
    g.translate(-thumbBounds.x, -thumbBounds.y);
}
Also used : Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Aggregations

Composite (java.awt.Composite)248 AlphaComposite (java.awt.AlphaComposite)236 Graphics2D (java.awt.Graphics2D)120 Paint (java.awt.Paint)80 Rectangle2D (java.awt.geom.Rectangle2D)80 Color (java.awt.Color)76 Shape (java.awt.Shape)64 BasicStroke (java.awt.BasicStroke)47 Stroke (java.awt.Stroke)44 BufferedImage (java.awt.image.BufferedImage)42 AffineTransform (java.awt.geom.AffineTransform)33 Point (java.awt.Point)32 Line2D (java.awt.geom.Line2D)30 Font (java.awt.Font)28 Point2D (java.awt.geom.Point2D)24 Rectangle (java.awt.Rectangle)23 GradientPaint (java.awt.GradientPaint)22 GeneralPath (java.awt.geom.GeneralPath)20 RectangleInsets (org.jfree.ui.RectangleInsets)20 FontMetrics (java.awt.FontMetrics)19