Search in sources :

Example 1 with AbstractLookAndFeel

use of com.jtattoo.plaf.AbstractLookAndFeel in project LoboEvolution by LoboEvolution.

the class TextureSplitPaneDivider method paint.

/**
 * {@inheritDoc}
 */
@Override
public void paint(final Graphics g) {
    if (!isFlatMode()) {
        TextureUtils.fillComponent(g, this, TextureUtils.getTextureType(splitPane));
        Graphics2D g2D = (Graphics2D) g;
        Composite savedComposite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
        g2D.setComposite(alpha);
        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;
        }
        Icon horBumps = null;
        Icon verBumps = null;
        if (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel) {
            AbstractLookAndFeel laf = (AbstractLookAndFeel) UIManager.getLookAndFeel();
            horBumps = laf.getIconFactory().getSplitterHorBumpIcon();
            verBumps = laf.getIconFactory().getSplitterVerBumpIcon();
        }
        if (orientation == JSplitPane.HORIZONTAL_SPLIT) {
            if (horBumps != null && width > horBumps.getIconWidth()) {
                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 {
            if (verBumps != null && height > verBumps.getIconHeight()) {
                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 : AbstractLookAndFeel(com.jtattoo.plaf.AbstractLookAndFeel) AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Icon(javax.swing.Icon) Graphics2D(java.awt.Graphics2D)

Aggregations

AbstractLookAndFeel (com.jtattoo.plaf.AbstractLookAndFeel)1 AlphaComposite (java.awt.AlphaComposite)1 Composite (java.awt.Composite)1 Graphics2D (java.awt.Graphics2D)1 Icon (javax.swing.Icon)1