Java Code Examples for java.awt.Paint#getTransparency()

The following examples show how to use java.awt.Paint#getTransparency() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SunGraphics2D.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 2
Source File: SunGraphics2D.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 3
Source File: SunGraphics2D.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 4
Source File: SunGraphics2D.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 5
Source File: SunGraphics2D.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 6
Source File: SunGraphics2D.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 7
Source File: SunGraphics2D.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 8
Source File: SunGraphics2D.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 9
Source File: SunGraphics2D.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 10
Source File: SunGraphics2D.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 11
Source File: SunGraphics2D.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 12
Source File: SimpleButtonFill.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public Paint getFill(ButtonState.Float state, Rectangle fillRect) {
	Paint darkestFill = getDarkestFill(fillRect);
	Paint normalFill = getNormalFill(fillRect);

	int imageType = BufferedImage.TYPE_INT_RGB;
	for (Paint p : new Paint[] { darkestFill, normalFill }) {
		if (p.getTransparency() != Transparency.OPAQUE)
			imageType = BufferedImage.TYPE_INT_ARGB;
	}
	int width = Math.max(1, fillRect.width);
	int height = Math.max(1, fillRect.height);
	BufferedImage bi = new BufferedImage(width, height, imageType);
	Graphics2D g = bi.createGraphics();
	g.translate(-fillRect.x, -fillRect.y);

	paint(g, normalFill, 1, fillRect);

	if (state.isArmed > 0) {
		paint(g, darkestFill, state.isArmed(), fillRect);
	}
	if (state.isSelected() > 0) {
		paint(g, darkestFill, state.isSelected() * .7f, fillRect);
	}
	if (state.isRollover() > 0) {
		paint(g, darkestFill, state.isRollover() * .4f, fillRect);
	}

	return new TransformedTexturePaint(bi, new Rectangle(0, 0,
			fillRect.width, fillRect.height),
			AffineTransform.getTranslateInstance(fillRect.x, fillRect.y));
}
 
Example 13
Source File: SunGraphics2D.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 14
Source File: SunGraphics2D.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}
 
Example 15
Source File: SunGraphics2D.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the Paint in the current graphics state.
 * @param paint The Paint object to be used to generate color in
 * the rendering process.
 * @see java.awt.Graphics#setColor
 * @see GradientPaint
 * @see TexturePaint
 */
public void setPaint(Paint paint) {
    if (paint instanceof Color) {
        setColor((Color) paint);
        return;
    }
    if (paint == null || this.paint == paint) {
        return;
    }
    this.paint = paint;
    if (imageComp == CompositeType.SrcOverNoEa) {
        // special case where compState depends on opacity of paint
        if (paint.getTransparency() == Transparency.OPAQUE) {
            if (compositeState != COMP_ISCOPY) {
                compositeState = COMP_ISCOPY;
            }
        } else {
            if (compositeState == COMP_ISCOPY) {
                compositeState = COMP_ALPHA;
            }
        }
    }
    Class<? extends Paint> paintClass = paint.getClass();
    if (paintClass == GradientPaint.class) {
        paintState = PAINT_GRADIENT;
    } else if (paintClass == LinearGradientPaint.class) {
        paintState = PAINT_LIN_GRADIENT;
    } else if (paintClass == RadialGradientPaint.class) {
        paintState = PAINT_RAD_GRADIENT;
    } else if (paintClass == TexturePaint.class) {
        paintState = PAINT_TEXTURE;
    } else {
        paintState = PAINT_CUSTOM;
    }
    validFontInfo = false;
    invalidatePipe();
}