Example usage for java.awt AlphaComposite getRule

List of usage examples for java.awt AlphaComposite getRule

Introduction

In this page you can find the example usage for java.awt AlphaComposite getRule.

Prototype

public int getRule() 

Source Link

Document

Returns the compositing rule of this AlphaComposite .

Usage

From source file:SWTGraphics2D.java

/**
 * Sets the current color for this graphics context.
 *
 * @param color  the color./* w  w w  .  j a v a  2 s  .c o  m*/
 *
 * @see #getColor()
 */
public void setColor(Color color) {
    org.eclipse.swt.graphics.Color swtColor = getSwtColorFromPool(color);
    this.gc.setForeground(swtColor);
    // handle transparency and compositing.
    if (this.composite instanceof AlphaComposite) {
        AlphaComposite acomp = (AlphaComposite) this.composite;
        switch (acomp.getRule()) {
        case AlphaComposite.SRC_OVER:
            this.gc.setAlpha((int) (color.getAlpha() * acomp.getAlpha()));
            break;
        default:
            this.gc.setAlpha(color.getAlpha());
            break;
        }
    }
}

From source file:org.jfree.experimental.swt.SWTGraphics2D.java

/**
 * Sets the current color for this graphics context.
 *
 * @param color  the color (<code>null</code> permitted but ignored).
 *
 * @see #getColor()/*  ww w .  j  a  va2  s.c o  m*/
 */
public void setColor(Color color) {
    if (color == null) {
        return;
    }
    org.eclipse.swt.graphics.Color swtColor = getSwtColorFromPool(color);
    this.gc.setForeground(swtColor);
    // handle transparency and compositing.
    if (this.composite instanceof AlphaComposite) {
        AlphaComposite acomp = (AlphaComposite) this.composite;
        switch (acomp.getRule()) {
        case AlphaComposite.SRC_OVER:
            this.gc.setAlpha((int) (color.getAlpha() * acomp.getAlpha()));
            break;
        default:
            this.gc.setAlpha(color.getAlpha());
            break;
        }
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

/**
 * Method contributed by Alexej Suchov//from  w w  w.  j a v a2  s.  co  m
 *
 * @see Graphics2D#setComposite(Composite)
 */
@Override
public void setComposite(final Composite comp) {

    if (comp instanceof AlphaComposite) {

        final AlphaComposite composite = (AlphaComposite) comp;

        if (composite.getRule() == 3) {

            alpha = composite.getAlpha();
            this.composite = composite;

            if (realPaint != null && (realPaint instanceof Color)) {

                final Color c = (Color) realPaint;
                paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (c.getAlpha() * alpha));
            }
            return;
        }
    }

    this.composite = comp;
    alpha = 1.0F;

}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfGraphics2D.java

/**
 * Method contributed by Alexej Suchov/*from  w  ww  . j a va2 s.c  om*/
 *
 * @see Graphics2D#setPaint(Paint)
 */
@Override
public void setPaint(final Paint paint) {
    if (paint == null) {
        return;
    }
    this.paint = paint;
    realPaint = paint;

    if ((composite instanceof AlphaComposite) && (paint instanceof Color)) {

        final AlphaComposite co = (AlphaComposite) composite;

        if (co.getRule() == 3) {
            final Color c = (Color) paint;
            this.paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (c.getAlpha() * alpha));
            realPaint = paint;
        }
    }

}