本文整理匯總了Java中java.awt.Transparency.TRANSLUCENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Transparency.TRANSLUCENT屬性的具體用法?Java Transparency.TRANSLUCENT怎麽用?Java Transparency.TRANSLUCENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.Transparency
的用法示例。
在下文中一共展示了Transparency.TRANSLUCENT屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createComponentCM
/**
* Create a {@code ComponentColorModel} for use in creating
* an {@code ImageTypeSpecifier}.
*/
// This code was inspired by the method of the same name in
// javax.imageio.ImageTypeSpecifier
static ColorModel createComponentCM(ColorSpace colorSpace,
int numBands,
int[] bitsPerSample,
int dataType,
boolean hasAlpha,
boolean isAlphaPremultiplied) {
int transparency =
hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
return new ComponentColorModel(colorSpace,
bitsPerSample,
hasAlpha,
isAlphaPremultiplied,
transparency,
dataType);
}
示例2: getColorModel
@Override
public ColorModel getColorModel(int transparency) {
switch (transparency) {
case Transparency.OPAQUE:
// REMIND: once the ColorModel spec is changed, this should be
// an opaque premultiplied DCM...
return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
case Transparency.BITMASK:
return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
case Transparency.TRANSLUCENT:
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
return new DirectColorModel(cs, 32,
0xff0000, 0xff00, 0xff, 0xff000000,
true, DataBuffer.TYPE_INT);
default:
return null;
}
}
示例3: createComponentCM
static ColorModel createComponentCM(ColorSpace colorSpace,
int numBands,
int dataType,
boolean hasAlpha,
boolean isAlphaPremultiplied) {
int transparency =
hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
int[] numBits = new int[numBands];
int bits = DataBuffer.getDataTypeSize(dataType);
for (int i = 0; i < numBands; i++) {
numBits[i] = bits;
}
return new ComponentColorModel(colorSpace,
numBits,
hasAlpha,
isAlphaPremultiplied,
transparency,
dataType);
}
示例4: CGLVolatileSurfaceManager
public CGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
super(vImg, context);
/*
* We will attempt to accelerate this image only under the
* following conditions:
* - the image is opaque OR
* - the image is translucent AND
* - the GraphicsConfig supports the FBO extension OR
* - the GraphicsConfig has a stored alpha channel
*/
int transparency = vImg.getTransparency();
CGLGraphicsConfig gc = (CGLGraphicsConfig)vImg.getGraphicsConfig();
accelerationEnabled =
(transparency == Transparency.OPAQUE) ||
((transparency == Transparency.TRANSLUCENT) &&
(gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
gc.isCapPresent(CAPS_STORED_ALPHA)));
}
示例5: getColorModel
/**
* Returns the color model associated with this configuration that
* supports the specified transparency.
*/
public ColorModel getColorModel(int transparency) {
if (model.getTransparency() == transparency) {
return model;
}
switch (transparency) {
case Transparency.OPAQUE:
return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
case Transparency.BITMASK:
return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
case Transparency.TRANSLUCENT:
return ColorModel.getRGBdefault();
default:
return null;
}
}
示例6: getColorModel
/**
* Returns the color model associated with this configuration that
* supports the specified transparency.
*/
public ColorModel getColorModel(int transparency) {
switch (transparency) {
case Transparency.OPAQUE:
return getColorModel();
case Transparency.BITMASK:
return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
case Transparency.TRANSLUCENT:
return ColorModel.getRGBdefault();
default:
return null;
}
}
示例7: SunVolatileImage
protected SunVolatileImage(Component comp,
GraphicsConfiguration graphicsConfig,
int width, int height, Object context,
int transparency, ImageCapabilities caps,
int accType)
{
this.comp = comp;
this.graphicsConfig = graphicsConfig;
this.width = width;
this.height = height;
this.forcedAccelSurfaceType = accType;
if (!(transparency == Transparency.OPAQUE ||
transparency == Transparency.BITMASK ||
transparency == Transparency.TRANSLUCENT))
{
throw new IllegalArgumentException("Unknown transparency type:" +
transparency);
}
this.transparency = transparency;
this.volSurfaceManager = createSurfaceManager(context, caps);
SurfaceManager.setManager(this, volSurfaceManager);
// post-construction initialization of the surface manager
volSurfaceManager.initialize();
// clear the background
volSurfaceManager.initContents();
}
示例8: createABGRCCM
public static ComponentColorModel createABGRCCM() {
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] nBits = {8, 8, 8, 8};
int[] bOffs = {3, 2, 1, 0};
return new ComponentColorModel(cs, nBits, true, true,
Transparency.TRANSLUCENT,
DataBuffer.TYPE_BYTE);
}
示例9: TriStateImageType
public TriStateImageType(Group parent, String nodename, String desc,
int transparency)
{
super(parent, nodename, desc);
setHorizontal();
new DrawableImage(this, Transparency.OPAQUE, true);
new DrawableImage(this, Transparency.BITMASK,
(transparency != Transparency.OPAQUE));
new DrawableImage(this, Transparency.TRANSLUCENT,
(transparency == Transparency.TRANSLUCENT));
}
示例10: Grayscale
public Grayscale(int bits,
int dataType,
boolean isSigned,
boolean hasAlpha,
boolean isAlphaPremultiplied)
{
if (bits != 1 && bits != 2 && bits != 4 &&
bits != 8 && bits != 16)
{
throw new IllegalArgumentException("Bad value for bits!");
}
if (dataType != DataBuffer.TYPE_BYTE &&
dataType != DataBuffer.TYPE_SHORT &&
dataType != DataBuffer.TYPE_USHORT)
{
throw new IllegalArgumentException
("Bad value for dataType!");
}
if (bits > 8 && dataType == DataBuffer.TYPE_BYTE) {
throw new IllegalArgumentException
("Too many bits for dataType!");
}
this.bits = bits;
this.dataType = dataType;
this.isSigned = isSigned;
this.hasAlpha = hasAlpha;
this.isAlphaPremultiplied = isAlphaPremultiplied;
ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
if ((bits == 8 && dataType == DataBuffer.TYPE_BYTE) ||
(bits == 16 &&
(dataType == DataBuffer.TYPE_SHORT ||
dataType == DataBuffer.TYPE_USHORT))) {
// Use component color model & sample model
int numBands = hasAlpha ? 2 : 1;
int transparency =
hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
int[] nBits = new int[numBands];
nBits[0] = bits;
if (numBands == 2) {
nBits[1] = bits;
}
this.colorModel =
new ComponentColorModel(colorSpace,
nBits,
hasAlpha,
isAlphaPremultiplied,
transparency,
dataType);
int[] bandOffsets = new int[numBands];
bandOffsets[0] = 0;
if (numBands == 2) {
bandOffsets[1] = 1;
}
int w = 1;
int h = 1;
this.sampleModel =
new PixelInterleavedSampleModel(dataType,
w, h,
numBands, w*numBands,
bandOffsets);
} else {
int numEntries = 1 << bits;
byte[] arr = new byte[numEntries];
for (int i = 0; i < numEntries; i++) {
arr[i] = (byte)(i*255/(numEntries - 1));
}
this.colorModel =
new IndexColorModel(bits, numEntries, arr, arr, arr);
this.sampleModel =
new MultiPixelPackedSampleModel(dataType, 1, 1, bits);
}
}
示例11: getTransparency
public int getTransparency() {
return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
}
示例12: isSupportedOperation
@Override
public boolean isSupportedOperation(SurfaceData srcData, int txtype,
CompositeType comp, Color bgColor) {
return (bgColor == null || transparency == Transparency.TRANSLUCENT);
}
示例13: DirectColorModel
/**
* Constructs a {@code DirectColorModel} from the specified masks
* that indicate which bits in an {@code int} pixel representation
* contain the red, green and blue color samples and the alpha sample,
* if present. If {@code amask} is 0, pixel values do not contain
* alpha information and all pixels are treated as opaque, which means
* that alpha = 1.0. All of the bits in each mask must
* be contiguous and fit in the specified number of least significant bits
* of an {@code int} pixel representation. Alpha, if present, is not
* premultiplied. The {@code ColorSpace} is the default sRGB space.
* The transparency value is Transparency.OPAQUE if no alpha is
* present, or Transparency.TRANSLUCENT otherwise. The transfer type
* is the smallest of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
* or DataBuffer.TYPE_INT that can hold a single pixel.
* @param bits the number of bits in the pixel values; for example,
* the sum of the number of bits in the masks.
* @param rmask specifies a mask indicating which bits in an
* integer pixel contain the red component
* @param gmask specifies a mask indicating which bits in an
* integer pixel contain the green component
* @param bmask specifies a mask indicating which bits in an
* integer pixel contain the blue component
* @param amask specifies a mask indicating which bits in an
* integer pixel contain the alpha component
*/
public DirectColorModel(int bits, int rmask, int gmask,
int bmask, int amask) {
super (ColorSpace.getInstance(ColorSpace.CS_sRGB),
bits, rmask, gmask, bmask, amask, false,
amask == 0 ? Transparency.OPAQUE : Transparency.TRANSLUCENT,
ColorModel.getDefaultTransferType(bits));
setFields();
}
示例14: DirectColorModel
/**
* Constructs a <code>DirectColorModel</code> from the specified
* parameters. Color components are in the specified
* <code>ColorSpace</code>, which must be of type ColorSpace.TYPE_RGB
* and have minimum normalized component values which are all 0.0
* and maximum values which are all 1.0.
* The masks specify which bits in an <code>int</code> pixel
* representation contain the red, green and blue color samples and
* the alpha sample, if present. If <code>amask</code> is 0, pixel
* values do not contain alpha information and all pixels are treated
* as opaque, which means that alpha = 1.0. All of the
* bits in each mask must be contiguous and fit in the specified number
* of least significant bits of an <code>int</code> pixel
* representation. If there is alpha, the <code>boolean</code>
* <code>isAlphaPremultiplied</code> specifies how to interpret
* color and alpha samples in pixel values. If the <code>boolean</code>
* is <code>true</code>, color samples are assumed to have been
* multiplied by the alpha sample. The transparency value is
* Transparency.OPAQUE, if no alpha is present, or
* Transparency.TRANSLUCENT otherwise. The transfer type
* is the type of primitive array used to represent pixel values and
* must be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or
* DataBuffer.TYPE_INT.
* @param space the specified <code>ColorSpace</code>
* @param bits the number of bits in the pixel values; for example,
* the sum of the number of bits in the masks.
* @param rmask specifies a mask indicating which bits in an
* integer pixel contain the red component
* @param gmask specifies a mask indicating which bits in an
* integer pixel contain the green component
* @param bmask specifies a mask indicating which bits in an
* integer pixel contain the blue component
* @param amask specifies a mask indicating which bits in an
* integer pixel contain the alpha component
* @param isAlphaPremultiplied <code>true</code> if color samples are
* premultiplied by the alpha sample; <code>false</code> otherwise
* @param transferType the type of array used to represent pixel values
* @throws IllegalArgumentException if <code>space</code> is not a
* TYPE_RGB space or if the min/max normalized component
* values are not 0.0/1.0.
*/
public DirectColorModel(ColorSpace space, int bits, int rmask,
int gmask, int bmask, int amask,
boolean isAlphaPremultiplied,
int transferType) {
super (space, bits, rmask, gmask, bmask, amask,
isAlphaPremultiplied,
amask == 0 ? Transparency.OPAQUE : Transparency.TRANSLUCENT,
transferType);
if (ColorModel.isLinearRGBspace(colorSpace)) {
is_LinearRGB = true;
if (maxBits <= 8) {
lRGBprecision = 8;
tosRGB8LUT = ColorModel.getLinearRGB8TosRGB8LUT();
fromsRGB8LUT8 = ColorModel.getsRGB8ToLinearRGB8LUT();
} else {
lRGBprecision = 16;
tosRGB8LUT = ColorModel.getLinearRGB16TosRGB8LUT();
fromsRGB8LUT16 = ColorModel.getsRGB8ToLinearRGB16LUT();
}
} else if (!is_sRGB) {
for (int i = 0; i < 3; i++) {
// super constructor checks that space is TYPE_RGB
// check here that min/max are all 0.0/1.0
if ((space.getMinValue(i) != 0.0f) ||
(space.getMaxValue(i) != 1.0f)) {
throw new IllegalArgumentException(
"Illegal min/max RGB component value");
}
}
}
setFields();
}