/*
* $Id: BlendComposite.java,v 1.9 2007/02/28 01:21:29 gfx Exp $
*
* Dual-licensed under LGPL (Sun and Romain Guy) and BSD (Romain Guy).
*
* Copyright 2005 Sun Microsystems, Inc., 4150 Network Circle,
* Santa Clara, California 95054, U.S.A. All rights reserved.
*
* Copyright (c) 2006 Romain Guy <romain.guy@mac.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package composite;
import java.awt.Composite;
import java.awt.CompositeContext;
import java.awt.RenderingHints;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.DirectColorModel;
import java.awt.image.Raster;
import java.awt.image.RasterFormatException;
import java.awt.image.WritableRaster;
/**
* <p>A blend composite defines the rule according to which a drawing primitive
* (known as the source) is mixed with existing graphics (know as the
* destination.)</p>
* <p><code>BlendComposite</code> is an implementation of the
* {@link java.awt.Composite} interface and must therefore be set as a state on
* a {@link java.awt.Graphics2D} surface.</p>
* <p>Please refer to {@link java.awt.Graphics2D#setComposite(java.awt.Composite)}
* for more information on how to use this class with a graphics surface.</p>
* <h2>Blending Modes</h2>
* <p>This class offers a certain number of blending modes, or compositing
* rules. These rules are inspired from graphics editing software packages,
* like <em>Adobe Photoshop</em> or <em>The GIMP</em>.</p>
* <p>Given the wide variety of implemented blending modes and the difficulty
* to describe them with words, please refer to those tools to visually see
* the result of these blending modes.</p>
* <h2>Opacity</h2>
* <p>Each blending mode has an associated opacity, defined as a float value
* between 0.0 and 1.0. Changing the opacity controls the force with which the
* compositing operation is applied. For instance, a composite with an opacity
* of 0.0 will not draw the source onto the destination. With an opacity of
* 1.0, the source will be fully drawn onto the destination, according to the
* selected blending mode rule.</p>
* <p>The opacity, or alpha value, is used by the composite instance to mutiply
* the alpha value of each pixel of the source when being composited over the
* destination.</p>
* <h2>Creating a Blend Composite</h2>
* <p>Blend composites can be created in various manners:</p>
* <ul>
* <li>Use one of the pre-defined instance. Example:
* <code>BlendComposite.Average</code>.</li>
* <li>Derive one of the pre-defined instances by calling
* {@link #derive(float)} or {@link #derive(BlendingMode)}. Deriving allows
* you to change either the opacity or the blending mode. Example:
* <code>BlendComposite.Average.derive(0.5f)</code>.</li>
* <li>Use a factory method: {@link #getInstance(BlendingMode)} or
* {@link #getInstance(BlendingMode, float)}.</li>
* </ul>
* <h2>Implementation Caveat</h2>
* <p>TThe blending mode <em>SoftLight</em> has not been implemented yet.</p>
*
* @see java.awt.Graphics2D
* @see java.awt.Composite
* @see java.awt.AlphaComposite
* @author Romain Guy <romain.guy@mac.com>
*/
public final class BlendComposite implements Composite {
/**
* <p>A blending mode defines the compositing rule of a
* {@link BlendComposite}.</p>
*
* @author Romain Guy <romain.guy@mac.com>
*/
public enum BlendingMode {
AVERAGE,
MULTIPLY,
SCREEN,
DARKEN,
LIGHTEN,
OVERLAY,
HARD_LIGHT,
SOFT_LIGHT,
DIFFERENCE,
NEGATION,
EXCLUSION,
COLOR_DODGE,
INVERSE_COLOR_DODGE,
SOFT_DODGE,
COLOR_BURN,
INVERSE_COLOR_BURN,
SOFT_BURN,
REFLECT,
GLOW,
FREEZE,
HEAT,
ADD,
SUBTRACT,
STAMP,
RED,
GREEN,
BLUE,
HUE,
SATURATION,
COLOR,
LUMINOSITY
}
public static final BlendComposite Average = new BlendComposite(BlendingMode.AVERAGE);
public static final BlendComposite Multiply = new BlendComposite(BlendingMode.MULTIPLY);
public static final BlendComposite Screen = new BlendComposite(BlendingMode.SCREEN);
public static final BlendComposite Darken = new BlendComposite(BlendingMode.DARKEN);
public static final BlendComposite Lighten = new BlendComposite(BlendingMode.LIGHTEN);
public static final BlendComposite Overlay = new BlendComposite(BlendingMode.OVERLAY);
public static final BlendComposite HardLight = new BlendComposite(BlendingMode.HARD_LIGHT);
public static final BlendComposite SoftLight = new BlendComposite(BlendingMode.SOFT_LIGHT);
public static final BlendComposite Difference = new BlendComposite(BlendingMode.DIFFERENCE);
public static final BlendComposite Negation = new BlendComposite(BlendingMode.NEGATION);
public static final BlendComposite Exclusion = new BlendComposite(BlendingMode.EXCLUSION);
public static final BlendComposite ColorDodge = new BlendComposite(BlendingMode.COLOR_DODGE);
public static final BlendComposite InverseColorDodge = new BlendComposite(BlendingMode.INVERSE_COLOR_DODGE);
public static final BlendComposite SoftDodge = new BlendComposite(BlendingMode.SOFT_DODGE);
public static final BlendComposite ColorBurn = new BlendComposite(BlendingMode.COLOR_BURN);
public static final BlendComposite InverseColorBurn = new BlendComposite(BlendingMode.INVERSE_COLOR_BURN);
public static final BlendComposite SoftBurn = new BlendComposite(BlendingMode.SOFT_BURN);
public static final BlendComposite Reflect = new BlendComposite(BlendingMode.REFLECT);
public static final BlendComposite Glow = new BlendComposite(BlendingMode.GLOW);
public static final BlendComposite Freeze = new BlendComposite(BlendingMode.FREEZE);
public static final BlendComposite Heat = new BlendComposite(BlendingMode.HEAT);
public static final BlendComposite Add = new BlendComposite(BlendingMode.ADD);
public static final BlendComposite Subtract = new BlendComposite(BlendingMode.SUBTRACT);
public static final BlendComposite Stamp = new BlendComposite(BlendingMode.STAMP);
public static final BlendComposite Red = new BlendComposite(BlendingMode.RED);
public static final BlendComposite Green = new BlendComposite(BlendingMode.GREEN);
public static final BlendComposite Blue = new BlendComposite(BlendingMode.
没有合适的资源?快使用搜索试试~ 我知道了~
Java动画、图形、和极富客户端效果开发源代码
共1623个文件
xml:290个
properties:242个
java:200个
5星 · 超过95%的资源 需积分: 9 17 下载量 57 浏览量
2011-04-16
13:10:12
上传
评论
收藏 14.86MB RAR 举报
温馨提示
Chet Haase 写的 《 Java动画、图形、和极富客户端效果开发 》 的源代码
资源推荐
资源详情
资源评论
收起资源包目录
Java动画、图形、和极富客户端效果开发源代码 (1623个子文件)
GraphicsUtilities.class 6KB
GraphicsUtilities.class 6KB
ReflectionPanel.class 6KB
BrightnessIncreaseDemo.class 4KB
DummyPanel.class 4KB
RepaintManagerDemo.class 4KB
ReflectionPanel$ReflectionRepaintManager.class 2KB
RepaintManagerDemo$GradientPanel.class 1KB
BrightnessIncreaseDemo$2.class 1KB
DummyPanel$1.class 953B
BrightnessIncreaseDemo$1.class 947B
BrightnessIncreaseDemo$3.class 561B
RepaintManagerDemo$1.class 545B
ReflectionPanel$1.class 196B
.cvsignore 16B
.cvsignore 16B
.cvsignore 12B
.cvsignore 12B
.cvsignore 8B
.cvsignore 8B
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
._.DS_Store 82B
._.DS_Store 82B
共 1623 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
- kylin1011lu2014-07-22学习swing的很好教程
syj6516195
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功